-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmonthly_report.php
executable file
·70 lines (53 loc) · 1.67 KB
/
monthly_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
<?php
include 'header.php';
if(isset($_GET['prev'])) $prev = "previous"; else $prev = "this";
$month_fd = date("Y-n-j", strtotime("first day of $prev month"));
$month_ld = date("Y-n-j", strtotime("last day of $prev month"));
$month = date('F Y', strtotime("$prev month"));
include_once 'mysqli.php';
if(!isset($mysqli)) $mysqli = new mysqli($server, $user, $pass, $db);
$query2 = "SELECT sum(amount) as rev, count(bill_id) as trips FROM `billing` WHERE `time` BETWEEN '".$month_fd."' AND '".$month_ld."'";
$result = mysqli_query($mysqli, $query2);
if(!$result) die("Error");
$row = mysqli_fetch_assoc($result);
echo '<div class="container">
<a href="/monthly_report.php?prev" class="btn btn-info">Previous Month</a>
<a href="/monthly_report.php" class="btn btn-info">Current Month</a>
<h1>
Monthly Report '.$month.'
</h1>
<br>
<br>
<h2>Total trips '.$row['trips'].'</h2>
<h2>Monthly revenue '.$row['rev'].' LKR</h2>
<br>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">User</th>
<th scope="col">Amt</th>
<th scope="col"></th>
</tr>
</thead>
<tbody>';
$query = "SELECT * FROM `billing` WHERE `time` BETWEEN '".$month_fd."' AND '".$month_ld."'";
$result = mysqli_query($mysqli, $query);
while($row=mysqli_fetch_assoc($result))
{
echo '<tr>
<th scope="row">'.$row['bill_id'].'</th>
<td>'.get_fullname($row['uid']).'</td>
<td>'.$row['amount'].' LKR</td>
<td>
<div class="btn-group" role="group">
<a href="bill.php?id='.$row['bill_id'].'" class="btn btn-secondary btn-info">Bill</a>
</div>
</td>
</tr>';
}
echo '</tbody>
</table>
</div>';
include 'footer.php';
?>