driver changes + spelling mistake in key

This commit is contained in:
VE10-Sanjeev 2025-03-26 06:58:25 +00:00
parent 678178af7f
commit 6b8dba5cbc
5 changed files with 105 additions and 50 deletions

View File

@ -150,11 +150,12 @@ class Driver extends BaseController
public function loadDriverAttendance() 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_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') $input_date = $this->request->getGet('month_year')
? $this->request->getGet('date') ? get_date_time_dynamical_format('d-M-Y','d-m-Y',"01-".$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); 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['page_driver_name'] = $this->driver_model->getDriverName($input_driver_id,0);
$data['invoice_info'] = $this->driver_model->getInvoiceInfo(); $data['invoice_info'] = $this->driver_model->getInvoiceInfo();
$data['datefordropdown'] = $input_date; $data['datefordropdown'] = $input_date;
$data['gobal_driver_id'] = $input_driver_id; $data['input_driver_id'] = $input_driver_id;
$data['gobal_diesel_amount'] = isset($amount->diesel_amount) ? $amount->diesel_amount : 0 ; $data['input_diesel_amount'] = isset($amount->diesel_amount) ? $amount->diesel_amount : 0 ;
$data['gobal_shed_amount'] = isset($amount->shed_amount) ? $amount->shed_amount : 0 ; $data['input_shed_amount'] = isset($amount->shed_amount) ? $amount->shed_amount : 0 ;
$this->global['pageTitle'] = 'Driver Attendance List'; $this->global['pageTitle'] = 'Driver Attendance List';
$this->loadViews("driverAttendance", $this->global, $data, NULL); $this->loadViews("driverAttendance", $this->global, $data, NULL);
@ -209,8 +210,12 @@ class Driver extends BaseController
$food = $this->request->getPost('food_amount'); $food = $this->request->getPost('food_amount');
$diesel = $this->request->getPost('diesel_amount'); $diesel = $this->request->getPost('diesel_amount');
$shed = $this->request->getPost('shed_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']; $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) { if ((int)$id == 0) {
log_message('error', 'LAST DriverID : ' . $id); log_message('error', 'LAST DriverID : ' . $id);
@ -239,7 +244,7 @@ class Driver extends BaseController
*/ */
function deleteDriverAttendance() 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') : ''; $driverAttendanceId = $this->request->getGet('driverAttendanceId') ? $this->request->getGet('driverAttendanceId') : '';
$monthyear = $this->request->getGet('month_year') ?? date('M-Y'); $monthyear = $this->request->getGet('month_year') ?? date('M-Y');
@ -253,7 +258,7 @@ class Driver extends BaseController
$this->session->setFlashdata('success', $message); $this->session->setFlashdata('success', $message);
// return redirect()->to(current_url()); // return redirect()->to(current_url());
// return redirect()->route('loadDriverAttendance'); // 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(){ function gatheredCustAndQty(){
$data = $this->request->getPost(); $data = $this->request->getPost();
$invoice = $data['invoiceNumber']; $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); return $this->response->setJSON($results);
} }

View File

@ -21,7 +21,7 @@ class Driver_model extends Model
{ {
$this->table = 't_driver_attendance'; $this->table = 't_driver_attendance';
$this->primaryKey = 'driver_attendance_id'; $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; return $this;
} }
@ -92,7 +92,7 @@ class Driver_model extends Model
} }
function gatheredCustAndQty($invoice){ function gatheredInvoiceCustAndQty($invoice){
$builder = $this->db->table('ip_invoices') $builder = $this->db->table('ip_invoices')
->select('invoice_number,received_qty as quantity,ip_clients.client_name as customer') ->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') ->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id', 'left')
@ -100,8 +100,29 @@ class Driver_model extends Model
$query = $builder->get(); $query = $builder->get();
return $query->getRowArray() ?: []; 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){ 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') $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, ->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') 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_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') ->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_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'); ->groupBy('DATE_FORMAT(t_driver_attendance.date, "%M-%Y"),t_driver_attendance.driver_id');
$query = $builder->get(); $query = $builder->get();
// $last_query = $this->db->getLastQuery(); // $last_query = $this->db->getLastQuery();

View File

