-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.php
151 lines (134 loc) · 7.89 KB
/
home.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
<?php include 'db_connect.php' ?>
<style>
</style>
<div class="containe-fluid">
<div class="row">
<div class="col-lg-12">
</div>
</div>
<div class="row mt-3 ml-3 mr-3">
<div class="col-lg-12">
<div class="card">
<div class="card-body">
<?php echo "Welcome back ".($_SESSION['role'] == 1 ? " ".$_SESSION['username'] : $_SESSION['username'])."!" ?>
</div>
<hr>
<div class="row ml-2 mr-2">
<div class="col-md-3">
<div class="card bg-primary text-white mb-3">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div class="mr-3">
<div class="text-white-75 small">Payments Today</div>
<div class="text-lg font-weight-bold">
<?php
$payments = $conn->query("SELECT sum(monthly_repayment_amount) as total FROM loan_repayment ");
echo $payments->num_rows > 0 ? number_format($payments->fetch_array()['total'],2) : "0.00";
?>
</div>
</div>
<i class="fa fa-calendar"></i>
</div>
</div>
<div class="card-footer d-flex align-items-center justify-content-between">
<a class="small text-white stretched-link" href="index.php?page=payments">View Payments</a>
<div class="small text-white">
<i class="fas fa-angle-right"></i>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-success text-white mb-3">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div class="mr-3">
<div class="text-white-75 small">Clients</div>
<div class="text-lg font-weight-bold">
<?php
$borrowers = $conn->query("SELECT * FROM client");
echo $borrowers->num_rows > 0 ? $borrowers->num_rows : "0";
?>
</div>
</div>
<i class="fa fa-user-friends"></i>
</div>
</div>
<div class="card-footer d-flex align-items-center justify-content-between">
<a class="small text-white stretched-link" href="index.php?page=borrowers">View Clients</a>
<div class="small text-white">
<i class="fas fa-angle-right"></i>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-warning text-white mb-3">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div class="mr-3">
<div class="text-white-75 small">Active Loans</div>
<div class="text-lg font-weight-bold">
<?php
$loans = $conn->query("SELECT * FROM loans where loan_status = 2");
if($loans){
if($loans->num_rows > 0 ? $loans->num_rows : "0"){
$fetchUserData = $loans->fetch_assoc();
print_r($fetchUserData);
}
else{
echo "No record found";
}
}
else{
echo "Error in ".$query."<br>".$conn->error;
}
?>
</div>
</div>
<i class="fa fa-user-friends"></i>
</div>
</div>
<div class="card-footer d-flex align-items-center justify-content-between">
<a class="small text-white stretched-link" href="index.php?page=loans">View Loan List</a>
<div class="small text-white">
<i class="fas fa-angle-right"></i>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card bg-info text-white mb-3">
<div class="card-body">
<div class="d-flex justify-content-between align-items-center">
<div class="mr-3">
<div class="text-white-75 small">Total Receivable</div>
<div class="text-lg font-weight-bold">
<?php
$payments = $conn->query("SELECT sum(monthly_repayment_amount - penalty_amount) as total FROM loan_repayment ");
$loans = $conn->query("SELECT sum(l.loan_amount + (l.loan_amount * (p.interest_percentage/100))) as total FROM loans l inner join loan_plan p WHERE p.planID = l.planID AND l.loan_status = 2");
$loans = $loans->num_rows > 0 ? $loans->fetch_array()['total'] : "0";
$payments = $payments->num_rows > 0 ? $payments->fetch_array()['total'] : "0";
echo number_format($loans - $payments,2);
?>
</div>
</div>
<i class="fa fa-user-friends"></i>
</div>
</div>
<div class="card-footer d-flex align-items-center justify-content-between">
<a class="small text-white stretched-link" href="index.php?page=loans">View Loan List</a>
<div class="small text-white">
<i class="fas fa-angle-right"></i>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
</script>