forked from victorkagimu/KwaMoja
/
prlAuthoriseLoans.php
110 lines (100 loc) · 3.88 KB
/
prlAuthoriseLoans.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
<?php
/* $Revision: 1.0 $ */
include ('includes/session.php');
$Status = array();
$Status[0] = _('Pending Authorisation');
$Status[1] = _('Authorised');
$Status[2] = _('Posted');
$Status[3] = _('Cancelled');
$Status[4] = _('Rejected');
$Status[5] = _('Written Off');
$Title = _('Employee Loan Authorisation');
include ('includes/header.php');
if (isset($_POST['update'])) {
foreach ($_POST as $key => $value) {
if (mb_substr($key, 0, 6) == 'Status') {
$Loan = mb_substr($key, 6);
$SQL = "UPDATE prlloanfile SET status='" . $value . "' WHERE counterindex='" . $Loan . "'";
$Result = DB_query($SQL);
}
}
}
echo '<p class="page_title_text noPrint" ><img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/loan.png" title="' . $Title . '" alt="" />' . ' ' . $Title . '</p>';
echo '<form method="post" class="noPrint" id="LoanDeductionForm" action="' . htmlspecialchars(basename(__FILE__), ENT_QUOTES, 'UTF-8') . '">';
echo '<input type="hidden" name="FormID" value="' . $_SESSION['FormID'] . '" />';
$SQL = "SELECT prlloanfile.counterindex,
prlloanfile.loanfileid,
prlloanfile.loanfiledesc,
prlloanfile.employeeid,
prlemployeemaster.firstname,
prlemployeemaster.middlename,
prlemployeemaster.lastname,
prlloanfile.loandate,
prlloantable.loantabledesc,
departments.description,
prlloanfile.loanamount,
prlloanfile.amortization,
prlloanfile.nextdeduction,
prlloanfile.loanbalance,
prlloanfile.status,
www_users.realname
FROM prlloanfile
INNER JOIN prlemployeemaster
ON prlloanfile.employeeid=prlemployeemaster.employeeid
INNER JOIN departments
ON prlemployeemaster.departmentid=departments.departmentid
INNER JOIN prlloantable
ON prlloantable.loantableid=prlloanfile.loantableid
INNER JOIN www_users
ON www_users.userid=prlloanfile.authoriser
WHERE prlloanfile.loanbalance>0
AND status=0
AND prlloanfile.authoriser='" . $_SESSION['UserID'] . "'";
$Result = DB_query($SQL);
if (DB_num_rows($Result) > 0) {
$AllowedStatuses = array(0, 1, 3, 4);
echo '<table>
<tr>
<th>' . _('Description') . '</th>
<th>' . _('Employee ID') . '</th>
<th>' . _('Employee Name') . '</th>
<th>' . _('Department') . '</th>
<th>' . _('Loan Type') . '</th>
<th>' . _('Loan Date') . '</th>
<th>' . _('Loan Amount') . '</th>
<th>' . _('Repayment per') . '<br />' . _('Pay period') . '</th>
<th>' . _('Balance') . '</th>
<th>' . _('Status') . '</th>
</tr>';
while ($LoanRow = DB_fetch_array($Result)) {
echo '<tr>
<td>' . $LoanRow['loanfiledesc'] . '</td>
<td>' . $LoanRow['employeeid'] . '</td>
<td>' . $LoanRow['firstname'] . ' ' . $LoanRow['middlename'] . ' ' . $LoanRow['lastname'] . '</td>
<td>' . $LoanRow['description'] . '</td>
<td>' . $LoanRow['loantabledesc'] . '</td>
<td>' . ConvertSQLDate($LoanRow['loandate']) . '</td>
<td class="number">' . locale_number_format($LoanRow['loanamount'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
<td class="number">' . locale_number_format($LoanRow['amortization'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
<td class="number">' . locale_number_format($LoanRow['loanbalance'], $_SESSION['CompanyRecord']['decimalplaces']) . '</td>
<td><select name="Status' . $LoanRow['counterindex'] . '">';
foreach ($AllowedStatuses as $AllowedStatus) {
if ($AllowedStatus == $LoanRow['status']) {
echo '<option selected="selected" value="' . $AllowedStatus . '">' . $Status[$AllowedStatus] . '</option>';
} else {
echo '<option value="' . $AllowedStatus . '">' . $Status[$AllowedStatus] . '</option>';
}
}
echo '</select>
</td>
</tr>';
}
echo '</table>';
echo '<div class="centre">
<input type="submit" name="update" value="' . _('Update Status Information') . '" />
</div>';
} else {
prnMsg(_('There are no loans for you to authorise'), 'info');
}
include ('includes/footer.php');
?>