From dfa3bdff73a83a478dd9a8e9513b4ec70b0f8f49 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Wed, 17 Jan 2018 16:21:09 +0530 Subject: [PATCH] payroll new field changes and material & supplier duplication name alert --- application/controllers/payslip.php | 9 ++++- .../controllers/rawmaterialdetails.php | 12 ++++++ application/controllers/supplier.php | 11 +++++ application/models/monthlypay_model.php | 33 +++++++++------ .../models/rawmaterialdetails_model.php | 12 ++++++ application/models/supplier_model.php | 11 +++++ application/views/addRawMaterial.php | 36 ++++++++++++++++- application/views/addsupplier.php | 40 +++++++++++++++++-- application/views/includes/header.php | 4 +- application/views/monthlypayinputs.php | 2 + application/views/payslipgenerateprint.php | 16 ++++++++ 11 files changed, 167 insertions(+), 19 deletions(-) diff --git a/application/controllers/payslip.php b/application/controllers/payslip.php index 4c9e726a..86d8d669 100755 --- a/application/controllers/payslip.php +++ b/application/controllers/payslip.php @@ -569,6 +569,7 @@ function phpAlert($msg) { $OT_Hrs_Worked = $j['OT Hours Worked in Hrs']; $Loan_Recovered = $j['Loan Recovered in ₹']; $Incentives = $j['Incentives in ₹']; + $Festival_Bonus = $j['Festival Bonus in ₹']; $Other_Deductions = $j['Other Deductions in ₹']; $Created_By = $this->session->userdata ( 'userId' ); @@ -627,6 +628,11 @@ function phpAlert($msg) { $ErrorFlag++; } + $Festivalbonus_first = explode(".",$Festival_Bonus); + if(!is_numeric($Festival_Bonus) || (strlen((string)$Festival_Bonus))>8 || (strlen((string)$Festivalbonus_first[0]))> 5) + { + $ErrorFlag++; + } $Other_Deductions_first = explode(".",$Other_Deductions); if(!is_numeric($Other_Deductions) || (strlen((string)$Other_Deductions))>8 || (strlen((string)$Other_Deductions_first[0]))> 5) @@ -669,10 +675,11 @@ function phpAlert($msg) { $Loan_Recovered = strtoupper($Loan_Recovered); } $Incentives = $j['Incentives in ₹']; + $Festival_Bonus = $j['Festival Bonus in ₹']; $Other_Deductions = $j['Other Deductions 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,'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,'Created_By'=>$Created_By); $result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata); $total = $total + $result; } diff --git a/application/controllers/rawmaterialdetails.php b/application/controllers/rawmaterialdetails.php index 89f03a42..8bfc8637 100755 --- a/application/controllers/rawmaterialdetails.php +++ b/application/controllers/rawmaterialdetails.php @@ -450,6 +450,18 @@ class rawmaterialdetails extends BaseController $this->loadViews("404", $this->global, NULL, NULL); } + + function checkmaterial() + { + + $material = $this->input->post('id'); + $this->load->model('rawmaterialdetails_model'); + $query = $this->rawmaterialdetails_model->checkMaterialExists($material); + + //if(!empty($material)){ + echo json_encode($query); + //} + } } ?> \ No newline at end of file diff --git a/application/controllers/supplier.php b/application/controllers/supplier.php index 6b11eaab..457e35da 100755 --- a/application/controllers/supplier.php +++ b/application/controllers/supplier.php @@ -628,6 +628,17 @@ class supplier extends BaseController $this->loadViews("404", $this->global, NULL, NULL); } + function checksupplier() + { + + $supp_name = $this->input->post('id'); + $this->load->model('supplier_model'); + $query = $this->supplier_model->checkSupplierExists($supp_name); + + //if(!empty($supp_name)){ + echo json_encode($query); + //} + } } ?> \ No newline at end of file diff --git a/application/models/monthlypay_model.php b/application/models/monthlypay_model.php index 4cd0aba2..559c0186 100755 --- a/application/models/monthlypay_model.php +++ b/application/models/monthlypay_model.php @@ -13,21 +13,30 @@ class monthlypay_model extends CI_Model function monthlyListing($current="") { //echo $current; - $month_val = date('m',strtotime($current)); - $year_val = date('Y',strtotime($current)); + $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; - $this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Payroll.Key,T_Loan_Master.Loan_ID'); - $this->db->from('T_Monthly_Pay_Inputs'); - $this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID'); - $this->db->join('T_Payroll','T_Monthly_Pay_Inputs.EmpID=T_Payroll.EmpID','left'); - $this->db->join('T_Loan_Master','T_Monthly_Pay_Inputs.EmpID=T_Loan_Master.EmpID','left'); - $this->db->order_by('T_Employee_Details.EmpID','asc'); - $this->db->where('T_Employee_Details.DateofJoining <=',$lastdate); - $this->db->where('Month_Year',$current); + // $this->db->select('T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Payroll.Key,T_Loan_Master.Loan_ID'); + // $this->db->from('T_Monthly_Pay_Inputs'); + // $this->db->join('T_Employee_Details','T_Monthly_Pay_Inputs.EmpID=T_Employee_Details.EmpID'); + // $this->db->join('T_Payroll','T_Monthly_Pay_Inputs.EmpID=T_Payroll.EmpID','left'); + // $this->db->join('T_Loan_Master','T_Monthly_Pay_Inputs.EmpID=T_Loan_Master.EmpID','left'); + // $this->db->order_by('T_Employee_Details.EmpID','asc'); + // $this->db->where('T_Employee_Details.DateofJoining <=',$lastdate); + // $this->db->where('Month_Year',$current); + + $sql="select T_Monthly_Pay_Inputs.*,T_Employee_Details.FirstName,T_Employee_Details.LastName,T_Loan_Master.Loan_ID,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 + left join T_Loan_Master on T_Monthly_Pay_Inputs.EmpID=T_Loan_Master.EmpID and T_Loan_Master.is_Active = 1 + where Month_Year = ? + order by T_Employee_Details.EmpID asc"; - $query = $this->db->get(); + $query = $this->db->query($sql,array($lastdate,$current)); // print_r($query->result()); $result = $query->result(); @@ -69,7 +78,7 @@ class monthlypay_model extends CI_Model $date_val =cal_days_in_month(CAL_GREGORIAN,$month_val,$year_val); //$monthyear_val = date('Y-m',strtotime($current)); $lastdate = $year_val.'-'.$month_val.'-'.$date_val; - echo $lastdate; + //echo $lastdate; $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 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(?) diff --git a/application/models/rawmaterialdetails_model.php b/application/models/rawmaterialdetails_model.php index ef5087c7..2fdf5da0 100755 --- a/application/models/rawmaterialdetails_model.php +++ b/application/models/rawmaterialdetails_model.php @@ -174,5 +174,17 @@ class rawmaterialdetails_model extends CI_Model // $this->db->update('T_PurchaseOrderDetails', $POInfo); // return $this->db->affected_rows(); // } + function checkMaterialExists($material) + { + + $this->db->select('MaterialCode,MaterialName,MaterialType,Category'); + $this->db->from('T_MaterialMaster'); + $this->db->like('MaterialName', $material); + + $query = $this->db->get(); + //print_r($query->result()); + return $query->result(); + + } } ?> \ No newline at end of file diff --git a/application/models/supplier_model.php b/application/models/supplier_model.php index 1c57e8c3..01d11db7 100755 --- a/application/models/supplier_model.php +++ b/application/models/supplier_model.php @@ -177,7 +177,18 @@ function addNewsupplier($supplier) return $this->db->get('T_SupplierDetailsN as det')->result_array(); } + function checkSupplierExists($supp_name) + { + $this->db->select('SupplierID,SupplierName,Address'); + $this->db->from('T_SupplierDetailsN'); + $this->db->like('SupplierName', $supp_name); + + $query = $this->db->get(); + + return $query->result(); + + } /*SUPPLIER */ /*SUPPLIER TYPE */ diff --git a/application/views/addRawMaterial.php b/application/views/addRawMaterial.php index 7ed7032c..8941e3b1 100755 --- a/application/views/addRawMaterial.php +++ b/application/views/addRawMaterial.php @@ -60,7 +60,7 @@ function BlockSpecial(evt) { -
+
Back
@@ -278,6 +278,40 @@ function BlockSpecial(evt) { - \ No newline at end of file + +$('#supplierName').change(function() { + + var supplier = $('#supplierName').val(); + $('#content').loader('show'); + $.ajax({ + data:{id:supplier}, + type:"POST", + url:"supplier/checksupplier", + success:function(data) { + var count = data.length; + //alert(count); + + if(count >2 ){ + $('#content').loader('hide'); + alert('supplier already existed ! '); + dat = JSON.parse(data); + var related_supplier = ""; + $.each(dat,function(i,obj){ + + related_supplier += obj.SupplierID +" - "+ obj.SupplierName +" - "+obj.Address+"\n"; + + }); + + alert("'" + supplier + "' - related supplier are , " + " \n \n" + related_supplier); + } + else{ + $('#content').loader('hide'); + // alert("empty data"); + } + + } + }); + }); + + \ No newline at end of file diff --git a/application/views/includes/header.php b/application/views/includes/header.php index 99e823d4..5b157fb8 100755 --- a/application/views/includes/header.php +++ b/application/views/includes/header.php @@ -515,12 +515,12 @@ $(function() { Monthly Pay Information -
  • +
  • diff --git a/application/views/monthlypayinputs.php b/application/views/monthlypayinputs.php index ed67374b..d483f362 100755 --- a/application/views/monthlypayinputs.php +++ b/application/views/monthlypayinputs.php @@ -155,6 +155,7 @@ $('html').bind('keypress', function(e) Incentives in ₹ Other Deductions in ₹ + Festival Bonus in ₹ @@ -202,6 +203,7 @@ $('html').bind('keypress', function(e) Key) && !empty($record->Loan_ID)){ echo "contenteditable='true'; style='background-color:#ffcccc;text-align:right' title='Loan Pending'"; } ?> Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"style="text-align:right;" >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,'.','');} ?> Key)){echo "contenteditable='true';"; } ?> Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"style="text-align:right;" >Incentives)){echo $record->Incentives;}else{ echo number_format(0.00,2,'.','');;} ?> Key)){echo "contenteditable='true';"; } ?> Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"style="text-align:right;" >Other_Deductions)){echo $record->Other_Deductions; }else{ echo number_format(0.00,2,'.','');;} ?> + Key)){echo "contenteditable='true';"; } ?> Key)){?> title="Payslip Calculated" style="text-align:right;color:blue;"style="text-align:right;" >Festival_Bonus)){echo $record->Festival_Bonus; }else{ echo number_format(0.00,2,'.','');;} ?> diff --git a/application/views/payslipgenerateprint.php b/application/views/payslipgenerateprint.php index f576f751..9eaa5578 100755 --- a/application/views/payslipgenerateprint.php +++ b/application/views/payslipgenerateprint.php @@ -35,6 +35,7 @@ $SalaryAsPerPF = ''; $FoodAllowance =''; $Incentive = ''; + $Festival_bonus = ''; $TotalSalary = ''; $Advance = ''; $BalanceAdvance = ''; @@ -140,6 +141,15 @@ if(!empty($PayDetails)) { $Incentive = $IncenAmt; } + $festbonus = $Pay->Festival_Bonus; + if($festbonus == '') + { + $Festival_bonus = '0.00'; + } + else + { + $Festival_bonus = $festbonus; + } $TotalSalary = $WorkedSalary+$HRA+$Food+$IncenAmt+$OTSal+$Otherallowances; $Adv = $Pay->Advance; if($Adv == '') @@ -295,6 +305,12 @@ if($RecCount > 0) + + Festival Bonus +  + + +  Total Earning (Rounded) (TE)    Total Deduction (Rounded)(TD)