-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_grid_view.php
266 lines (225 loc) · 11.7 KB
/
index_grid_view.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<?php
require_once dirname(__FILE__) . '/db/core.php';
require_once dirname(__FILE__) . '/db/db_connect.php';
$db = new DB_CONNECT();
$conn = $db->connect();
if(!isset($_SESSION["staff_id"])){
header("location:staff_login.php");
}else{
$finalArray = array();
$staff_id = 3;
if(isset($_POST['add_job']) && isset($_POST['scooter_type']) && isset($_POST['phone'])){
$phone = $_POST['phone'];
$scooter_type = $_POST['scooter_type'];
$queryresult = mysqli_query($db->connect(), "SELECT * FROM `customers` WHERE `phone`='$phone' ");
if ($queryresult) {
if ( mysqli_num_rows($queryresult) <= 0) {
$password = 'user101';
$inject = "INSERT INTO `customers` (`customer_id`,`phone`,`password`)VALUES (NULL,'$phone', '$password')";
if(mysqli_query($conn,$inject)){
$customer_id = mysqli_insert_id($conn);
$addquery = mysqli_query($conn, "INSERT INTO orders(scooter_type,staff_id,customer_id) VALUES('$scooter_type',$staff_id,$customer_id)") or die(mysqli_error($db->connect()));
if ($addquery) {
echo '<script>alert("Successfully Added JOB !");</script>';
}
} else{
echo mysqli_error($conn);
}
}else{
$row = mysqli_fetch_array($queryresult);
$customer_id = $row['customer_id'];
$addquery = mysqli_query($conn, "INSERT INTO orders(scooter_type,staff_id,customer_id) VALUES('$scooter_type',$staff_id,$customer_id)") or die(mysqli_error($db->connect()));
if ($addquery) {
echo '<script>alert("Successfully Added JOB !");</script>';
}
}
}
}
$query = mysqli_query($conn, "SELECT order_id,scooter_type,`status`,`time`,(SELECT SUM(`price`) FROM `repairs` WHERE repairs.`order_id` = `orders`.order_id) as price,(SELECT `first_name` FROM `staff` WHERE staff.`staff_id` = `orders`.staff_id) as staff_name,(SELECT CONCAT(`first_name`,' ',`last_name`) FROM `customers` WHERE customers.`customer_id` = `orders`.customer_id) as customer_name,(SELECT phone FROM `customers` WHERE customers.`customer_id` = `orders`.customer_id) as phone FROM `orders`; ") or die(mysqli_error($db->connect()));
if ($query) {
$rows = mysqli_num_rows($query);
$count = 0;
if ($rows > 0) {
while ($row = mysqli_fetch_array($query)) {
$dataArray = array();
$order_id = $dataArray['order_id'] = $row['order_id'];
$dataArray['scooter_type'] = $row['scooter_type'];
$dataArray['time'] = $row['time'];
$dataArray['staff_name'] = $row['staff_name'];
$dataArray['phone'] = $row['phone'];
$dataArray['price'] = $row['price'];
$dataArray['status'] = $row['status'];
$dataArray['customer_name'] = $row['customer_name'];
$repairArray = array();
$query2 = mysqli_query($conn, "SELECT description,`status` FROM repairs WHERE order_id = $order_id ORDER BY `status` ASC ") or die(mysqli_error($db->connect()));
if ($query2) {
$rows2 = mysqli_num_rows($query2);
$count2 = 0;
if ($rows2 > 0) {
while ($row2 = mysqli_fetch_array($query2)) {
$dataArray2 = array();
$dataArray2['description'] = $row2['description'];
$dataArray2['status'] = $row2['status'];
$repairArray[$count2] = $dataArray2;
$count2++;
}
}
}
$dataArray['repair_array'] = $repairArray;
$finalArray[$count] = $dataArray;
$count++;
}
}
}
}
?>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="css/semantic.min.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/components/icon.min.css'>
</head>
<body>
<div class="ui menu">
<div class="ui container">
<a href="#" class="header item">
Scooter Repairs
</a>
<a href="index.php" class="item active">Home</a>
<div class="right menu">
<a href="#" class="item active"><i class="grid user icon"></i><?php echo $_SESSION["staff_name"]?></a>
<a href="staff_logout.php" class="item right">Logout</a>
</div>
</div>
</div>
<br>
<div class="ui container">
<div class="ui container grid">
<div class=" field column seven wide">
<div class="ui labeled icon menu ">
<a class="item" id='new_job_btn'>
<i class="briefcase icon"></i>
Add New Job
</a>
<a class="item right" href="index.php">
<i class="list icon"></i>
Switch to List View
</a>
</div>
</div>
<div class=" field column seven wide">
<label class="ui label">Filter: </label>
<select class="dropdown" name="filter" >
<option>View All</option>
<option>In Queue</option>
<option>Job Started</option>
<option>Waiting For Customer Response</option>
<option>Job Completed</option>
</select>
</div>
</div>
<br><br>
<div class="ui cards">
<?php
foreach ($finalArray as $data) {?>
<div class="card">
<div class="content" >
<span class="ui floated header">
<span class="card_title">JOB #<?php echo $data['order_id'];?></span>
<span><h5 class="card_date" >By <?php echo $data['staff_name'];?></h5></span>
</span>
<span class="ui right floated header" >
<?php $status = $data['status'];
if($status == "IN QUEUE"){ ?>
<span><h3 style="color: orangered;"><?php echo $status;?></h3></span>
<?php }elseif($status == "JOB STARTED"){?>
<span><h3 style="color: #4d82cb;"><?php echo $status;?></h3></span>
<?php }elseif($status == "WAITING FOR CUSTOMER RESPONSE"){?>
<span><h3 style="color: #ffcc00;"><?php echo 'IN WAITING'?></h3></span>
<?php }elseif($status == "JOB COMPLETED"){?>
<span><h3 style="color: green;"><?php echo 'COMPLETED';?></h3></span>
<?php } ?>
<span><h5 class="card_date" ><?php echo $data['time'];?></h5></span>
</span>
</div>
<div class="content" >
<div class="ui relaxed divided list">
<div class="item">
<strong>Customer:</strong> <?php echo $data['customer_name'];?>
</div>
<div class="item">
<div class="content">
<strong>Phone:</strong> <?php echo $data['phone'];?>
</div>
</div>
<div class="item">
<div class="content">
<strong>Scooter Type:</strong> <?php echo $data['scooter_type'];?>
</div>
</div>
</div>
</div>
<div class="content">
<div class="header">PRICE: $<?php echo $data['price'];?></div>
</div>
<form method="GET" action="more_details.php" class=" ui bottom compact teal icon button compact" >
<button class="ui button compact" type="submit" style="background-color: 80cbc4; " name="order_id" value="<?php echo $data['order_id'];?>"> <i class="add icon"></i> More Details</button>
</form>
</div>
<?php }?>
</div>
</div>
<div class="ui modal" id="addNewJobModal">
<div class="header"><i class="briefcase icon"></i> Add New Job</div>
<div class="content">
<form method="POST" action="index.php">
<div class="ui form">
<div class="ui segments ">
<div class="ui segment ">
<div class="field ">
<label>Scooter Type</label>
<div class=" fields">
<div class="field fifteen wide">
<input name="scooter_type" placeholder="Scooter Type" type="text" required="">
</div>
</div>
</div>
</div>
<div class="ui segment ">
<div class="field ">
<label>Client Phone:</label>
<div style="margin-bottom: 5px;"><small style="color: grey;">New Clients will be automatically registered.</small></div>
<div class=" fields">
<div class="field seven wide">
<input name="phone" placeholder="e.g +123456789" type="text" required="">
</div>
</div>
</div>
<input class="right ui button teal compact" name="add_job" type="submit" value="Add Job"/>
</div>
</div>
</div>
</form>
</div>
<div class="actions">
<div class="ui cancel button compact">Cancel</div>
</div>
</div>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/semantic.min.js"></script>
<script >
$(document).ready(function () {
$('.dropdown').dropdown();
});
</script>
<script >
$(document).ready(function () {
$("#new_job_btn").on("click",function(){
$('#addNewJobModal').modal('show')
});
});
</script>
</body>
</html>