-
Notifications
You must be signed in to change notification settings - Fork 1
/
permout.php
638 lines (516 loc) · 24 KB
/
permout.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
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
<?php
// session_start(); // Start the session
session_start();
// Check if the user is logged in
if (!isset($_SESSION['email'])) {
// If not logged in, redirect to login page
header("Location: pages-login.php");
exit();
}
include 'config/db.php';
$email = $_SESSION['email'];
//get user name and email from register table
$getAdminData = "SELECT * FROM register WHERE email = '$email'";
$resultData = mysqli_query($conn, $getAdminData);
if ($resultData->num_rows > 0) {
$row2 = $resultData->fetch_assoc();
$adminName = $row2['name'];
$adminEmail = $row2['email'];
}
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Favicons -->
<link href="assets/img/dtl.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link href="https://fonts.gstatic.com" rel="preconnect">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i" rel="stylesheet">
<!--bootstrap search and select-->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.13.14/css/bootstrap-select.min.css">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Serif+Pro:400,600&display=swap" rel="stylesheet">
<!-- Style -->
<link rel="stylesheet" href="assets/css/style.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<!-- Favicons -->
<link href="assets/img/favicon.png" rel="icon">
<link href="assets/img/apple-touch-icon.png" rel="apple-touch-icon">
<!-- Google Fonts -->
<link href="https://fonts.gstatic.com" rel="preconnect">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/simple-datatables@latest/dist/style.css" rel="stylesheet" type="text/css">
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@latest" type="text/javascript"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Source+Serif+Pro:400,600&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
/* Custom CSS to decrease font size of the table */
.overflow-auto {
overflow: auto !important;
margin-top: 92px !important;
}
.add {
/* cursor: pointer; */
margin-left: 976px;
margin-top: 85px;
margin-bottom: 103px;
}
/* Basic styling for search bar */
input.btn.btn-success {
margin-left: 7px;
height: 41px;
padding: 2%;
padding-top: 3px;
padding-bottom: 3px;
text-align: center;
justify-items: center;
}
.search-container {
margin: 50px;
margin-left: 320px;
margin-bottom: 3px !important;
}
#main {
margin-top: 0 !important;
}
input[type="text"] {
padding: 8px;
font-size: 0.9rem;
width: 363px;
}
input[type="submit"] {
padding: 10px 20px;
font-size: 16px;
}
.pagetitle {
display: flex;
width: 989px;
flex-direction: column;
}
.barcode {
height: 55px;
width: 250px;
position: relative;
left: -38px;
}
/*
#main {
margin-top: 20px !important;
padding: 20px 30px;
transition: all 0.3s;
} */
.row {
margin-left: 52px;
--bs-gutter-x: 1.5rem;
--bs-gutter-y: 0;
display: flex;
flex-wrap: wrap;
margin-top: calc(var(--bs-gutter-y)* -1);
margin-right: calc(var(--bs-gutter-x)* 1.5);
margin-left: calc(var(--bs-gutter-x)* 0.2);
}
.datatable-container {
border: none;
margin-left: 12px;
margin-top: 12px;
/* table-layout: fixed; */
}
/* Define the pulse animation */
.pagetitle {
display: flex;
width: 989px;
flex-direction: column;
}
#fixedButtonBranch {
position: relative;
top: 110px;
left: 1187px;
}
.row {
margin-left: 52px;
--bs-gutter-x: 1.5rem;
--bs-gutter-y: 0;
display: flex;
flex-wrap: wrap;
margin-top: calc(var(--bs-gutter-y)* -1);
margin-right: calc(var(--bs-gutter-x)* 1.5);
margin-left: calc(var(--bs-gutter-x)* 0.2);
}
.datatable-container {
border: none;
margin-left: 12px;
margin-top: 12px;
/* table-layout: fixed; */
}
.card-body {
padding: 0 20px 20px 18px !important;
}
/* Define the pulse animation */
@keyframes pulse {
0% {
transform: scale(1);
}
50% {
transform: scale(1.1);
}
100% {
transform: scale(1);
}
}
/* Define the click animation */
@keyframes clickEffect {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(0.9);
opacity: 0.7;
}
100% {
transform: scale(1);
opacity: 1;
}
}
.company-name {
color: #000;
text-decoration: none;
display: inline-block;
transition: color 0.3s ease;
}
.mt-4 {
margin-top: 1.5rem !important;
margin-right: 214px;
}
.datatable-dropdown label {
font-size: 0.9rem;
}
.datatable-info {
display: none;
}
.datatable-top {
width: 942px;
}
/* Card */
.cardBranch {
margin-bottom: 30px;
border: none;
border-radius: 5px;
box-shadow: 0px 0 30px rgba(1, 41, 112, 0.1);
background-color: white;
font-size: 0.8rem;
margin-top: 7px;
}
.company-name:active {
animation: clickEffect 0.s ease;
/* Apply the click effect animation on click */
color: #0056b3;
/* Darken color on click */
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.req_span {
font-size: 10px;
}
.req_auth_span {
font-size: 10px;
}
</style>
<title>Permout Workorders</title>
</head>
<body> <!-- ======= Header ======= -->
<header id="header" class="header fixed-top d-flex align-items-center">
<div class="d-flex align-items-center justify-content-between">
<img class="navbar-image" src="assets/img/dtl.png" alt="">
<a href="index.php" class="logo d-flex align-items-center">
<span class="d-none d-lg-block"></span>
</a>
<i class="bi bi-list toggle-sidebar-btn"></i>
</div><!-- End Logo -->
<!--
<div class="search-bar">
<form class="search-form d-flex align-items-center" method="POST" action="#">
<input type="text" name="query" placeholder="Search" title="Enter search keyword">
<button type="submit" title="Search"><i class="bi bi-search"></i></button>
</form>
</div>
End Search Bar -->
<nav class="header-nav ms-auto">
<ul class="d-flex align-items-center">
<li class="nav-item d-block d-lg-none">
<a class="nav-link nav-icon search-bar-toggle " href="#">
<i class="bi bi-search"></i>
</a>
</li><!-- End Search Icon-->
<li class="nav-item profileimage dropdown pe-3 mr-4">
<a class="nav-link nav-profile d-flex align-items-center pe-0" href="#" data-bs-toggle="dropdown">
<img src="image/admin-png.png" alt="Profile" class="rounded-circle">
<span class="d-none d-md-block dropdown-toggle ps-2"><?php echo $adminName ?></span>
</a><!-- End Profile Image Icon -->
<ul class="dropdown-menu dropdown-menu-end dropdown-menu-arrow profile">
<li class="dropdown-header">
<h6><?php echo $adminName ?></h6>
<span><?php echo $adminEmail ?></span>
</li>
<li>
<hr class="dropdown-divider">
</li>
</li>
<li>
<a class="dropdown-item d-flex align-items-center" href="logout.php">
<i class="bi bi-box-arrow-right"></i>
<span>Sign Out</span>
</a>
</li>
</ul><!-- End Profile Dropdown Items -->
</li><!-- End Profile Nav -->
</ul>
</nav><!-- End Icons Navigation -->
</header><!-- End Header -->
<!-- sidebar start -->
<?php
include "sidebarcode.php";
?>
<!-- sidebar end -->
<!--form--------------------------------------form--------------------------------------->
<!-- Main content -->
<main id="main" class="main">
<div class="col-15">
<!-- Add the buttton for the work order -->
<div class="cardBranch recent-sales overflow-auto">
<div class="card-body">
<!-- Title and Add Button -->
<div class="row mb-3">
<div class="col-6">
<h5 class="card-title">Permout Work Orders</h5>
</div>
<div class="col-6 text-end mt-2">
<button type="button" onclick="window.location.href = 'createPermoutWO.php'" class="btn btn-primary mb-3">Add</button>
</div>
</div>
<!-- Search Form -->
<form method="GET" action="" class="row g-3 mb-3">
<!-- Dropdown for Column Selection -->
<div class="col-md-4">
<label for="column" class="form-label">Select Column</label>
<select name="column" id="column" class="form-select">
<option value="" selected>Choose...</option>
<option value="comp_id_fk">Company</option>
<option value="branch_id_fk">Branch</option>
<option value="dept_id_fk">Department</option>
<!-- <option value="status">Status</option> -->
<option value="priority">Priority</option>
</select>
</div>
<!-- Input Field for Search Value -->
<div class="col-md-4">
<label for="value" class="form-label">Search Value</label>
<input type="text" name="value" id="value" class="form-control" placeholder="Enter search value">
</div>
<!-- Buttons -->
<div class="col-md-4 d-flex align-items-end gap-2">
<button type="submit" name="search" class="btn btn-primary w-100">Search</button>
<button type="submit" name="show_all" class="btn btn-secondary w-100">Show All</button>
</div>
<!-- Date Range Filter -->
<div class="col-md-4">
<label for="start_date" class="form-label">Start Date</label>
<input type="date" name="start_date" id="start_date" class="form-control">
</div>
<div class="col-md-4">
<label for="end_date" class="form-label">End Date</label>
<input type="date" name="end_date" id="end_date" class="form-control">
</div>
<div class="col-md-4 d-flex align-items-end">
<button type="submit" name="filter_date" class="btn btn-info w-50">Filter Dates</button>
</div>
</form>
<!-- Table -->
<?php
// Query logic
$query = "SELECT * FROM orders WHERE 1=0"; // Default no rows
// Search by Column and Value
if (isset($_GET['search']) && !empty($_GET['column']) && !empty($_GET['value'])) {
$column = $conn->real_escape_string($_GET['column']);
$value = $conn->real_escape_string($_GET['value']);
if ($column === 'comp_id_fk') {
// Search by Company Name
$query = "SELECT o.* FROM orders o
JOIN compani c ON o.comp_id_fk = c.comp_id
WHERE c.comp_name LIKE '%$value%'";
} elseif ($column === 'branch_id_fk') {
// Search by Branch Name
$query = "SELECT o.* FROM orders o
JOIN branches b ON o.branch_id_fk = b.branch_id
WHERE b.branch_name LIKE '%$value%'";
} elseif ($column === 'dept_id_fk') {
// Search by Department Name
$query = "SELECT o.* FROM orders o
JOIN departments d ON o.dept_id_fk = d.dept_id
WHERE d.dept_name LIKE '%$value%'";
} else {
// Search other fields in the orders table
$query = "SELECT * FROM orders WHERE flag = 'Permout' AND $column LIKE '%$value%' ORDER BY order_creation_date DESC";
}
}
// Filter by Date Range
if (isset($_GET['filter_date']) && !empty($_GET['start_date']) && !empty($_GET['end_date'])) {
$start_date = $conn->real_escape_string($_GET['start_date']);
$end_date = $conn->real_escape_string($_GET['end_date']);
$query = "SELECT * FROM orders WHERE flag = 'Permout' AND order_creation_date BETWEEN '$start_date' AND '$end_date'";
}
// Show All Button
if (isset($_GET['show_all'])) {
$query = "SELECT * FROM orders where flag = 'Permout' LIMIT 100";
}
// Execute the query
$result = $conn->query($query);
if ($result && $result->num_rows > 0) {
echo '<table id="orderT" class="table table-striped mt-4">
<thead>
<tr>
<th>Workorder#</th>
<th>Company</th>
<th>Branch</th>
<th>Department</th>
<th>Create Date</th>
<th>Priority</th>
<th>Required By</th>';
if ($_SESSION['role'] == 'admin') {
echo '<th>Action</th>';
}
echo '</tr></thead><tbody>';
$counter = 1;
while ($row = $result->fetch_assoc()) {
// Fetch Company Name
$comp_name = get_name($conn, "compani", "comp_name", "comp_id", $row['comp_id_fk']);
// Fetch Branch Name
$branch_name = get_name($conn, "branches", "branch_name", "branch_id", $row['branch_id_fk']);
// Fetch Department Name
$dept_name = get_name($conn, "departments", "dept_name", "dept_id", $row['dept_id_fk']);
// Format Dates
$createDate = date("d-m-Y", strtotime($row['order_creation_date']));
$requiredBy = date("d-m-Y", strtotime($row['date']));
echo "<tr>
<td>{$row['order_no']}</td>
<td>{$comp_name}</td>
<td>{$branch_name}</td>
<td>{$dept_name}</td>
<td>{$createDate}</td>
<td>{$row['priority']}</td>
<td>{$requiredBy}</td>";
if ($_SESSION['role'] == 'admin') {
echo '<td>
<div class="d-flex gap-2">
<a href="viewOrder.php?id=' . $row['order_no'] . '" class="btn btn-info btn-sm">
<i class="fa-solid fa-print"></i>
</a>
<a href="deleteOrder.php?id=' . $row['order_no'] . '" class="btn btn-danger btn-sm" onclick="return confirm(\'Are you sure?\');">
<i class="fa-solid fa-trash"></i>
</a>
</div>
</td>';
}
echo '</tr>';
$counter++;
}
echo '</tbody></table>';
} elseif (isset($_GET['search']) || isset($_GET['filter_date']) || isset($_GET['show_all'])) {
echo '<p class="text-center mt-3">No results found.</p>';
}
?>
</div>
</div>
<?php
// Function to fetch names based on IDs
function get_name($conn, $table, $column_name, $id_column, $id_value)
{
$query = "SELECT $column_name FROM $table WHERE $id_column = '$id_value' LIMIT 1";
$result = $conn->query($query);
if ($result && $result->num_rows > 0) {
return $result->fetch_assoc()[$column_name];
}
return "N/A"; // Return default if not found
}
?>
</div>
</main>
<a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>
<!-- jQuery library -->
<script src="https://code.jquery.com/jquery-3.7.1.js"></script>
<!-- DataTables core library and export buttons -->
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.js"></script>
<script src="https://cdn.datatables.net/2.1.8/js/dataTables.bootstrap5.js"></script>
<script src="https://cdn.datatables.net/buttons/3.1.2/js/dataTables.buttons.js"></script>
<script src="https://cdn.datatables.net/buttons/3.1.2/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/3.1.2/js/buttons.print.min.js"></script>
<!-- Additional libraries for exporting (Excel, PDF) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<!-- Bootstrap and DataTables styling -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/2.1.8/css/dataTables.bootstrap5.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>
<!-- SearchPanes and Select styling and functionality -->
<link rel="stylesheet" href="https://cdn.datatables.net/searchpanes/2.3.3/css/searchPanes.bootstrap5.css">
<link rel="stylesheet" href="https://cdn.datatables.net/select/2.1.0/css/select.bootstrap5.css">
<script src="https://cdn.datatables.net/searchpanes/2.3.3/js/dataTables.searchPanes.js"></script>
<script src="https://cdn.datatables.net/searchpanes/2.3.3/js/searchPanes.bootstrap5.js"></script>
<script src="https://cdn.datatables.net/select/2.1.0/js/dataTables.select.js"></script>
<!--for icons-->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<link href="https://cdn.jsdelivr.net/npm/remixicon/fonts/remixicon.css" rel="stylesheet">
<!-- Vendor JS Files -->
<script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
<script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="assets/vendor/chart.js/chart.umd.js"></script>
<script src="assets/vendor/echarts/echarts.min.js"></script>
<script src="assets/vendor/quill/quill.js"></script>
<script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
<script src="assets/vendor/tinymce/tinymce.min.js"></script>
<script src="assets/vendor/php-email-form/validate.js"></script>
<!-- Template Main JS File -->
<script src="assets/js/main.js"></script>
<!--for datatable-->
<script>
new DataTable('#orderT', {
// <!--make the table => datatable.net table and also change the alignment of the text in columns-->
columnDefs: [{
className: "text-left",
targets: [0, 1, 2, 3, 4, 5, 6, 7]
} // change alignment
],
//show the rows in descending order by the date
"order": [
[3, "desc"]
],
//show 100 rows by default
"pageLength": 100,
//collapse by default
"searchPanes": {
"initCollapsed": true,
columns: []
}
});
</script>
</body>
</html>