payslipmanual loan due and estimate total

This commit is contained in:
venbatechnologies@gmail.com 2018-09-21 14:06:02 +05:30
parent eabe4c020c
commit 7591af6f5c
4 changed files with 946 additions and 64 deletions

View File

@ -467,19 +467,166 @@ class payslip extends BaseController
public function monthlyInputs()
{
$current = date("m-Y");
$data['month'] = $this-> monthlypay_model->monthlyListing($current);
$data['fresh'] = $this-> monthlypay_model->getEmpPayDetailsforMonthInputs($current);
$data['dropdownvalue'] = $current;
$data['month'] = $this->monthlypay_model->monthlyListing($current);
$data['dropdownvalue'] = $current;
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
$employeeSalary = [];
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;
$Food_Allowances= $value->Food_Allowances;
$Days_worked = $value->Days_worked; // working day
$LOP_Days = $value->LOP_Days; // not working day
$Paid_leave = $value->Paid_leave; // leave day
$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
$MasterIncentives=$value->MasterIncentives;//Master values get
// echo 'master'.$MasterIncentives;
$due_start_date = $value->DueDate;
$paydate = $current;//From POST parm
$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)
{
// current= Balance_Amount - autoLoan;
//alert('hi');
$loan = $Balance_Amount;
}
$Allowances =$value->Allowances;
$HRA_Rate=$value->HRA_Rate;
$PF_Rate=$value->PF_Rate;
$ESI_Rate=$value->ESI_Rate;
$MonthIncentive = $value->MonthlyIncentives;//T_Monthly_Pay_Inputs,for change month
$Incentive = 0;
if(empty($MonthIncentive))
{
$Incentive = $MasterIncentives;
}
else
{
$Incentive = $MonthIncentive;
}
// echo $Incentive;
$daySalarys = $Days_worked + $Paid_leave;
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
//$Allowances = $allowances * $values;
$dayFood_Allowance = $Food_Allowances * $Days_worked;
$daySalary = $Basic_Pay / $NoofDays;
/**per day salary working hour**/
//echo $daySalary.'<br/>';
$dayHra = $HRA_Amount / $NoofDays;
/** per day hra amount **/
//echo $dayHra.'<br/>';
$onehoursSalary = ($daySalary + $dayHra) / 8;
/**one hour salay ot calculation**/
if ($OT_Hrs_Worked != 0)
{
$totSalayOT = $OT_Hrs_Worked * $onehoursSalary;
}
else
{
$totSalayOT = 0;
}
$currentDaySalary = $daySalary * $daySalarys;
/** current day salary working days calculation**/
$currentDayHra = $dayHra * $daySalarys;
/** total working days hra calculations**/
// echo $currentDayHra.'<br/>';
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
if ($TotalSalary <= 20000)
{
$esiAmount = $currentDatePF * $ESI_Rate/ 100;
/** esiamount not elgiable for 20000 **/
}
else
{
$esiAmount = 0;
}
$pfAmount = $currentDaySalary * $PF_Rate/ 100;
/** pf amount per day**/
//echo $totalothour;die;
$empSalaryAdd = $currentDaySalary + $totSalayOT + $currentDayHra + $dayFood_Allowance + $Allowances + $Incentive;
$empSalarySub = $esiAmount + $pfAmount + $loan;
$salaryInCurrentday= $empSalaryAdd - $empSalarySub;
$employeeSalary []= round($salaryInCurrentday);
}
$data['empSalary'] = $employeeSalary;
//$this->global['pageTitle'] = 'Resico : Payroll Monthly Inputs';
$this->global['pageTitle'] = $this->CompanyName.' : Monthly Payroll Details';
$this->loadViews("monthlypayinputs", $this->global,$data,NULL);
}
/**
* To Change the Month in payslip dropdown
*/
}
function changeMonth()
{
@ -489,15 +636,179 @@ class payslip extends BaseController
// $data = json_encode(array_merge($month,$fresh));
// echo $data;
$current = $this->input->post('monthyear');
$data['month'] = $this-> monthlypay_model->monthlyListing($current);
$data['fresh'] = $this-> monthlypay_model->getEmpPayDetailsforMonthInputs($current);
$data['month'] = $this->monthlypay_model->monthlyListing($current);
$data['dropdownvalue'] = $current;
$data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current);
$employeeSalary = [];
foreach($data['fresh'] as $value){
//print_r($value);
//die();
$NoofDays=$value->NoofDays;//Month day 30,31,28
$HRA_Amount = $value->HRA_Amount;
$Basic_Pay = $value->Basic_Pay;
$TotalSalary = $value->TotalSalary;
$Food_Allowances= $value->Food_Allowances;
$Days_worked = $value->Days_worked; // working day
$LOP_Days = $value->LOP_Days; // not working day
$Paid_leave = $value->Paid_leave; // leave day
$OT_Hrs_Worked = $value->OT_Hrs_Worked; //OT hours
$Monthly_Due = $value->Monthly_Due;// AUTO LOAN DUE
$due_start_date = $value->DueDate;
$paydate = $current;//From POST parm
if(strlen($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_Recovered = $value->Loan_Recovered; //MANUAL LOAN DUE
$MasterIncentives=$value->MasterIncentives;//Master values get
// echo 'master'.$MasterIncentives;
$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)
{
// current= Balance_Amount - autoLoan;
//alert('hi');
$loan = $Balance_Amount;
}
$Allowances =$value->Allowances;
$HRA_Rate=$value->HRA_Rate;
$PF_Rate=$value->PF_Rate;
$ESI_Rate=$value->ESI_Rate;
$MonthIncentive = $value->MonthlyIncentives;//T_Monthly_Pay_Inputs,for change month
$Incentive = 0;
if(empty($MonthIncentive))
{
$Incentive = $MasterIncentives;
}
else
{
$Incentive = $MonthIncentive;
}
// echo $Incentive;
$daySalarys = $Days_worked + $Paid_leave;
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
//$Allowances = $allowances * $values;
$dayFood_Allowance = $Food_Allowances * $Days_worked;
$daySalary = $Basic_Pay / $NoofDays;
/**per day salary working hour**/
//echo $daySalary.'<br/>';
$dayHra = $HRA_Amount / $NoofDays;
/** per day hra amount **/
//echo $dayHra.'<br/>';
$onehoursSalary = ($daySalary + $dayHra) / 8;
/**one hour salay ot calculation**/
if ($OT_Hrs_Worked != 0)
{
$totSalayOT = $OT_Hrs_Worked * $onehoursSalary;
}
else
{
$totSalayOT = 0;
}
$currentDaySalary = $daySalary * $daySalarys;
/** current day salary working days calculation**/
$currentDayHra = $dayHra * $daySalarys;
/** total working days hra calculations**/
// echo $currentDayHra.'<br/>';
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
/** current date pf calculation**/
if ($TotalSalary <= 20000)
{
$esiAmount = $currentDatePF * $ESI_Rate/ 100;
/** esiamount not elgiable for 20000 **/
}
else
{
$esiAmount = 0;
}
$pfAmount = $currentDaySalary * $PF_Rate/ 100;
/** pf amount per day**/
//echo $totalothour;die;
$empSalaryAdd = $currentDaySalary + $totSalayOT + $currentDayHra + $dayFood_Allowance + $Allowances + $Incentive;
$empSalarySub = $esiAmount + $pfAmount + $loan;
$salaryInCurrentday= $empSalaryAdd - $empSalarySub;
$employeeSalary []= round($salaryInCurrentday);
}
$data['empSalary'] = $employeeSalary;
//$this->global['pageTitle'] = 'Resico : Payroll Monthly Inputs';
$this->global['pageTitle'] = $this->CompanyName.' : Monthly Payroll Inputs';
$this->loadViews("monthlypayinputs", $this->global,$data,NULL);
}
}
/**
* To Store the Month in payslip datas
@ -533,20 +844,26 @@ class payslip extends BaseController
$total = 0;
$ErrorEmpId = '';
$TotalErrorFlag = 0;
foreach($json as $j)
$i = sizeof($json);
$len = $i-2;
foreach($json as $index=>$j)
{
$ErrorFlag = 0;
if($index<=$len){
$ErrorFlag = 0;
$Emp = $j['Employee'];
$EmpID = substr($Emp,0,4);
$EmpID = $j['Employee Id'];
$Name = $j['Employee Name'];
$DaysWorked = $j['Days Worked'];
$LOP_Days = $j['LOP Days'];
$Paid_leave = $j['Paid Leave'];
$OT_Hrs_Worked = $j['OT Hours Worked in Hrs'];
$Loan_Recovered = $j['Loan Recovered in ₹'];
$OT_Hrs_Worked = $j['OT Hrs'];
$Loan_Recovered = $j['Manual Loan Due ₹'];
$Incentives = $j['Incentives in ₹'];
$Festival_Bonus = $j['Festival Bonus in ₹'];
$Other_Deductions = $j['Other Deductions in ₹'];
$Estimate =$j['Estimate in ₹'];
$Created_By = $this->session->userdata ( 'userId' );
if(!is_numeric($DaysWorked) || ($DaysWorked > 31) || (strlen((string)$DaysWorked)) > 5 )
@ -607,6 +924,12 @@ class payslip extends BaseController
$ErrorFlag++;
}
$Estimate_first = explode(".",$Estimate);
if(!is_numeric($Estimate) || (strlen((string)$Estimate))>8 || (strlen((string)$Estimate_first[0]))> 5)
{
//echo $EmpID . "-Loan Recoverd Invalid Data!";
$ErrorFlag++;
}
if($ErrorFlag != 0)
{
$ErrorEmpId = $ErrorEmpId ."|". $EmpID;
@ -617,18 +940,24 @@ class payslip extends BaseController
//nothing
}
}
}
if($TotalErrorFlag == 0)
{
foreach($json as $j)
foreach($json as $index=>$j)
{
$EmpID = $j['Employee Id'];
$Name = $j['Employee Name'];
// $EmpID = $j['Employee Id'];
// $Name = $j['Employee Name'];
$Emp = $j['Employee'];
$EmpID = substr($Emp,0,4);
$DaysWorked = $j['Days Worked'];
$LOP_Days = $j['LOP Days'];
$LOP_Days = $j['LOP Days'];
$Paid_leave = $j['Paid Leave'];
$OT_Hrs_Worked = $j['OT Hours Worked in Hrs'];
$Loan_Recovered = $j['Loan Recovered in ₹'];
$OT_Hrs_Worked = $j['OT Hrs'];
$Loan_Recovered = $j['Manual Loan Due ₹'];
if(is_string($Loan_Recovered))
{
$Loan_Recovered = strtoupper($Loan_Recovered);
@ -636,14 +965,15 @@ class payslip extends BaseController
$Incentives = $j['Incentives in ₹'];
$Festival_Bonus = $j['Festival Bonus in ₹'];
$Other_Deductions = $j['Other Deductions in ₹'];
$Estimate =$j['Estimate in ₹'];
$Created_By = $this->session->userdata ( 'userId' );
$monthlypaydata = array('Month_Year'=>$month,'EmpID'=>$EmpID,'Days_worked'=>$DaysWorked,'LOP_Days'=>$LOP_Days,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Festival_Bonus'=>$Festival_Bonus,'Other_Deductions'=>$Other_Deductions,'Created_By'=>$Created_By);
$monthlypaydata = array('Month_Year'=>$month,'EmpID'=>$EmpID,'Days_worked'=>$DaysWorked,'LOP_Days'=>$LOP_Days,'Paid_leave'=>$Paid_leave,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Festival_Bonus'=>$Festival_Bonus,'Other_Deductions'=>$Other_Deductions,'Estimate'=>$Estimate,'Created_By'=>$Created_By);
$result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata);
$total = $total + $result;
}
}
$total = $total -1;
if(!empty($ErrorEmpId))
{
echo $ErrorEmpId . "- are have Invalid Data!";
@ -668,6 +998,7 @@ class payslip extends BaseController
function reload_paysliplist()
{
$pre_monthyear = $this->input->post('month');
//$this->global['pageTitle'] = 'Resico : Payslip Listing';
@ -1012,7 +1343,7 @@ class payslip extends BaseController
$LOPDays = $sheet->getCell('D'.$x)->getValue();
$Paid_leave =$sheet->getCell('E'.$x)->getValue();
$OTHoursWorked =$sheet->getCell('F'.$x)->getValue();
$loanRecovered=$sheet->getCell('G'.$x)->getValue();
$LoanRecovered=$sheet->getCell('G'.$x)->getValue();
if(is_string($loanRecovered))
{
$loanRecovered = strtoupper($loanRecovered);

View File

@ -51,7 +51,7 @@ class batchcard_model extends CI_Model
$this->db->select('MaterialCode,MaterialName,');
$this->db->from('T_MaterialMaster');
$this->db->where('T_MaterialMaster.Category',Consumables);
$this->db->where('T_MaterialMaster.Category like','%Consumables%');
$supp = $this->db->get();
return $supp->result();
@ -64,7 +64,7 @@ class batchcard_model extends CI_Model
{
$this->db->select('MaterialCode,MaterialName,');
$this->db->from('T_MaterialMaster');
$this->db->where('T_MaterialMaster.Category',RawMaterial);
$this->db->where('T_MaterialMaster.Category like','%Raw Material%');
$supp = $this->db->get();
return $supp->result();
}
@ -76,7 +76,7 @@ class batchcard_model extends CI_Model
{
$this->db->select('MaterialCode,MaterialName,');
$this->db->from('T_MaterialMaster');
$this->db->where('T_MaterialMaster.Category',Packingmaterial);
$this->db->where('T_MaterialMaster.Category like','%Packing%');
$supp = $this->db->get();
return $supp->result();
}

View File

@ -10,13 +10,18 @@ class monthlypay_model extends CI_Model
*/
function monthlyListing($current="")
{
$month = $current;
if(strlen($month) == 6)
{
$month = '0'.$month;
}
$curr_split = explode('-',$current);
$month_val = $curr_split[0];
$year_val = $curr_split[1];
$date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val);
$lastdate = $year_val.'-'.$month_val.'-'.$date_val;
$sql="select T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Loan_Master.Loan_ID,T_Payroll.Key
$sql="select T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Loan_Master.Loan_ID,T_Loan_Master.Monthly_Due,T_Payroll.Key
from T_Monthly_Pay_Inputs
left join T_Employee_Details on T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID and T_Employee_Details.DateofJoining <= ?
left join T_Payroll on T_Monthly_Pay_Inputs.EmpID=T_Payroll.EmpID
@ -63,7 +68,11 @@ class monthlypay_model extends CI_Model
*/
function getEmpPayDetailsforMonthInputs($current="")
{
$month = $current;
if(strlen($month) == 6)
{
$month = '0'.$month;
}
$current = '01-'.$current;
$current = date_create($current);
$current = date_format($current,'Y-m-d');
@ -73,16 +82,20 @@ class monthlypay_model extends CI_Model
$date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val);
$lastdate = $year_val.'-'.$month_val.'-'.$date_val;
$sql = "select T_Emp_Pay_Data.EmpID,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining,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_Loan_Master.Loan_ID,T_Payroll.Key from T_Emp_Pay_Data
$sql ="select T_Emp_Pay_Data.EmpID, T_Emp_Pay_Data.Incentives as MasterIncentives,T_Emp_Pay_Data.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Employee_Details.DateofJoining,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_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.Key,T_Monthly_Pay_Inputs.Incentives as MonthlyIncentives,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
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 month(T_Payroll.PayOn) = month(?) and year(T_Payroll.PayOn) = year(?)
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_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(?)
order by T_Employee_Details.EmpID";
$query = $this->db->query($sql,array($current,$current,$lastdate,$current,$current));
$query = $this->db->query($sql,array($month,$month,$lastdate,$current,$current));
return $query->result();
}
@ -180,7 +193,7 @@ class monthlypay_model extends CI_Model
$this->db->join('T_Employee_Details','T_Attendance.EmpID=T_Employee_Details.EmpID');
$this->db->where('T_Employee_Details.DateofJoining <= ',$lastdate);
$this->db->where('Month_Year',$current);
$this->db->where('T_Employee_Details.IsActive',1);
// $this->db->where('T_Employee_Details.IsActive',1);
$this->db->order_by('T_Attendance.EmpID', 'asc');
$query = $this->db->get();

