1527 lines
45 KiB
PHP
1527 lines
45 KiB
PHP
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
// require APPPATH . '/third_party/mpdf/mpdf.php';
|
|
|
|
use App\Models\Monthlypay_model;
|
|
use App\Models\Payroll_model;
|
|
use Mpdf\Mpdf;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Spreadsheet;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
|
|
|
use PhpOffice\PhpSpreadsheet\Style\Alignment;
|
|
use PhpOffice\PhpSpreadsheet\IOFactory;
|
|
|
|
|
|
|
|
/**
|
|
* Module : Payslip
|
|
* Payslip Class to control all payslip related operations.
|
|
* @author : Gandhimathi
|
|
* @version : 1.1
|
|
* @since : 07 Apr 2017
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Payslip extends BaseController
|
|
{
|
|
protected $payroll_model;
|
|
protected $monthlypay_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->payroll_model = new Payroll_model();
|
|
$this->monthlypay_model = new Monthlypay_model();
|
|
$this->session = session();
|
|
helper('form'); //$this->load->library('form_validation');
|
|
$this->isLoggedIn();
|
|
|
|
}
|
|
|
|
function phpAlert($msg)
|
|
{
|
|
echo '<script type="text/javascript">alert("' . $msg . '")</script>';
|
|
}
|
|
|
|
|
|
/**
|
|
* This function used to call stored procedure named with final_payroll_data()
|
|
*/
|
|
public function callsp()
|
|
{
|
|
|
|
$payon = $this->request->getPost('payon');
|
|
$employee = $this->request->getPost('employee');
|
|
$result = $this->payroll_model->model_sp($payon, $employee);
|
|
// $result = $this->db->last_query();
|
|
return $result;
|
|
//$this->db->call_function('model_sp');
|
|
|
|
}
|
|
|
|
function loadBankreportScreen()
|
|
{
|
|
|
|
$Data['Payon'] = $this->payroll_model->getPayOn();
|
|
$Data['Bank'] = $this->payroll_model->getBankInfo();
|
|
$this->global['pageTitle'] = 'Bank Report Screen';
|
|
$this->loadViews("bankreport", $this->global, $Data, NULL);
|
|
}
|
|
|
|
function getBankReport()
|
|
{
|
|
$bank = $this->request->getPost('bank');
|
|
$payon = $this->request->getPost('month');
|
|
$chequeno = $this->request->getPost('chequeno');
|
|
$chequedate = format_date($this->request->getPost('chequedate'));
|
|
$createdby = $this->session->get('userId');
|
|
|
|
$monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr", "05" => "May", "06" => "June", "07" => "July", "08" => "Aug", "09" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");
|
|
$m = substr((string)$payon, 0, 2);
|
|
$y = substr((string)$payon, 3);
|
|
$month = $monthsoptions[$m] . "-" . $y;
|
|
$excel = $this->request->getPost('excel');
|
|
$HTML = '';
|
|
//echo $excel;
|
|
// if(empty($excel))
|
|
// {
|
|
// echo "PDF";
|
|
// }
|
|
// else
|
|
// {
|
|
// echo "EXCEL";
|
|
// }
|
|
// die();
|
|
|
|
|
|
|
|
$filename = '';
|
|
if ($this->request->getPost('Bank_Report')) {
|
|
$data['result'] = $this->payroll_model->getReportforBank($bank, $payon);
|
|
if ($chequeno != '' && $chequedate != '') {
|
|
$empcount = count($data['result']);
|
|
$cheque = array('ChequeNO' => $chequeno, 'ChequeDate' => $chequedate, 'BankName' => $bank, 'Monthyear' => $payon, 'Empcount' => $empcount, 'CreatedBy' => $createdby);
|
|
$data['insertcheque'] = $this->payroll_model->ChequeDetails($cheque);
|
|
}
|
|
//print_r($data['result']);die();
|
|
$totamtwords = '';
|
|
$totalamt = 0.00;
|
|
if (!empty($data['result'])) {
|
|
foreach ($data['result'] as $amt) {
|
|
$totalamt += $amt->LessAdvance;
|
|
}
|
|
}
|
|
$totamtwords = $this->convertNumber($totalamt);
|
|
$data['bankdetails'] = $this->payroll_model->getBankInfo($bank);
|
|
$data['chequedetails'] = $this->payroll_model->getChequeInfo($bank, $payon);
|
|
$data['Totalamount'] = $totalamt;
|
|
$data['Totalamtwords'] = $totamtwords;
|
|
$data['PayMonth'] = $month;
|
|
$filename = 'Bank Report for' . $payon . 'pdf';
|
|
$HTML = view("bankreportprint", $data);
|
|
}
|
|
if ($this->request->getPost('PF_Report')) {
|
|
$data['PFESI'] = $this->payroll_model->getReportforPFESI($payon);
|
|
$data['PayMonth'] = $month;
|
|
$data['companyinfo'] = $this->payroll_model->getCompanyInformation();
|
|
//print_r($data['companyinfo']);die();
|
|
$totamtwords = '';
|
|
$totalamt = 0.00;
|
|
$totemppf = 0.00;
|
|
$totemprpf = 0.00;
|
|
if (!empty($data['PFESI'])) {
|
|
foreach ($data['PFESI'] as $pf) {
|
|
$totalamt += ($pf->PF + $pf->CompanyPF);
|
|
$totemppf += ($pf->PF);
|
|
$totemprpf += ($pf->CompanyPF);
|
|
}
|
|
}
|
|
$data['Totalamount'] = $totalamt;
|
|
$data['TotalEmployeeContribution'] = $totemppf;
|
|
$data['TotalEmployerContribution'] = $totemprpf;
|
|
$totamtwords = $this->convertNumber($totalamt);
|
|
$data['Totalamtwords'] = $totamtwords;
|
|
if (empty($excel)) {
|
|
$filename = 'PF Report for' . $payon . 'pdf';
|
|
$HTML = view("pfreportprint", $data);
|
|
// echo "PDF PART 1";
|
|
} else {
|
|
// Create a new Spreadsheet object
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet->setTitle('Employee PF Report ' . $data['PayMonth']);
|
|
|
|
// Set headers
|
|
$sheet->setCellValue('A1', 'Employee PF Report ' . $data['PayMonth']);
|
|
$sheet->mergeCells('A1:H1');
|
|
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
|
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
|
$sheet->getStyle('A1')->getFill()->getStartColor()->setARGB('#333');
|
|
|
|
// Set column headers
|
|
$sheet->setCellValue('A4', 'S.No.');
|
|
$sheet->setCellValue('B4', 'Employee Name');
|
|
$sheet->setCellValue('C4', 'PF Account No');
|
|
$sheet->setCellValue('D4', 'Employee Contribution');
|
|
$sheet->setCellValue('E4', 'Employer Contribution');
|
|
$sheet->setCellValue('F4', 'No Of Days Worked');
|
|
$sheet->setCellValue('G4', 'OT Hrs Worked');
|
|
$sheet->setCellValue('H4', 'Total Amount');
|
|
|
|
// Style column headers
|
|
for ($col = ord('A'); $col <= ord('H'); $col++) {
|
|
$sheet->getColumnDimension(chr($col))->setAutoSize(true);
|
|
$sheet->getStyle(chr($col))->getFont()->setSize(12);
|
|
$sheet->getStyle(chr($col))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
|
}
|
|
|
|
|
|
// Populate data
|
|
$i = 6;
|
|
$j = 1;
|
|
$overall = 0;
|
|
$overallemp = 0;
|
|
$overallemr = 0;
|
|
|
|
foreach ($data['PFESI'] as $row) {
|
|
$sheet->setCellValue('A' . $i, $j);
|
|
$sheet->setCellValue('B' . $i, $row->FName . ' ' . $row->Lname);
|
|
$sheet->setCellValue('C' . $i, $row->PFNO);
|
|
$sheet->setCellValue('D' . $i, number_format($row->PF, 2, '.', ''));
|
|
$sheet->setCellValue('E' . $i, number_format($row->CompanyPF, 2, '.', ''));
|
|
$sheet->setCellValue('F' . $i, number_format($row->NoofDaysWorked, 2, '.', ''));
|
|
$sheet->setCellValue('G' . $i, number_format($row->OTperHours, 2, '.', ''));
|
|
|
|
$total = $row->PF + $row->CompanyPF;
|
|
$overall += $total;
|
|
$overallemp += $row->PF;
|
|
$overallemr += $row->CompanyPF;
|
|
$sheet->setCellValue('H' . $i, $total);
|
|
|
|
$i++;
|
|
$j++;
|
|
}
|
|
|
|
// Total
|
|
$sheet->setCellValue('C' . $i, 'Total');
|
|
$sheet->setCellValue('D' . $i, $overallemp);
|
|
$sheet->setCellValue('E' . $i, $overallemr);
|
|
$sheet->setCellValue('H' . $i, $overall);
|
|
|
|
// Protect the sheet
|
|
$sheet->getProtection()->setSheet(true);
|
|
$sheet->getProtection()->setSort(true);
|
|
$sheet->getProtection()->setInsertRows(true);
|
|
$sheet->getProtection()->setFormatCells(true);
|
|
|
|
// Set the headers for file download
|
|
// $filename = 'EmployeePFReport_' . date('Ymd_His') . '.xls';
|
|
$filename = 'EmployeePFReport' . $payon . 'xls';
|
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
header('Content-Disposition: attachment;filename="' . $filename . '"');
|
|
header('Cache-Control: max-age=0');
|
|
|
|
// Write the file
|
|
$writer = new Xlsx($spreadsheet);
|
|
$writer->save('php://output');
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
if ($this->request->getPost('ESI_Report')) {
|
|
$data['PFESI'] = $this->payroll_model->getReportforPFESI($payon);
|
|
//print_r($data['PFESI']);die();
|
|
$data['PayMonth'] = $month;
|
|
$data['companyinfo'] = $this->payroll_model->getCompanyInformation();
|
|
|
|
$totamtwords = '';
|
|
$totalamt = 0.00;
|
|
$totemppf = 0.00;
|
|
$totemprpf = 0.00;
|
|
if (!empty($data['PFESI'])) {
|
|
foreach ($data['PFESI'] as $pf) {
|
|
$totalamt += ($pf->EmployeeESI + $pf->CompanyESI);
|
|
$totemppf += ($pf->EmployeeESI);
|
|
$totemprpf += ($pf->CompanyESI);
|
|
}
|
|
}
|
|
$data['Totalamount'] = $totalamt;
|
|
$totamtwords = $this->convertNumber($totalamt);
|
|
$data['TotalEmployeeContribution'] = $totemppf;
|
|
$data['TotalEmployerContribution'] = $totemprpf;
|
|
$data['Totalamtwords'] = $totamtwords;
|
|
|
|
|
|
if (empty($excel)) {
|
|
$filename = 'ESI Report for' . $payon . 'pdf';
|
|
$HTML = view("esireportprint", $data);
|
|
// echo "PDF PART 1";
|
|
} else {
|
|
// Create a new Spreadsheet object
|
|
$spreadsheet = new Spreadsheet();
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$sheet->setTitle('Employee PF Report ' . $data['PayMonth']);
|
|
|
|
// Set headers
|
|
$sheet->setCellValue('A1', 'Employee PF Report ' . $data['PayMonth']);
|
|
$sheet->mergeCells('A1:H1');
|
|
$sheet->getStyle('A1')->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
|
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(16);
|
|
$sheet->getStyle('A1')->getFill()->getStartColor()->setARGB('#333');
|
|
|
|
// Set column headers
|
|
$sheet->setCellValue('A4', 'S.No.');
|
|
$sheet->setCellValue('B4', 'Employee Name');
|
|
$sheet->setCellValue('C4', 'PF Account No');
|
|
$sheet->setCellValue('D4', 'Employee Contribution');
|
|
$sheet->setCellValue('E4', 'Employer Contribution');
|
|
$sheet->setCellValue('F4', 'No Of Days Worked');
|
|
$sheet->setCellValue('G4', 'OT Hrs Worked');
|
|
$sheet->setCellValue('H4', 'Total Amount');
|
|
|
|
// Style column headers
|
|
for ($col = ord('A'); $col <= ord('H'); $col++) {
|
|
$sheet->getColumnDimension(chr($col))->setAutoSize(true);
|
|
$sheet->getStyle(chr($col))->getFont()->setSize(12);
|
|
$sheet->getStyle(chr($col))->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER);
|
|
}
|
|
|
|
|
|
// Populate data
|
|
$i = 6;
|
|
$j = 1;
|
|
$overall = 0;
|
|
$overallemp = 0;
|
|
$overallemr = 0;
|
|
|
|
foreach ($data['PFESI'] as $row) {
|
|
$sheet->setCellValue('A' . $i, $j);
|
|
$sheet->setCellValue('B' . $i, $row->FName . ' ' . $row->Lname);
|
|
$sheet->setCellValue('C' . $i, $row->PFNO);
|
|
$sheet->setCellValue('D' . $i, number_format($row->PF, 2, '.', ''));
|
|
$sheet->setCellValue('E' . $i, number_format($row->CompanyPF, 2, '.', ''));
|
|
$sheet->setCellValue('F' . $i, number_format($row->NoofDaysWorked, 2, '.', ''));
|
|
$sheet->setCellValue('G' . $i, number_format($row->OTperHours, 2, '.', ''));
|
|
|
|
$total = $row->PF + $row->CompanyPF;
|
|
$overall += $total;
|
|
$overallemp += $row->PF;
|
|
$overallemr += $row->CompanyPF;
|
|
$sheet->setCellValue('H' . $i, $total);
|
|
|
|
$i++;
|
|
$j++;
|
|
}
|
|
|
|
// Total
|
|
$sheet->setCellValue('C' . $i, 'Total');
|
|
$sheet->setCellValue('D' . $i, $overallemp);
|
|
$sheet->setCellValue('E' . $i, $overallemr);
|
|
$sheet->setCellValue('H' . $i, $overall);
|
|
|
|
// Protect the sheet
|
|
$sheet->getProtection()->setSheet(true);
|
|
$sheet->getProtection()->setSort(true);
|
|
$sheet->getProtection()->setInsertRows(true);
|
|
$sheet->getProtection()->setFormatCells(true);
|
|
|
|
// Set the headers for file download
|
|
// $filename = 'EmployeePFReport_' . date('Ymd_His') . '.xls';
|
|
$filename = 'EmployeePFReport' . $payon . 'xls';
|
|
|
|
header('Content-Type: application/vnd.ms-excel');
|
|
header('Content-Disposition: attachment;filename="' . $filename . '"');
|
|
header('Cache-Control: max-age=0');
|
|
|
|
// Write the file
|
|
$writer = new Xlsx($spreadsheet);
|
|
$writer->save('php://output');
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (empty($excel)) {
|
|
// Load the HTML content for the Header,footer
|
|
$HtmlHeading = view('includes/bankreport_header', $data);
|
|
$HTMLFooter = view('includes/bankreport_footer', $data);
|
|
|
|
// Create an instance of mPDF
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 38,
|
|
'margin_bottom' => 4,
|
|
'margin_header' => 10,
|
|
'margin_footer' => 6,
|
|
]);
|
|
|
|
// Set document properties
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
$mpdf->SetHTMLHeader($HtmlHeading); // You need to define $HtmlHeading somewhere in your code
|
|
$mpdf->SetHTMLFooter($HTMLFooter . 'Page {PAGENO} of {nb}');
|
|
$mpdf->SetTitle('Resicoindustries:PayrollReport');
|
|
|
|
// Configure mPDF settings
|
|
$mpdf->list_indent_first_level = 1;
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
|
|
// Write HTML to PDF
|
|
$mpdf->WriteHTML($HTML);
|
|
|
|
// Output the PDF
|
|
$filename = 'EmployeePayrollReport'; // Define your filename here
|
|
$mpdf->Output($filename . '.pdf', 'D');
|
|
}
|
|
}
|
|
|
|
|
|
function loadLoanReport($param1 = null, $param2 = null)
|
|
{
|
|
$eid = $param1 ?? '';
|
|
$fyr = $param2 ?? '';
|
|
$currentyear = '';
|
|
$nxtyear = '';
|
|
|
|
|
|
if (!empty($eid) and !empty($fyr) and !is_numeric($eid) and !($fyr == 'Overall')) {
|
|
//echo "EMPLOYEE WITH FINYEAR";
|
|
$currentyear = substr($fyr, 0, 4);
|
|
$nxtyear = substr($fyr, 5, 4);
|
|
$data['fyear'] = $currentyear . '-' . $nxtyear;
|
|
$data['loanrecords'] = $this->payroll_model->getLoanReportforEmp($eid, $currentyear, $nxtyear, 'emp');
|
|
$data['selsource'] = $eid;
|
|
} else if (!empty($eid) and !empty($fyr) and $fyr == 'Overall') {
|
|
// echo "EMPLOYEE WITH OVERALL";
|
|
$data['fyear'] = "Overall";
|
|
$currentyear = '';
|
|
$nxtyear = '';
|
|
$data['loanrecords'] = $this->payroll_model->getLoanReportforEmp($eid, $currentyear, $nxtyear, 'emp');
|
|
$data['selsource'] = $eid;
|
|
} else if (is_numeric($eid)) {
|
|
//echo "LOAN HISTORY";
|
|
$currentyear = '';
|
|
$nxtyear = '';
|
|
$data['selsource'] = $eid;
|
|
$data['fyear'] = $currentyear . '-' . $nxtyear;
|
|
$data['childdata'] = $this->payroll_model->getLoanReportforEmp($eid, $currentyear = "", $nxtyear = "", 'history');
|
|
} else {
|
|
|
|
if (empty($this->request->getPost('finyear'))) {
|
|
//echo "DEFAULT LOAD";
|
|
$year = date("Y");
|
|
$month = date("m");
|
|
$currentyear = '';
|
|
$nxtyear = '';
|
|
$source = $this->request->getPost('source');
|
|
$data['selsource'] = 'Company';
|
|
} else {
|
|
if (!empty($this->request->getPost('finyear'))) {
|
|
|
|
//echo "FIN YEAR WITH SOURCE";
|
|
$source = $this->request->getPost('source');
|
|
$data['selsource'] = $source;
|
|
$finyear = $this->request->getPost('finyear');
|
|
$currentyear = substr((string)$finyear, 0, 4);
|
|
$nxtyear = substr((string)$finyear, 5, 4);
|
|
$data['fyear'] = $currentyear . '-' . $nxtyear;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// echo $currentyear.'-'.$nxtyear;
|
|
// echo "Company";
|
|
$data['loanrecords'] = $this->payroll_model->getLoanReport($source, $currentyear, $nxtyear);
|
|
// print_r($data['loanrecords']);
|
|
|
|
|
|
}
|
|
|
|
$data['loanemployees'] = $this->payroll_model->getEmpDetailsforLoan();
|
|
$this->global['pageTitle'] = 'Loan Reports';
|
|
$this->loadViews("loanreports", $this->global, $data, NULL);
|
|
}
|
|
|
|
public function leaveReport()
|
|
{
|
|
$fyr = get_financial_year();
|
|
if ($this->request->getMethod() == 'POST') {
|
|
$fyr = $this->request->getPost('fyr');
|
|
}
|
|
// $fiscalYears = get_financial_year_list();
|
|
$fiscalYears = get_financial_year_list(date('Y'), 8);
|
|
|
|
$data['fiscalyears'] = $fiscalYears;
|
|
$data['selectedfiscalyears'] = $fyr;
|
|
$data['leaverecords'] = $this->payroll_model->getEmpDetailsforLeave($fyr);
|
|
// echo '<script type="text/javascript">alert("' . $fyr . '")</script>';
|
|
$this->global['pageTitle'] = 'Leave Reports';
|
|
$this->loadViews("leavereports", $this->global, $data, NULL);
|
|
}
|
|
function monthwiseLeaveReport($param1,$param2)
|
|
{
|
|
$EmployeeID = $param1;
|
|
$Fin_year = $param2;
|
|
$data['finyear'] = $Fin_year;
|
|
|
|
$this->global['pageTitle'] = 'Monthwise Leave Reports';
|
|
$data['MonthwiseReport'] = $this->payroll_model->getMonthwiseEmpDetailsforLeave($Fin_year, $EmployeeID);
|
|
|
|
$this->loadViews("leavereportsmonthwise", $this->global, $data, NULL);
|
|
}
|
|
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function viewUpload2()
|
|
{
|
|
|
|
$this->global['pageTitle'] = 'Payroll Data Upload2';
|
|
|
|
|
|
$this->loadViews("payslipupload2", $this->global, NULL);
|
|
}
|
|
|
|
public function monthlyInputs()
|
|
{
|
|
$current = date("m-Y");
|
|
//echo $current;
|
|
$data['month'] = $this->monthlypay_model->monthlyListing($current);
|
|
// $data['fresh'] = $this-> monthlypay_model->getEmpPayDetails($current);
|
|
$data['dropdownvalue'] = $current;
|
|
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
|
|
$employeeSalary = [];
|
|
|
|
|
|
foreach ($data['fresh'] as $value) {
|
|
|
|
|
|
$NoofDays = $value->NoofDays; //Month day 30,31,28
|
|
$HRA_Amount = $value->HRA_Amount;
|
|
$Basic_Pay = $value->Basic_Pay;
|
|
$TotalSalary = $value->TotalSalary;
|
|
$Food_Allowances = $value->Food_Allowances;
|
|
$Days_worked = $value->Days_worked; // working day
|
|
$LOP_Days = $value->LOP_Days; // not working day
|
|
$Paid_leave = $value->Paid_leave; // leave day
|
|
$OT_Hrs_Worked = $value->OT_Hrs_Worked; //OT hours
|
|
$Monthly_Due = $value->Monthly_Due; // AUTO LOAN DUE
|
|
|
|
$Loan_Recovered = $value->Loan_Recovered; //MANUAL LOAN DUE
|
|
|
|
$MasterIncentives = $value->MasterIncentives; //Master values get
|
|
// echo 'master'.$MasterIncentives;
|
|
|
|
|
|
$due_start_date = $value->DueDate;
|
|
$paydate = $current; //From POST parm
|
|
$pmonth = substr($paydate, 0, 2);
|
|
$pyear = substr($paydate, -4);
|
|
|
|
$pday = cal_days_in_month(CAL_GREGORIAN, $pmonth, $pyear);
|
|
$paymonth = $pyear . '-' . $pmonth . '-' . $pday;
|
|
$Loan_amount = $value->Loan_Amount;
|
|
$Paid_Amount = $value->Paid_Amount;
|
|
|
|
|
|
$Balance_Amount = $Loan_amount - $Paid_Amount;
|
|
|
|
|
|
|
|
$loan = 0;
|
|
if ($Loan_Recovered == 'NA') {
|
|
$loan = 0.00;
|
|
} else if ($Loan_Recovered == 0.00) {
|
|
if (strtotime($due_start_date) <= strtotime($paymonth)) {
|
|
$loan = $Monthly_Due;
|
|
}
|
|
} else if ($Loan_Recovered >= 0.00) {
|
|
if (strtotime($due_start_date) <= strtotime($paymonth)) {
|
|
$loan = $Loan_Recovered;
|
|
}
|
|
}
|
|
|
|
|
|
if ($Monthly_Due > $Balance_Amount) {
|
|
|
|
// current= Balance_Amount - autoLoan;
|
|
//alert('hi');
|
|
$loan = $Balance_Amount;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$Allowances = $value->Allowances;
|
|
$HRA_Rate = $value->HRA_Rate;
|
|
$PF_Rate = $value->PF_Rate;
|
|
$ESI_Rate = $value->ESI_Rate;
|
|
|
|
$MonthIncentive = $value->MonthlyIncentives; //t_monthly_pay_inputs,for change month
|
|
|
|
$Incentive = 0;
|
|
|
|
if (empty($MonthIncentive)) {
|
|
|
|
$Incentive = $MasterIncentives;
|
|
} else {
|
|
$Incentive = $MonthIncentive;
|
|
}
|
|
// echo $Incentive;
|
|
|
|
|
|
|
|
$daySalarys = $Days_worked + $Paid_leave;
|
|
|
|
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
|
|
//$Allowances = $allowances * $values;
|
|
$dayFood_Allowance = $Food_Allowances * $Days_worked;
|
|
|
|
$daySalary = $Basic_Pay / $NoofDays;
|
|
/**per day salary working hour**/
|
|
//echo $daySalary.'<br/>';
|
|
|
|
$dayHra = $HRA_Amount / $NoofDays;
|
|
/** per day hra amount **/
|
|
//echo $dayHra.'<br/>';
|
|
|
|
$onehoursSalary = ($daySalary + $dayHra) / 8;
|
|
/**one hour salay ot calculation**/
|
|
if ($OT_Hrs_Worked != 0) {
|
|
$totSalayOT = $OT_Hrs_Worked * $onehoursSalary;
|
|
} else {
|
|
$totSalayOT = 0;
|
|
}
|
|
$currentDaySalary = $daySalary * $daySalarys;
|
|
/** current day salary working days calculation**/
|
|
|
|
|
|
$currentDayHra = $dayHra * $daySalarys;
|
|
/** total working days hra calculations**/
|
|
// echo $currentDayHra.'<br/>';
|
|
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
|
|
/** current date pf calculation**/
|
|
if ($TotalSalary <= 20000) {
|
|
|
|
$esiAmount = $currentDatePF * $ESI_Rate / 100;
|
|
/** esiamount not elgiable for 20000 **/
|
|
} else {
|
|
$esiAmount = 0;
|
|
}
|
|
$pfAmount = $currentDaySalary * $PF_Rate / 100;
|
|
/** pf amount per day**/
|
|
|
|
//echo $totalothour;die;
|
|
$empSalaryAdd = $currentDaySalary + $totSalayOT + $currentDayHra + $dayFood_Allowance + $Allowances + $Incentive;
|
|
$empSalarySub = $esiAmount + $pfAmount + $loan;
|
|
|
|
$salaryInCurrentday = $empSalaryAdd - $empSalarySub;
|
|
|
|
|
|
$employeeSalary[] = round($salaryInCurrentday);
|
|
}
|
|
$data['empSalary'] = $employeeSalary;
|
|
|
|
|
|
//echo sizeof($data['fresh'])."-".sizeof($data['empSalary']);die;
|
|
$this->global['pageTitle'] = 'Payroll Monthly Inputs';
|
|
$this->loadViews("monthlypayinputs", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function changeMonth()
|
|
{
|
|
|
|
$current = $this->request->getPost('monthyear');
|
|
|
|
$data['month'] = $this->monthlypay_model->monthlyListing($current);
|
|
//print_r($data['month']);
|
|
$data['dropdownvalue'] = $current;
|
|
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
|
|
//print_r($data['fresh']);
|
|
$employeeSalary = [];
|
|
|
|
|
|
foreach ($data['fresh'] as $value) {
|
|
|
|
//print_r($value);
|
|
//die();
|
|
|
|
$NoofDays = $value->NoofDays; //Month day 30,31,28
|
|
$HRA_Amount = $value->HRA_Amount;
|
|
$Basic_Pay = $value->Basic_Pay;
|
|
$TotalSalary = $value->TotalSalary;
|
|
$Food_Allowances = $value->Food_Allowances;
|
|
$Days_worked = $value->Days_worked; // working day
|
|
$LOP_Days = $value->LOP_Days; // not working day
|
|
$Paid_leave = $value->Paid_leave; // leave day
|
|
$OT_Hrs_Worked = $value->OT_Hrs_Worked; //OT hours
|
|
$Monthly_Due = $value->Monthly_Due; // AUTO LOAN DUE
|
|
$due_start_date = $value->DueDate;
|
|
$paydate = $current; //From POST parm
|
|
|
|
if (strlen((string)$paydate) == 6) {
|
|
$paydate = '0' . $paydate;
|
|
}
|
|
$pmonth = substr($paydate, 0, 2);
|
|
$pyear = substr($paydate, -4);
|
|
|
|
$pday = cal_days_in_month(CAL_GREGORIAN, $pmonth, $pyear);
|
|
$paymonth = $pyear . '-' . $pmonth . '-' . $pday;
|
|
|
|
$Loan_Recovered = $value->Loan_Recovered; //MANUAL LOAN DUE
|
|
|
|
$MasterIncentives = $value->MasterIncentives; //Master values get
|
|
// echo 'master'.$MasterIncentives;
|
|
$Loan_amount = $value->Loan_Amount;
|
|
$Paid_Amount = $value->Paid_Amount;
|
|
|
|
|
|
$Balance_Amount = $Loan_amount - $Paid_Amount;
|
|
|
|
|
|
|
|
$loan = 0;
|
|
if ($Loan_Recovered == 'NA') {
|
|
$loan = 0.00;
|
|
} else if ($Loan_Recovered == 0.00) {
|
|
if (strtotime($due_start_date) <= strtotime($paymonth)) {
|
|
$loan = $Monthly_Due;
|
|
}
|
|
} else if ($Loan_Recovered >= 0.00) {
|
|
|
|
if (strtotime($due_start_date) <= strtotime($paymonth)) {
|
|
$loan = $Loan_Recovered;
|
|
}
|
|
}
|
|
|
|
|
|
if ($Monthly_Due > $Balance_Amount) {
|
|
|
|
// current= Balance_Amount - autoLoan;
|
|
//alert('hi');
|
|
$loan = $Balance_Amount;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$Allowances = $value->Allowances;
|
|
$HRA_Rate = $value->HRA_Rate;
|
|
$PF_Rate = $value->PF_Rate;
|
|
$ESI_Rate = $value->ESI_Rate;
|
|
|
|
$MonthIncentive = $value->MonthlyIncentives; //t_monthly_pay_inputs,for change month
|
|
|
|
$Incentive = 0;
|
|
|
|
if (empty($MonthIncentive)) {
|
|
|
|
$Incentive = $MasterIncentives;
|
|
} else {
|
|
$Incentive = $MonthIncentive;
|
|
}
|
|
// echo $Incentive;
|
|
|
|
|
|
|
|
$daySalarys = $Days_worked + $Paid_leave;
|
|
|
|
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
|
|
//$Allowances = $allowances * $values;
|
|
$dayFood_Allowance = $Food_Allowances * $Days_worked;
|
|
|
|
$daySalary = $Basic_Pay / $NoofDays;
|
|
/**per day salary working hour**/
|
|
//echo $daySalary.'<br/>';
|
|
|
|
$dayHra = $HRA_Amount / $NoofDays;
|
|
/** per day hra amount **/
|
|
//echo $dayHra.'<br/>';
|
|
|
|
$onehoursSalary = ($daySalary + $dayHra) / 8;
|
|
/**one hour salay ot calculation**/
|
|
if ($OT_Hrs_Worked != 0) {
|
|
$totSalayOT = $OT_Hrs_Worked * $onehoursSalary;
|
|
} else {
|
|
$totSalayOT = 0;
|
|
}
|
|
$currentDaySalary = $daySalary * $daySalarys;
|
|
/** current day salary working days calculation**/
|
|
|
|
|
|
$currentDayHra = $dayHra * $daySalarys;
|
|
/** total working days hra calculations**/
|
|
// echo $currentDayHra.'<br/>';
|
|
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
|
|
/** current date pf calculation**/
|
|
if ($TotalSalary <= 20000) {
|
|
|
|
$esiAmount = $currentDatePF * $ESI_Rate / 100;
|
|
/** esiamount not elgiable for 20000 **/
|
|
} else {
|
|
$esiAmount = 0;
|
|
}
|
|
$pfAmount = $currentDaySalary * $PF_Rate / 100;
|
|
/** pf amount per day**/
|
|
|
|
//echo $totalothour;die;
|
|
$empSalaryAdd = $currentDaySalary + $totSalayOT + $currentDayHra + $dayFood_Allowance + $Allowances + $Incentive;
|
|
$empSalarySub = $esiAmount + $pfAmount + $loan;
|
|
|
|
$salaryInCurrentday = $empSalaryAdd - $empSalarySub;
|
|
|
|
|
|
$employeeSalary[] = round($salaryInCurrentday);
|
|
}
|
|
$data['empSalary'] = $employeeSalary;
|
|
|
|
//echo sizeof($data['fresh'])."-".sizeof($data['empSalary']);die;
|
|
$this->global['pageTitle'] = 'Payroll Monthly Inputs';
|
|
$this->loadViews("monthlypayinputs", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function saveMonthlyData()
|
|
{
|
|
|
|
$month = (string)$this->request->getPost('param2');
|
|
$jsondata = (string)$this->request->getPost('param1');
|
|
$json = json_decode($jsondata, true);
|
|
|
|
|
|
$mon = '';
|
|
$year = '';
|
|
|
|
if (strlen($month) == 7) {
|
|
//echo "SEVEN";
|
|
$mon = substr($month, 0, 2);
|
|
$year = substr($month, 3);
|
|
} else {
|
|
//echo "NOT SEVEN";
|
|
$mon = substr($month, 0, 1);
|
|
$year = substr($month, 2);
|
|
|
|
if ((int)$mon < 10) {
|
|
|
|
$mon = '0' . $mon;
|
|
}
|
|
}
|
|
|
|
|
|
$month = $mon . "-" . $year;
|
|
//echo $month;die();
|
|
$total = 0;
|
|
$ErrorEmpId = '';
|
|
$TotalErrorFlag = 0;
|
|
$i = sizeof($json);
|
|
$len = $i - 2;
|
|
foreach ($json as $index => $j) {
|
|
if ($index <= $len) {
|
|
|
|
$ErrorFlag = 0;
|
|
|
|
$Emp = $j['Employee'];
|
|
|
|
$EmpID = substr($Emp, 0, 4);
|
|
|
|
//$Name = $j['Employee Name'];
|
|
//echo $EmpID; die;
|
|
|
|
$DaysWorked = $j['Days Worked'];
|
|
$LOP_Days = $j['LOP Days'];
|
|
$Paid_leave = $j['Paid Leave'];
|
|
$OT_Hrs_Worked = $j['OT Hrs'];
|
|
$Loan_Recovered = $j['Manual Loan Due ₹'];
|
|
$Incentives = $j['Incentives in ₹'];
|
|
$Festival_Bonus = $j['Festival Bonus in ₹'];
|
|
$Other_Deductions = $j['Other Deductions in ₹'];
|
|
$Estimate = $j['Estimate in ₹'];
|
|
$Created_By = $this->session->get('userId');
|
|
|
|
if (!is_numeric($DaysWorked) || ($DaysWorked > 31) || (strlen((string)$DaysWorked)) > 5) {
|
|
//echo $EmpID . "-LOP_Days Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
if (!is_numeric($LOP_Days) || ($LOP_Days > 31) || (strlen((string)$LOP_Days)) > 5) {
|
|
//echo $EmpID . "-LOP_Days Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
if (!is_numeric($Paid_leave) || ($Paid_leave > 31) || (strlen((string)$Paid_leave)) > 5) {
|
|
//echo $EmpID . "-Paid Leave Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
|
|
|
|
|
|
$OT_Hrs_Worked_first = explode(".", $OT_Hrs_Worked);
|
|
if (!is_numeric($OT_Hrs_Worked) || (strlen((string)$OT_Hrs_Worked)) > 6 || (strlen((string)$OT_Hrs_Worked_first[0])) >= 4) // || (strlen((string)$OT_Hrs_Worked_first[1]))> 3 )
|
|
{
|
|
//echo $EmpID . "-OT Hrs Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
|
|
if (is_numeric($Loan_Recovered)) {
|
|
|
|
$Loan_Recovered_first = explode(".", $Loan_Recovered);
|
|
if ((strlen((string)$Loan_Recovered)) > 8 || (strlen((string)$Loan_Recovered_first[0])) > 5) {
|
|
//echo $EmpID . "-Loan Recoverd Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
} else if (is_string($Loan_Recovered)) {
|
|
|
|
//echo "STRING";
|
|
if (strcasecmp($Loan_Recovered, 'NA')) {
|
|
//echo "NOT NA";
|
|
$ErrorFlag++;
|
|
}
|
|
}
|
|
|
|
$Incentives_first = explode(".", $Incentives);
|
|
if (!is_numeric($Incentives) || (strlen((string)$Incentives)) > 8 || (strlen((string)$Incentives_first[0])) > 5) {
|
|
//echo $EmpID . "-Loan Recoverd Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
$Festivalbonus_first = explode(".", $Festival_Bonus);
|
|
if (!is_numeric($Festival_Bonus) || (strlen((string)$Festival_Bonus)) > 8 || (strlen((string)$Festivalbonus_first[0])) > 5) {
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
$Other_Deductions_first = explode(".", $Other_Deductions);
|
|
if (!is_numeric($Other_Deductions) || (strlen((string)$Other_Deductions)) > 8 || (strlen((string)$Other_Deductions_first[0])) > 5) {
|
|
//echo $EmpID . "-Loan Recoverd Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
$Estimate_first = explode(".", $Estimate);
|
|
if (!is_numeric($Estimate) || (strlen((string)$Estimate)) > 8 || (strlen((string)$Estimate_first[0])) > 5) {
|
|
//echo $EmpID . "-Loan Recoverd Invalid Data!";
|
|
$ErrorFlag++;
|
|
}
|
|
|
|
if ($ErrorFlag != 0) {
|
|
//echo $EmpID ."- has Invalid Data!";
|
|
$ErrorEmpId = $ErrorEmpId . "|" . $EmpID;
|
|
$TotalErrorFlag++;
|
|
} else //if($ErrorFlag == 0)
|
|
{
|
|
//nothing
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($TotalErrorFlag == 0) {
|
|
|
|
foreach ($json as $index => $j) {
|
|
|
|
$Emp = $j['Employee'];
|
|
|
|
// $EmpID = substr($Emp, 0, 4);
|
|
$parts = explode("-", $Emp);
|
|
$EmpID = $parts[0];
|
|
|
|
//$Name = $j['Employee'];
|
|
|
|
$DaysWorked = $j['Days Worked'];
|
|
$LOP_Days = $j['LOP Days'];
|
|
$Paid_leave = $j['Paid Leave'];
|
|
$OT_Hrs_Worked = $j['OT Hrs'];
|
|
$Loan_Recovered = isset($j['Manual Loan Due ₹']) ? $j['Manual Loan Due ₹'] : 0.00;
|
|
if (is_string($Loan_Recovered)) {
|
|
$Loan_Recovered = strtoupper($Loan_Recovered);
|
|
}
|
|
$Incentives = isset($j['Incentives in ₹']) ? $j['Incentives in ₹'] : 0.00 ;
|
|
$Festival_Bonus = isset($j['Festival Bonus in ₹']) ? $j['Festival Bonus in ₹'] : 0.00;
|
|
$Other_Deductions = isset($j['Other Deductions in ₹']) ? $j['Other Deductions in ₹'] : 0.00;
|
|
$Estimate = isset($j['Estimate in ₹']) ? $j['Estimate in ₹'] : 0.00;
|
|
$Created_By = $this->session->get('userId');
|
|
|
|
$monthlypaydata = array('Month_Year' => $month, 'EmpID' => $EmpID, 'Days_worked' => $DaysWorked, 'LOP_Days' => $LOP_Days, 'Paid_leave' => $Paid_leave, 'OT_Hrs_Worked' => $OT_Hrs_Worked, 'Loan_Recovered' => $Loan_Recovered, 'Incentives' => $Incentives, 'Festival_Bonus' => $Festival_Bonus, 'Other_Deductions' => $Other_Deductions, 'Estimate' => $Estimate, 'Created_By' => $Created_By);
|
|
// print_r($monthlypaydata); die;
|
|
$result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata);
|
|
$total = $total + $result;
|
|
}
|
|
}
|
|
$total = $total - 1;
|
|
//echo "<script> alert($ErrorEmpId + '- are have Invalid Data!'); </script>";
|
|
if (!empty($ErrorEmpId)) {
|
|
echo $ErrorEmpId . "- are have Invalid Data!";
|
|
}
|
|
echo $total . "- Employees Updated Successfully ";
|
|
}
|
|
|
|
|
|
function payslipLisiting()
|
|
{
|
|
$curr_year = date('Y');
|
|
$curr_month = date('m');
|
|
$curr_monthyear = $curr_month . '-' . $curr_year;
|
|
$this->global['pageTitle'] = 'Payslip Listing';
|
|
$data['PayInfo'] = $this->payroll_model->GetPayslipdata();
|
|
$data['dropdownvalue'] = $curr_monthyear;
|
|
$this->loadViews("paysliplist", $this->global, $data, NULL);
|
|
}
|
|
|
|
function reload_paysliplist()
|
|
{
|
|
|
|
$pre_monthyear = $this->request->getPost('month');
|
|
$this->global['pageTitle'] = 'Payslip Listing';
|
|
$data['PayInfo'] = $this->payroll_model->GetPayslipdata($pre_monthyear);
|
|
$data['dropdownvalue'] = $pre_monthyear;
|
|
$this->loadViews("paysliplist", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function editPayslip($EmpID, $PayOn)
|
|
{
|
|
|
|
|
|
$this->global['pageTitle'] = 'Edit Employee Payslip';
|
|
$data['PayInfo'] = $this->payroll_model->GetPayslipdata($PayOn, $EmpID);
|
|
$this->loadViews("editPayslip", $this->global, $data, NULL);
|
|
}
|
|
public function viewGenerator()
|
|
{
|
|
|
|
$Data['Payon'] = $this->payroll_model->getPayOn();
|
|
|
|
|
|
|
|
$this->global['pageTitle'] = 'Payroll Generater';
|
|
|
|
$this->loadViews("payslipgenerate", $this->global, $Data, NULL);
|
|
}
|
|
/* Validation for Employee Dropdow */
|
|
public function Employee_validate(string $str, string &$error = null): bool
|
|
{
|
|
if ($str == '-1') {
|
|
$error = 'Please Select Employee.';
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
|
|
function getEmployee()
|
|
{
|
|
$id = $this->request->getPost('id1');
|
|
|
|
$result = $this->payroll_model->getEmployeelist2($id);
|
|
$HTML = "";
|
|
|
|
if (count($result) > 0) {
|
|
|
|
foreach ($result as $list) {
|
|
|
|
|
|
$HTML .= "<option value='" . $list->EmpId . "'>" . $list->EmpId . "-" . $list->Fname . "</option>";
|
|
}
|
|
}
|
|
echo $HTML;
|
|
}
|
|
|
|
/* Validation for PayOn Dropdown */
|
|
public function PayOn_validate(string $str, string &$error = null): bool
|
|
{
|
|
if ($str == '-1') {
|
|
$error = 'Please Select PayOn.';
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function PrintPdf()
|
|
{
|
|
|
|
$filename = " ";
|
|
$html = "";
|
|
$All = $this->request->getPost('All');
|
|
if ($All == '') {
|
|
$this->validator->setRules([
|
|
'Employee' => [
|
|
'label' => 'Employee',
|
|
'rules' => 'trim|callback_Employee_validate',
|
|
]
|
|
]);
|
|
}
|
|
|
|
$this->validator->setRules([
|
|
'PayOn' => [
|
|
'label' => 'PayOn',
|
|
'rules' => 'trim|callback_PayOn_validate',
|
|
]
|
|
]);
|
|
|
|
if ($this->validator->run() == FALSE) {
|
|
$this->viewGenerator();
|
|
} else {
|
|
$Payon = $this->request->getPost('PayOn');
|
|
|
|
$m = date("M", mktime(0, 0, 0, (int)$Payon, 10));
|
|
//$y =date("Y",mktime(0, 0, 0, $Payon, 10));
|
|
//$m=date("M-Y",mktime(0,0,0,$month,1,$year));
|
|
$y = substr((string)$Payon, 3);
|
|
//echo "Payon" . $Payon;
|
|
|
|
if ($All != '') {
|
|
$filename = 'PayslipFor-' . $m . '-' . $y;
|
|
$result = $this->payroll_model->getEmpAll($Payon);
|
|
// print_r($result);
|
|
// die();
|
|
|
|
if ($result > 0) {
|
|
for ($i = 0; $i < count($result); $i++) {
|
|
|
|
$EmpID = $result[$i]['EmpId'];
|
|
//print_r(
|
|
//$EmpID );
|
|
// die();
|
|
$Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon, $EmpID);
|
|
//
|
|
|
|
$totalsalary = $Data['PayDetails'][0]->LessAdvance;
|
|
$totalsalaryinwords = $this->convertNumber(round($totalsalary));
|
|
$Data['amtinwords'] = $totalsalaryinwords;
|
|
// print_r ($Data);
|
|
// exit();
|
|
//$Data['Count'] = $i;
|
|
|
|
$html .= view("payslipgenerateprint", $Data);
|
|
|
|
// print_r ($Data);
|
|
// exit();
|
|
}
|
|
}
|
|
} else {
|
|
$EmpID = $this->request->getPost('Employee');
|
|
//echo "EmpID" . $EmpID;
|
|
$Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon, $EmpID);
|
|
|
|
$fname = $Data['PayDetails'][0]->FName;
|
|
$filename = 'PayslipFor-' . $EmpID . ' ' . $fname . ' ' . $m . ' ' . $y;
|
|
|
|
$totalsalary = $Data['PayDetails'][0]->LessAdvance;
|
|
$totalsalaryinwords = $this->convertNumber(round($totalsalary));
|
|
$Data['amtinwords'] = $totalsalaryinwords;
|
|
//print_r ($Data);
|
|
//exit();
|
|
$html = view("payslipgenerateprint", $Data);
|
|
}
|
|
|
|
|
|
// $php = $this->output->get_output();
|
|
|
|
// // Load library
|
|
// $this->load->library('dompdf_gen');
|
|
|
|
// if($All != '')
|
|
// {
|
|
// $filename = 'Payslip-'.$Payon.'.pdf' ;
|
|
// }
|
|
// else
|
|
// {
|
|
// $filename = 'Payslip-'.$EmpID . '-' .$Payon.'.pdf' ;
|
|
// }
|
|
|
|
// require_once(APPPATH .'third_party/dompdf/dompdf_config.inc.php');
|
|
// $dompdf = new DOMPDF();
|
|
// $dompdf->set_paper('A4', 'portrait');
|
|
// $dompdf->load_html($php);
|
|
|
|
// $dompdf->render();
|
|
|
|
// // add the header
|
|
// $canvas = $dompdf->get_canvas();
|
|
// $font = Font_Metrics::get_font("helvetica", "bold");
|
|
|
|
// // the same call as in my previous example
|
|
// $canvas->page_text(72, 18, "Page: {PAGE_NUM} of {PAGE_COUNT}",
|
|
// $font, 6, array(0,0,0));
|
|
|
|
// $dompdf->stream($filename);
|
|
// }
|
|
|
|
// $mpdf = new mPDF('utf-8', 'A4-P', 10, 10, 10, 10, 10, 24, 4, 6);
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 10,
|
|
'margin_bottom' => 10,
|
|
'margin_header' => 10,
|
|
'margin_footer' => 6,
|
|
'setAutoTopMargin' => 'stretch',
|
|
'setAutoBottomMargin' => 'stretch'
|
|
]);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
// $mpdf->SetHTMLHeader($HtmlHeading);
|
|
$mpdf->setFooter("Page {PAGENO} of {nb}");
|
|
$mpdf->list_indent_first_level = 1;
|
|
$mpdf->WriteHTML($html);
|
|
$mpdf->SetTitle('Resico:Payslip');
|
|
|
|
$mpdf->Output("Payslip-" . $filename . ".pdf", 'D');
|
|
}
|
|
}
|
|
|
|
function updatePayslip()
|
|
{
|
|
|
|
$paykey = $this->request->getPost("Key");
|
|
$EmpID = $this->request->getPost("EmpID");
|
|
$PayOn = $this->request->getPost("PayOn");
|
|
$otherallowence = $this->request->getPost("otherallowence");
|
|
$otherdeductions = $this->request->getPost("otherdeductions");
|
|
$incentive = $this->request->getPost("incentive");
|
|
$netpay = $this->request->getPost("netpay");
|
|
$esi = $this->request->getPost("txtesi");
|
|
$pf = $this->request->getPost("txtpf");
|
|
$basic = $this->request->getPost("txtbasicda");
|
|
$hra = $this->request->getPost("txthra");
|
|
$otsalary = $this->request->getPost("otsalary");
|
|
|
|
$Totaldeduction = $esi + $pf + $otherdeductions;
|
|
$SalaryAsPerPF = ($basic + $hra + $otsalary) - $Totaldeduction;
|
|
$userid = $this->session->get('userId');
|
|
|
|
$remarks = 'Manual Edit By' . $userid . " On " . get_current_date();
|
|
$paydetails = array('Key' => $paykey, 'EmpID' => $EmpID, 'PayOn' => $PayOn, 'Other_allowances' => $otherallowence, 'OtherDeductions' => $otherdeductions, 'Incentive' => $incentive, 'LessAdvance' => $netpay, 'TotalSalary' => $netpay, 'SalaryAsPerPF' => $SalaryAsPerPF, 'Totaldeduction' => $Totaldeduction, 'remarks' => $remarks);
|
|
$monthdetails = array('Month_Year' => $PayOn, 'Other_Deductions' => $otherdeductions, 'Incentives' => $incentive);
|
|
$result = $this->payroll_model->updateEmpPayslip($paydetails);
|
|
$res = $this->monthlypay_model->editmonth($monthdetails, $EmpID);
|
|
echo $result;
|
|
}
|
|
|
|
|
|
/**
|
|
* This function used to upload the Excel file Details
|
|
*/
|
|
|
|
|
|
/**
|
|
* This function used to upload the Excel file Details2
|
|
*/
|
|
function uploadExcel2()
|
|
{
|
|
$path = ROOTPATH.'public/uploads/files/';
|
|
if(!is_dir($path)) { mkdir($path, 0777, true); }
|
|
|
|
$PayrollFileName = '';
|
|
$file = $this->request->getFile('userfile');
|
|
if ($file && $file->isValid() && !$file->hasMoved()) {
|
|
|
|
$pathinfo = pathinfo($file->getName());
|
|
$config['upload_path'] = $path;
|
|
$config['allowed_types'] = 'xls|xlsx|csv';
|
|
$config['file_name'] = $_FILES['userfile']['name'];
|
|
$config['overwrite'] = true;
|
|
|
|
if (in_array($pathinfo['extension'], ['xlsx', 'xls']) && $file->getSize() > 0)
|
|
{
|
|
$file->move($config['upload_path'], $config['file_name']);
|
|
$PayrollFileName = $file->getName();
|
|
|
|
$inputFileName = $path . $PayrollFileName;
|
|
// $inputFileName = $_FILES['userfile']['tmp_name'];
|
|
|
|
$spreadsheet = IOFactory::load($inputFileName);
|
|
$sheet = $spreadsheet->getActiveSheet();
|
|
$highestRow = $sheet->getHighestRow();
|
|
$highestColumn = $sheet->getHighestColumn();
|
|
|
|
|
|
$x = 8;
|
|
$month = $this->request->getPost('mon');
|
|
$year = $this->request->getPost('yr');
|
|
$PayOn = $month . "-" . $year;
|
|
$createdby = $this->session->get('userId');
|
|
|
|
|
|
if ($month == '01' || $month == '03' || $month == '05' || $month == '07' || $month == '08' || $month == '10' || $month == '12') {
|
|
$Totaldays = 31;
|
|
} else if ($month == '04' || $month == '06' || $month == '09' || $month == '11') {
|
|
$Totaldays = 30;
|
|
} else {
|
|
$Totaldays = 28;
|
|
}
|
|
|
|
|
|
// $Totaldays = 0;
|
|
//echo $highestRow;
|
|
$FileDetails = array('PayOn' => $PayOn, 'TotalNoofDays' => $Totaldays, 'FileName' => $config['file_name'], 'CreatedBy' => $createdby);
|
|
$result = $this->payroll_model->UploadFileName($FileDetails);
|
|
$emplid = $this->payroll_model->getEmpID($q = '');
|
|
$payEmpID = $this->payroll_model->getEmpIDfromPayData();
|
|
//print_r($payEmpID);die();
|
|
|
|
$nopaydata = 0;
|
|
$nopayid = '';
|
|
$nopayrowid = '';
|
|
$Unknowncount = 0;
|
|
$Unknown = "";
|
|
$row = "";
|
|
$d = array("-1" => "");
|
|
$fail = 0;
|
|
$success = 0;
|
|
for ($x = 8; $x <= $highestRow; $x++) {
|
|
|
|
$EmpId = $sheet->getCell('A' . $x)->getValue();
|
|
|
|
|
|
/**** For Check Uploading EmpID existing in Employee Details(Valid or Not) *****/
|
|
$flag = 0;
|
|
foreach ($emplid as $e) {
|
|
|
|
if (strtoupper($EmpId) == $e->EmpID) {
|
|
|
|
$flag++;
|
|
}
|
|
}
|
|
if ($flag == 0) {
|
|
|
|
$Unknowncount++;
|
|
$Unknown .= '-' . $EmpId;
|
|
$row .= '-' . $x;
|
|
}
|
|
|
|
/***** For Check Uploading EmpID existing in Emp Pay Data Details(Whether master pay data available or not) *****/
|
|
if ($flag != 0) {
|
|
$flag2 = 0;
|
|
foreach ($payEmpID as $p) {
|
|
if (strtoupper($EmpId) == $p->EmpID) {
|
|
$flag2++;
|
|
}
|
|
}
|
|
if ($flag2 == 0) {
|
|
$nopaydata++;
|
|
$nopayid .= '-' . $EmpId;
|
|
$nopayrowid .= '-' . $x;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
$FileDataExists = $this->payroll_model->checkFileDetailsExists2($PayOn, $EmpId);
|
|
|
|
if ($FileDataExists == '' || $FileDataExists == 0) {
|
|
|
|
|
|
|
|
$EmpId = $sheet->getCell('A' . $x)->getValue();
|
|
$EmpId = strtoupper($EmpId);
|
|
$Days_worked = $sheet->getCell('C' . $x)->getValue();
|
|
$LOPDays = $sheet->getCell('D' . $x)->getValue();
|
|
$Paid_leave = $sheet->getCell('E' . $x)->getValue();
|
|
$OTHoursWorked = $sheet->getCell('F' . $x)->getValue();
|
|
$LoanRecovered = $sheet->getCell('G' . $x)->getValue();
|
|
if (is_string($LoanRecovered)) {
|
|
$LoanRecovered = strtoupper($LoanRecovered);
|
|
}
|
|
$Incentive = $sheet->getCell('G' . $x)->getValue();
|
|
$Other_Deductions = $sheet->getCell('H' . $x)->getValue();
|
|
|
|
if ($EmpId != '') {
|
|
|
|
|
|
|
|
if ($flag != 0 && $flag2 != 0) {
|
|
|
|
|
|
$FileData = array('Month_Year' => $PayOn, 'EmpID' => $EmpId, 'Days_worked' => $Days_worked, 'LOP_Days' => $LOPDays, 'Paid_leave' => $Paid_leave, 'OT_Hrs_Worked' => $OTHoursWorked, 'Loan_Recovered' => $LoanRecovered, 'Incentives' => $Incentive, 'Other_Deductions' => $Other_Deductions, 'Created_By' => $createdby, 'Created_Time' => date("Y-m-d h:i:sa"));
|
|
$result = $this->payroll_model->UploadFileData2($FileData);
|
|
$success++;
|
|
}
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
}
|
|
} else {
|
|
|
|
$fail++;
|
|
}
|
|
} //End of For Loop
|
|
|
|
|
|
|
|
echo "<script>alert('File Uploaded Successfully!');</script>";
|
|
echo "<script> alert($success +' - Data Uploaded sucessfully and ' + $fail + ' - Duplicate Data Found'); </script>";
|
|
echo "<script>alert($Unknowncount+'-data invalid, and data are'+'$Unknown'+'- found at rows'+'$row');</script>";
|
|
echo "<script>alert($nopaydata+'-data no have pay data, and data are'+'$nopayid'+'- found at rows'+'$nopayrowid');</script>";
|
|
|
|
|
|
echo "<script>window.location.href='ExcelUpload2';</script>"; //redirect('payslip/viewUpload2');
|
|
|
|
|
|
|
|
}
|
|
else {
|
|
echo "<script>alert('Please select valid Excel file to Upload!');window.location.href='ExcelUpload2';</script>";
|
|
}
|
|
} else {
|
|
|
|
echo "<script>alert('Please select Excel file to Upload!');window.location.href='ExcelUpload2';</script>";
|
|
}
|
|
}
|
|
|
|
function checkExistPay()
|
|
{
|
|
$empid = $this->request->getPost('employee');
|
|
$payon = $this->request->getPost('payon');
|
|
$result = $this->payroll_model->checkExistPayData($empid, $payon);
|
|
echo json_encode(count($result));
|
|
}
|
|
|
|
|
|
|
|
function convertNumber($amt)
|
|
{
|
|
$ShowPaise = '0';
|
|
$totalAmt = explode(".", $amt);
|
|
|
|
$number = $totalAmt[0];
|
|
$no = $number;
|
|
|
|
if (!empty($totalAmt[1]) && $totalAmt[1] != 0) {
|
|
$point = $totalAmt[1];
|
|
$ShowPaise = '1';
|
|
} else {
|
|
$point = 0;
|
|
$ShowPaise = '0';
|
|
}
|
|
|
|
|
|
$hundred = null;
|
|
$digits_1 = strlen($no);
|
|
|
|
$i = 0;
|
|
$str = array();
|
|
$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' => 'Fourty', '50' => 'Fifty',
|
|
'60' => 'Sixty', '70' => 'Seventy',
|
|
'80' => 'Eighty', '90' => 'Ninety'
|
|
);
|
|
$digits = array('', 'Hundred', 'Thousand', 'Lakh', 'Crore');
|
|
while ($i < $digits_1) {
|
|
$divider = ($i == 2) ? 10 : 100;
|
|
$number = floor($no % $divider);
|
|
$no = floor($no / $divider);
|
|
$i += ($divider == 10) ? 1 : 2;
|
|
if ($number) {
|
|
$plural = (($counter = count($str)) && $number > 1) ? 's' : null;
|
|
$hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
|
|
$str[] = ($number < 21) ? $words[$number] .
|
|
" " . $digits[$counter] . $plural . " " . $hundred
|
|
:
|
|
$words[floor($number / 10) * 10]
|
|
. " " . $words[$number % 10] . " "
|
|
. $digits[$counter] . $plural . " " . $hundred;
|
|
} else $str[] = null;
|
|
}
|
|
$str = array_reverse($str);
|
|
$result = implode('', $str);
|
|
|
|
$points = ($point) ?
|
|
" " . $words[$point / 10] . " " .
|
|
$words[$point = $point % 10] : '';
|
|
|
|
if ($ShowPaise == '0') {
|
|
|
|
$amountInWords = "Rupees " . $result . " Only";
|
|
} else {
|
|
|
|
$amountInWords = "Rupees " . $result . " Paise " . $points . " Only";
|
|
}
|
|
|
|
|
|
return $amountInWords;
|
|
}
|
|
|
|
|
|
|
|
function Bonusreport()
|
|
{
|
|
//echo"function in controller";
|
|
|
|
$this->global['pageTitle'] = 'Incentive and Bonus Reports';
|
|
|
|
$fin_year = $this->request->getPost('finyear');
|
|
//echo "values are,".$year.$fin_year;
|
|
$data['finyear'] = $fin_year;
|
|
|
|
$data['Reportvalue'] = $this->monthlypay_model->reportvalue($fin_year);
|
|
|
|
$this->loadViews("Bonusreport", $this->global, $data, NULL);
|
|
}
|
|
function MonthwiseBonusreport()
|
|
{
|
|
//echo"in controller";
|
|
// $EmployeeID = $_GET['EID'];
|
|
// $Fin_year = $_GET['Finyear'];
|
|
$EmployeeID = $this->request->getGet('EID');
|
|
$Fin_year = $this->request->getGet('Finyear');
|
|
|
|
$data['finyear'] = $Fin_year;
|
|
//echo $EmployeeID;
|
|
//echo $Fin_year;
|
|
$this->global['pageTitle'] = 'Monthwise Incentive and Bonus Reports';
|
|
$data['MonthwiseReport'] = $this->monthlypay_model->Monthwisereportvalue($Fin_year, $EmployeeID);
|
|
//print_r($data['MonthwiseReport']);
|
|
$this->loadViews("Bonusreportmonthwise", $this->global, $data, NULL);
|
|
}
|
|
function ValidationCheque()
|
|
{
|
|
|
|
$bank = $this->request->getPost("id1");
|
|
$payon = $this->request->getPost("id2");
|
|
|
|
$result = $this->payroll_model->getChequeInfo($bank, $payon);
|
|
|
|
$count = count($result);
|
|
|
|
echo $count;
|
|
}
|
|
}
|