-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorders.php
More file actions
127 lines (125 loc) · 7.28 KB
/
Copy pathorders.php
File metadata and controls
127 lines (125 loc) · 7.28 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
<?php include('user/includes1/header.php'); ?>
<div class="container-fluid px-4">
<div class="card mt-4 shadow-sm">
<div style="background-color:#4153B7; color:white; " class="card-header">
<div class="row align-items-center">
<div class="col-md-4">
<h4 class="mb-0">Orders</h4>
</div>
<div class="col-md-8">
<form action="" method="GET">
<div class="row g-1 align-items-center">
<div class="col-md-4">
<input type="date" name="date" class="form-control form-control-sm" value="<?= isset($_GET['date']) == true ? $_GET['date'] : ''; ?>" />
</div>
<div class="col-md-4">
<select name="payment_status" class="form-select form-select-sm">
<option value="">-- Select Payment Status --</option>
<option value="Cash Payment" <?= isset($_GET['payment_status']) == true ? ($_GET['payment_status'] == 'Cash Payment' ? 'selected' : '') : ''; ?>>Cash Payment</option>
<option
value="Card Payment - Credit Card"
<?= isset($_GET['payment_status']) == true
?
($_GET['payment_status'] == 'Card Payment - Credit Card' ? 'selected' : '')
:
'';
?>>
Credit Card
</option>
<option
value="Card Payment - Debit Card"
<?= isset($_GET['payment_status']) == true
?
($_GET['payment_status'] == 'Card Payment - Debit Card' ? 'selected' : '')
:
'';
?>>
Debit Card
</option>
<option
value="E-Transfer"
<?= isset($_GET['payment_status']) == true
?
($_GET['payment_status'] == 'E-Transfer' ? 'selected' : '')
:
'';
?>>
E-Transfer
</option>
</select>
</div>
<div class="col-md-4 text-end">
<button type="submit" class="btn btn-primary btn-sm">Filter</button>
<a href="orders.php" class="btn btn-danger btn-sm">Reset</a>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="card-body">
<?php
if (isset($_GET['date']) || isset($_GET['payment_status'])) {
$orderDate = validate($_GET['date']);
$paymentStatus = validate($_GET['payment_status']);
if ($orderDate != '' && $paymentStatus == '') {
$query = "SELECT o.*, c.* FROM orders o, customers c WHERE c.id = o.customer_id AND o.order_date = '$orderDate' ORDER BY o.id DESC";
} elseif ($orderDate == '' && $paymentStatus != '') {
$query = "SELECT o.*, c.* FROM orders o, customers c WHERE c.id = o.customer_id AND o.payment_mode = '$paymentStatus' ORDER BY o.id DESC";
} elseif ($orderDate != '' && $paymentStatus != '') {
$query = "SELECT o.*, c.* FROM orders o, customers c WHERE c.id = o.customer_id AND o.order_date = '$orderDate' AND o.payment_mode = '$paymentStatus' ORDER BY o.id DESC";
} else {
$query = "SELECT o.*, c.* FROM orders o, customers c WHERE c.id = o.customer_id ORDER BY o.id DESC";
}
} else {
$query = "SELECT o.*, c.* FROM orders o, customers c WHERE c.id = o.customer_id ORDER BY o.id DESC";
}
$orders = mysqli_query($conn, $query);
if ($orders) {
if (mysqli_num_rows($orders) > 0) {
?>
<div class="table-responsive">
<table class="table table-striped table-bordered align-middle" style="font-size: 0.9rem;">
<thead>
<tr>
<th>Invoice No.</th>
<th>Tracking No.</th>
<th>C Name</th>
<th>C Phone</th>
<th>Order Date</th>
<th>Order Status</th>
<th>Payment Mode</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($orders as $orderItem) : ?>
<tr>
<td class="fw-bold"><?= $orderItem['invoice_no']; ?></td>
<td><?= $orderItem['tracking_no']; ?></td>
<td class="fw-normal"><?= $orderItem['name']; ?></td>
<td class="fw-normal"><?= $orderItem['phone']; ?></td>
<td><?= date('d M, Y', strtotime($orderItem['order_date'])); ?></td>
<td class="fw-normal"><?= $orderItem['order_status']; ?></td>
<td class="fw-normal"><?= $orderItem['payment_mode']; ?></td>
<td class="text-center">
<a href="orders-view.php?track=<?= $orderItem['tracking_no']; ?>" class="btn btn-info btn-sm px-2 py-1">View</a>
<a href="orders-view-print.php?track=<?= $orderItem['tracking_no']; ?>" class="btn btn-primary btn-sm px-2 py-1">Print</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
} else {
echo "<h5 class='text-center'>No Record Found</h5>";
}
} else {
echo "<h5 class='text-center'>Something Went Wrong</h5>";
}
?>
</div>
</div>
</div>
<?php include('user/includes1/footer.php') ?>