View File

@ -1,5 +1,19 @@
<?php
$sample = array_merge($month,$fresh);
$show_hide_column_value = true;
//print_r($sample);die();
foreach($sample as $s)
{
if(!empty($s->Key))
{
$show_hide_column_value = false;
}
else
{
$show_hide_column_value = true;
}
break;
}
$ex = explode('-',$dropdownvalue);
if(strlen($ex[0])== '2')
{
@ -24,7 +38,7 @@
</script>
<script>
@ -54,7 +68,7 @@ $('html').bind('keypress', function(e)
</section>
<section class="content">
<input type="hidden" id="paydate" value="<?php echo $drop;?>"/>
<div class="row">
<div class="col-xs-12">
<div class="box">
@ -150,18 +164,21 @@ $('html').bind('keypress', function(e)
<tr>
<th>S.No</th>
<th>Employee Id</th>
<th>Employee Name</th>
<th>Employee </th>
<!-- <th>Employee Name</th> -->
<th>Days Worked</th>
<th>LOP Days</th>
<th>Paid Leave</th>
<th>OT Hours Worked in Hrs</th>
<th>Loan Recovered in </th>
<th>OT Hrs</th>
<th>Auto Loan Due </th>
<th>Manual Loan Due </th>
<th>Incentives in </th>
<th>Other Deductions in </th>
<th>Festival Bonus in </th>
<th>Estimate in </th>
</tr>
</thead>
<tbody>
@ -176,8 +193,9 @@ $('html').bind('keypress', function(e)
if(!empty($sample))
{
foreach($sample as $record)
$index = 0;
$i = 0;
foreach($sample as $i=> $record)
{
$index++;
@ -197,19 +215,91 @@ $('html').bind('keypress', function(e)
?>
<tr>
<tr class="lastvalue">
<td style="text-align:right;" style="background-color:blue;"><?php echo $index; ?></td>
<td style="text-align:right;"><?php echo $record->EmpID ?></td>
<td><?php echo $record->FirstName ." ". $record->LastName ?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Days_worked)){echo $record->Days_worked;}else{echo "0.00";}?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->LOP_Days)){echo $record->LOP_Days;}else{echo "0.00";}?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Paid_leave)){echo number_format($record->Paid_leave,2,'.','');}else { echo number_format(0.00,2,'.','');} ?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->OT_Hrs_Worked)){echo $record->OT_Hrs_Worked;}else { echo number_format(0.00,2,'.','');} ?></td>
<td <?php if(empty($record->Key) && !empty($record->Loan_ID)){ echo "contenteditable='true'; style='background-color:#ffcccc;text-align:right' title='Loan Pending'"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Loan_Recovered)){if(is_numeric($record->Loan_Recovered)){echo number_format($record->Loan_Recovered,2,'.','');}else {echo $record->Loan_Recovered;}}else{echo number_format(0.00,2,'.','');} ?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='true';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Incentives)){echo $record->Incentives;}else{ echo number_format(0.00,2,'.','');;} ?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='true';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Other_Deductions)){echo $record->Other_Deductions; }else{ echo number_format(0.00,2,'.','');;} ?></td>
<td <?php if(empty($record->Key)){echo "contenteditable='true';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Festival_Bonus)){echo $record->Festival_Bonus; }else{ echo number_format(0.00,2,'.','');;} ?></td>
<td style="max-width:80px"><?php echo $record->EmpID ."-".$record->FirstName ."". $record->LastName ?></td>
<td id="dayWork<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Days_worked)){echo $record->Days_worked;}else{echo "0.00";}?></td>
<td id="lopDay<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->LOP_Days)){echo $record->LOP_Days;}else{echo "0.00";}?></td>
<td id="paidLeave<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Paid_leave)){echo number_format($record->Paid_leave,2,'.','');}else { echo number_format(0.00,2,'.','');} ?></td>
<td id="otHrsWork<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->OT_Hrs_Worked)){echo $record->OT_Hrs_Worked;}else { echo number_format(0.00,2,'.','');} ?></td>
<td id="monthDue<?php echo $index?>" <?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Monthly_Due)){echo $record->Monthly_Due; $totalmonthloan []=$record->Monthly_Due;}else { echo number_format(0.00,2,'.','');} ?></td>
<td id="loanRecd<?php echo $index?>" onkeypress="return isCheckKeyCode(event);" onkeyup="changeInput(event);"<?php if(empty($record->Key) && !empty($record->Loan_ID)){ echo "contenteditable='true'; style='background-color:#ffcccc;text-align:right' title='Loan Pending'"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> >
<?php if(!empty($record->Loan_Recovered))
{if(is_numeric($record->Loan_Recovered)){echo number_format($record->Loan_Recovered,2,'.',''); $totalmanualoan[] = $record->Loan_Recovered;}else {echo $record->Loan_Recovered; $totalmanualoan[] = $record->Loan_Recovered;}}else{echo number_format(0.00,2,'.','');} ?>
</td>
<td id="incentie<?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" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> >
<!-- <?php if(!empty($record->MasterIncentives)){echo $record->MasterIncentives;}else {echo $record->MonthlyIncentives;} ?> -->
<?php if(!empty($record->MonthlyIncentives)){echo $record->MonthlyIncentives; $totalinst [] = $record->MonthlyIncentives;}else {echo $record->MasterIncentives; $totalinst [] = $record->MasterIncentives;}
?>
</td>
<?php ?>
<!-- else{ echo number_format(0.00,2,'.','');;} -->
<td id ="otherDet<?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" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Other_Deductions)){echo $record->Other_Deductions;$totalotherDet [] = $record->Other_Deductions;}else{ echo number_format(0.00,2,'.','');} ?></td>
<?php $totalotherDet [] = $Other_Deductions;?>
<td id="Festival<?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" style="text-align:right;color:blue;"<?php } else{?>style="text-align:right;"<?php }?> ><?php if(!empty($record->Festival_Bonus)){echo $record->Festival_Bonus;$totalfestival [] = $record->Festival_Bonus;}else{ echo number_format(0.00,2,'.','');;} ?></td>
<?php $totalfestival [] = $Festival_Bonus;?>
<td id="empsal<?php echo $index?>"<?php if(empty($record->Key)){echo "contenteditable='false';"; } ?> <?php if(!empty($record->Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"<?php }?>> <?php if(!empty($record->Estimate)){echo $record->Estimate; $estTotal [] = $record->Estimate; }else { echo $empSalary[$i]; $estTotal [] = $empSalary[$i];
}?></td>
<!-- <input type="hidden" id = "eid" value="<?php echo $record->EmpID?>">
<input type="hidden" id = "inv" value="<?php echo $record->Incentives?>">
<input type="hidden" id = "pdi" value="<?php echo $record->Pay_Data_ID?>"> -->
<input type="hidden" id = "bPay<?php echo $index?>" value="<?php echo $record->Basic_Pay?>">
<input type="hidden" id = "hraRate<?php echo $index?>" value="<?php echo $record->HRA_Rate?>">
<input type="hidden" id = "allow<?php echo $index?>" value="<?php echo $record->Allowances?>">
<input type="hidden" id = "fAllow<?php echo $index?>" value="<?php echo $record->Food_Allowances?>">
<input type="hidden" id = "pfRate<?php echo $index?>" value="<?php echo $record->PF_Rate?>">
<input type="hidden" id = "eslRate<?php echo $index?>" value="<?php echo $record->ESI_Rate?>">
<input type="hidden" id = "hraAmt<?php echo $index?>" value="<?php echo $record->HRA_Amount?>">
<input type="hidden" id = "loanamt<?php echo $index?>" value="<?php echo $record->Loan_amount?>">
<input type="hidden" id = "paidamt<?php echo $index?>" value="<?php echo $record->Paid_Amount?>">
<input type="hidden" id = "duedate<?php echo $index?>" value="<?php echo $record->DueDate?>">
<!-- <input type="hidden" id = "eid" value="<?php echo $record->TotalSalary?>">
<input type="hidden" id = "eid" value="<?php echo $record->LOP_Days?>">
<input type="hidden" id = "eid" value="<?php echo $record->Paid_leave?>">
<input type="hidden" id = "eid" value="<?php echo $record->OT_Hrs_Worked?>">
<input type="hidden" id = "eid" value="<?php echo $record->NoofDays?>">
<input type="hidden" id = "eid" value="<?php echo $record->Monthly_Due?>"> -->
</tr>
<?php
@ -221,6 +311,20 @@ $('html').bind('keypress', function(e)
?>
</tbody>
<tfoot><tr>
<th colspan="5"></th>
<th>Total</th>
<th id="manualoan"><?php echo array_sum($totalmonthloan);?></th>
<th id="monthloan"><?php echo array_sum($totalmanualoan);?></th>
<th id="inst"><?php echo array_sum($totalinst);?></th>
<th id="other"><?php echo array_sum($totalotherDet);?></th>
<th id="fest"><?php echo array_sum($totalfestival);?></th>
<th id="estsal"><?php echo array_sum($estTotal);?></th>
</tr>
</tfoot>
</table>
<p>&nbsp;</p>
<div class="row">
@ -239,7 +343,47 @@ $('html').bind('keypress', function(e)
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/common.js" charset="utf-8"></script>
<script type="text/javascript">
var estTotal = [];
var totalinst = [];
var totalotherDet =[];
var totalmonthloan =[];
var totalmanualoan =[];
$(function () {
var i = 0;
$('tr.lastvalue').each(function(){
i = i+1;
estTotal [i]=$(this).find('td').eq(11).text();
});
var i = 0;
$('tr.lastvalue').each(function(){
i = i+1;
totalinst [i]=$(this).find('td').eq(8).text();
});
var i = 0;
$('tr.lastvalue').each(function(){
i = i+1;
totalotherDet [i]=$(this).find('td').eq(9).text();
});
var i = 0;
$('tr.lastvalue').each(function(){
i = i+1;
totalmanualoan [i]=$(this).find('td').eq(6).text();
});
//console.log(totalmanualoan);
var i = 0;
$('tr.lastvalue').each(function(){
i = i+1;
totalmonthloan[i]=$(this).find('td').eq(7).text();
});
/* $('#monthlylisting').DataTable({
@ -279,7 +423,25 @@ $('html').bind('keypress', function(e)
savebuttonvalidation();
});
function isNumber(evt) {
//alert("hi");
var iKeyCode = (evt.which) ? evt.which : evt.keyCode
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57))
{ return false;}
return true;
}
function isCheckKeyCode(event){
var iKeyCode = (event.which) ? event.which : event.keyCode
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57 ) && (iKeyCode ==78 && iKeyCode == 65))
{ return false;}
return true;
}
function getAllData()
@ -345,12 +507,14 @@ $('html').bind('keypress', function(e)
{
if(year == 1)
{
$("#savebutton").hide();
//$("#savebutton").hide();
$("#savebutton").show();
}
else
{
$("#savebutton").hide();
}
//$("#savebutton").hide();
$("#savebutton").show();
}
}
else if(savebuttonstatus < 0 )
{
@ -361,16 +525,19 @@ $('html').bind('keypress', function(e)
}
else if(year == 0)
{
$("#savebutton").hide();
//$("#savebutton").hide();
$("#savebutton").show();
}
else
{
$("#savebutton").hide();
//$("#savebutton").hide();
$("#savebutton").show();
}
}
else if(savebuttonstatus == 0 && year == 0)
{
$("#savebutton").hide();
//$("#savebutton").hide();
$("#savebutton").show();
}
else if(savebuttonstatus == 1)
{
@ -386,4 +553,375 @@ $('html').bind('keypress', function(e)
}
var totalfestival =[];
var totalempSal=[];
var grandtotal = [];
function changeInput(event,k)
{
var str=event.target.id;
var sno = str.substr(8);
var dayWorks=parseFloat(document.getElementById('dayWork'+sno).textContent);
var lopDay=parseFloat(document.getElementById('lopDay'+sno).textContent);
var paidLeave =parseFloat(document.getElementById('paidLeave'+sno).textContent);
var otHrsWork =parseFloat(document.getElementById('otHrsWork'+sno).textContent);
var monthDue =parseFloat(document.getElementById('monthDue'+sno).textContent);
var duedate = document.getElementById('duedate'+sno).value;
duedate = new Date(duedate);
var paydate = document.getElementById('paydate').value;
if(paydate.length == 6)
{
paydate = '0'+paydate;
}
var pmonthonly = paydate.substring(0,2);
var pyearonly = paydate.substring(3);
var pday = new Date(pyearonly, pmonthonly, 0).getDate();
var finalpaydate = pyearonly+'-'+pmonthonly+'-'+pday;
finalpaydate = new Date(finalpaydate);
var loanRecd=document.getElementById('loanRecd'+sno).textContent;
//totalmanualoan[sno]=loanRecd;
var incentie=parseFloat(document.getElementById('incentie'+sno).textContent);
var otherDet =parseFloat(document.getElementById('otherDet'+sno).textContent);
//totalotherDet[sno] = otherDet;
var Festival =parseFloat(document.getElementById('Festival'+sno).textContent);
totalfestival[sno]= Festival ;
var empsal =parseFloat(document.getElementById('empsal'+sno).textContent);
var bpay =parseFloat(document.getElementById('bPay'+sno).value);
var hraRate=parseFloat(document.getElementById('hraRate'+sno).value);
var allow=parseFloat(document.getElementById('allow'+sno).value);
var fAllow =parseFloat(document.getElementById('fAllow'+sno).value);
var pfRate =parseFloat(document.getElementById('pfRate'+sno).value);
var eslRate =parseFloat(document.getElementById('eslRate'+sno).value);
var hraAmt =parseFloat(document.getElementById('hraAmt'+sno).value);
// var Balance_Amount =parseFloat(document.getElementById('Balance'+sno).value);
var loanamt =parseFloat(document.getElementById('loanamt'+sno).value);
var paidamt =parseFloat(document.getElementById('paidamt'+sno).value);
var dayWorkPaid=dayWorks+paidLeave;
// console.log("day"+dayWorkPaid);
var NoofDays=dayWorks+paidLeave +lopDay;
// console.log("monthday"+NoofDays);
var Food_Allowances = fAllow * dayWorks;
// console.log("workedFA"+Food_Allowances);
var daySalary = bpay / NoofDays;
// console.log("1daysalary "+daySalary);
var dayHra = hraAmt / NoofDays;
// console.log("1dayHRA"+dayHra);
var onehoursSalary = (daySalary + dayHra) / 8;
//console.log("onehours "+onehoursSalary);
var totSalayOT =0;
if (otHrsWork!= 0)
{
totSalayOT = otHrsWork * onehoursSalary;
}
else
{
totSalayOT = 0;
}
//console.log(totSalayOT);
var currentDaySalary = daySalary * dayWorkPaid;
//console.log("11days salary"+currentDaySalary);
var currentDayHra = dayHra * dayWorkPaid;
// console.log("11days hra"+currentDayHra);
var current_loan_amt = 0;
var autoLoan =parseFloat(monthDue);
console.log(monthDue);
var manualLoan =parseFloat(loanRecd);
// var manualLoan = Math.min.apply(null, arrayOfNumbers.filter(function(loanRecd) { return !isNaN(loanRecd); }))
//console.log(manualLoan);
if(manualLoan == 0.00){
if(duedate <= finalpaydate)
{
current_loan_amt = autoLoan;
}
//alert('}0.00');
}
else if(isNaN(manualLoan))
{
//alert('else if1');
current_loan_amt = 0.00;
}
else if(manualLoan == 'NA')
{
//alert('elseif2');
current_loan_amt = 0.00;
}
else if(manualLoan >= 0.00)
{
if(duedate <= finalpaydate)
{
current_loan_amt = manualLoan;
}
//alert('manual'+current_loan_amt);
}
var Balance_Amount = loanamt - paidamt;
if(autoLoan > Balance_Amount) {
if(duedate <= finalpaydate)
{
current_loan_amt = Balance_Amount;
}
//alert('HI');
}
// console.log(current_loan_amt);
if(parseFloat(incentie) == parseFloat(incentie)){
var incent =parseFloat(incentie);
//console.log("Incentives"+incent);
}
if(parseFloat(Festival) == parseFloat(Festival)){
var Festivals =parseFloat(Festival);
//console.log("Festivals"+Festivals);
}
if(parseFloat( otherDet) == parseFloat( otherDet)){
var otherDets =parseFloat( otherDet);
//console.log("otherDets"+ otherDets);
}
var currentDatePF = currentDaySalary + currentDayHra + totSalayOT;
// console.log("pf "+currentDatePF);
// var totalsalary= empsal + hraAmt;
var totalsalary =currentDaySalary+currentDayHra;
// console.log("total"+totalsalary);
var esiAmount=0;
if (totalsalary <= 20000)
{
esiAmount = currentDatePF * eslRate / 100;
/** esiamount not elgiable for 20000 **/
}
else
{
esiAmount = 0;
}
var pfAmount = currentDaySalary * pfRate / 100;
// console.log("11daypf"+pfAmount);
var empSalaryAdd= currentDaySalary + totSalayOT + currentDayHra + Food_Allowances + allow +incent+Festivals ;
var empSalarySub = current_loan_amt + esiAmount + pfAmount + otherDets;
var empMonthSalary = empSalaryAdd - empSalarySub
var employeeSalary = Math.round(empMonthSalary);
//console.log( employeeSalary);
var cals =(employeeSalary).toFixed(0);
document.getElementById("empsal"+sno).innerHTML = cals;
$.each(estTotal,function(i,value){
if(sno==i){
estTotal[i] = cals;
}
});
//console.log(estTotal);
$.each(totalinst,function(i,value){
if(sno==i){
totalinst[i] = incentie;
}
});
$.each(totalotherDet,function(i,value){
if(sno==i){
totalotherDet[i] = otherDet;
}
});
$.each(totalmonthloan,function(i,value){
if(sno==i){
totalmonthloan[i] = loanRecd;
}
});
$.each(totalmanualoan,function(i,value){
if(sno==i){
totalmanualoan[i] = monthDue;
}
});
//console.log(totalinst);
calculategrandtotal();
}
var tempTotal = [];
function calculategrandtotal(){
$.each(totalinst, function( index, value )
{
//var res2 = value.split('-');
tempTotal[index]=parseFloat(value);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i] << 0;
}
$('#inst').text(parseFloat(sum).toFixed(2));
$.each(totalotherDet, function( index, value )
{
//var res2 = value.split('-');
tempTotal[index]=parseFloat(value);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i] << 0;
}
$('#other').text(parseFloat(sum).toFixed(2));
$.each(totalfestival, function( index, value )
{
//var res2 = value.split('-');
tempTotal[index]=parseFloat(value);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i] << 0;
}
$('#fest').text(parseFloat(sum).toFixed(2));
$.each(estTotal, function( index, value )
{
//var res2 = value.split('-');
tempTotal[index]=parseFloat(value);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i] << 0;
}
$('#estsal').text(parseFloat(sum).toFixed(2));
$.each(totalmonthloan, function( index, value )
{
//var res2 = value.split('-');
tempTotal[index]=parseFloat(value);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i] << 0;
}
$('#monthloan').text(parseFloat(sum).toFixed(2));
console.log(totalmanualoan);
$.each(totalmanualoan, function( index, value )
{
//var res2 = value.split('-');
tempTotal[index]=parseFloat(value);
});
var sum = 0;
for (var i = 0; i < tempTotal.length; i++) {
sum += tempTotal[i] << 0;
}
$('#manualoan').text(parseFloat(sum).toFixed(2));
}
function show_hide_column(col_no, do_show) {
var rows = document.getElementById('monthlylistings').rows;
for (var row = 0; row < rows.length; row++) {
var cols = rows[row].cells;
if (col_no >= 0 && col_no < cols.length) {
cols[col_no].style.display = do_show ? '' : 'none';
}
}
}
</script>