-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayment_report.php
119 lines (117 loc) · 3.41 KB
/
payment_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
<?php include 'db_connect.php' ?>
<?php
$month_of = isset($_GET['month_of']) ? $_GET['month_of'] : date('Y-m');
?>
<style>
.on-print{
display: none;
}
</style>
<noscript>
<style>
.text-center{
text-align:center;
}
.text-right{
text-align:right;
}
table{
width: 100%;
border-collapse: collapse
}
tr,td,th{
border:1px solid black;
}
</style>
</noscript>
<div class="container-fluid">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<div class="col-md-12">
<form id="filter-report">
<div class="row form-group">
<label class="control-label col-md-2 offset-md-2 text-right">Month of: </label>
<input type="month" name="month_of" class='from-control col-md-4' value="<?php echo ($month_of) ?>">
<button class="btn btn-sm btn-block btn-primary col-md-2 ml-1">Filter</button>
</div>
</form>
<hr>
<div class="row">
<div class="col-md-12 mb-2">
<button class="btn btn-sm btn-block btn-success col-md-2 ml-1 float-right" type="button" id="print"><i class="fa fa-print"></i> Print</button>
</div>
</div>
<div id="report">
<div class="on-print">
<p><center>Rental Payments Report</center></p>
<p><center>for the Month of <b><?php echo date('F ,Y',strtotime($month_of.'-1')) ?></b></center></p>
</div>
<div class="row">
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Tenant</th>
<th>House #</th>
<th>Invoice</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
$tamount = 0;
$payments = $conn->query("SELECT p.*,concat(t.lastname,', ',t.firstname,' ',t.middlename) as name,h.house_no FROM payments p inner join tenants t on t.id = p.tenant_id inner join houses h on h.id = t.house_id where date_format(p.date_created,'%Y-%m') = '$month_of' order by unix_timestamp(date_created) asc");
if($payments->num_rows > 0 ):
while($row=$payments->fetch_assoc()):
$tamount += $row['amount'];
?>
<tr>
<td><?php echo $i++ ?></td>
<td><?php echo date('M d,Y',strtotime($row['date_created'])) ?></td>
<td><?php echo ucwords($row['name']) ?></td>
<td><?php echo $row['house_no'] ?></td>
<td><?php echo $row['invoice'] ?></td>
<td class="text-right"><?php echo number_format($row['amount'],2) ?></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<th colspan="6"><center>No Data.</center></th>
</tr>
<?php endif; ?>
</tbody>
<tfoot>
<tr>
<th colspan="5">Total Amount</th>
<th class='text-right'><?php echo number_format($tamount,2) ?></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('#print').click(function(){
var _style = $('noscript').clone()
var _content = $('#report').clone()
var nw = window.open("","_blank","width=800,height=700");
nw.document.write(_style.html())
nw.document.write(_content.html())
nw.document.close()
nw.print()
setTimeout(function(){
nw.close()
},500)
})
$('#filter-report').submit(function(e){
e.preventDefault()
location.href = 'index.php?page=payment_report&'+$(this).serialize()
})
</script>