-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtoday-report.php
370 lines (348 loc) · 14.6 KB
/
today-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
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
<?php
session_start();
if(!isset($_SESSION['store_id'])) {
header("location:login.php");
exit();
}else{
include('config/db.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pharmacy</title>
<!-- Data Table CSS -->
<?php include("part/data-table-css.php");?>
<!-- Data Table CSS end -->
<!-- All CSS -->
<?php include("part/all-css.php");?>
<!-- All CSS end -->
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
<!-- Navbar -->
<?php include("part/navbar.php");?>
<!-- Navbar end -->
<!-- Sidebar -->
<?php include("part/sidebar.php");?>
<!-- Sidebar end -->
<div class="content-wrapper">
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1>Today's Report</h1>
</div>
</div>
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-3">
<div class="card card-body bg-success">
<h6 class="text-white text-uppercase">Sell Amount</h6>
<?php $result = mysqli_fetch_assoc($conn->query("SELECT IFNULL(SUM(`paid`), 0) as paid FROM `p_invoice_summary` WHERE `store` = '$_SESSION[store_id]' AND `date` = '$date'"));?>
<p class="fs-18 fw-700">৳ <?php echo $result['paid']; ?></p>
</div>
</div>
<div class="col-md-3">
<div class="card card-body bg-primary">
<h6 class="text-white text-uppercase">Sell Profit</h6>
<?php $result = mysqli_fetch_assoc($conn->query("SELECT IFNULL(SUM(`payable`-`total_cost`), 0) as profit FROM `p_invoice_summary` WHERE `store` = '$_SESSION[store_id]' AND `date` = '$date'"));?>
<p class="fs-18 fw-700">৳ <?php echo $result['profit']; ?> </p>
</div>
</div>
<div class="col-md-3">
<div class="card card-body bg-danger">
<h6 class="text-white text-uppercase">Purchase Cost</h6>
<?php $result = mysqli_fetch_assoc($conn->query("SELECT IFNULL(SUM(`total_price`), 0) as purchase FROM `p_purchase_summary` WHERE `store` = '$_SESSION[store_id]' AND `transection_submit_date` = '$date' AND `paid_status` != 'unpaid'"));?>
<p class="fs-18 fw-700">৳ <?php echo $result['purchase']; ?> </p>
</div>
</div>
<div class="col-md-3">
<div class="card card-body bg-dark">
<h6 class="text-white text-uppercase">Expense</h6>
<?php $result = mysqli_fetch_assoc($conn->query("SELECT IFNULL(SUM(`amount`), 0) as expense FROM `p_expense` WHERE `store` = '$_SESSION[store_id]' AND `expense_date` = '$date'"));?>
<p class="fs-18 fw-700">৳ <?php echo $result['expense']; ?></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="card">
<div class="card-header">
<h4>Top Sell Product</h4>
</div>
<div class="card-body">
<table id="mytable" class="table table-bordered table-hover">
<thead>
<tr class="bg-info">
<th>Total Sale</th>
<th>Product Name</th>
<th>Quantity</th>
<th>Price</th>
<th>Sale Amount</th>
</tr>
</thead>
<tbody>
<?php
$n = 0;
$sql = $conn->query("SELECT `name`, `qty`, `price` FROM `p_medicine` WHERE `store` = '$_SESSION[store_id]'");
while($row = mysqli_fetch_assoc($sql)){
$sellQty = mysqli_fetch_assoc($conn->query("SELECT sum(qty) AS `qty` FROM `p_invoice` where `product` = '$row[name]' AND `store` = '$_SESSION[store_id]' AND `date` = '$date'"));
if($sellQty['qty'] > 0){
?>
<tr>
<td><?php echo (!empty($sellQty['qty'])) ? $sellQty['qty'] : 0;?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['qty']; ?></td>
<td><?php echo $row['price']; ?></td>
<td><?php echo $sellQty['qty']*$row['price']; ?></td>
</tr>
<?php } } ?>
</tbody>
<tfoot class="bg-light">
<tr>
<td colspan="4" class="text-right"><strong>Total Sales (tk): </strong></td>
<td><strong id="totalSales"> 0.00 </strong></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-header">
<h4>Expense</h4>
</div>
<div class="card-body">
<table id="mytable2" class="table table-bordered table-hover">
<thead>
<tr class="bg-info">
<th>#</th>
<th>Expense</th>
<th>Category</th>
<th>Payment Method</th>
<th>Amount</th>
<th>Date</th>
</tr>
</thead>
<tbody>
<?php
$n = 0;
$sql = $conn->query("SELECT * FROM p_expense WHERE store = '$_SESSION[store_id]' AND `expense_date` = '$date'");
while($row = mysqli_fetch_assoc($sql)){
?>
<tr>
<td><?php echo ++$n; ?></td>
<td><?php echo $row['name']; ?></td>
<td><?php echo $row['category']; ?></td>
<td><?php echo $row['payment_method']; ?></td>
<td><?php echo $row['amount']; ?></td>
<td><?php echo $row['expense_date']; ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot class="bg-light">
<tr>
<td colspan="4" class="text-right"><strong> Total (tk): </strong> </td>
<td colspan="1"><strong id="totalExpense"> 0.00 </strong> </td>
<td></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-header">
<h4>Purchase Product</h4>
</div>
<div class="card-body">
<table id="mytable3" class="table table-bordered table-hover">
<thead>
<tr class="bg-info">
<th>#</th>
<th>Invoice</th>
<th>Total Items</th>
<th>Total Price</th>
<th>Paid Status</th>
<th>Order Status</th>
</tr>
</thead>
<tbody>
<?php
$n = 0;
$sql = $conn->query("SELECT * FROM `p_purchase_summary` WHERE store = '$_SESSION[store_id]' AND `date` = '$date'");
while($row = mysqli_fetch_assoc($sql)){
?>
<tr>
<td>1</td>
<td> <?php echo $row['invoice']; ?> </td>
<td><?php echo $row['total_qty']; ?></td>
<td><?php echo $row['total_price']; ?></td>
<td><?php echo $row['paid_status']; ?></td>
<td><?php echo $row['status']; ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td colspan="3" class="text-right"> <strong> Total (tk):</strong></td>
<td> <strong id="totalPurchase"> 0 </strong> </td>
<td></td>
<td></td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-header">
<h4>Cash Received</h4>
</div>
<div class="card-body">
<table id="mytable4" class="table table-bordered table-hover">
<thead>
<tr class="bg-info">
<th>#</th>
<th>Name</th>
<th>Customer/Supplier</th>
<th>Payment Date</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<?php
$n = 0;
$sql = $conn->query("SELECT * FROM `p_payment` WHERE `store` = '$_SESSION[store_id]' AND `payment_type` = 'Cash Receivable' AND `payment_date` = '$date'");
while($row = mysqli_fetch_assoc($sql)){
?>
<tr>
<td><?php echo ++$n; ?></td>
<td> <?php echo $row['name']; ?> </td>
<td><?php echo $row['account_type']; ?></td>
<td><?php echo $row['payment_date']; ?></td>
<td><?php echo $row['amount']; ?></td>
</tr>
<?php } ?>
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right"><strong>Total (tk): </strong> </td>
<td> <strong id="totalReceived"> 0.00 </strong> </td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- Footer -->
<?php include("part/footer.php");?>
<!-- Footer End -->
</div>
<!-- Alert -->
<?php include("part/alert.php");?>
<!-- Alert end -->
<!-- All JS -->
<?php include("part/all-js.php");?>
<!-- All JS end -->
<!-- Data Table JS -->
<?php include("part/data-table-js.php");?>
<!-- Data Table JS end -->
<!-- Page specific script -->
<script>
$(function () {
$(".select2").select2();
$(".select2bs4").select2({
theme: "bootstrap4",
});
});
</script>
<script>
$(document).ready(function () {
$('#mytable').DataTable({
order: [[0, 'desc']],
// pageLength : 3,
dom: 'Bfrtip',
aaSorting: [],
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print', 'colvis' ],
"footerCallback": function (row, data, start, end, display) {
var totalAmount = 0;
for (var i = 0; i < data.length; i++) {
totalAmount += parseFloat(data[i][4]);
}
// console.log(totalAmount);
$("#totalSales").text(totalAmount);
}
});
$('#mytable2').DataTable({
// order: [[0, 'desc']],
dom: 'Bfrtip',
aaSorting: [],
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print', 'colvis' ],
"footerCallback": function (row, data, start, end, display) {
//Get data here
// console.log(data);
var totalAmount = 0;
for (var i = 0; i < data.length; i++) {
totalAmount += parseFloat(data[i][4]);
}
// console.log(totalAmount);
$("#totalExpense").text(totalAmount);
}
});
$('#mytable3').DataTable({
// order: [[0, 'desc']],
dom: 'Bfrtip',
aaSorting: [],
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print', 'colvis' ],
"footerCallback": function (row, data, start, end, display) {
//Get data here
// console.log(data);
var totalAmount = 0;
for (var i = 0; i < data.length; i++) {
totalAmount += parseFloat(data[i][3]);
}
// console.log(totalAmount);
$("#totalPurchase").text(totalAmount);
}
});
$('#mytable4').DataTable({
// order: [[0, 'desc']],
dom: 'Bfrtip',
aaSorting: [],
buttons: [ 'copy', 'csv', 'excel', 'pdf', 'print', 'colvis' ],
"footerCallback": function (row, data, start, end, display) {
//Get data here
// console.log(data);
var totalAmount = 0;
for (var i = 0; i < data.length; i++) {
totalAmount += parseFloat(data[i][4]);
}
// console.log(totalAmount);
$("#totalReceived").text(totalAmount);
}
});
});
</script>
</body>
</html>