diff --git a/app/Controllers/Driver.php b/app/Controllers/Driver.php index 07fec509..f77d1622 100755 --- a/app/Controllers/Driver.php +++ b/app/Controllers/Driver.php @@ -463,13 +463,13 @@ class Driver extends BaseController { $loan_id = $result->Loan_ID; - if($result->Remaining_Due - 1 == 0){ $is_Active = 0; }else{ $is_Active = 1; } + $loan = [ 'Paid_Due' => $result->Paid_Due + 1, 'Remaining_Due' => $result->Remaining_Due - 1, 'Paid_Amount' => $result->Paid_Amount + $result->Loan_Recovered, - 'is_Active' => $is_Active + ]; diff --git a/app/Controllers/Payslip.php b/app/Controllers/Payslip.php index 2adae210..e62a8164 100755 --- a/app/Controllers/Payslip.php +++ b/app/Controllers/Payslip.php @@ -72,8 +72,16 @@ class Payslip extends BaseController $EmpId = $this->request->getPost('employee'); $res = $this->payroll_model->getMonthlyPayDetails($EmpId, $PayOn); + + $this->payroll_model->updatePaySlipGeneration($EmpId, $PayOn); + + $result = $res[0]; + + if($result->is_payslip_generated == 0){ + + } $loan = []; $loanHistory = []; @@ -86,13 +94,13 @@ class Payslip extends BaseController { $loan_id = $result->Loan_ID; - if($result->Remaining_Due - 1 == 0){ $is_Active = 0; }else{ $is_Active = 1; } + $loan = [ 'Paid_Due' => $result->Paid_Due + 1, 'Remaining_Due' => $result->Remaining_Due - 1, 'Paid_Amount' => $result->Paid_Amount + $result->Loan_Recovered, - 'is_Active' => $is_Active + ]; $loanHistory = [ @@ -160,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() { @@ -598,7 +176,7 @@ class Payslip extends BaseController $data['month'] = $this->monthlypay_model->monthlyListing($current); $data['dropdownvalue'] = $current; $data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current); - // dd($data['fresh']); + // dd($data['fresh']); $data['drivermonthinputs'] = $this->driverMonthlyPayInputs($current); $employeeSalary = []; $esi = []; @@ -883,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() { @@ -1898,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/Controllers/StockController.php b/app/Controllers/StockController.php index bf26151b..cb7d78d9 100644 --- a/app/Controllers/StockController.php +++ b/app/Controllers/StockController.php @@ -346,7 +346,8 @@ class StockController extends BaseController 'clayOrLossOfIgnition' => $postData['clayOrLossOfIgnition'], 'reportComments' => $postData['reportComments'], 'gradeRange' => $postData['gradeRange'], - 'reportTime' => $postData['reportTime'] + 'reportTime' => $postData['reportTime'], + 'remark' => $postData['remark'] ]; @@ -1189,7 +1190,7 @@ class StockController extends BaseController //diesel stock details - + public function dieselMachineStockDetails(){ @@ -1244,9 +1245,17 @@ class StockController extends BaseController ->where('machine_category','diesel') ->findAll(); + $filterUpdateNeeded = true ; + if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){ + $customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + + } + + //check user applies for filter currently - if(!empty($customisedMachineCodes)){ + if(!empty($customisedMachineCodes) && $filterUpdateNeeded){ //user applied filter, @@ -1407,11 +1416,62 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + // Sort each date's machines based on the custom order to set table body td + if (!empty($customisedMachineCodes)) { + + foreach ($groupedByDate as $date => &$machines) { + + usort($machines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['machine_id'], $customisedMachineCodes); + $indexB = array_search($b['machine_id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($machines); + } + // Reset the structure to have indexed arrays without the date keys $data['groupedDieselMachineStockDetails'] = array_values($groupedByDate); + // Sort each date's machines based on the custom order to set table header th + + if (!empty($customisedMachineCodes)) { + + + + usort($dieselMachines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['id'], $customisedMachineCodes); + $indexB = array_search($b['id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } $dieselMachinesCount = count($dieselMachines); @@ -1602,9 +1662,17 @@ class StockController extends BaseController ->where('machine_category','electric') ->findAll(); + $filterUpdateNeeded = true ; + if( empty($customisedMachineCodes) && !empty($existingCustomMachineCodes)){ + $customisedMachineCodes = array_column($existingCustomMachineCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + + } + + //check user applies for filter currently - if(!empty($customisedMachineCodes)){ + if(!empty($customisedMachineCodes) && $filterUpdateNeeded){ //user applied filter, @@ -1769,10 +1837,63 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + + // Sort each date's machines based on the custom order to set table body td + if (!empty($customisedMachineCodes)) { + + foreach ($groupedByDate as $date => &$machines) { + + usort($machines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['machine_id'], $customisedMachineCodes); + $indexB = array_search($b['machine_id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($machines); + } + // Reset the structure to have indexed arrays without the date keys $data['groupedPowerConsumptionStockDetails'] = array_values($groupedByDate); + // Sort each date's machines based on the custom order to set table header th + + if (!empty($customisedMachineCodes)) { + + + + usort($electricMachines, function ($a, $b) use ($customisedMachineCodes) { + + $indexA = array_search($a['id'], $customisedMachineCodes); + $indexB = array_search($b['id'], $customisedMachineCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } + $electricMachinesCount = count($electricMachines); $data['electricMachinesCount'] = $electricMachinesCount; @@ -2064,11 +2185,19 @@ class StockController extends BaseController ->where('stock_category','resin') ->findAll(); + $filterUpdateNeeded = true ; + + if( empty($customisedMaterialCodes) && !empty($existingCustomMaterialCodes)){ + $customisedMaterialCodes = array_column($existingCustomMaterialCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + + } + //check user applies for filter currently - if(!empty($customisedMaterialCodes)){ + if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){ - //user applied filter, + //user applied new filter, //check already filter existing , if exists remove that , if(!empty($existingCustomMaterialCodes)){ @@ -2129,7 +2258,7 @@ class StockController extends BaseController //no filter applied at all just present all active material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model->getAllResinMaterialCode(); }else{ - //if filter present,get that material codes + //if filter present , Reuse the filter and get that material codes $existingCustomMaterialCodes = $this->rawmaterialdetails_model ->getSelectedResinMaterialCode(array_column($existingCustomMaterialCodes, 'materialCode')); } @@ -2201,7 +2330,35 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + // Sort each date's materials based on the custom order to set table body td + if (!empty($customisedMaterialCodes)) { + + foreach ($groupedByDate as $date => &$materials) { + + usort($materials, function ($a, $b) use ($customisedMaterialCodes) { + + $indexA = array_search($a['materialCode'], $customisedMaterialCodes); + $indexB = array_search($b['materialCode'], $customisedMaterialCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($materials); + } + // Reset the structure to have indexed arrays without the date keys + + //this is for tbody table data td $data['groupedResinStockDetails'] = array_values($groupedByDate); @@ -2219,6 +2376,30 @@ class StockController extends BaseController ->first()['customer'] ?? ''; } + // Sort each date's materials based on the custom order to set table header th + if (!empty($customisedMaterialCodes)) { + + usort($resinMaterials, function ($a, $b) use ($customisedMaterialCodes) { + + $indexA = array_search($a['MaterialCode'], $customisedMaterialCodes); + $indexB = array_search($b['MaterialCode'], $customisedMaterialCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } + + $resinMaterialCount = count($resinMaterials); $data['resinMaterialCount'] = $resinMaterialCount; @@ -2381,9 +2562,17 @@ class StockController extends BaseController ->where('stock_category','packing_material') ->findAll(); + $filterUpdateNeeded = true ; + + if( empty($customisedMaterialCodes) && !empty($existingCustomMaterialCodes)){ + $customisedMaterialCodes = array_column($existingCustomMaterialCodes, 'materialCode') ; + $filterUpdateNeeded = false ; + } + + //check user applies for filter currently - if(!empty($customisedMaterialCodes)){ + if(!empty($customisedMaterialCodes) && $filterUpdateNeeded){ //user applied filter, @@ -2522,6 +2711,34 @@ class StockController extends BaseController $groupedByDate[$date][] = $detail; } + // Sort each date's materials based on the custom order to set table body td + if (!empty($customisedMaterialCodes)) { + + foreach ($groupedByDate as $date => &$materials) { + + usort($materials, function ($a, $b) use ($customisedMaterialCodes) { + + $indexA = array_search($a['materialCode'], $customisedMaterialCodes); + $indexB = array_search($b['materialCode'], $customisedMaterialCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + } + unset($materials); + } + + + // Reset the structure to have indexed arrays without the date keys $data['groupedBagStockDetails'] = array_values($groupedByDate); @@ -2540,6 +2757,31 @@ class StockController extends BaseController ->first()['customer'] ?? ''; } + + // Sort each date's materials based on the custom order to set table header th + if (!empty($customisedMaterialCodes)) { + + usort($bagMaterials, function ($a, $b) use ($customisedMaterialCodes) { + + $indexA = array_search($a['MaterialCode'], $customisedMaterialCodes); + $indexB = array_search($b['MaterialCode'], $customisedMaterialCodes); + + if ($indexA === false && $indexB === false) { + return 0; + } + if ($indexA === false) { + return 1; + } + if ($indexB === false) { + return -1; + } + + return $indexA - $indexB; + }); + + } + + $bagMaterialcount = count($bagMaterials); $data['bagMaterialcount'] = $bagMaterialcount; @@ -2793,7 +3035,7 @@ class StockController extends BaseController $trpAbstract = $this->trpAbstract_model->where('date', $startDate)->findAll(); - // dd( $trpAbstract ); + $groupedTrpAbstract = [] ; diff --git a/app/Models/Dashboard_model.php b/app/Models/Dashboard_model.php index b9580445..82e2cd67 100755 --- a/app/Models/Dashboard_model.php +++ b/app/Models/Dashboard_model.php @@ -2188,12 +2188,20 @@ category = '" . $cat . "' "; function pending_purchase($cname, $prod, $fa, $aa, $m, $frm, $t, $purchaseorder_number) { - $sql = "select po.PONO as po,date_format(po.PODate,'%d-%m-%Y') as pdate,sup.SupplierName as supplier,mm.MaterialName as material,mm.Category as category,pl.Quantity as quantity,pl.ReceivedQuantity as received, (pl.Quantity - pl.ReceivedQuantity) as pending + $sql = "select po.PONO as po, + date_format(po.PODate,'%d-%m-%Y') as pdate, + sup.SupplierName as supplier, + mm.MaterialName as material, + cd.ConfigValue as category, + pl.Quantity as quantity, + pl.ReceivedQuantity as received, + (pl.Quantity - pl.ReceivedQuantity) as pending from t_purchaseorder_lineitem pl join t_purchaseorder_master po on po.PONO = pl.PONO join t_supplierdetailsn sup on sup.SupplierID=po.SupplierID join t_materialmaster mm on mm.MaterialCode=pl.MaterialCode -where po.Status != 'ST030' and po.Status = 'ST026' +join t_configdetails cd on cd.key = mm.Category +where po.Status != 'ST030' and po.Status = 'ST026' "; if ($cname != '') { @@ -2231,7 +2239,7 @@ where po.Status != 'ST030' and po.Status = 'ST026' if($purchaseorder_number != ''){ $sql .= " and po.PONO = '" . $purchaseorder_number . "' "; } - $sql .= "order by po.PONO"; + $sql .= "order by date(po.PODate) desc"; $query = $this->db->query($sql); //echo $sql; return $query->getResult(); diff --git a/app/Models/Driver_model.php b/app/Models/Driver_model.php index 97fecf21..601d28a2 100755 --- a/app/Models/Driver_model.php +++ b/app/Models/Driver_model.php @@ -111,7 +111,7 @@ class Driver_model extends Model ->select('t_loan_master.Loan_ID,Loan_Amount,Loan_Issued_Date,Monthly_Due,Due_Start_Date as DueDate,No_of_Dues,Paid_Due,Remaining_Due,Paid_Amount,t_loan_history.Balance_Amount, t_driver_monthly_pay_inputs.Loan_Recovered') ->join('t_employee_details as driver_details', 'driver_details.EmpID = t_driver_attendance.driver_id', 'left') ->join('t_emp_pay_data','t_emp_pay_data.EmpID=driver_details.EmpID','Left') - ->join('t_loan_master','t_loan_master.EmpID = driver_details.EmpID','Left') + ->join('t_loan_master','t_loan_master.EmpID = driver_details.EmpID and t_loan_master.Remaining_Due != 0','Left') ->join('t_loan_history','t_loan_history.Loan_ID = t_loan_master.Loan_ID','Left') ->join('t_driver_monthly_pay_inputs','t_driver_monthly_pay_inputs.driver_id = driver_details.EmpID','Left') ->where('t_driver_attendance.date BETWEEN "'.$from.'" AND "'.$to.'"') @@ -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/Monthlypay_model.php b/app/Models/Monthlypay_model.php index c2e59ce0..0cb0d3ae 100755 --- a/app/Models/Monthlypay_model.php +++ b/app/Models/Monthlypay_model.php @@ -101,13 +101,13 @@ class Monthlypay_model extends Model //echo $lastdate; //left join t_payroll on t_employee_details.EmpID = t_payroll.EmpID and month(t_payroll.PayOn) = month(?) and year(t_payroll.PayOn) = year(?) - $sql = "select t_emp_pay_data.EmpID,t_emp_pay_data.*,t_employee_details.FirstName,t_employee_details.DateofJoining,t_employee_details.Designation,t_employee_details.esi_applicable,t_employee_details.pf_applicable,t_employee_details.is_management_team,t_attendance.Days_Worked as Days_worked,t_attendance.Absent as LOP_Days,t_attendance.Paid_Leave as Paid_leave,t_attendance.Total_OTHrs as OT_Hrs_Worked,t_attendance.NoofDays,t_attendance.sunday_count,t_loan_master.Loan_ID,t_loan_master.Monthly_Due,t_loan_master.Due_Start_Date as DueDate,t_loan_master.Loan_Amount,t_loan_master.Paid_Amount,t_payroll.Id,t_monthly_pay_inputs.Loan_Recovered,t_monthly_pay_inputs.Estimate,t_monthly_pay_inputs.Festival_Bonus,t_monthly_pay_inputs.Other_Deductions,t_loan_history .Balance_Amount,t_employee_details.is_driver + $sql = "select t_emp_pay_data.EmpID,t_emp_pay_data.*,t_employee_details.FirstName,t_employee_details.DateofJoining,t_employee_details.Designation,t_employee_details.esi_applicable,t_employee_details.pf_applicable,t_employee_details.is_management_team,t_attendance.Days_Worked as Days_worked,t_attendance.Absent as LOP_Days,t_attendance.Paid_Leave as Paid_leave,t_attendance.Total_OTHrs as OT_Hrs_Worked,t_attendance.NoofDays,t_attendance.sunday_count,t_loan_master.Loan_ID,t_loan_master.Monthly_Due,t_loan_master.Due_Start_Date as DueDate,t_loan_master.Loan_Amount,t_loan_master.Paid_Amount,t_payroll.Id,t_monthly_pay_inputs.Loan_Recovered,t_monthly_pay_inputs.Estimate,t_monthly_pay_inputs.Festival_Bonus,t_monthly_pay_inputs.Other_Deductions,t_monthly_pay_inputs.is_payslip_generated,t_loan_history .Balance_Amount,t_employee_details.is_driver from t_emp_pay_data left join t_employee_details on t_employee_details.EmpID = t_emp_pay_data.EmpID left join t_payroll on t_employee_details.EmpID = t_payroll.EmpID and t_payroll.PayOn = ? left join t_attendance on t_emp_pay_data.EmpID = t_attendance.EmpID left join t_monthly_pay_inputs on t_monthly_pay_inputs.EmpID = t_emp_pay_data.EmpID and t_monthly_pay_inputs.Month_Year = ? - left join t_loan_master on t_emp_pay_data.EmpID = t_loan_master.EmpID and t_loan_master.is_Active = 1 + left join t_loan_master on t_emp_pay_data.EmpID = t_loan_master.EmpID and t_loan_master.Remaining_Due != 0 left join t_loan_history on t_loan_history .Loan_ID = t_loan_master.Loan_ID where t_employee_details.DateofJoining <= ? and month(t_attendance.Month_Year) = month(?) and year(t_attendance.Month_Year) = year(?) @@ -180,13 +180,13 @@ class Monthlypay_model extends Model $builder = $this->db->table('t_attendance') ->select('t_attendance.*,t_employee_details.FirstName,t_employee_details.LastName') - ->join('t_employee_details', 't_attendance.EmpID=t_employee_details.EmpID') + ->join('t_employee_details', 't_attendance.EmpID=t_employee_details.EmpID' , 'left') // ->where('year(t_employee_details.DateofJoining) <= ',$year_val) // ->where('month(t_employee_details.DateofJoining) <= ',$month_val) ->where('t_employee_details.DateofJoining <= ', $lastdate) - ->where('Month_Year', $current) + ->where('t_attendance.Month_Year', $current) ->where('t_employee_details.is_driver', 0) - // ->where('t_employee_details.IsActive',1) + ->where('t_employee_details.IsActive',1) ->orderBy('t_attendance.EmpID', 'asc'); $query = $builder->get(); diff --git a/app/Models/Payroll_model.php b/app/Models/Payroll_model.php index 48b7e907..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); @@ -521,6 +521,19 @@ class Payroll_model extends Model return $query->getResult(); } + function updatePaySlipGeneration($EmpId, $PayOn) + { + $builder = $this->db->table('t_monthly_pay_inputs'); // Define the table + $builder->where('EmpID', $EmpId) + ->where('Month_Year', $PayOn) + ->set(['is_payslip_generated' => 1]) + ->update(); + + return $this->db->affectedRows(); // Return number of affected rows + } + + + function insertPayroll($data) { $builder = $this->db->table('t_payroll'); diff --git a/app/Views/Report_pending_purchase.php b/app/Views/Report_pending_purchase.php index 901e3a75..bc2f926f 100755 --- a/app/Views/Report_pending_purchase.php +++ b/app/Views/Report_pending_purchase.php @@ -220,11 +220,12 @@ $yqt = 0.00; $yvt = 0.00; - + foreach ($ppurchse as $rel) { $cat = $rel->category; + //dd($rel); ?> @@ -363,140 +364,21 @@ // Bootstrap datepicker // Set up your table $(document).ready(function() { - // $.fn.dataTable.moment('DD-MM-YYYY'); - // table = $('#cc').DataTable({ - // "language": { - // "emptyTable": "
Data Not Found !
" - // }, - // "aaSorting": [ - // [0, "desc"] - // ], - // "pageLength": 10, - // "lengthMenu": [10, 25, 50, 100], - // "autoWidth": false, - // orderCellsTop: true, - // "dom": "<'row'<'col-md-6'l><'col-md-6'Bf>>" + - // "<'row'<'col-md-6'><'col-md-6'>>" + - // "<'row'<'col-md-12't>><'row'<'col-md-4'i><'col-md-8'p>>", - // buttons: [ - - // // { - // // extend: 'excelHtml5', - // // footer: 'true', - // // //messageTop: $('h3').text(), - // // title: $('h3').text(), - // // exportOptions: { - // // columns: ':visible' - // // } - // // }, - - // 'colvis' - // ], - // "footerCallback": function(row, data, start, end, display) { - // var api = this.api(), - // data; - - // // Remove the formatting to get integer data for summation - // var intVal = function(i) { - // return typeof i === 'string' ? - // parseFloat(i.replace(/[^0-9]+/g, "") * 1) : - // typeof i === 'number' ? - // parseFloat(i) : 0; - // }; - - // TotalOrderedQTY = api - // .column(5, { - // search: 'applied' - // }) - // .data() - // .reduce(function(a, b) { - // return intVal(a) + intVal(b); - // }, 0); - - // $(api.column(5).footer()).html(TotalOrderedQTY.toFixed().bold()); - - // TotalRcvdQTY = api - // .column(6, { - // search: 'applied' - // }) - // .data() - // .reduce(function(a, b) { - // return intVal(a) + intVal(b); - // }, 0); - - // $(api.column(6).footer()).html(TotalRcvdQTY.toFixed().bold()); - - // TotalPendingQTY = api - // .column(7, { - // search: 'applied' - // }) - // .data() - // .reduce(function(a, b) { - // return intVal(a) + intVal(b); - // }, 0); - - // $(api.column(7).footer()).html(TotalPendingQTY.toFixed().bold()); - // } - // }); - - // Initialize the DataTable - var table = $('#cc').DataTable({ - dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination - buttons: [ - 'copy', 'csv' // Export buttons - ], - pageLength: 10, // Default rows per page - lengthMenu: [ - [10, 20, 30, 50, -1], - [10, 20, 30, 50, "All"] - ], // Rows per page options - responsive: true, // Responsive table - order: [ - [0, 'desc'] - ], // Default ordering (column index 0, descending) - language: { - paginate: { - next: '', // Next button icon - previous: '' // Previous button icon - } - } - }); - }); - $('#mySelect').on('change', function() { - - table - .column(4) - .search(this.value) - .draw(); - }); - - $(function() { - var dateFormat = 'dd-mm-yyyy'; - - // Initialize min-date (Start Date) - var from = $("#min-date").datepicker({ - format: dateFormat, - autoclose: true, - todayHighlight: true, - clearBtn: true, - orientation: 'bottom' - }).on('changeDate', function(e) { - // When a date is selected in #min-date, update the minDate option for #max-date - // to.datepicker('setStartDate', e.date); - }); - - // Initialize max-date (End Date) - var to = $("#max-date").datepicker({ - format: dateFormat, - // startDate: new Date(), // Start date cannot be in the past - autoclose: true, - todayHighlight: true, - clearBtn: true, - orientation: 'bottom' - }).on('changeDate', function(e) { - // When a date is selected in #max-date, update the endDate option for #min-date - from.datepicker('setStartDate', e.date); + // Initialize the DataTable with only pagination enabled + var table = $('#cc').DataTable({ + paging: true, // Enable pagination + searching: true, // Disable search + ordering: false, // Disable column sorting + info: false, // Disable table information + lengthChange: false, // Disable page length options + pageLength: 10, // Default rows per page + responsive: true, // Keep responsive design + language: { + paginate: { + next: '', // Next button icon + previous: '' // Previous button icon + } + } }); }); - \ No newline at end of file diff --git a/app/Views/monthlypayinputs.php b/app/Views/monthlypayinputs.php index c7e7877f..41702239 100755 --- a/app/Views/monthlypayinputs.php +++ b/app/Views/monthlypayinputs.php @@ -392,8 +392,8 @@ Key)) { echo "contenteditable='true';"; } ?> - Key)) { ?> title="Payslip Calculated" + is_payslip_generated == 0) { echo "contenteditable='true';"; } ?> + is_payslip_generated == 1) { ?> title="Payslip Calculated" style="text-align:right;color:blue;" style="text-align:right;" > @@ -407,10 +407,10 @@ Key)) { + is_payslip_generated == 0) { echo "contenteditable='true';"; } ?> - Key)) { ?> title="Payslip Calculated" + is_payslip_generated == 1) { ?> title="Payslip Calculated" style="text-align:right;color:blue;" style="text-align:right;" > @@ -426,10 +426,10 @@ Key)) { + is_payslip_generated == 0) { echo "contenteditable='true';"; } ?> - Key)) { ?> title="Payslip Calculated" + is_payslip_generated == 1) { ?> title="Payslip Calculated" style="text-align:right;color:blue;" style="text-align:right;" > Festival_Bonus)) { @@ -443,10 +443,10 @@ Key)) { + is_payslip_generated == 1) { echo "contenteditable='false';"; } ?> - Key)) { ?> title="Payslip Calculated" + is_payslip_generated == 1) { ?> title="Payslip Calculated" style="text-align:right;color:blue;" style="text-align:right;" > Estimate)) { echo $record->Estimate; diff --git a/app/Views/payslipgenerate.php b/app/Views/payslipgenerate.php index 09364f18..9e8a618c 100755 --- a/app/Views/payslipgenerate.php +++ b/app/Views/payslipgenerate.php @@ -112,6 +112,7 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr type: "POST", url: ""+result['path'], success: function(result) { + console.log(result); $('form#PayslipGenerator').submit(); $('#loader').hide(); alert("Salary Calculated Successfully..!"); 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 @@