-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbalance_report.php
More file actions
137 lines (136 loc) · 5.3 KB
/
balance_report.php
File metadata and controls
137 lines (136 loc) · 5.3 KB
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
<?php include 'db_connect.php' ?>
<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 mt-5">
<marquee onMouseOver="this.stop()" style="color: #e92f33;" onMouseOut="this.start()">This is a Code Camp BD's free source code for educational use only. It can never be used for commercial purposes. Don't forget to take <a target="_blank" href="https://www.youtube.com/@codecampbdofficial">Code Camp BD</a> permission if needed! to contact - <a target="_blank" href="https://www.facebook.com/dev.mhrony">MH RONY</a> </marquee>
<div class="card">
<div class="card-body">
<div class="col-md-12">
<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 Balances Report</center></p>
<p><center>As of <b><?php echo date('F ,Y') ?></b></center></p>
</div>
<div class="row">
<table class="table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Tenant</th>
<th>House #</th>
<th>Monthly Rate</th>
<th>Payable Months</th>
<th>Payable Amount</th>
<th>Paid</th>
<th>Outstanding Balance</th>
<th>Last Payment</th>
</tr>
</thead>
<!-- Author Name: MH RONY.
GigHub Link: https://github.com/dev-mhrony
Facebook Link:https://www.facebook.com/dev.mhrony
Youtube Link: https://www.youtube.com/channel/UChYhUxkwDNialcxj-OFRcDw
for any PHP, Laravel, Python, Dart, Flutter work contact me at developer.mhrony@gmail.com
Visit My Website : developerrony.com
-->
<tbody>
<?php
$i = 1;
// $tamount = 0;
$tenants =$conn->query("SELECT t.*,concat(t.lastname,', ',t.firstname,' ',t.middlename) as name,h.house_no,h.price FROM tenants t inner join houses h on h.id = t.house_id where t.status = 1 order by h.house_no desc ");
if($tenants->num_rows > 0):
while($row=$tenants->fetch_assoc()):
$months = abs(strtotime(date('Y-m-d')." 23:59:59") - strtotime($row['date_in']." 23:59:59"));
$months = floor(($months) / (30*60*60*24));
$payable = $row['price'] * $months;
$paid = $conn->query("SELECT SUM(amount) as paid FROM payments where tenant_id =".$row['id']);
$last_payment = $conn->query("SELECT * FROM payments where tenant_id =".$row['id']." order by unix_timestamp(date_created) desc limit 1");
$paid = $paid->num_rows > 0 ? $paid->fetch_array()['paid'] : 0;
$last_payment = $last_payment->num_rows > 0 ? date("M d, Y",strtotime($last_payment->fetch_array()['date_created'])) : 'N/A';
$outstanding = $payable - $paid;
?>
<tr>
<td><?php echo $i++ ?></td>
<td><?php echo ucwords($row['name']) ?></td>
<td><?php echo $row['house_no'] ?></td>
<td class="text-right"><?php echo number_format($row['price'],2) ?></td>
<td class="text-right"><?php echo $months.' mo/s' ?></td>
<td class="text-right"><?php echo number_format($payable,2) ?></td>
<td class="text-right"><?php echo number_format($paid,2) ?></td>
<td class="text-right"><?php echo number_format($outstanding,2) ?></td>
<td><?php echo date('M d,Y',strtotime($last_payment)) ?></td>
</tr>
<?php endwhile; ?>
<?php else: ?>
<tr>
<th colspan="9"><center>No Data.</center></th>
</tr>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<p class="text-muted mb-1 mb-md-0">Copyright © 2024 <a href="https://www.facebook.com/dev.mhrony/" target="_blank">Tenant Management System Software</a> - Design and Develop By MH RONY </p>
<!-- Author Name: MH RONY.
GigHub Link: https://github.com/dev-mhrony
Facebook Link:https://www.facebook.com/dev.mhrony
Youtube Link: https://www.youtube.com/channel/UChYhUxkwDNialcxj-OFRcDw
for any PHP, Laravel, Python, Dart, Flutter work contact me at developer.mhrony@gmail.com
Visit My Website : developerrony.com
-->
</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><!-- Author Name: MH RONY.
GigHub Link: https://github.com/dev-mhrony
Facebook Link:https://www.facebook.com/dev.mhrony
Youtube Link: https://www.youtube.com/channel/UChYhUxkwDNialcxj-OFRcDw
for any PHP, Laravel, Python, Dart, Flutter work contact me at developer.mhrony@gmail.com
Visit My Website : developerrony.com
-->