diff --git a/app/Controllers/Payslip.php b/app/Controllers/Payslip.php index 9e50df14..e62a8164 100755 --- a/app/Controllers/Payslip.php +++ b/app/Controllers/Payslip.php @@ -168,436 +168,6 @@ class Payslip extends BaseController } - 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 ''; - $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() { @@ -891,151 +461,6 @@ class Payslip extends BaseController } - // function changeMonth() - // { - - // $current = $this->request->getPost('monthyear'); - - // $data['month'] = $this->monthlypay_model->monthlyListing($current); - // $data['dropdownvalue'] = $current; - // $data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current); - // // dd($data['fresh']); - - - // $employeeSalary = []; - // $esi = []; - // $pf = []; - // $ot = []; - // 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; - // $Days_worked = $value->Days_worked; // working day - // $Sunday = $value->sunday_count; // Sunday count - // $LOP_Days = $value->NoofDays - ($Days_worked); // not working day - // $Paid_leave = $value->Paid_leave; // leave day - // if ($value->is_management_team == 1) - // { - // $OT_Hrs_Worked = 0; //OT hours - // $value->OT_Hrs_Worked = 0; - // } else { - // $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 - // $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_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) { - // $loan = $Balance_Amount; - // } - - - // $PF_Rate = $value->PF_Rate; - // $ESI_Rate = $value->ESI_Rate; - - - - - - - // $totalDaysWorked = $Days_worked + $Paid_leave; - - // $dayBasic = $Basic_Pay / $NoofDays; - // $dayHra = $HRA_Amount / $NoofDays; - // $onehoursSalary = ($dayBasic + $dayHra) / 8; - - // /**one hour salay ot calculation**/ - // if ($OT_Hrs_Worked != 0) { - // $totSalayOT = $OT_Hrs_Worked * $onehoursSalary; - // } else { - // $totSalayOT = 0; - // } - - - // //current day basic and hra salary - // if ($value->is_management_team == 1) - // { - // $currentDayBasic = $dayBasic * $NoofDays; - // $currentDayHra = $dayHra * $NoofDays; - // } else { - // $currentDayBasic = $dayBasic * $totalDaysWorked; - // $currentDayHra = $dayHra * $totalDaysWorked; - // } - - - - // //$totalSalary = $currentDayBasic + $currentDayHra + $totSalayOT; - - - // if ($value->esi_applicable == 1) { $esiAmount = ($currentDayBasic + $currentDayHra) * $ESI_Rate / 100; } else { $esiAmount = 0;} - // if ($value->pf_applicable == 1) { $pfAmount = $currentDayBasic * $PF_Rate / 100; } else { $pfAmount = 0;} - - // /** pf amount per day**/ - - // //echo $totalothour;die; - // $empSalaryAdd = $currentDayBasic + $currentDayHra + $totSalayOT; - // $empSalarySub = $esiAmount + $pfAmount + $loan; - // $salaryInCurrentday = $empSalaryAdd - $empSalarySub; - - // // echo $esiAmount .'
'; - // // echo $pfAmount .'
'; - // // echo $loan .'
'; - // // echo $empSalarySub .'
'; - // // echo $empSalaryAdd .'
'; - // // echo $salaryInCurrentday .'
'; - // // die; - - // $employeeSalary[] = round($salaryInCurrentday); - // $esi[] = number_format($esiAmount,2, '.', ''); - // $pf[] = number_format($pfAmount,2, '.', ''); - // $ot[] = number_format($totSalayOT,2, '.', ''); - // } - // $data['empSalary'] = $employeeSalary; - // $data['esi'] = $esi; - // $data['pf'] = $pf; - // $data['over_time'] = $ot; - - - - - - // // dd($data); - // //echo sizeof($data['fresh'])."-".sizeof($data['empSalary']);die; - // $this->global['pageTitle'] = 'Payroll Monthly Inputs'; - // $this->loadViews("monthlypayinputs", $this->global, $data, NULL); - // } - function saveMonthlyData() { @@ -1906,4 +1331,427 @@ class Payslip extends BaseController echo $count; } + + + + 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 = ''; + + + + $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 ''; + $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); + } } diff --git a/app/Models/Driver_model.php b/app/Models/Driver_model.php index a325bfe8..601d28a2 100755 --- a/app/Models/Driver_model.php +++ b/app/Models/Driver_model.php @@ -231,7 +231,7 @@ class Driver_model extends Model ->select('CONCAT_WS(" ", driver.FirstName, driver.LastName) AS FullName') ->select('MonthlyPay.*,driver.BankAccountNo , driver.PFNO , driver.ESI as ESINO , L.Loan_ID, L.Loan_Amount, L.Loan_Issued_Date, L.Monthly_Due, L.Due_Start_Date, L.No_of_Dues, L.Paid_Due, L.Remaining_Due, L.Paid_Amount') ->join('t_employee_details as driver', 'driver.EmpID = MonthlyPay.driver_id and driver.is_driver = 1', 'left') - ->join('t_loan_master as L', 'MonthlyPay.driver_id = L.EmpID and L.is_Active = 1', 'left') + ->join('t_loan_master as L', 'MonthlyPay.driver_id = L.EmpID and L.is_Active = 1 and L.Remaining_Due != 0', 'left') ->where('MonthlyPay.driver_id', $driver_id) ->where('MonthlyPay.month_year', $PayOn); diff --git a/app/Models/Payroll_model.php b/app/Models/Payroll_model.php index d94f8b7a..0315e182 100755 --- a/app/Models/Payroll_model.php +++ b/app/Models/Payroll_model.php @@ -513,7 +513,7 @@ class Payroll_model extends Model $builder = $this->db->table('t_monthly_pay_inputs MonthlyPay ') ->select('MonthlyPay.*, E.BankAccountNo , E.PFNO , E.ESI as ESINO , L.Loan_ID, L.Loan_Amount, L.Loan_Issued_Date, L.Monthly_Due, L.Due_Start_Date, L.No_of_Dues, L.Paid_Due, L.Remaining_Due, L.Paid_Amount') ->join('t_employee_details as E', 'MonthlyPay.EmpID = E.EmpID', 'left') - ->join('t_loan_master as L', 'MonthlyPay.EmpID = L.EmpID and L.is_Active = 1', 'left') + ->join('t_loan_master as L', 'MonthlyPay.EmpID = L.EmpID and L.is_Active = 1 and L.Remaining_Due != 0', 'left') ->where('MonthlyPay.EmpID', $EmpId) ->where('MonthlyPay.Month_Year', $PayOn); diff --git a/app/Views/sales_invoice.php b/app/Views/sales_invoice.php index 11eab401..85469efa 100755 --- a/app/Views/sales_invoice.php +++ b/app/Views/sales_invoice.php @@ -338,16 +338,7 @@