-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathsales_by_order.php
188 lines (161 loc) · 6.1 KB
/
sales_by_order.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
<?php
$page_title = 'All sales by Order';
require_once('includes/load.php');
// Checkin What level user has permission to view this page
page_require_level(3);
?>
<?php
if(isset($_GET['id']))
{
$order_id = (int) $_GET['id'];
} else {
$session->msg("d","Missing order id.");
}
$sales = find_sales_by_order_id( $order_id );
$order = find_by_id("orders", $order_id);
?>
<?php include_once('layouts/header.php'); ?>
<div class="row">
<div class="col-md-12">
<?php echo display_msg($msg); ?>
</div>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<strong>
<span class="glyphicon glyphicon-th"></span>
<!-- ************************* -->
<span>Order #<?php echo $order_id; ?></span>
<!-- ************************* -->
</strong>
</div>
<div class="panel-body">
<table class="table table-bordered table-striped table-hover">
<thead>
<tr>
<th class="text-center" style="width: 50px;">#</th>
<th class="text-center" style="width: 50px;">Customer</th>
<th class="text-center" style="width: 50px;">Pay Method</th>
<th class="text-center" style="width: 50px;">Notes</th>
<th class="text-center" style="width: 50px;">Date</th>
<th class="text-center" style="width: 100px;">Actions</th>
</tr>
</thead>
<tbody>
<!-- ************************* -->
<tr>
<td class="text-center">
<a href="add_sale_to_order.php?id=<?php echo (int)$order['id'];?>">
<?php echo $order['id'];?>
</a>
</td>
<td class="text-center">
<?php echo remove_junk(ucfirst($order['customer']));?>
</td>
<td class="text-center">
<?php echo remove_junk(ucfirst($order['paymethod']));?>
</td>
<td class="text-center">
<?php echo remove_junk(ucfirst($order['notes']));?>
</td>
<td class="text-center">
<?php echo remove_junk(ucfirst($order['date']));?>
</td>
<td class="text-center">
<div class="btn-group">
<a href="edit_order.php?id=<?php echo (int)$order['id'];?>" class="btn btn-xs btn-warning" data-toggle="tooltip" title="Edit">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a href="delete_order.php?id=<?php echo (int)$order['id'];?>" onClick="return confirm('Are you sure you want to delete?')" class="btn btn-xs btn-danger" data-toggle="tooltip" title="Remove">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<!-- ************************* -->
</tbody>
</table>
</div>
</div>
<!-- ************************* -->
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<strong>
<span class="glyphicon glyphicon-th"></span>
<span>Sales</span>
</strong>
<div class="pull-right">
<a href="add_sale_to_order.php?id=<?php echo $order_id; ?>" class="btn btn-primary">Add sale</a>
</div>
</div>
<div class="panel-body">
<!-- ************************* -->
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-center" style="width: 50px;">#</th>
<th> Product name </th>
<th class="text-center" style="width: 15%;"> Quantity</th>
<th class="text-center" style="width: 15%;"> Total </th>
<th class="text-center" style="width: 15%;"> Date </th>
<th class="text-center" style="width: 100px;"> Actions </th>
</tr>
</thead>
<!-- ************************* -->
<tbody>
<?php foreach ($sales as $sale):?>
<tr>
<td class="text-center"><?php echo count_id();?></td>
<td><?php echo remove_junk($sale['name']); ?></td>
<td class="text-center"><?php echo (int)$sale['qty']; ?></td>
<td class="text-center"><?php echo remove_junk($sale['price']); ?></td>
<td class="text-center"><?php echo $sale['date']; ?></td>
<td class="text-center">
<div class="btn-group">
<a href="edit_sale.php?id=<?php echo (int)$sale['id'];?>" class="btn btn-warning btn-xs" title="Edit" data-toggle="tooltip">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a href="delete_sale.php?id=<?php echo (int)$sale['id'];?>" class="btn btn-danger btn-xs" title="Delete" data-toggle="tooltip">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<?php endforeach;?>
<!-- ************************* -->
<tr>
<td class="text-center"></td>
<td class="text-center"></td>
<td class="text-center"></td>
<?php
$order_total = 0;
foreach ($sales as $sale)
{
$order_total = $order_total + $sale['price'];
}
?>
<td class="text-center">$<?php echo number_format($order_total,2); ?></td>
<td class="text-center"></td>
<td class="text-center"></td>
</tr>
</tbody>
</table>
<!-- ************************* -->
</div>
</div>
<?php
// print "<pre>";
// print_r($sales);
// print "</pre>\n";
?>
<?php
// print "<pre>";
// print_r($order);
// print "</pre>\n";
?>
</div>
</div>
<?php include_once('layouts/footer.php'); ?>