forked from zhouhu/openpayroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayslipreport.php
More file actions
340 lines (273 loc) · 24 KB
/
payslipreport.php
File metadata and controls
340 lines (273 loc) · 24 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
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
//include_once('config.php');
//exit($base_url);
include_once('assets/includes/header.php');
if($_SESSION['logged_in'] != '1'){
session_start();
header('Status: 401');
header('Location: ' . urlencode('index.php'));
}
include_once('assets/includes/menubar.php');
?>
<!-- BEGIN PAGE TITLE-->
<h1 class="page-title"> Payslip Report
</h1>
<!-- END PAGE TITLE-->
<!-- END PAGE HEADER-->
<!--Begin Page Content-->
<?php
$query = $conn->prepare('SELECT empNumber FROM employees WHERE companyId = ? AND active =? ORDER BY id ASC');
$query->execute([$_SESSION['companyid'], '1']);
$ftres = $query->fetchAll(PDO::FETCH_COLUMN);
$count = $query->rowCount();
$counter = 1;
//print($count . "<br />");
//print_r($ftres);
$counter = 0;
if ($_SESSION['emptrack'] >= $count) {
$_SESSION['emptrack'] = 0;
}
$currentemp = $ftres[''.$_SESSION['emptrack'].''];
?>
<div class="row">
<div class="col-md-12">
<!-- BEGIN EXAMPLE TABLE PORTLET-->
<div class="portlet light bordered">
<div class="portlet-body">
<div class="table-toolbar">
<div class="row">
<div class="col-md-6">
<button class="btn btn-sm btn-primary" type="button">
Payroll Period <span class="badge"><?php print $_SESSION['activeperiodDescription']?></span>
</button>
<button class="btn btn-sm purple" type="button">
Number of Employees <span class="badge"><?php print $count?></span>
</button>
</div>
<div class="col-md-6">
<div class="btn-group pull-right">
<button class="btn btn-sm red" id="btnPrint">Print <i class="fa fa-print" aria-hidden="true"></i></button>
<!--<button class="btn blue btn-outline dropdown-toggle" data-toggle="dropdown">Tools
<i class="fa fa-angle-down"></i>
</button>
<ul class="dropdown-menu pull-right">
<li>
<a href="javascript:;">
<i class="fa fa-print"></i> Print </a>
</li>
<li>
<a href="javascript:;">
<i class="fa fa-file-pdf-o"></i> Save as PDF </a>
</li>
<li>
<a href="javascript:;">
<i class="fa fa-file-excel-o"></i> Export to Excel </a>
</li>
</ul>-->
</div>
</div>
</div>
</div>
<!--Printer-->
<script type='text/javascript'>//<![CDATA[
window.onload=function(){
jQuery.fn.extend({
printElem: function() {
var cloned = this.clone();
var printSection = $('#printSection');
if (printSection.length == 0) {
printSection = $('<div id="printSection"></div>')
$('body').append(printSection);
}
printSection.append(cloned);
var toggleBody = $('body *:visible');
toggleBody.hide();
$('#printSection, #printSection *').show();
window.print();
printSection.remove();
toggleBody.show();
}
});
$(document).ready(function(){
$(document).on('click', '#btnPrint', function(){
$('.printMe').printElem();
});
});
}//]]>
</script>
<!--Printer-->
<?php
while ($counter < $count) {
//Print employee payslips
$thisemployee = $ftres[''.$counter.''];
//print_r($thisemployee);
?>
<!-- START ROLL-->
<div class="row bottom-spacer-40">
<div class="col-md-3"></div>
<div class="col-md-6">
<div id="printThis" class="printMe payslip-wrapper">
<div class="payslip-header">
<div class="row header-label">
<div class="col-md-12 txt-ctr text-uppercase"><b>
<?php
retrieveDescSingleFilter ('company', 'companyName', 'id', $_SESSION['companyid']);
?>
</b></div>
<div class="col-md-12 txt-ctr text-uppercase">
<b> Employee PAYSLIP </b></div>
</div>
<div class="row header-label">
<div class="col-md-6 col-xs-6">
<span class="pay-header-item">Name:
<?php
retrieveDescSingleFilter('employees', 'fName', 'empNumber', $thisemployee);
echo " ";
retrieveDescSingleFilter('employees', 'lName', 'empNumber', $thisemployee);
?>
</span>
</div>
<div class="col-md-6 col-xs-6 txt-right">Period: <?php print $_SESSION['activeperiodDescription']?></div>
</div>
<div class="row header-label">
<div class="col-md-6 col-xs-6">Emp #: <?php print_r($thisemployee);?> </div>
<div class="col-md-6 col-xs-6 txt-right">
Title:
<?php
$mainFilter = &returnDescSingleFilter('employees', 'companyDept', 'empNumber', $thisemployee);
retrieveDescDualFilter('company_departments', 'companyDescription', $mainFilter, 'departmentId', 'companyId', $_SESSION['companyid']);
?>
</div>
</div>
<div class="row header-label">
<div class="col-md-6 col-xs-6">Employment:
<?php
$mainFilter = &returnDescSingleFilter('employees', 'empType', 'empNumber', $thisemployee);
retrieveDescDualFilter('employment_types', 'description', $mainFilter, 'id', 'companyId', $_SESSION['companyid']);
?>
</div>
<div class="col-md-6 col-xs-6 txt-right">Location:
<?php
$mainFilter = &returnDescSingleFilter('employees', 'companyBranch', 'empNumber', $thisemployee);
retrieveDescDualFilter('company_branches', 'branchName', $mainFilter, 'branchId', 'companyId', $_SESSION['companyid']);
?>
</div>
</div>
</div>
<div class="payslip-body">
<div class="row header-label">
<div class="col-md-12 col-xs-12"><b>Earnings</b></div>
</div>
<div class="row payslip-data">
<?php
try{
$query = $conn->prepare('SELECT * FROM employee_earnings_deductions WHERE employeeId = ? AND companyId = ? AND transactionType = ? AND payPeriod = ? AND active = ? ORDER BY earningDeductionCode');
$fin = $query->execute([$thisemployee, $_SESSION['companyid'], 'Earning', $_SESSION['currentactiveperiod'], '1']);
$res = $query->fetchAll(PDO::FETCH_ASSOC);
//print_r($res);
foreach ($res as $row => $link) {
//Get ED description
$payp = $conn->prepare('SELECT edDesc FROM earnings_deductions WHERE companyId = ? AND edCode = ?');
$myperiod = $payp->execute([$_SESSION['companyid'], $link['earningDeductionCode']]);
$final = $payp->fetch();
//End ED Fetch
echo '<div class="col-md-8 col-xs-8">' . $final['edDesc'];
echo '</div><div class="col-md-4 col-xs-4 payslip-amount">' . number_format($link['amount']) . '</div>';
}
}
catch(PDOException $e){
echo $e->getMessage();
}
?>
</div>
<div class="row payslip-total">
<div class="col-md-8 col-xs-8"><b>Gross Salary</b></div>
<div class="col-md-4 col-xs-4 payslip-amount"><b>
<?php
retrievePayrollSubTotal('amount', 'employee_earnings_deductions', 'employeeId', 'earningDeductionCode', 'payperiod', 'active', $thisemployee, '601');
?>
</b></div>
</div>
</div>
<div class="payslip-body">
<div class="row header-label">
<div class="col-md-12 col-xs-12"><b>Deductions</b></div>
</div>
<div class="row payslip-data">
<?php
try{
$query = $conn->prepare('SELECT * FROM employee_earnings_deductions WHERE employeeId = ? AND companyId = ? AND transactionType = ? AND earningDeductionCode != ? AND payPeriod = ? AND active = ? ORDER BY earningDeductionCode');
$fin = $query->execute([$thisemployee, $_SESSION['companyid'], 'Deduction', '483', $_SESSION['currentactiveperiod'], '1']);
$res = $query->fetchAll(PDO::FETCH_ASSOC);
foreach ($res as $row => $link) {
//Get ED description
$payp = $conn->prepare('SELECT edDesc FROM earnings_deductions WHERE companyId = ? AND edCode = ?');
$myperiod = $payp->execute([$_SESSION['companyid'], $link['earningDeductionCode']]);
$final = $payp->fetch();
//End ED Fetch
echo '<div class="col-md-8 col-xs-8">' . $final['edDesc'];
echo '</div><div class="col-md-4 col-xs-4 payslip-amount">' . number_format($link['amount']) . '</div>';
}
}
catch(PDOException $e){
echo $e->getMessage();
}
?>
</div>
<div class="row payslip-total">
<div class="col-md-8 col-xs-8"><b>Total Deductions</b></div>
<div class="col-md-4 col-xs-4 payslip-amount"><b>
<?php
retrievePayrollSubTotal('amount', 'employee_earnings_deductions', 'employeeId', 'earningDeductionCode', 'payperiod', 'active', $thisemployee, '603');
?>
</b></div>
</div>
</div>
<div class="payslip-body">
<div class="row payslip-data">
<div class="col-md-8 col-xs-8">Tax Relief</div>
<div class="col-md-4 col-xs-4 payslip-amount">1,280</div>
</div>
<div class="row payslip-total">
<div class="col-md-8 col-xs-8"><b>Net Pay</b></div>
<div class="col-md-4 col-xs-4 payslip-amount"><b>
<?php
retrievePayrollSubTotal('amount', 'employee_earnings_deductions', 'employeeId', 'earningDeductionCode', 'payperiod', 'active', $thisemployee, '600');
?>
</b></div>
</div>
</div>
</div>
</div>
<div class="col-md-3"></div>
</div>
<!-- END ROLL-->
<?php
$counter++;
//end employee payslips
}
?>
</div>
</div>
<!-- END EXAMPLE TABLE PORTLET-->
</div>
</div>
<div class="clearfix"></div>
<!-- END DASHBOARD STATS 1-->
</div>
<!-- END CONTENT BODY -->
</div>
<!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<div class="page-footer">
<div class="page-footer-inner"> 2016 © Redsphere Consulting v0.8
</div>
<div class="scroll-to-top">
<i class="icon-arrow-up"></i>
</div>
</div>
<!-- END FOOTER -->
</div>
<?php include_once('assets/includes/footer.php');?>