-
Notifications
You must be signed in to change notification settings - Fork 0
/
getOrderReport.php
53 lines (41 loc) · 1.23 KB
/
getOrderReport.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
<?php
require_once 'core.php';
if($_POST) {
$startDate = $_POST['startDate'];
$date = DateTime::createFromFormat('m/d/Y',$startDate);
$start_date = $date->format("Y-m-d");
$endDate = $_POST['endDate'];
$format = DateTime::createFromFormat('m/d/Y',$endDate);
$end_date = $format->format("Y-m-d");
$sql = "SELECT * FROM orders WHERE order_date >= '$start_date' AND order_date <= '$end_date' and order_status = 1";
$query = $connect->query($sql);
$table = '
<table border="1" cellspacing="0" cellpadding="0" style="width:100%;">
<tr>
<th>Order Date</th>
<th>Client Name</th>
<th>Contact</th>
<th>Grand Total</th>
</tr>
<tr>';
$totalAmount = 0;
while ($result = $query->fetch_assoc()) {
$table .= '<tr>
<td><center>'.$result['order_date'].'</center></td>
<td><center>'.$result['client_name'].'</center></td>
<td><center>'.$result['client_contact'].'</center></td>
<td><center>'.$result['grand_total'].'</center></td>
</tr>';
$totalAmount += $result['grand_total'];
}
$table .= '
</tr>
<tr>
<td colspan="3"><center>Total Amount</center></td>
<td><center>'.$totalAmount.'</center></td>
</tr>
</table>
';
echo $table;
}
?>