GWM : loan details

This commit is contained in:
Gowtham M 2025-03-12 12:18:48 +05:30
parent dd835f830f
commit 6b8a1af6c3
7 changed files with 147 additions and 125 deletions

View File

@ -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
];

View File

@ -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 .'</br>';
// echo $pfAmount .'</br>';
// echo $loan .'</br>';
// echo $empSalarySub .'</br>';
// echo $empSalaryAdd .'</br>';
// echo $salaryInCurrentday .'</br>';
// die;
// // echo $esiAmount .'</br>';
// // echo $pfAmount .'</br>';
// // echo $loan .'</br>';
// // echo $empSalarySub .'</br>';
// // echo $empSalaryAdd .'</br>';
// // echo $salaryInCurrentday .'</br>';
// // 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()

View File

@ -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.'"')

View File

@ -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();

View File

@ -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');

View File

@ -392,8 +392,8 @@
<td style="max-width:80px;text-align:right;"> <?php echo $over_time[$i]; ?> </td>
<td id="monthDue<?php echo $index ?>" onkeypress="return isNumber(event);" onkeyup="changeInput(event);"
<?php if (empty($record->Key)) { echo "contenteditable='true';"; } ?>
<?php if (!empty($record->Key)) { ?> title="Payslip Calculated"
<?php if ($record->is_payslip_generated == 0) { echo "contenteditable='true';"; } ?>
<?php if ($record->is_payslip_generated == 1) { ?> title="Payslip Calculated"
style="text-align:right;color:blue;"
<?php } else { ?>style="text-align:right;" <?php } ?>>
@ -407,10 +407,10 @@
<td id="otherDet<?php echo $index ?>" onkeypress="return isNumber(event);" onkeyup="changeInput(event);"
<?php if (empty($record->Key)) {
<?php if ($record->is_payslip_generated == 0) {
echo "contenteditable='true';";
} ?>
<?php if (!empty($record->Key)) { ?> title="Payslip Calculated"
<?php if ($record->is_payslip_generated == 1) { ?> title="Payslip Calculated"
style="text-align:right;color:blue;"
<?php } else { ?>style="text-align:right;" <?php } ?>>
@ -426,10 +426,10 @@
<td id="Festival<?php echo $index ?>" onkeypress="return isNumber(event);"
onkeyup="changeInput(event);"
<?php if (empty($record->Key)) {
<?php if ($record->is_payslip_generated == 0) {
echo "contenteditable='true';";
} ?>
<?php if (!empty($record->Key)) { ?> title="Payslip Calculated"
<?php if ($record->is_payslip_generated == 1) { ?> title="Payslip Calculated"
style="text-align:right;color:blue;"
<?php } else { ?>style="text-align:right;" <?php } ?>>
<?php if (!empty($record->Festival_Bonus)) {
@ -443,10 +443,10 @@
<?php $totalfestival[] = isset($Festival_Bonus) ? $Festival_Bonus : []; ?>
<td id="empsal<?php echo $index ?>"
<?php if (empty($record->Key)) {
<?php if ($record->is_payslip_generated == 1) {
echo "contenteditable='false';";
} ?>
<?php if (!empty($record->Key)) { ?> title="Payslip Calculated"
<?php if ($record->is_payslip_generated == 1) { ?> title="Payslip Calculated"
style="text-align:right;color:blue;" <?php }else{ ?>style="text-align:right;" <?php } ?>>
<?php if (!empty($record->Estimate)) {
echo $record->Estimate;

View File

@ -112,6 +112,7 @@ $monthsoptions = array("01" => "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr
type: "POST",
url: "<?php echo base_url(); ?>"+result['path'],
success: function(result) {
console.log(result);
$('form#PayslipGenerator').submit();
$('#loader').hide();
alert("Salary Calculated Successfully..!");