From 926c3ed2a9fda63ade93b1e87321e1734edcddd2 Mon Sep 17 00:00:00 2001 From: VE10-Sanjeev Date: Wed, 26 Feb 2025 13:22:04 +0000 Subject: [PATCH] drive payslip merged : ps --- app/Config/Routes.php | 1 + app/Controllers/Driver.php | 30 ++- app/Controllers/Payslip.php | 168 +++++++++++++++- app/Models/Driver_model.php | 76 +++++-- app/Models/Monthlypay_model.php | 9 +- app/Models/Payroll_model.php | 5 +- app/Views/driverAttendance.php | 148 ++++++++++++++ app/Views/driverListing.php | 4 +- .../driverPayslipGeneratePrint (Copy).php | 82 ++++++++ app/Views/driverPayslipGeneratePrint.php | 107 +++++++--- app/Views/editrequisitionform.php | 18 +- app/Views/includes/new_header.php | 8 +- app/Views/monthlypayinputs.php | 188 +++++++++++++++++- app/Views/payslipgenerate.php | 19 +- app/Views/requisitionform.php | 8 +- 15 files changed, 763 insertions(+), 108 deletions(-) create mode 100755 app/Views/driverPayslipGeneratePrint (Copy).php diff --git a/app/Config/Routes.php b/app/Config/Routes.php index b08ca39c..99b93bea 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -87,6 +87,7 @@ $routes->post('fetchDriverAttendanceDetails', 'Driver::fetchDriverAttendanceDeta $routes->get('reActivateDriverAttendance', 'Driver::reActivateDriverAttendance'); $routes->get('deleteDriverAttendance', 'Driver::deleteDriverAttendance'); $routes->post('gatheredCustAndQty', 'Driver::gatheredCustAndQty'); +$routes->match(['GET', 'POST'], 'updateDieselAndShedValuesBasedonEmpID', 'Driver::updateDieselAndShedValuesBasedonEmpID'); // Driver Monthly Pay Inputs Routes $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'driverMonthlyPayInputs', 'Driver::driverMonthlyPayInputs'); $routes->post('saveMonthlyData', 'Driver::saveMonthlyData'); diff --git a/app/Controllers/Driver.php b/app/Controllers/Driver.php index 2fd070a2..8f091691 100755 --- a/app/Controllers/Driver.php +++ b/app/Controllers/Driver.php @@ -133,7 +133,7 @@ class Driver extends BaseController return $this->response->setJSON($results); } - public function loadDriverAttendance() + public function loadDriverAttendance() { $input_driver_id = $this->request->getGet('gobal_driver_id'); @@ -150,16 +150,36 @@ class Driver extends BaseController $to_mysql_date = get_date_time_dynamical_format('d-m-Y','Y-m-d',"$get_last_date_of_the_month-$month-$year"); $indian_date = get_date_time_dynamical_format('d-m-Y','d-m-Y',"$get_last_date_of_the_month-$month-$year"); + $amount = $this->driver_model->getDriverAttendanceTable($input_driver_id,"$year-$month"); + $data['driver_attendance_list'] = $this->driver_model->useDriverAttendanceTable()->getDriverAttendanceList($input_driver_id,$from_mysql_date,$to_mysql_date); - $data['page_driver_name'] = $this->driver_model->getDriverName($input_driver_id); + $data['page_driver_name'] = $this->driver_model->getDriverName($input_driver_id,0); $data['invoice_info'] = $this->driver_model->getInvoiceInfo(); $data['datefordropdown'] = $input_date; $data['gobal_driver_id'] = $input_driver_id; + $data['gobal_diesel_amount'] = isset($amount->diesel_amount) ? $amount->diesel_amount : 0 ; + $data['gobal_shed_amount'] = isset($amount->shed_amount) ? $amount->shed_amount : 0 ; $this->global['pageTitle'] = 'Driver Attendance List'; $this->loadViews("driverAttendance", $this->global, $data, NULL); } + public function updateDieselAndShedValuesBasedonEmpID(){ + $arr = $this->request->getPost(); + $userId = $this->session->get('userId'); + $to_mysql_date = get_date_time_dynamical_format('d-m-Y','Y-m',$arr['date']); + + $update_arr = ['driver_id' =>$arr['empid'],$arr['column'] =>$arr['value'],'updated_by' => $userId]; + $where_arr = ['DATE_FORMAT(t_driver_attendance.date, "%Y-%m")' =>$to_mysql_date,'t_driver_attendance.driver_id' =>$arr['empid']]; + $data = $this->driver_model->updateDieselAndShedValuesBasedonEmpID($where_arr,$update_arr); + return $data; + // [column] => shed_amount + // [value] => 400 + // [date] => 21-02-2025 + // [empid] => RIPL136 + + + } public function fetchDriverAttendanceDetails(){ $userId = $this->session->get('userId'); @@ -385,7 +405,7 @@ class Driver extends BaseController { $PayOn = $this->request->getPost('payon'); - $Driver = $this->request->getPost('driver'); + $Driver = $this->request->getPost('employee'); $res = $this->driver_model->getMonthlyPayDetails($Driver, $PayOn); @@ -394,13 +414,9 @@ class Driver extends BaseController $data = [ 'PayOn' => $result->month_year, 'driver_id' => $result->driver_id, - 'driver_name' => $result->driver_name, 'no_of_loads' => $result->no_of_loads, 'driver_monthly_salary_amount' => $result->driver_monthly_salary_amount, - 'driver_monthly_food_amount' => $result->driver_monthly_food_amount, 'driver_earnings_amount' => $result->driver_earnings_amount, - 'diesel' => $result->diesel, - 'shed_duty_amount' => $result->shed_duty_amount, 'driver_final_payment' => $result->driver_final_payment, 'created_by' => $this->session->get('userId') ]; diff --git a/app/Controllers/Payslip.php b/app/Controllers/Payslip.php index 5e3aae25..e1c7b5b2 100755 --- a/app/Controllers/Payslip.php +++ b/app/Controllers/Payslip.php @@ -10,6 +10,7 @@ use CodeIgniter\Validation\Exceptions\ValidationException; use App\Models\Monthlypay_model; use App\Models\Payroll_model; +use App\Models\Driver_model; use Mpdf\Mpdf; use PhpOffice\PhpSpreadsheet\Spreadsheet; @@ -33,6 +34,7 @@ class Payslip extends BaseController { protected $payroll_model; protected $monthlypay_model; + protected $driver_model; protected $session; /** @@ -43,6 +45,7 @@ class Payslip extends BaseController parent::__construct(); $this->payroll_model = new Payroll_model(); $this->monthlypay_model = new Monthlypay_model(); + $this->driver_model = new Driver_model(); $this->session = session(); helper('form'); //$this->load->library('form_validation'); $this->isLoggedIn(); @@ -596,14 +599,15 @@ class Payslip extends BaseController $data['month'] = $this->monthlypay_model->monthlyListing($current); $data['dropdownvalue'] = $current; $data['fresh'] = $this->monthlypay_model->getEmpPayDetailsforMonthInputs($current); - + // dd($data['fresh']); + $data['drivermonthinputs'] = $this->driverMonthlyPayInputs($current); $employeeSalary = []; $esi = []; $pf = []; $ot = []; foreach ($data['fresh'] as $value) { - + $is_driver = $value->is_driver; $NoofDays = $value->NoofDays; //Month day 30,31,28 $HRA_Amount = $value->HRA_Amount; $Basic_Pay = $value->Basic_Pay; @@ -722,6 +726,78 @@ class Payslip extends BaseController $this->loadViews("monthlypayinputs", $this->global, $data, NULL); } + public function driverMonthlyPayInputs($current) + { + + list($month, $year) = explode('-', $current); + + $month_in_number = get_date_time_dynamical_format('n','m',"$month");// refer helper + + $get_last_date_of_the_month = cal_days_in_month(CAL_GREGORIAN, $month_in_number, $year); + + $from_mysql_date = get_date_time_dynamical_format('d-m-Y','Y-m-d',"01-$month_in_number-$year"); + $to_mysql_date = get_date_time_dynamical_format('d-m-Y','Y-m-d',"$get_last_date_of_the_month-$month_in_number-$year"); + + // $data['monthinputs'] + $load_driver_data = $this->driver_model->driverAttendanceForMonthlyPayInputs($from_mysql_date,$to_mysql_date); + // dd($load_driver_data); + + + $format_month_year = get_date_time_dynamical_format('n-Y','m-Y',"$current"); + + $monthly_pay_data = $this->driver_model->driverMonthlyPayInputs($format_month_year); + + + + // both foreach refer with chatgpt array data replacement.... + $monthly_pay_array = []; + foreach ($monthly_pay_data as $row) { + $monthly_pay_array[$row->driver_id] = $row; + } + + for ($i = 0; $i < count((array)$load_driver_data); $i++) { + $driver_id = $load_driver_data[$i]->driver_id; + if (isset($monthly_pay_array[$driver_id])) { + + $PF_Rate = $load_driver_data[$i]->PF_Rate; + $ESI_Rate = $load_driver_data[$i]->ESI_Rate; + + $basic = isset($load_driver_data[$i]->driver_earnings_amount) ? (int)$load_driver_data[$i]->driver_earnings_amount + (int)$load_driver_data[$i]->shed_amount+(int)$load_driver_data[$i]->diesel_amount : 0; + + $load_driver_data[$i]->driver_basic = $basic; + $load_driver_data[$i]->driver_earnings_amount = $monthly_pay_array[$driver_id]->driver_earnings_amount; + + // $load_driver_data[$i]->diesel = $monthly_pay_array[$driver_id]->diesel; + // $load_driver_data[$i]->shed_duty_amount = $monthly_pay_array[$driver_id]->shed_duty_amount; + $load_driver_data[$i]->driver_final_payment = $monthly_pay_array[$driver_id]->driver_final_payment; + $load_driver_data[$i]->payroll_id = $monthly_pay_array[$driver_id]->payroll_id; + $load_driver_data[$i]->Festival_Bonus = $monthly_pay_array[$driver_id]->Festival_Bonus; + $load_driver_data[$i]->esi_amount = ($load_driver_data[$i]->esi_applicable == 1) ? $basic * $ESI_Rate / 100 : 0; + $load_driver_data[$i]->pf_amount = ($load_driver_data[$i]->pf_applicable == 1) ? $basic * $PF_Rate / 100 : 0; + $load_driver_data[$i]->basic_worked = $basic * 30 / 100; + $load_driver_data[$i]->hra_worked = $basic * 70 / 100; + + }else { + $PF_Rate = $load_driver_data[$i]->PF_Rate; + $ESI_Rate = $load_driver_data[$i]->ESI_Rate; + + $basic = isset($load_driver_data[$i]->driver_earnings_amount) ? (int)$load_driver_data[$i]->driver_earnings_amount + (int)$load_driver_data[$i]->shed_amount+(int)$load_driver_data[$i]->diesel_amount : 0; + $load_driver_data[$i]->driver_basic = $basic; + $load_driver_data[$i]->driver_earnings_amount = $load_driver_data[$i]->driver_earnings_amount; + $load_driver_data[$i]->driver_final_payment = $basic; + $load_driver_data[$i]->payroll_id = ''; + $load_driver_data[$i]->Festival_Bonus = 0; + $load_driver_data[$i]->esi_amount = ($load_driver_data[$i]->esi_applicable == 1) ? $basic * $ESI_Rate / 100 : 0; + $load_driver_data[$i]->pf_amount = ($load_driver_data[$i]->pf_applicable == 1) ? $basic * $PF_Rate / 100 : 0; + $load_driver_data[$i]->basic_worked = $basic * 30 / 100; + $load_driver_data[$i]->hra_worked = $basic * 70 / 100; + } + } + // dd($load_driver_data); + return $load_driver_data; + + } + function changeMonth() { @@ -857,6 +933,11 @@ class Payslip extends BaseController $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'; @@ -1002,6 +1083,7 @@ class Payslip extends BaseController $EmpID = $j['Emp ID']; + $is_driver = $this->driver_model->getDriverName($EmpID,1); $DaysWorked = $j['Days Worked']; $TotalCalDays = isset($j['Total Days']) ? $j['Total Days'] : 0.00 ; $ActualSalary = isset($j['Basic Salary']) ? $j['Basic Salary'] : 0.00 ; @@ -1022,6 +1104,18 @@ class Payslip extends BaseController $Estimate = isset($j['Estimate in ₹']) ? $j['Estimate in ₹'] : 0.00; $Created_By = $this->session->get('userId'); + $ID = $EmpID ; + $LOAD = $DaysWorked; + $SALARY = $Basic ; + $TOTAL = $Basic ; + $DIESEL = $Festival_Bonus ; + $GRAND = $Estimate; + $CREATED = $this->session->get('userId'); + $UPDATED = $this->session->get('userId'); + + if($is_driver == 0){ + + $monthlypaydata = array( 'Month_Year' => $month, 'EmpID' => $EmpID, @@ -1046,6 +1140,26 @@ class Payslip extends BaseController ); // print_r($monthlypaydata); die; $result = $this->monthlypay_model->saveMonthlyData_model($monthlypaydata); + + }else{ + $CREATED = $this->session->get('userId'); + $UPDATED = $this->session->get('userId'); + + $drivermonthlypaydata = array( + 'month_year' => $month, + 'driver_id' =>$EmpID, + 'no_of_loads' =>(strpos($TotalCalDays, "(trip)") !== false) ? explode(" ", $TotalCalDays)[0] : 0, + 'driver_monthly_salary_amount' => $WorkedSalary, + 'Festival_Bonus' => $Festival_Bonus, + 'driver_final_payment' =>$Estimate, + 'created_by'=>$CREATED, + 'updated_by'=>$UPDATED + + ); + + $result = $this->driver_model->saveMonthlyData($drivermonthlypaydata); + + } $total = $total + $result; } } @@ -1091,6 +1205,7 @@ class Payslip extends BaseController public function viewGenerator() { + $Data['Payon'] = $this->payroll_model->getPayOn(); $this->global['pageTitle'] = 'Payroll Generater'; @@ -1112,7 +1227,11 @@ class Payslip extends BaseController { $id = $this->request->getPost('id1'); - $result = $this->payroll_model->getEmployeelist2($id); + $employee = $this->payroll_model->getEmployeelist2($id); + $driver = $this->driver_model->getDriverlist2($id); + + $result = array_merge($employee, $driver); + $HTML = ""; @@ -1120,8 +1239,7 @@ class Payslip extends BaseController foreach ($result as $list) { - - $HTML .= ""; + $HTML .= ""; } } echo $HTML; @@ -1196,6 +1314,24 @@ class Payslip extends BaseController } } else { $EmpID = $this->request->getPost('Employee'); + $is_driver = $this->driver_model->getDriverName($EmpID,1); + if($is_driver == "1"){ + $Data['PayDetails'] = $this->driver_model->GetPayslipdata($Payon, $EmpID); + + + $name = $Data['PayDetails'][0]->driver_name; + $filename = 'PayslipFor-' . $EmpID . ' ' . $name . ' ' . $m . ' ' . $y; + + $totalsalary = $Data['PayDetails'][0]->driver_final_payment; + $totalsalaryinwords = $this->convertNumberToWords(round($totalsalary)); + $Data['amtinwords'] = $totalsalaryinwords; + $currentDayBasic = isset($Data['PayDetails'][0]->driver_monthly_salary_amount) ? $Data['PayDetails'][0]->driver_monthly_salary_amount : 0; + $PF_Rate = $Data['PayDetails'][0]->PF_Rate; + $ESI_Rate = $Data['PayDetails'][0]->ESI_Rate; + $Data['esi_amount'] = ($Data['PayDetails'][0]->esi_applicable == 1) ? $currentDayBasic * $ESI_Rate / 100 : 0; + $Data['pf_amount'] = ($Data['PayDetails'][0]->pf_applicable == 1) ? $currentDayBasic * $PF_Rate / 100 : 0; + $html = view("driverPayslipGeneratePrint", $Data); + }else{ //echo "EmpID" . $EmpID; $Data['PayDetails'] = $this->payroll_model->GetPayslipdata($Payon, $EmpID); @@ -1210,6 +1346,8 @@ class Payslip extends BaseController // echo view("payslipgenerateprint", $Data);die; $html = view("payslipgenerateprint", $Data); } + + } $mpdf = new Mpdf([ @@ -1231,7 +1369,7 @@ class Payslip extends BaseController $mpdf->WriteHTML($html); $mpdf->SetTitle('Resico:Payslip'); - $mpdf->Output("Payslip-" . $filename . ".pdf", 'D'); + $mpdf->Output("Payslip-" . $filename . ".pdf", 'D'); } @@ -1530,10 +1668,24 @@ class Payslip extends BaseController { $empid = $this->request->getPost('employee'); $payon = $this->request->getPost('payon'); - $result = $this->payroll_model->checkExistPayData($empid, $payon); - echo json_encode(count($result)); + $is_driver = $this->driver_model->getDriverName($empid,1); + if($is_driver){ + $result = $this->driver_model->checkDriverExistPay($empid, $payon); + $data['count'] = count($result); + $data['path'] = "driverPayslip"; + echo json_encode($data); + }else{ + $result = $this->payroll_model->checkExistPayData($empid, $payon); + $data['count'] = count($result); + $data['path'] = "payslip/callsp"; + echo json_encode($data); + } + + } + + function convertNumber($amt) diff --git a/app/Models/Driver_model.php b/app/Models/Driver_model.php index bc60b32d..6a15d465 100755 --- a/app/Models/Driver_model.php +++ b/app/Models/Driver_model.php @@ -21,7 +21,7 @@ class Driver_model extends Model { $this->table = 't_driver_attendance'; $this->primaryKey = 'driver_attendance_id'; - $this->allowedFields = ['driver_attendance_id','date','driver_id','invoice_number','vehicle_number','load_type','salary_amount','food_amount','created_on','created_by','updated_on','updated_by','isactive']; + $this->allowedFields = ['driver_attendance_id','date','driver_id','invoice_number','vehicle_number','load_type','salary_amount','food_amount','created_on','created_by','updated_on','updated_by','isactive','diesel_amount','shed_amount']; return $this; } @@ -72,17 +72,24 @@ class Driver_model extends Model return $query->getResult(); } - function getDriverName($id) + function getDriverName($id,$flag) { $builder = $this->db->table('t_employee_details') - ->select('CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) as driver_name') + ->select('CONCAT_WS(" ", t_employee_details.FirstName, t_employee_details.LastName) as driver_name,is_driver') ->where('EmpID', $id); $query = $builder->get()->getRow(); - $driver_name = $query ? $query->driver_name : null; - - return $driver_name; + if ($flag == 0){ + $driver_name = $query ? $query->driver_name : null; + return $driver_name; + } + if ($flag == 1){ + $is_driver = $query ? $query->is_driver : null; + return $is_driver; + } + return null; + } function gatheredCustAndQty($invoice){ @@ -93,20 +100,28 @@ class Driver_model extends Model $query = $builder->get(); return $query->getRowArray() ?: []; } - - + function driverAttendanceForMonthlyPayInputs($from,$to){ $builder = $this->db->table('t_driver_attendance') - ->select('t_driver_attendance.driver_id,SUM(t_driver_attendance.salary_amount) as driver_monthly_salary_amount,SUM(t_driver_attendance.food_amount) as driver_monthly_food_amount,t_driver.driver_name, - DATE_FORMAT(date, "%M-%Y") AS month_year,SUM(salary_amount + food_amount) AS driver_earnings_amount,COUNT(t_driver_attendance.load_type) AS no_of_loads') - ->join('t_driver', 't_driver.driver_id = t_driver_attendance.driver_id and t_driver.isactive = 1', 'left') + ->select('t_driver_attendance.driver_id,driver_details.FirstName as driver_name,driver_details.is_driver, + DATE_FORMAT(date, "%M-%Y") AS month_year,COUNT(t_driver_attendance.load_type) AS no_of_loads,driver_details.*,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate') + ->select('SUM(t_driver_attendance.salary_amount) as driver_monthly_salary_amount, + SUM(t_driver_attendance.food_amount) as driver_monthly_food_amount, + SUM(salary_amount + food_amount) AS driver_earnings_amount, + diesel_amount,shed_amount,CONCAT_WS(" ", driver_details.FirstName, driver_details.LastName) AS FullName') + ->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') ->where('t_driver_attendance.date BETWEEN "'.$from.'" AND "'.$to.'"') - ->groupBy('t_driver.driver_id, DATE_FORMAT(t_driver_attendance.date, "%M-%Y")'); + ->groupBy('DATE_FORMAT(t_driver_attendance.date, "%M-%Y")'); $query = $builder->get(); + // $last_query = $this->db->getLastQuery(); + // echo $last_query;die; return $query->getResult(); } + + function driverMonthlyPayInputs($monthYear){ $builder = $this->db->table('t_driver_monthly_pay_inputs'); @@ -143,13 +158,13 @@ class Driver_model extends Model if ($count == 0) { - unset($data['updated_by']); + unset($data['updated_by']);// we need createdby. thats why updatedby unset $builder = $this->db->table('t_driver_monthly_pay_inputs'); $builder->insert($data); $i = $this->db->affectedRows(); return $i; } elseif ($count == 1) { - unset($data['created_by']); + unset($data['created_by']); // we need updatedby. thats why createdby unset $this->db->table('t_driver_monthly_pay_inputs') ->where('driver_id', $data['driver_id']) ->where('month_year', $data['month_year']) @@ -159,7 +174,21 @@ class Driver_model extends Model return $i; } } - + function updateDieselAndShedValuesBasedonEmpID($where_arr,$data){ + $this->db->table('t_driver_attendance') + ->where($where_arr) + ->update($data); + $i = $this->db->affectedRows(); + return $i; + } + public function getDriverAttendanceTable($input_driver_id,$monthyear){ + $builder = $this->db->table('t_driver_attendance') + ->where('DATE_FORMAT(`t_driver_attendance`.`date`, "%Y-%m")',$monthyear) + ->where('t_driver_attendance.driver_id',$input_driver_id); + $query = $builder->get()->getRow(); + // $last_query = $this->db->getLastQuery(); + return $query; + } function getPayOn() { $builder = $this->db->table('t_driver_monthly_pay_inputs') @@ -172,8 +201,8 @@ class Driver_model extends Model function getDriverlist2($Payon = '') { $builder = $this->db->table('t_driver_monthly_pay_inputs Pay') - ->select('Pay.driver_id as driver_id,driver.driver_name as name') - ->join('t_driver driver', 'Pay.driver_id = driver.driver_id'); + ->select('Pay.driver_id,driver.EmpID as EmpId,CONCAT_WS(" ", driver.FirstName, driver.LastName) AS FullName') + ->join('t_employee_details as driver', 'driver.EmpID = Pay.driver_id and driver.is_driver = 1', 'left'); if ($Payon != '') { $builder->where('Pay.month_year', $Payon); } @@ -197,7 +226,8 @@ class Driver_model extends Model function getMonthlyPayDetails($driver_id, $PayOn) { $builder = $this->db->table('t_driver_monthly_pay_inputs MonthlyPay ') - ->select('MonthlyPay.*') + ->select('MonthlyPay.*,driver.EmpID as EmpId,CONCAT_WS(" ", driver.FirstName, driver.LastName) AS FullName') + ->join('t_employee_details as driver', 'driver.EmpID = MonthlyPay.driver_id and driver.is_driver = 1', 'left') ->where('MonthlyPay.driver_id', $driver_id) ->where('MonthlyPay.month_year', $PayOn); @@ -231,8 +261,14 @@ class Driver_model extends Model function GetPayslipdata($PayOn = '', $EmpId = '') { //echo "FROM MODEL" . $PayOn . $EmpId; - $builder = $this->db->table('t_driver_payroll Pay')->select('Pay.*,driver.driver_name as name ') - ->join('t_driver driver', 'Pay.driver_id = driver.driver_id'); + $builder = $this->db->table('t_driver_payroll Pay')->select('Pay.*') + ->select('Emp.EmpID,CONCAT_WS(" ", Emp.FirstName, Emp.LastName) as driver_name,Emp.DateofBirth as Dob,Emp.PANNo as Pan,Emp.BankBranchName as BankName,Emp.BankAccountNo as BankAccountNumber,Emp.IFSCCode as IFSCCode,Emp.DateofJoining as DOJ,Emp.AadharNo,Emp.Designation as Designation,Dep.DepartmentName as DeptName,Emp.esi_applicable,Emp.pf_applicable') + ->select('att.diesel_amount , att.shed_amount,t_emp_pay_data.PF_Rate,t_emp_pay_data.ESI_Rate,month.Festival_Bonus') + ->join('t_employee_details Emp', 'Pay.driver_id = Emp.EmpID') + ->join('t_departmentdetails Dep', 'Emp.Departmentcode = Dep.DEPCode') + ->join('t_emp_pay_data','t_emp_pay_data.EmpID=Emp.EmpID','Left') + ->join('t_driver_attendance att', 'att.driver_id = Emp.EmpID') + ->join('t_driver_monthly_pay_inputs month', 'month.driver_id = Emp.EmpID'); if ($PayOn != '') { $builder->where('Pay.PayOn', $PayOn); } diff --git a/app/Models/Monthlypay_model.php b/app/Models/Monthlypay_model.php index 569790f8..e50c3b83 100755 --- a/app/Models/Monthlypay_model.php +++ b/app/Models/Monthlypay_model.php @@ -39,12 +39,12 @@ class Monthlypay_model extends Model // $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_loan_master.Monthly_Due,t_payroll.Id + $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.Id,t_employee_details.is_driver 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 = ? + where t_employee_details.is_driver = 0 and Month_Year = ? order by t_employee_details.EmpID asc"; $query = $this->db->query($sql, array($lastdate, $current)); @@ -64,7 +64,7 @@ class Monthlypay_model extends Model //$monthyear_val = date('Y-m',strtotime($current)); $lastdate = $year_val . '-' . $month_val . '-' . $date_val; $builder = $this->db->table('t_employee_details') - ->select('t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName,t_employee_details.DateofJoining') + ->select('t_employee_details.EmpID,t_employee_details.FirstName,t_employee_details.LastName,t_employee_details.DateofJoining,t_employee_details.is_driver') //->join('t_emp_pay_data','t_emp_pay_data.EmpID=t_employee_details.EmpID','Left') ->where('t_employee_details.IsActive', 1) ->where('t_employee_details.DateofJoining <=', $lastdate) @@ -100,7 +100,7 @@ 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 + $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 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 = ? @@ -110,6 +110,7 @@ class Monthlypay_model extends Model 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(?) + and t_employee_details.is_driver = 0 order by t_employee_details.EmpID"; $query = $this->db->query($sql, array($month, $month, $lastdate, $current, $current)); diff --git a/app/Models/Payroll_model.php b/app/Models/Payroll_model.php index 51e22f3a..3b71a779 100755 --- a/app/Models/Payroll_model.php +++ b/app/Models/Payroll_model.php @@ -331,9 +331,10 @@ class Payroll_model extends Model function getEmployeelist2($Payon = '') { + // CONCAT_WS(' ', Emp.FirstName, Emp.LastName) $builder = $this->db->table('t_monthly_pay_inputs Pay') - ->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname') - ->join('t_employee_details Emp', 'Pay.EmpID = Emp.EmpID'); + ->select('Pay.EmpID as EmpId,CONCAT_WS(" ",Emp.FirstName,Emp.LastName) AS FullName') + ->join('t_employee_details Emp', 'Pay.EmpID = Emp.EmpID and Emp.is_driver = 0'); if ($Payon != '') { $builder->where('Pay.Month_Year', $Payon); } diff --git a/app/Views/driverAttendance.php b/app/Views/driverAttendance.php index 48425ef5..9a843fbd 100755 --- a/app/Views/driverAttendance.php +++ b/app/Views/driverAttendance.php @@ -93,6 +93,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); Vehicle Number Salary Amount Food Amount + Total Load Type Action @@ -118,6 +119,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); + '> @@ -134,6 +136,64 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); + + + + + + + + Salary Amount + + + + + + + + + + + + + + + + + Diesel + + + + + + + + + + + + + + Shed Amount + + + + + + + + + + + + + + Total + - + + + + @@ -303,6 +363,14 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); $("#gobal_driver_id").val(""); $("#driver_id").val(""); } + let gobal_diesel_amount = ""; + let gobal_shed_amount = ""; + if(gobal_diesel_amount != '' || gobal_shed_amount != ''){ + $('input[data-column="diesel_amount"]').val(parseFloat(gobal_diesel_amount) || 0); + $('input[data-column="shed_amount"]').val(parseFloat(gobal_shed_amount) || 0); + calculateTotal(); + } + @@ -430,8 +498,88 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); next: '', // Next button icon previous: '' // Previous button icon } + }, + + + footerCallback: function (row, data, start, end, display) { + var api = this.api(); + var isTableEmpty = api.data().length === 0; + // Hide or show the tfoot based on whether the table is empty + if (isTableEmpty) { + $(this).find('tfoot').hide(); // Hide tfoot if the table is empty + } else { + $(this).find('tfoot').show(); // Show tfoot if the table has data + } + var api = this.api(); + var columnIndex = 7; + var sum = api + .column(columnIndex, { page: 'current' }) + .data() + .reduce(function (a, b) { + return a + parseFloat(b.replace(/[^\d.-]/g, '')); + }, 0); + $(api.column(columnIndex).footer()).html(sum); + var api = this.api(); + var columnIndex = 8; + var sum = api + .column(columnIndex, { page: 'current' }) + .data() + .reduce(function (a, b) { + return a + parseFloat(b.replace(/[^\d.-]/g, '')); + }, 0); + $(api.column(columnIndex).footer()).html(sum); + var api = this.api(); + var columnIndex = 9; + var sum = api + .column(columnIndex, { page: 'current' }) + .data() + .reduce(function (a, b) { + return a + parseFloat(b.replace(/[^\d.-]/g, '')); + }, 0); + $(api.column(columnIndex).footer()).html(sum); + } + }); + // Function to calculate the total + function calculateTotal() { + var diesel = parseFloat($('input[data-column="diesel_amount"]').val()) || 0; + var shed = parseFloat($('input[data-column="shed_amount"]').val()) || 0; + var row = parseInt($('#rowTotalAmount').text()) || 0; + console.log(row); + + var total = row + diesel + shed; + $('#totalAmount').text(total); // Display the total with 2 decimal places + } + // Make the cells editable and calculate the total on input change + $(document).on('input', '.editable', function() { + calculateTotal(); + }); + $(document).on('blur', '.editable', function() { + var column = $(this).data('column'); // Get the column name (diesel or shed) + var value = $(this).val(); // Get the updated value + let gobal_driver_id = urlParams.get("gobal_driver_id"); + let gobal_date = urlParams.get("date"); + + // Send data to the server using AJAX + $.ajax({ + url: "updateDieselAndShedValuesBasedonEmpID", + method: 'POST', + data: { + column: column, + value: value, + date: gobal_date, + empid:gobal_driver_id + }, + success: function(response) { + console.log('Data saved successfully:', response); + }, + error: function(xhr, status, error) { + console.error('Error saving data:', error); } }); + }); + + // Initial calculation of the total + calculateTotal(); }); diff --git a/app/Views/driverListing.php b/app/Views/driverListing.php index f6cb32c8..184ad120 100755 --- a/app/Views/driverListing.php +++ b/app/Views/driverListing.php @@ -63,9 +63,7 @@     - -     - + diff --git a/app/Views/driverPayslipGeneratePrint (Copy).php b/app/Views/driverPayslipGeneratePrint (Copy).php new file mode 100755 index 00000000..0650169c --- /dev/null +++ b/app/Views/driverPayslipGeneratePrint (Copy).php @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + +
+
+ +
+ +
+
Resico (India) Pvt Ltd
196/4 B, 126, Mettupalayam Village, Sriperumbudur(Taluk), +
kancheepuram (Dist), Tamil Nadu, India - 631604.
PaySlip for the Month of PayOn ?>
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Name name; ?>
Designation
No Of Loads no_of_loads ?>
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
EarningsAmount
 Driver Monthly Salary Amount driver_monthly_salary_amount; ?> 
 Driver Monthly Food Amountdriver_monthly_food_amount; ?> 
 Diesel diesel ?> 
 Shed Duty Amount shed_duty_amount ?> 
Net Pay(Rounded)  driver_final_payment),2,'.','') ?> 
Total Amount In Words  
This is a computer generated document. This document does not require signature.
+ + \ No newline at end of file diff --git a/app/Views/driverPayslipGeneratePrint.php b/app/Views/driverPayslipGeneratePrint.php index 0650169c..a9cc7576 100755 --- a/app/Views/driverPayslipGeneratePrint.php +++ b/app/Views/driverPayslipGeneratePrint.php @@ -11,7 +11,7 @@ - +
Resico (India) Pvt Ltd
196/4 B, 126, Mettupalayam Village, Sriperumbudur(Taluk),
kancheepuram (Dist), Tamil Nadu, India - 631604.
PaySlip for the Month of PayOn ?>
@@ -23,24 +23,45 @@ Name -name; ?> +driver_name; ?> - - +Employee ID +EmpID ?> Designation - + Designation ?> - - +Department +DeptName ?> -No Of Loads - no_of_loads ?> +Date Of Joining + DOJ)) ?> - - +No Of Loads + no_of_loads ?> + + +Bank Name +BankName ?> + +PAN Number +Pan;?> + + +Bank Acc No + BankAccountNumber ?> + + Aadhar Number +AadharNo);?> + + +Bank IFSC +IFSCCode ?> + + + @@ -48,35 +69,61 @@ - + - - + + + + - - + + + + - - + + + + + + - - + + + + + + + + + + + + + + - - + + - - - + + + -
EarningsAmount
EarningsAmount DeductionsAmount
 Driver Monthly Salary Amount driver_monthly_salary_amount; ?>  Monthly Salarydriver_monthly_salary_amount; ?>  PF 
 Driver Monthly Food Amountdriver_monthly_food_amount; ?>  Dieseldiesel_amount; ?>  ESI  
 Diesel diesel ?>  Shed Duty Amountshed_amount; ?>   
 Shed Duty Amount shed_duty_amount ?>  BonusFestival_Bonus; ?>   
 Total Earning (Rounded) + driver_monthly_salary_amount + $PayDetails[0]->Festival_Bonus + $PayDetails[0]->diesel_amount + $PayDetails[0]->shed_amount; + echo number_format(round($totEarning),2) + ?> +  Total Deduction (Rounded) +