@ -60,7 +60,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<div class="col-4"> <div class="col-4">
<?php $today = date('M-Y'); ?> <?php $today = date('M-Y'); ?>
<input type="text" value="<?php echo $datefordropdown; ?>" name="month_year" class="form-control monthpicker" id="month_year"> <input type="text" value="<?php echo $datefordropdown; ?>" name="month_year" class="form-control monthpicker" id="month_year">
<input type="hidden" name="gobal_driver_id" id="gobal_driver_id" value="<?php echo $gobal_driver_id; ?>" > <input type="hidden" name="drv_id" id="drv_id" value="<?php echo $input_driver_id; ?>" >
</div> </div>
<div class="col-4"> <div class="col-4">
@ -126,7 +126,7 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<i class="fas fa-edit"></i>&nbsp;&nbsp;&nbsp; <i class="fas fa-edit"></i>&nbsp;&nbsp;&nbsp;
</a> </a>
<a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&gobal_driver_id='.esc($record['driver_id']).'&month_year='.esc($datefordropdown); ?>"> <a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&drv_id='.esc($record['driver_id']).'&month_year='.esc($datefordropdown); ?>">
<i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp; <i class="fa fa-trash"></i>&nbsp;&nbsp;&nbsp;
</a> </a>
@ -244,7 +244,19 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
</div> </div>
<div class="col-md-4"> <div class="col-md-4">
<label class="form" for="category_type">Category</label>
<select class="form-control" id="category_type" name="category_type" onchange="resetthefields();">
<option value="">Select</option>
<option value="IGR">IGR</option>
<option value="INVOICE">INVOICE</option>
</select>
</div>
</div>
<!-- second row -->
<div class="row mt-2">
<div class="col-md-4">
<label class="form" for="invoice_number">Invoice Number</label> <label class="form" for="invoice_number">Invoice Number</label>
<input type="text" class="form-control" id="invoice_number" name="invoice_number" onchange="customerandquantity();"> <input type="text" class="form-control" id="invoice_number" name="invoice_number" onchange="customerandquantity();">
<!-- <select class="form-control" id="invoice_number" name="invoice_number"> <!-- <select class="form-control" id="invoice_number" name="invoice_number">
@ -253,19 +265,13 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
<option value="<?= $value->invoice_id; ?>"> <?= $value->invoice_number; ?> </option> <option value="<?= $value->invoice_id; ?>"> <?= $value->invoice_number; ?> </option>
<?php } ?> <?php } ?>
</select> --> </select> -->
</div>
</div> <div class="col-md-4">
</div>
<!-- second row -->
<div class="row mt-2">
<div class="col-md-6">
<label class="form" for="customer">Customer</label> <label class="form" for="customer">Customer</label>
<input type="text" class="form-control" id="customer" name="customer" readonly> <input type="text" class="form-control" id="customer" name="customer" readonly>
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
<label class="form" for="quantity">Quantity</label> <label class="form" for="quantity">Quantity</label>
<input type="text" class="form-control" id="quantity" name="quantity" readonly> <input type="text" class="form-control" id="quantity" name="quantity" readonly>
</div> </div>
@ -354,20 +360,20 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
$("#driver_name").val("<?php echo $page_driver_name; ?>"); $("#driver_name").val("<?php echo $page_driver_name; ?>");
let urlParams = new URLSearchParams(window.location.search); let urlParams = new URLSearchParams(window.location.search);
let gobal_driver_id = urlParams.get("gobal_driver_id"); let input_driver_id = urlParams.get("drv_id");
if (gobal_driver_id !== null) { if (input_driver_id !== null) {
$("#gobal_driver_id").val(gobal_driver_id); $("#drv_id").val(input_driver_id);
$("#driver_id").val(gobal_driver_id); $("#driver_id").val(input_driver_id);
} }
else { else {
$("#gobal_driver_id").val("<?php echo $gobal_driver_id; ?>"); $("#drv_id").val("<?php echo $input_driver_id; ?>");
$("#driver_id").val("<?php echo $gobal_driver_id; ?>"); $("#driver_id").val("<?php echo $input_driver_id; ?>");
} }
let gobal_diesel_amount = "<?php echo $gobal_diesel_amount; ?>"; let input_diesel_amount = "<?php echo $input_diesel_amount; ?>";
let gobal_shed_amount = "<?php echo $gobal_shed_amount; ?>"; let input_shed_amount = "<?php echo $input_shed_amount; ?>";
if(gobal_diesel_amount != '' || gobal_shed_amount != ''){ if(input_diesel_amount != '' || input_shed_amount != ''){
$('input[data-column="diesel_amount"]').val(parseFloat(gobal_diesel_amount) || 0); $('input[data-column="diesel_amount"]').val(parseFloat(input_diesel_amount) || 0);
$('input[data-column="shed_amount"]').val(parseFloat(gobal_shed_amount) || 0); $('input[data-column="shed_amount"]').val(parseFloat(input_shed_amount) || 0);
calculateTotal(); calculateTotal();
} }
@ -443,13 +449,16 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
driver_attendance_id:$('#driver_attendance_id').val() ? $('#driver_attendance_id').val() : 0, driver_attendance_id:$('#driver_attendance_id').val() ? $('#driver_attendance_id').val() : 0,
date: $('#date').val(), date: $('#date').val(),
driver_id: $('#driver_id').val(), driver_id: $('#driver_id').val(),
category_type: $('#category_type').val(),
customer: $('#customer').val(),
quantity: $('#quantity').val(),
invoice_number: $('#invoice_number').val(), invoice_number: $('#invoice_number').val(),
vehicle_number: $('#vehicle_number').val(), vehicle_number: $('#vehicle_number').val(),
load_type: $('#load_type').val(), load_type: $('#load_type').val(),
salary_amount: $('#salary_amount').val(), salary_amount: $('#salary_amount').val(),
food_amount: $('#food_amount').val(), food_amount: $('#food_amount').val(),
diesel_amount: "<?php echo $gobal_diesel_amount; ?>", diesel_amount: "<?php echo $input_diesel_amount; ?>",
shed_amount: "<?php echo $gobal_shed_amount; ?>" shed_amount: "<?php echo $input_shed_amount; ?>"
}; };
$('#loader').show(); $('#loader').show();
@ -552,8 +561,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
$(document).on('blur', '.editable', function() { $(document).on('blur', '.editable', function() {
var column = $(this).data('column'); // Get the column name (diesel or shed) var column = $(this).data('column'); // Get the column name (diesel or shed)
var value = $(this).val(); // Get the updated value var value = $(this).val(); // Get the updated value
let gobal_driver_id = urlParams.get("gobal_driver_id"); let input_driver_id = urlParams.get("drv_id");
let gobal_date = ''; let input_date = '';
let param_month_year = urlParams.get("month_year"); let param_month_year = urlParams.get("month_year");
let param_date = urlParams.get("date"); let param_date = urlParams.get("date");
@ -561,10 +570,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
if(param_date == ""){ 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 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('-'); let [month, year] = param_month_year.split('-');
gobal_date = `01-${monthMap[month]}-${year}`; input_date = `01-${monthMap[month]}-${year}`;
}else{ }else{
gobal_date = param_date; input_date = param_date;
} }
// Send data to the server using AJAX // Send data to the server using AJAX
@ -574,8 +583,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
data: { data: {
column: column, column: column,
value: value, value: value,
date: gobal_date, date: input_date,
empid:gobal_driver_id empid:input_driver_id
}, },
success: function(response) { success: function(response) {
console.log('Data saved successfully:', response); console.log('Data saved successfully:', response);
@ -628,8 +637,10 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
var type = $('#load_type').val(); var type = $('#load_type').val();
if (type == 'Load') { if (type == 'Load') {
$('#salary_amount').val(1300); $('#salary_amount').val(1300);
$('#food_amount').val(100);
} else if (type == 'Waste Core') { } else if (type == 'Waste Core') {
$('#salary_amount').val(1050); $('#salary_amount').val(1050);
$('#food_amount').val(100);
} }
fetchSalary(); fetchSalary();
} }
@ -643,20 +654,25 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
} }
function customerandquantity(){ 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'); alert('Please Enter the Valid Invoice Number');
return; return;
}else{ }else{
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
url: "<?php echo base_url(); ?>gatheredCustAndQty", url: "<?php echo base_url(); ?>gatheredCustAndQty",
data: { data: {
invoiceNumber : $('#invoice_number').val() invoiceNumber : $('#invoice_number').val(),
type : $('#category_type').val()
}, },
success: function (data) { success: function (data) {
console.log('got the result: ' + data); console.log('got the result: ' + data);
console.log(data);
if (data) { if (data) {
if(data == ""){ if(data == ""){
alert('Please Enter the Valid Invoice Number'); 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("");
}
</script> </script>

View File

@ -55,7 +55,7 @@
<td> <td>
<?php if($record->is_driver){ ?> <?php if($record->is_driver){ ?>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<a title="Trip Details" style="cursor:pointer;" href="<?= base_url() . 'loadDriverAttendance?gobal_driver_id=' . $record->EmpID.'&date='.$cdate; ?>"> <a title="Trip Details" style="cursor:pointer;" href="<?= base_url() . 'loadDriverAttendance?drv_id=' . $record->EmpID; ?>">
<i class="fa fa-truck"></i>&nbsp;&nbsp;&nbsp; <i class="fa fa-truck"></i>&nbsp;&nbsp;&nbsp;
</a> </a>
<?php } ?> <?php } ?>

View File

@ -138,7 +138,7 @@
<td><a class="a_tag_link" href="<?php echo base_url() . 'employeedetails/ViewEmployee/?EmpID=' . $record->EmpID; ?>" data-toggle="tooltip" title="<?php echo $record->EmpID; ?> - Click here to view Employee details"><?php echo $record->EmpID ?> </a></u> <td><a class="a_tag_link" href="<?php echo base_url() . 'employeedetails/ViewEmployee/?EmpID=' . $record->EmpID; ?>" data-toggle="tooltip" title="<?php echo $record->EmpID; ?> - Click here to view Employee details"><?php echo $record->EmpID ?> </a></u>
<?php if($record->is_driver){ ?> <?php if($record->is_driver){ ?>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
<a title="Trip Details" style="cursor:pointer;" href="<?= base_url() . 'loadDriverAttendance?gobal_driver_id=' . $record->EmpID.'&date='.$cdate; ?>"> <a title="Trip Details" style="cursor:pointer;" href="<?= base_url() . 'loadDriverAttendance?drv_id=' . $record->EmpID; ?>">
<i class="fa fa-truck"></i>&nbsp;&nbsp;&nbsp; <i class="fa fa-truck"></i>&nbsp;&nbsp;&nbsp;
</a> </a>
<?php } ?> <?php } ?>