-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview-all-service-jc-page.php
More file actions
405 lines (308 loc) · 28.6 KB
/
view-all-service-jc-page.php
File metadata and controls
405 lines (308 loc) · 28.6 KB
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
<?php include('partials/navbar.php');
// include('fetch_data_technician.php');
include('fetch_data_view_all_service_jc.php');
include('assign_jc_technician.php');
?>
<!-----------------------------------RIGHT TAB-------------------------------------------------------------->
<style>
.red-text {
color: red;
}
</style>
<main id="main" class="main" style="margin-bottom: 0px;">
<section>
<div class="container" style="padding-top: 0px; margin-left: 0px; padding-bottom: 0px;">
<div class="tab-content" id="customer_content">
<div class="tab-pane in active">
<h1 style="padding-top: 0px;">VIEW ALL JOBCARDS</h1><br>
<!-- ... Your previous code ... -->
<div class="table-responsive">
<!-- Job Card Assignment Form -->
<form id="assignTechnicianForm" method="POST">
<!-- Your form fields -->
</form>
</div>
<!-- Display Assigned Job Cards -->
<div class="table-responsive">
<table class="table">
<thead class="thead-dark">
<tr>
<th scope="col">JC</th>
<th scope="col">Role</th>
<!-- <th scope="col">JC Type</th> -->
<th scope="col">Customer Name</th>
<!-- <th scope="col">Company Name</th> -->
<!-- <th scope="col">Project Name</th> -->
<!-- <th scope="col">Customer Type</th> -->
<!-- <th scope="col">Create Date</th> -->
<!-- <th scope="col">Technician</th> -->
<!-- <th scope="col">Amount</th>
<th scope="col">Material</th>
<th scope="col">Fuel</th>-->
<th scope="col">Technician</th>
<th scope="col">Area</th>
<th scope="col">Time</th>
<!-- <th scope="col">Total</th> -->
<th scope="col">JC1</th>
<th scope="col">JC2</th>
<th scope="col">JC3</th>
<th scope="col">P</th>
<th scope="col">Status</th>
<th scope="col" style="text-align: right;">Amount</th>
<th scope="col" style="text-align: right;">Material</th>
<th scope="col" style="text-align: right;">Fuel</th>
<th scope="col" style="text-align: right;">Technician</th>
<th scope="col" style="text-align: right;">Total</th>
<th scope="col" style="text-align: right;">% Cost</th>
</tr>
</thead>
<tbody>
<?php
if(mysqli_num_rows( $query_run) > 0)
{
while($rowAssigned = mysqli_fetch_array($query_run)){
// Display the row with assigned technician and an "Edit" button
echo '<tr>';
echo '<td>' . $rowAssigned["id"] . '</td>';
echo '<td>' . $rowAssigned["role"] . '</td>';
// echo '<td>' . $rowAssigned["jc_type"] . '</td>';
echo '<td>' . $rowAssigned["customer_name"] . '</td>';
// echo '<td>' . $rowAssigned["company_name"] . '</td>';
// echo '<td>' . $rowAssigned["project_name"] . '</td>';
// echo '<td>' . $rowAssigned["customer_type"] . '</td>';
// echo '<td>' . $rowAssigned["jc_create_date"] . '</td>';
echo '<td>' . $rowAssigned["jc_assigned_to"] . '</td>';
echo '<td>' . $rowAssigned["area"] . '</td>';
echo '<td>' . $rowAssigned["hours"] . '</td>';
// echo '<td>' . $rowAssigned["total_paid_amount"] . '</td>';
// echo '<td>' . $rowAssigned["material_cost"] . '</td>';
// echo '<td>' . $rowAssigned["fuel_cost"] . '</td>';
// echo '<td>' . $rowAssigned["technician_cost"] . '</td>';
// echo '<td>' . $rowAssigned["total_cost"] . '</td>';
echo '<td style="display: none;">' . $rowAssigned["paid"] . '</td>';
echo '<td style="display: none;">' . $rowAssigned["jc_closed"] . '</td>';
// Check if the role is 'Trading'
if ($rowAssigned["paid"] === 'Paid' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["role"] === 'Service' && $rowAssigned["jc_type"] !== 'AMC Service') {
echo '<td><a href="pdf_service_jc_paid.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="Service PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="Product/Item"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_service_jc_paid_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="Merged Service PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_jc_p.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="Payment"><i class="bi bi-currency-dollar"></i></a></td>';
// echo '<td><a href="pdf_jobcard_costing.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank">COST</a></td>';
echo '<td><b>PAID</b></td>';
} else if ($rowAssigned["paid"] === 'Paid' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["role"] === 'Service' && $rowAssigned["jc_type"] === 'AMC Service') {
echo '<td><a href="pdf_service_jc_paid.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-danger btn-sm col-xs-2" target="_blank" title="AMC PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-danger btn-sm col-xs-2" target="_blank" title="Product/Item"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_service_jc_paid_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-danger btn-sm col-xs-2" target="_blank" title="Merged AMC Service PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_jc_p.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-danger btn-sm col-xs-2" target="_blank" title="Payment"><i class="bi bi-currency-dollar"></i></a></td>';
// echo '<td><a href="pdf_jobcard_costing.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank">COST</a></td>';
echo '<td><b>PAID</b></td>';
} else if ($rowAssigned["paid"] === 'Paid' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["role"] === 'Trading') {
echo '<td><a href="pdf_trading_jc_paid.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank" title="Trading PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_trading_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank" title="Product/Item"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_trading_jc_paid_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank" title="Merged Trading PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_jc_p.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank" title="Payment"><i class="bi bi-currency-dollar"></i></a></td>';
// echo '<td><a href="pdf_jobcard_costing.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank">COST</a></td>';
echo '<td><b>PAID</b></td>';
} else if ($rowAssigned["paid"] === 'Paid' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["role"] === 'Project') {
echo '<td><a href="pdf_project_jc_paid.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank" title="Project PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_project_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank" title="Product/Item"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_project_jc_paid_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank" title="Merged Project PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_jc_project_admin_p.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank" title="Payment"><i class="bi bi-currency-dollar"></i></a></td>';
echo '<td><b>PAID</b></td>';
} else if ($rowAssigned["paid"] === 'Paid' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["role"] === 'Admin') {
echo '<td><a href="pdf_admin_jc_paid.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-secondary btn-sm col-xs-2" target="_blank" title="Admin PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><a href="pdf_jc_project_admin_p.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-secondary btn-sm col-xs-2" target="_blank" title="Payment"><i class="bi bi-currency-dollar"></i></a></td>';
echo '<td><b>PAID</b></td>';
} else if($rowAssigned["role"] === 'Service' && $rowAssigned["jc_closed"] === 'Cancelled' && $rowAssigned["jc_type"] !== 'AMC Service') {
// For roles other than 'Trading'
echo '<td><a href="pdf_service_jc_cancel.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="AMC PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="Product/Item"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_service_jc_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank" title="Merged AMC PDF"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:grey;">Cancelled</b></td>';
} else if($rowAssigned["role"] === 'Service' && $rowAssigned["jc_closed"] === 'Cancelled' && $rowAssigned["jc_type"] === 'AMC Service') {
// For roles other than 'Trading'
echo '<td><a href="pdf_service_jc_cancel.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-danger btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
// echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:grey;">Cancelled</b></td>';
} else if($rowAssigned["role"] === 'Trading' && $rowAssigned["jc_closed"] === 'Cancelled') {
// For roles other than 'Trading'
echo '<td><a href="pdf_trading_jc_cancel.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_trading_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_service_jc_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:grey;">Cancelled</b></td>';
} else if($rowAssigned["role"] === 'Project' && $rowAssigned["jc_closed"] === 'Cancelled') {
// For roles other than 'Trading'
echo '<td><a href="pdf_project_jc_cancel.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_project_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_service_jc_merge.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:grey;">Cancelled</b></td>';
} else if($rowAssigned["role"] === 'Admin' && $rowAssigned["jc_closed"] === 'Cancelled') {
// For roles other than 'Trading'
echo '<td><a href="pdf_admin_jc_cancel.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-secondary btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b style="color:grey;">Cancelled</b></td>';
} else if($rowAssigned["role"] === 'Service' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["jc_type"] !== 'AMC Service') {
// For roles other than 'Trading'
echo '<td><a href="pdf_assign_jc.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:red;">Payment ?</b></td>';
} else if($rowAssigned["role"] === 'Service' && $rowAssigned["jc_closed"] === 'Closed' && $rowAssigned["jc_type"] === 'AMC Service') {
// For roles other than 'Trading'
echo '<td><a href="pdf_assign_jc.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-danger btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
// echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-primary btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:red;">Payment ?</b></td>';
} else if($rowAssigned["role"] === 'Trading' && $rowAssigned["jc_closed"] === 'Closed') {
// For roles other than 'Trading'
echo '<td><a href="pdf_assign_trading_jc.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td><a href="pdf_assign_trading_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
echo '<td></td>';
echo '<td><b style="color:red;">Payment ?</b></td>';
} else if($rowAssigned["role"] === 'Service' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] === '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b>Unassigned</b></td>';
} else if($rowAssigned["role"] === 'Trading' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] === '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b>Unassigned</b></td>';
} else if($rowAssigned["role"] === 'Project' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] === '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b>Unassigned</b></td>';
}else if($rowAssigned["role"] === 'Admin' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] === '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b>Unassigned</b></td>';
} else if($rowAssigned["role"] === 'Service' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] !== '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b style="color:green;">Running</b></td>';
} else if($rowAssigned["role"] === 'Trading' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] !== '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b style="color:green;">Running</b></td>';
} else if($rowAssigned["role"] === 'Project' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] !== '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b style="color:green;">Running</b></td>';
} else if($rowAssigned["role"] === 'Admin' && $rowAssigned["jc_closed"] !== 'Closed' && $rowAssigned["paid"] !== 'Paid' && $rowAssigned["jc_closed"] !== 'Cancelled' && $rowAssigned["jc_assigned_to"] !== '' ) {
// For roles other than 'Trading'
echo '<td></td>';
echo '<td></td>';
echo '<td></td>';
echo '<td><b style="color:green;">Running</b></td>';
}
// echo '<td><a href="pdf_assign_jc.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-success btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
// echo '<td><a href="pdf_assign_item_product.php?id=' . $rowAssigned["id"] . '&ACTION=VIEW" class="btn btn-warning btn-sm col-xs-2" target="_blank"><i class="bi bi-file-pdf"></i></a></td>';
// echo '<td>' . $rowAssigned["percent_cost"] . '%</td>';
// Get the percent_cost value
$percentCost = $rowAssigned["percent_cost"];
// Check if the value is less than 40
$colorClass = ($percentCost < 40) ? 'red-text' : '';
// Output the table cell with the appropriate style
echo '<td style="text-align: right;">' . number_format($rowAssigned["total_paid_amount"], 0) . '</td>';
echo '<td style="text-align: right;">' . number_format($rowAssigned["material_cost"], 0) . '</td>';
echo '<td style="text-align: right;">' . number_format($rowAssigned["fuel_cost"], 0) . '</td>';
echo '<td style="text-align: right;">' . number_format($rowAssigned["technician_cost"], 0) . '</td>';
echo '<td style="text-align: right;">' . number_format($rowAssigned["total_cost"], 0) . '</td>';
echo '<td class="' . $colorClass . '" style="text-align: right;">' . $percentCost . '</td>';
echo '</tr>';
}
}
else {
echo "<h5>No Record Found</h5>";
}
?>
</tbody>
</table>
</div>
<!-- ... Your remaining code ... -->
</div>
</div>
</div>
</section>
</main><!-- End #main -->
<!-- ======= Footer ======= -->
<!--<footer id="footer" class="footer">
<div class="copyright">
© Copyright <strong><span>Aquashine</span></strong>. All Rights Reserved 2023
</div>
</footer> End Footer -->
<!-- Template Main JS File -->
<?php
if(isset($_FILES["image"]["name"])){
$id = $_POST["id"];
$name = $_POST["name"];
$imageName = $_FILES["image"]["name"];
$imageSize = $_FILES["image"]["size"];
$tmpName = $_FILES["image"]["tmp_name"];
// Image validation
$validImageExtension = ['jpg', 'jpeg', 'png'];
$imageExtension = explode('.', $imageName);
$imageExtension = strtolower(end($imageExtension));
if (!in_array($imageExtension, $validImageExtension)){
echo
"
<script>
alert('Invalid Image Extension');
document.location.href = '../aquashine';
</script>
";
}
elseif ($imageSize > 1200000){
echo
"
<script>
alert('Image Size Is Too Large');
//document.location.href = '../aquashine';
</script>
";
}
else{
$newImageName = $name . " - " . date("Y.m.d") . " - " . date("h.i.sa"); // Generate new image name
$newImageName .= '.' . $imageExtension;
$query = "UPDATE tbl_admin SET image_name = '$newImageName' WHERE id = $id";
mysqli_query($conn, $query);
move_uploaded_file($tmpName, 'images/admin-images/' . $newImageName);
echo
"
<script>
document.location.href = '../aquashine/general-manager.php'?id='.$id;
</script>
";
}
}
?>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<!-- <script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-geWF76RCwLtnZ8qwWowPQNguL3RmwHVBC9FhGdlKrxdiJJigb/j/68SIy3Te4Bkz" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="js/main.js"></script>
<script src="js/assign_jc.js"></script>
<script src="js/unassign_jc.js"></script>
</body>
</html>