-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathpending_payments.php
94 lines (87 loc) · 3.11 KB
/
pending_payments.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
<?php include 'db_connect.php' ?>
<div class="container-fluid" style="margin-bottom: 58px;">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<large class="card-title">
<b>Pending Payment List</b>
</large>
</div>
<div class="card-body" style="overflow-x:auto;">
<table class="table table-bordered" id="loan-list">
<colgroup>
<col width="5%">
<col width="15%">
<col width="20%">
<col width="25%">
<col width="20%">
<col width="15%">
</colgroup>
<thead>
<tr>
<th class="text-center text-white">#</th>
<th class="text-center text-white">Loan Reference No</th>
<th class="text-center text-white">Borrower</th>
<th class="text-center text-white">Address</th>
<th class="text-center text-white">Contact No</th>
<th class="text-center text-white">Pending Amount</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
$qry = $conn->query("(SELECT DISTINCT l.id, l.ref_no, concat(b.firstname,' ',b.lastname)as borrower, b.address, b.contact_no, l.daily_amount from borrowers b JOIN loan_list l ON b.id=l.borrower_id WHERE l.status=2
EXCEPT
SELECT DISTINCT l.id, l.ref_no, concat(b.firstname,' ',b.lastname)as borrower, b.address, b.contact_no, l.daily_amount from borrowers b JOIN loan_list l ON b.id=l.borrower_id JOIN payments p on l.id=p.loan_id WHERE l.status=2 AND date(p.date_created)=date(CURRENT_DATE))
UNION
SELECT DISTINCT l.id, l.ref_no, concat(b.firstname,' ',b.lastname)as borrower, b.address, b.contact_no, l.daily_amount from borrowers b JOIN loan_list l ON b.id=l.borrower_id JOIN payments p on l.id=p.loan_id WHERE l.status=2 AND date(p.date_created)=date(CURRENT_DATE) AND l.daily_amount>(SELECT sum(amount) from payments p2 where l.id=p2.loan_id and date(p2.date_created)=date(CURRENT_DATE))");
while($row = $qry->fetch_assoc()):
$payments = $conn->query("SELECT * from payments where date(date_created)=date(CURRENT_DATE) and loan_id =".$row['id']);
$paid = $payments->num_rows;
$offset = $paid > 0 ? " offset $paid ": "";
$sum_paid = 0;
while($p = $payments->fetch_assoc()){
$sum_paid += ($p['amount'] - $p['penalty_amount']);
}
$pending = $row['daily_amount'] - $sum_paid;
?>
<tr>
<td class="text-center"><?php echo $i++ ?></td>
<td>
<?php echo $row['ref_no'] ?>
</td>
<td>
<?php echo $row['borrower'] ?>
</td>
<td>
<?php echo $row['address'] ?>
</td>
<td class="text-center">
<?php echo $row['contact_no'] ?>
</td>
<td class="text-center">
<?php echo number_format($pending,2) ?>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<style>
td p {
margin:unset;
}
td img {
width: 8vw;
height: 12vh;
}
td{
vertical-align: middle !important;
}
</style>
<script>
$('#loan-list').dataTable();
</script>