diff --git a/app/Controllers/Driver.php b/app/Controllers/Driver.php index 7ba0e211..6cc47a6d 100755 --- a/app/Controllers/Driver.php +++ b/app/Controllers/Driver.php @@ -150,11 +150,12 @@ class Driver extends BaseController public function loadDriverAttendance() { - $input_driver_id = $this->request->getGet('gobal_driver_id'); + $input_driver_id = $this->request->getGet('drv_id'); // $input_month_year = $this->request->getPost('month_year') ? $this->request->getPost('month_year') : get_date_time_dynamical_format('d-M-Y','d-m-',"01-"+$this->request->getGet('month_year')) ; - $input_date = $this->request->getGet('date') - ? $this->request->getGet('date') - : get_date_time_dynamical_format('d-M-Y','d-m-Y',"01-".$this->request->getGet('month_year')); + $input_date = $this->request->getGet('month_year') + ? get_date_time_dynamical_format('d-M-Y','d-m-Y',"01-".$this->request->getGet('month_year')) + : get_date_time_dynamical_format('Y-m-d','d-m-Y',get_current_date()); + list($date,$month,$year) = explode('-', $input_date); @@ -170,9 +171,9 @@ class Driver extends BaseController $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 ; + $data['input_driver_id'] = $input_driver_id; + $data['input_diesel_amount'] = isset($amount->diesel_amount) ? $amount->diesel_amount : 0 ; + $data['input_shed_amount'] = isset($amount->shed_amount) ? $amount->shed_amount : 0 ; $this->global['pageTitle'] = 'Driver Attendance List'; $this->loadViews("driverAttendance", $this->global, $data, NULL); @@ -209,8 +210,12 @@ class Driver extends BaseController $food = $this->request->getPost('food_amount'); $diesel = $this->request->getPost('diesel_amount'); $shed = $this->request->getPost('shed_amount'); + $ct = $this->request->getPost('category_type'); + $c = $this->request->getPost('customer'); + $q = $this->request->getPost('quantity'); + $data = ['status' => false, 'message' => 'An error occurred while creating driver Trip details']; - $driver_details = ['date' => $date,'driver_id' =>$driver_id,'invoice_number' =>$inv,'vehicle_number' =>$veh,'load_type' =>$load,'salary_amount' => $sal,'food_amount' =>$food,'diesel_amount'=> $diesel,'shed_amount' => $shed]; + $driver_details = ['date' => $date,'driver_id' =>$driver_id,'invoice_number' =>$inv,'vehicle_number' =>$veh,'load_type' =>$load,'salary_amount' => $sal,'food_amount' =>$food,'diesel_amount'=> $diesel,'shed_amount' => $shed,'type'=>$ct,'customer'=>$c,'quantity'=>$q]; if ((int)$id == 0) { log_message('error', 'LAST DriverID : ' . $id); @@ -239,7 +244,7 @@ class Driver extends BaseController */ function deleteDriverAttendance() { - $driverId = $this->request->getGet('gobal_driver_id') ? $this->request->getGet('gobal_driver_id') : ''; + $driverId = $this->request->getGet('drv_id') ? $this->request->getGet('drv_id') : ''; $driverAttendanceId = $this->request->getGet('driverAttendanceId') ? $this->request->getGet('driverAttendanceId') : ''; $monthyear = $this->request->getGet('month_year') ?? date('M-Y'); @@ -253,7 +258,7 @@ class Driver extends BaseController $this->session->setFlashdata('success', $message); // return redirect()->to(current_url()); // return redirect()->route('loadDriverAttendance'); - return redirect()->to(base_url('loadDriverAttendance?gobal_driver_id=' . $driverId . '&month_year=' . $monthyear)); + return redirect()->to(base_url('loadDriverAttendance?drv_id=' . $driverId . '&month_year=' . $monthyear)); } @@ -261,7 +266,13 @@ class Driver extends BaseController function gatheredCustAndQty(){ $data = $this->request->getPost(); $invoice = $data['invoiceNumber']; - $results = $this->driver_model->gatheredCustAndQty($invoice); + $type = $data['type']; + if($type == 'IGR'){ + $results = $this->driver_model->gatheredIgrCustAndQty($invoice); + }else if($type == 'INVOICE'){ + $results = $this->driver_model->gatheredInvoiceCustAndQty($invoice); + } + return $this->response->setJSON($results); } diff --git a/app/Models/Driver_model.php b/app/Models/Driver_model.php index 601d28a2..fc0d982a 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','diesel_amount','shed_amount']; + $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','type','customer','quantity']; return $this; } @@ -92,7 +92,7 @@ class Driver_model extends Model } - function gatheredCustAndQty($invoice){ + function gatheredInvoiceCustAndQty($invoice){ $builder = $this->db->table('ip_invoices') ->select('invoice_number,received_qty as quantity,ip_clients.client_name as customer') ->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id', 'left') @@ -100,8 +100,29 @@ class Driver_model extends Model $query = $builder->get(); return $query->getRowArray() ?: []; } + + function gatheredIgrCustAndQty($igr){ + + $builder = $this->db->table('t_igr_master as mstr') + ->select('mstr.IGRNO,mstr.DeliveryChellanOrInvoiceNo,sum(dtls.QuantityAsPerInvoice) as quantity,splr.supplierName as customer') + ->join('t_igr_details dtls', 'dtls.IGRNO = mstr.IGRNO', 'left') + ->join('t_purchaseorder_master pomstr', 'pomstr.PONO = mstr.PONO', 'left') + ->join('t_supplierdetailsn splr', 'splr.SupplierID = pomstr.SupplierID', 'left') + ->where('mstr.IGRNO', $igr); + $query = $builder->get(); + $result = $query->getRowArray(); + if (empty($result['IGRNO'])) { + return []; + }else{ + return $result ?: []; + } + + } function driverAttendanceForMonthlyPayInputs($from,$to){ + // list($year,$month,$date) = explode('-', get_current_date()); + // $new_date_format = "$year-$month-01"; + $builder = $this->db->table('t_driver_attendance') ->select('t_driver_attendance.driver_id,driver_details.FirstName as driver_name,driver_details.is_driver,COUNT(DISTINCT t_driver_attendance.date) AS unique_days, 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') @@ -115,6 +136,7 @@ class Driver_model extends Model ->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.'"') + // ->where("t_loan_master.Due_Start_Date", $new_date_format) ->groupBy('DATE_FORMAT(t_driver_attendance.date, "%M-%Y"),t_driver_attendance.driver_id'); $query = $builder->get(); // $last_query = $this->db->getLastQuery(); diff --git a/app/Views/driverAttendance.php b/app/Views/driverAttendance.php index 46ef4d79..78b67715 100755 --- a/app/Views/driverAttendance.php +++ b/app/Views/driverAttendance.php @@ -60,7 +60,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
- +
@@ -126,7 +126,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');     - +     @@ -244,7 +244,19 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
- + + +
+ + + + +
+
- -
-
- - - -
-
+
+
-
+
@@ -354,20 +360,20 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); $("#driver_name").val(""); let urlParams = new URLSearchParams(window.location.search); - let gobal_driver_id = urlParams.get("gobal_driver_id"); - if (gobal_driver_id !== null) { - $("#gobal_driver_id").val(gobal_driver_id); - $("#driver_id").val(gobal_driver_id); + let input_driver_id = urlParams.get("drv_id"); + if (input_driver_id !== null) { + $("#drv_id").val(input_driver_id); + $("#driver_id").val(input_driver_id); } else { - $("#gobal_driver_id").val(""); - $("#driver_id").val(""); + $("#drv_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); + let input_diesel_amount = ""; + let input_shed_amount = ""; + if(input_diesel_amount != '' || input_shed_amount != ''){ + $('input[data-column="diesel_amount"]').val(parseFloat(input_diesel_amount) || 0); + $('input[data-column="shed_amount"]').val(parseFloat(input_shed_amount) || 0); calculateTotal(); } @@ -443,13 +449,16 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); driver_attendance_id:$('#driver_attendance_id').val() ? $('#driver_attendance_id').val() : 0, date: $('#date').val(), driver_id: $('#driver_id').val(), + category_type: $('#category_type').val(), + customer: $('#customer').val(), + quantity: $('#quantity').val(), invoice_number: $('#invoice_number').val(), vehicle_number: $('#vehicle_number').val(), load_type: $('#load_type').val(), salary_amount: $('#salary_amount').val(), food_amount: $('#food_amount').val(), - diesel_amount: "", - shed_amount: "" + diesel_amount: "", + shed_amount: "" }; $('#loader').show(); @@ -552,8 +561,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); $(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 = ''; + let input_driver_id = urlParams.get("drv_id"); + let input_date = ''; let param_month_year = urlParams.get("month_year"); let param_date = urlParams.get("date"); @@ -561,10 +570,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); if(param_date == ""){ let monthMap = {"Jan": "01", "Feb": "02", "Mar": "03", "Apr": "04","May": "05", "Jun": "06", "Jul": "07", "Aug": "08","Sep": "09", "Oct": "10", "Nov": "11", "Dec": "12"}; let [month, year] = param_month_year.split('-'); - gobal_date = `01-${monthMap[month]}-${year}`; + input_date = `01-${monthMap[month]}-${year}`; }else{ - gobal_date = param_date; + input_date = param_date; } // Send data to the server using AJAX @@ -574,8 +583,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); data: { column: column, value: value, - date: gobal_date, - empid:gobal_driver_id + date: input_date, + empid:input_driver_id }, success: function(response) { console.log('Data saved successfully:', response); @@ -628,8 +637,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); var type = $('#load_type').val(); if (type == 'Load') { $('#salary_amount').val(1300); + $('#food_amount').val(100); } else if (type == 'Waste Core') { $('#salary_amount').val(1050); + $('#food_amount').val(100); } fetchSalary(); } @@ -643,20 +654,25 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); } function customerandquantity(){ - if ($('#invoice_number').val() === '') { + if ($('#category_type').val() === '') { + alert('Please Select the Valid Type'); + return; + } + else if ($('#invoice_number').val() === '') { alert('Please Enter the Valid Invoice Number'); return; }else{ - $.ajax({ type: 'POST', url: "gatheredCustAndQty", data: { - invoiceNumber : $('#invoice_number').val() + invoiceNumber : $('#invoice_number').val(), + type : $('#category_type').val() }, success: function (data) { console.log('got the result: ' + data); + console.log(data); if (data) { if(data == ""){ alert('Please Enter the Valid Invoice Number'); @@ -679,5 +695,11 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); } }); } - } + } + + function resetthefields(){ + $('#invoice_number').val(""); + $('#customer').val(""); + $('#quantity').val(""); + } diff --git a/app/Views/driverListing.php b/app/Views/driverListing.php index d03a6dca..157abc92 100755 --- a/app/Views/driverListing.php +++ b/app/Views/driverListing.php @@ -55,7 +55,7 @@ is_driver){ ?>     - +     diff --git a/app/Views/employeeListing.php b/app/Views/employeeListing.php index 7c160032..3aab43fd 100755 --- a/app/Views/employeeListing.php +++ b/app/Views/employeeListing.php @@ -138,7 +138,7 @@ EmpID ?> is_driver){ ?>     - +