-
Notifications
You must be signed in to change notification settings - Fork 0
/
view-payslip.php
222 lines (197 loc) · 8.48 KB
/
view-payslip.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
require_once "importance.php";
if (!User::loggedIn()) {
Config::redir("login.php");
}
?>
<html>
<head>
<title><?php echo CONFIG::SYSTEM_NAME; ?> : Payslip</title>
<?php require_once "inc/head.inc.php"; ?>
</head>
<body>
<?php require_once "inc/header.inc.php"; ?>
<div class='container-fluid'>
<div class='row'>
<div class='col-md-3'><?php require_once "inc/sidebar.inc.php"; ?></div> <!-- this should be a sidebar -->
<div class='col-md-8'>
<div class='content-area'>
<div class='content-header'>
<?php echo "Employee Payslip"; ?>
</div>
<!-- <div class='content-body'> -->
<?php
if (isset($_GET['eid'])) {
$empid = $_GET['eid'];
}
if (isset($_GET['pid'])) {
$ref = $_GET['pid'];
$df = date("d M Y", strtotime(Payroll::get($ref, "date_from")));
$dt = date("d M Y", strtotime(Payroll::get($ref, "date_to")));
}
$fName = User::getbyid($empid, "firstName");
$sName = User::getbyid($empid, "secondName");
$bsal = User::getbyid($empid, "salary");
$accno = User::getbyid($empid, "account_no");
$ename = $fName . " " . $sName;
$role = User::getbyid($empid, "designation");
$ab = Payroll::getes($empid, $ref, "absent");
$totalw = Payroll::getes($empid, $ref, "allowance_amt");
$totded = Payroll::getes($empid, $ref, "deduction_amt");
$totsal = Payroll::getes($empid, $ref, "net_salary");
$it = Payroll::getes($empid, $ref, "income_tax");
$amtinwrds = AmountInWords("$totsal");
?>
<div class='content-bodyes'>
<p align="right">
<button class="btn btn-primary" onclick="printDiv('p')" type="button" id="print_btn"></span>Print</button>
</p>
<div class='contriner-fluid' id='p'>
<div class='form-holder'>
<div class='col-12'>
<div class='row'>
<div class='col-md-6'>
<h5><b>Employee ID : <small style="font-size:17px"><?php echo $empid ?></small></b></h5>
<h5><b>Employee Name : <small style="font-size:17px"><?php echo $ename ?></small></b></h5>
<h5><b>Designation : <small style="font-size:17px"><?php echo $role ?></small></b></h5>
<h5><b>Account No. : <small style="font-size:17px"><?php echo $accno ?></small></b></h5>
</div>
<div class='col-md-6'>
<h5><b>Payroll Ref. : <small style="font-size:17px"><?php echo $ref ?></small></b></h5>
<h5><b>Payroll Range : <small style="font-size:17px"><?php echo $df . " - " . $dt ?></small></b></h5>
<h5><b>Mode of transfer : <small style="font-size:17px"><?php echo "Bank Tranfer" ?></small></b></h5>
<h5><b>Absent : <small style="font-size:17px"><?php echo $ab . " days" ?></small></b></h5>
</div>
</div>
<hr class="divider" style="border-color:black">
<h5><b>Basic Salary       :   <small style="font-size:17px"><?php echo "kshs " . $bsal ?></small></b></h5>
<hr class="divider" style="border-color:black">
<div class="row">
<div class="col-md-6">
<h5><b>Allowances : </b></h5><br>
<div class='col-md-11'>
<ul class="list-group" style="list-style-type:none;">
<?php
$con = Db::connect();
$sql = "SELECT ea.*, a.allowance_name as aname FROM emp_allowances ea inner join allowances a on ea.a_id=a.a_id where ea.e_id= $empid ";
$query = $con->prepare($sql);
$query->execute();
while ($data = Db::assoc($query)) : ?>
<li class="list-group-item" data-id="<?php echo $data['a_id'] ?>">
<div class='row'>
<div class='col-md-8'>
<small style="font-size:15px">
<?php echo $data['aname'] ?>
</small>
</div>
<div class='col-md-4'>
<p style="font-size:15px">
<?php echo "kshs " . $data['amount'] ?>
</p>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<h5><b><?php echo "Total Amount :              kshs" . $totalw ?></b></h5>
</div>
</div>
<div class='col-md-6'>
<h5><b>Deductions : </b></h5><br>
<div class='col-md-11'>
<ul class="list-group" style="list-style-type:none;">
<?php
$con = Db::connect();
$sql = "SELECT ed.*, d.deduction_name as dname FROM emp_deductions ed inner join deductions d on ed.d_id=d.d_id where ed.e_id= $empid ";
$query = $con->prepare($sql);
$query->execute();
while ($data = Db::assoc($query)) : ?>
<li class="list-group-item" data-id="<?php echo $data['d_id'] ?>">
<div class='row'>
<div class='col-md-8'>
<small style="font-size:15px">
<?php echo $data['dname'] ?>
</small>
</div>
<div class='col-md-4'>
<small style="font-size:15px">
<?php echo "kshs " . $data['amount'] ?>
</small>
</div>
</div>
</li>
<?php endwhile; ?>
</ul>
<h5><b><?php echo "Total Amount :              kshs " . $totded ?></b></h5>
<!--echo str_repeat(" ", 60); -->
</div>
</div>
</div>
<hr class="divider" style="border-color:black">
<h5><b>Income Tax      :   <small style="font-size:17px"><?php echo "kshs" . $it ?></small></b></h5>
<h5><b>Net Salary        :   <small style="font-size:17px"><?php echo "kshs " . $totsal ?></small></b></h5>
<h5><b>Amount in words   :   <small style="font-size:17px"><?php echo $amtinwrds ?></small></b></h5>
<!-- <h5><b>Mode of Transfer   :   <small style="font-size:17px"><?php echo "Bank Transfer" ?></small></b></h5> -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>
</body>
</html>
<?php
// Create a function for converting the amount in words
function AmountInWords(float $amount)
{
if ($amount == 0)
return "---";
$amount_after_decimal = round($amount - ($num = floor($amount)), 2) * 100;
// Check if there is any number after decimal
$amt_hundred = null;
$count_length = strlen($num);
$x = 0;
$string = array();
$change_words = array(
0 => '', 1 => 'One', 2 => 'Two',
3 => 'Three', 4 => 'Four', 5 => 'Five', 6 => 'Six',
7 => 'Seven', 8 => 'Eight', 9 => 'Nine',
10 => 'Ten', 11 => 'Eleven', 12 => 'Twelve',
13 => 'Thirteen', 14 => 'Fourteen', 15 => 'Fifteen',
16 => 'Sixteen', 17 => 'Seventeen', 18 => 'Eighteen',
19 => 'Nineteen', 20 => 'Twenty', 30 => 'Thirty',
40 => 'Forty', 50 => 'Fifty', 60 => 'Sixty',
70 => 'Seventy', 80 => 'Eighty', 90 => 'Ninety'
);
$here_digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
while ($x < $count_length) {
$get_divider = ($x == 2) ? 10 : 100;
$amount = floor($num % $get_divider);
$num = floor($num / $get_divider);
$x += $get_divider == 10 ? 1 : 2;
if ($amount) {
$add_plural = (($counter = count($string)) && $amount > 9) ? null : null;
$amt_hundred = ($counter == 1 && $string[0]) ? /*' and '*/ null : null;
$string[] = ($amount < 21) ? $change_words[$amount] . ' ' . $here_digits[$counter] . $add_plural . '
' . $amt_hundred : $change_words[floor($amount / 10) * 10] . ' ' . $change_words[$amount % 10] . '
' . $here_digits[$counter] . $add_plural . ' ' . $amt_hundred;
} else $string[] = null;
}
$implode_to_shillings = implode('', array_reverse($string));
$paise_first_digit = floor($amount_after_decimal / 10) * 10;
$get_paise = ($amount_after_decimal > 0) ? "And " . ($change_words[$paise_first_digit] . "
" . $change_words[$amount_after_decimal % 10]) . ' shillings' : '';
return ($implode_to_shillings ? $implode_to_shillings . 'shillings ' : '') . $get_paise;
}
?>