-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPayslipOutter.php
More file actions
executable file
·45 lines (35 loc) · 1.2 KB
/
PayslipOutter.php
File metadata and controls
executable file
·45 lines (35 loc) · 1.2 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
<?php
class PayslipOutter {
protected $employees;
/**
* This function is used to output the payslip into a string.
* param[object]
*
*/
public function stringOutPut(PayslipInfo $payslipInfo) {
$payslipString = sprintf("%s,%s,%u,%u,%u,%u", $payslipInfo->getName(), $payslipInfo->getPayPeriod(), $payslipInfo->getGrossIncome(),
$payslipInfo->getIncomeTax(), $payslipInfo->getNetIncome(), $payslipInfo->getSuper());
echo $payslipString;
}
/**
* This function is used to output the payslip into a csv file.
* param [array] $payslips
*/
public function csvOutPut($payslips) {
$payslipsArray = [];
foreach ($payslips as $payslipObject) {
$payslipsArray[] = (array)$payslipObject;
}
header('Content-Type: text/csv');
header('Content-Disposition: attachment; filename='. 'testing.csv');
header('Pragma: no-cache');
header("Expires: 0");
$outstream = fopen("php://output", "w");
foreach($payslipsArray as $payslip)
{
fputcsv($outstream, $payslip);
}
fclose($outstream);
}
}
?>