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..!");