From 6b8a1af6c37934d6860c819a3d7c75f4c8143824 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 12 Mar 2025 12:18:48 +0530 Subject: [PATCH 1/3] GWM : loan details --- app/Controllers/Driver.php | 4 +- app/Controllers/Payslip.php | 226 +++++++++++++++++--------------- app/Models/Driver_model.php | 2 +- app/Models/Monthlypay_model.php | 10 +- app/Models/Payroll_model.php | 13 ++ app/Views/monthlypayinputs.php | 16 +-- app/Views/payslipgenerate.php | 1 + 7 files changed, 147 insertions(+), 125 deletions(-) diff --git a/app/Controllers/Driver.php b/app/Controllers/Driver.php index f73d7c7b..c595c3a4 100755 --- a/app/Controllers/Driver.php +++ b/app/Controllers/Driver.php @@ -449,13 +449,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..9e50df14 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 = [ @@ -598,7 +606,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,150 +891,150 @@ class Payslip extends BaseController } - function changeMonth() - { + // function changeMonth() + // { - $current = $this->request->getPost('monthyear'); + // $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']); + // $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) { + // $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 + // $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); + // 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; + // $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_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; - } - } + // $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; - } + // if ($Monthly_Due > $Balance_Amount) { + // $loan = $Balance_Amount; + // } - $PF_Rate = $value->PF_Rate; - $ESI_Rate = $value->ESI_Rate; + // $PF_Rate = $value->PF_Rate; + // $ESI_Rate = $value->ESI_Rate; - $totalDaysWorked = $Days_worked + $Paid_leave; + // $totalDaysWorked = $Days_worked + $Paid_leave; - $dayBasic = $Basic_Pay / $NoofDays; - $dayHra = $HRA_Amount / $NoofDays; - $onehoursSalary = ($dayBasic + $dayHra) / 8; + // $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; - } + // /**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; - } + // //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; + // //$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;} + // 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**/ + // /** pf amount per day**/ - //echo $totalothour;die; - $empSalaryAdd = $currentDayBasic + $currentDayHra + $totSalayOT; - $empSalarySub = $esiAmount + $pfAmount + $loan; - $salaryInCurrentday = $empSalaryAdd - $empSalarySub; + // //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; + // // 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; + // $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); - } + // // 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() diff --git a/app/Models/Driver_model.php b/app/Models/Driver_model.php index 97fecf21..a325bfe8 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.'"') 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..d94f8b7a 100755 --- a/app/Models/Payroll_model.php +++ b/app/Models/Payroll_model.php @@ -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/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..!"); From c8a8e1a329a68c16b24c6583d4b22d20a062c687 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Wed, 12 Mar 2025 14:42:01 +0530 Subject: [PATCH 2/3] GWM : loan details --- app/Controllers/Payslip.php | 998 +++++++++++++++-------------------- app/Models/Driver_model.php | 2 +- app/Models/Payroll_model.php | 2 +- app/Views/sales_invoice.php | 38 +- 4 files changed, 453 insertions(+), 587 deletions(-) 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 @@ @@ -23,7 +23,7 @@
- +
@@ -32,7 +32,6 @@ - @@ -41,29 +40,24 @@ format('d-m-Y'); - $time = $createdat->format('h:i A'); + + if (date('d-m-Y', strtotime($record->Created_date)) == "30-11--0001") { + $cdate = '00-00-0000'; + } else { + $cdate = date('d-m-Y', strtotime($record->Created_date)); + } ?> - - - - - - + + + + diff --git a/app/Views/editCapitalAmendPO.php b/app/Views/editCapitalAmendPO.php index a2a2d2dd..b2f8eabb 100755 --- a/app/Views/editCapitalAmendPO.php +++ b/app/Views/editCapitalAmendPO.php @@ -1,3 +1,58 @@ +SNo + @@ -827,6 +883,18 @@ if (!empty($POItem) && $CapitalRange == '1') { + @@ -856,6 +924,10 @@ if (!empty($POItem) && $CapitalRange == '1') { $row = array("materialCode" => $record->MaterialCode, "ReqNo" => $record->ReqNo); array_push($res_arr_values, $row); ?> + -
-

-
- - - - - +
+
+
+ +
+
+ + + +
+
+
+ + +      + + +
-
-
+
+
+ + + + + + + + +
+

@@ -1622,19 +1718,19 @@ if (!empty($POItem) && $CapitalRange == '1') { -   Draft + onClick="window.location ='amendmentpurchaseorder';"> +   Save as Draft   Submit - + class="bold">Submit
+ +
--> + --> + + Driver Load Details Attendance
- + 'VehicleNo', 'value' => set_value('VehicleNo'), 'id' => 'VehicleNo', 'class' => 'form-control', 'maxlength' => '20', 'autocomplete' => 'off'); echo form_input($data); diff --git a/app/Views/po_pdf.php b/app/Views/po_pdf.php index b2b75fd7..bfdbcbbe 100755 --- a/app/Views/po_pdf.php +++ b/app/Views/po_pdf.php @@ -165,16 +165,22 @@ $purchaseorderDate = (!empty($POItem) && !empty($POItem[0]->PODate)) ? new DateTime($POItem[0]->PODate, new DateTimeZone('Asia/Kolkata')) : ""; $poDate = $purchaseorderDate ? $purchaseorderDate->format('d-m-Y') : "-"; $IsOpenOrder = (!empty($POItem) && !empty($POItem[0]->IsOpenOrder)) ? $POItem[0]->IsOpenOrder : ""; - $DeliveryDate = ""; - $DeliverySchedule = ""; - if (!empty($POItem) && !empty($POItem[0]->DeliveryOption)) { + $DlvSch = ""; + if ($POItem[0]->DeliveryOption == 1) { - $DeliverySchedule = $POItem[0]->DeliverySchedule; - } else if ($POItem[0]->DeliveryOption == 0 && !empty($POItem[0]->DeliveryDate)) { + $DlvSch = $POItem[0]->DeliverySchedule; + } + + if ($POItem[0]->DeliveryOption == 0 && !empty($POItem[0]->DeliveryDate)) { $dtDe = new DateTime($POItem[0]->DeliveryDate, new DateTimeZone('Asia/Kolkata')); - $DeliveryDate = $dtDe ? $dtDe->format('d-m-Y') : ""; + $DlvSch = $dtDe ? $dtDe->format('d-m-Y') : ""; } - } + + if(!empty($dispatch)){ + $DlvSch = $dispatch; // for import means. + } + + $RequistionNo = (!empty($RequistionDetails) && !empty($RequistionDetails[0]['RequistionNo'])) ? $RequistionDetails[0]['RequistionNo'] : "-"; $ReqDate = (!empty($RequistionDetails) && !empty($RequistionDetails[0]['ReqDate'])) ? $RequistionDetails[0]['ReqDate'] : ""; // $RequestedDept = (!empty($RequistionDetails) && !empty($RequistionDetails[0]['RequestedDept'])) ? $RequistionDetails[0]['RequestedDept'] : "-"; @@ -371,7 +377,7 @@
- +
Create Date Driver Name Driver Mobile Create By Status Action
- -     - - - -     - - -     - - - + FirstName; ?>ContactNumber ?>IsActive == 1 ? 'Active' : 'InActive' ?> + is_driver){ ?> +     + +     +
Requisition No Item DescriptionLine Item Specs Quantity UOM RateReqNo ?> MaterialName, 0, 13, "..."); echo $shortName; ?> + + LineitemAuditorNotes) ? $record->LineitemAuditorNotes : "-"; ?> + + + Quantity ?> UOM ?> Rate, 2, '.', ''); ?>