-
Notifications
You must be signed in to change notification settings - Fork 0
/
sales_report.php
117 lines (117 loc) · 4.07 KB
/
sales_report.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
<?php
include 'db_connect.php';
$month = isset($_GET['month']) ? $_GET['month'] : date('Y-m');
?>
<div class="container-fluid">
<div class="col-lg-12">
<div class="card">
<div class="card_body">
<div class="row justify-content-center pt-4">
<label for="" class="mt-2">Month</label>
<div class="col-sm-3">
<input type="month" name="month" id="month" value="<?php echo $month ?>" class="form-control">
</div>
</div>
<hr>
<div class="col-md-12">
<table class="table table-bordered" id='report-list'>
<thead>
<tr>
<th class="text-center">#</th>
<th class="">Date</th>
<th class="">Invoice</th>
<th class="">Order Number</th>
<th class="">Amount</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$total = 0;
$sales = $conn->query("SELECT * FROM orders where amount_tendered > 0 and date_format(date_created,'%Y-%m') = '$month' order by unix_timestamp(date_created) asc ");
if($sales->num_rows > 0):
while($row = $sales->fetch_array()):
$total += $row['total_amount'];
?>
<tr>
<td class="text-center"><?php echo $i++ ?></td>
<td>
<p> <b><?php echo date("M d,Y",strtotime($row['date_created'])) ?></b></p>
</td>
<td>
<p> <b><?php echo $row['amount_tendered'] > 0 ? $row['ref_no'] : 'N/A' ?></b></p>
</td>
<td>
<p> <b><?php echo $row['order_number'] ?></b></p>
</td>
<td>
<p class="text-right"> <b><?php echo number_format($row['total_amount'],2) ?></b></p>
</td>
</tr>
<?php
endwhile;
else:
?>
<tr>
<th class="text-center" colspan="5">No Data.</th>
</tr>
<?php
endif;
?>
</tbody>
<tfoot>
<tr>
<th colspan="4" class="text-right">Total</th>
<th class="text-right"><?php echo number_format($total,2) ?></th>
</tr>
</tfoot>
</table>
<hr>
<div class="col-md-12 mb-4">
<center>
<button class="btn btn-success btn-sm col-sm-3" type="button" id="print"><i class="fa fa-print"></i> Print</button>
</center>
</div>
</div>
</div>
</div>
</div>
</div>
<noscript>
<style>
table#report-list{
width:100%;
border-collapse:collapse
}
table#report-list td,table#report-list th{
border:1px solid
}
p{
margin:unset;
}
.text-center{
text-align:center
}
.text-right{
text-align:right
}
</style>
</noscript>
<script>
$('#month').change(function(){
location.replace('index.php?page=sales_report&month='+$(this).val())
})
$('#print').click(function(){
var _c = $('#report-list').clone();
var ns = $('noscript').clone();
ns.append(_c)
var nw = window.open('','_blank','width=900,height=600')
nw.document.write('<p class="text-center"><b>Order Report as of <?php echo date("F, Y",strtotime($month)) ?></b></p>')
nw.document.write(ns.html())
nw.document.close()
nw.print()
setTimeout(() => {
nw.close()
}, 500);
})
</script>