Net Pay(Rounded)  driver_final_payment),2,'.','') ?> 
Net Pay(Rounded)  driver_final_payment),2,'.','') ?> 
Total Amount In Words  
Total Amount In Words  
This is a computer generated document. This document does not require signature.
- - \ No newline at end of file + \ No newline at end of file diff --git a/app/Views/editrequisitionform.php b/app/Views/editrequisitionform.php index 0af694b4..1762c5ee 100755 --- a/app/Views/editrequisitionform.php +++ b/app/Views/editrequisitionform.php @@ -70,12 +70,12 @@ td { .th-requestedQuantity{ - text-align:center !important; + text-align:right !important; width:15%; } .th-PoQuantity{ - text-align:center !important; + text-align:right !important; width:15%; } @@ -85,7 +85,7 @@ td { } .th-uom{ - text-align:center !important; + text-align:left !important; width:10%; } @@ -226,9 +226,9 @@ td { MaterialCode; ?> MaterialName; ?> - UOM; ?> - Quantity; ?> - POQTY; ?> + UOM; ?> + Quantity; ?> + POQTY; ?> StatusName; ?> @@ -818,9 +818,9 @@ td { ${temp} ${materialCode} ${materialName} - ${uom} - ${quantity} - 0.00 + ${uom} + ${quantity} + 0.00 NEW diff --git a/app/Views/includes/new_header.php b/app/Views/includes/new_header.php index 2f08bd30..620cbf87 100755 --- a/app/Views/includes/new_header.php +++ b/app/Views/includes/new_header.php @@ -764,13 +764,13 @@