Merge branch 'new_theme' of bitbucket.org:venbainformationtechnology/ria into new_theme
This commit is contained in:
commit
67ba0ffce8
@ -77,6 +77,19 @@ $routes->get('deleteCostCenter', 'CostCenter::deleteCostCenter');
|
||||
$routes->post('checkCostCenter', 'CostCenter::checkCostCenter');
|
||||
$routes->get('exportcost', 'CostCenter::exportcost');
|
||||
|
||||
// Driver Routes
|
||||
$routes->get('DriverListing', 'Driver::index');
|
||||
$routes->post('fetchDriverDetails', 'Driver::fetchDriverDetails');// for Ajax both add and edit....
|
||||
$routes->get('reActivateDriver', 'Driver::reActivateDriver');
|
||||
$routes->get('deleteDriver', 'Driver::deleteDriver');
|
||||
$routes->post('checkDriver', 'Driver::checkDriver');
|
||||
|
||||
$routes->match(['GET', 'POST'], 'loadDriverAttendance', 'Driver::loadDriverAttendance');
|
||||
$routes->post('fetchDriverAttendanceDetails', 'Driver::fetchDriverAttendanceDetails');
|
||||
$routes->get('reActivateDriverAttendance', 'Driver::reActivateDriverAttendance');
|
||||
$routes->get('deleteDriverAttendance', 'Driver::deleteDriverAttendance');
|
||||
$routes->post('gatheredCustAndQty', 'Driver::gatheredCustAndQty');
|
||||
|
||||
// Asset Detail Routes
|
||||
$routes->get('assetListing', 'Assetdetails::assetListing');
|
||||
$routes->get('addasset', 'Assetdetails::addasset');
|
||||
|
||||
279
app/Controllers/Driver.php
Executable file
279
app/Controllers/Driver.php
Executable file
@ -0,0 +1,279 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\Driver_model;
|
||||
|
||||
|
||||
class Driver extends BaseController
|
||||
{
|
||||
protected $driver_model;
|
||||
protected $session;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->driver_model = new Driver_model();
|
||||
$this->session = session();
|
||||
helper('form');
|
||||
$this->isLoggedIn();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data['driver_list'] = $this->driver_model->useDriverTable()->getDriverList();
|
||||
$this->global['pageTitle'] = 'Driver List';
|
||||
$this->loadViews("driverListing", $this->global, $data, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used to add/edit driver details
|
||||
*/
|
||||
public function fetchDriverDetails() {
|
||||
|
||||
$id = $this->request->getPost('driver_id');
|
||||
log_message('error', 'driver_id: ' . $id);
|
||||
$Name = $this->request->getPost('driver_name');
|
||||
$Mobile = $this->request->getPost('driver_mobile');
|
||||
$userId = $this->session->get('userId');
|
||||
|
||||
|
||||
$data = ['status' => false, 'message' => 'An error occurred while creating driver details'];
|
||||
|
||||
if ((int)$id == 0) {
|
||||
log_message('error', 'LAST DriverID : ' . $id);
|
||||
$driver_details = [
|
||||
'driver_name' => $Name,
|
||||
'driver_mobile' => $Mobile,
|
||||
'created_by' => $userId,
|
||||
];
|
||||
$this->driver_model->useDriverTable()->insert($driver_details);
|
||||
$insertedId = $this->driver_model->insertID();
|
||||
if ($insertedId > 0) {
|
||||
$data = ['status' => true, 'message' => 'Successfully created driver details'];
|
||||
}
|
||||
} else {
|
||||
$driver_details = [
|
||||
'driver_id' => $id,
|
||||
'driver_name' => $Name,
|
||||
'driver_mobile' => $Mobile,
|
||||
'updated_by' => $userId,
|
||||
];
|
||||
$this->driver_model->useDriverTable()->update($id, $driver_details);
|
||||
|
||||
if ($this->driver_model->affectedRows() > 0) {
|
||||
$data = ['status' => true, 'message' => 'Successfully updated driver details'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* reactive the driver details isactive - 0 into 1
|
||||
*/
|
||||
public function reActivateDriver(){
|
||||
|
||||
$driverId = $_GET['driverId'];
|
||||
if(!empty($driverId)){
|
||||
$data = ['isactive' => 1,'updated_by' => $this->session->get('userId')];
|
||||
$this->driver_model->useDriverTable()->update($driverId, $data);
|
||||
if ($this->driver_model->affectedRows() > 0) {
|
||||
// $data = ['status' => true, 'message' => 'Successfully updated driver details'];
|
||||
$message = 'Successfully Updated Driver details';
|
||||
}
|
||||
}else{
|
||||
$message = "Driver details Not Avalable";
|
||||
}
|
||||
$this->session->setFlashdata('success', $message);
|
||||
return redirect()->route('DriverListing');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the driver details
|
||||
*/
|
||||
function deleteDriver($driverId = NULL)
|
||||
{
|
||||
|
||||
$driverId = $driverId ?? $_GET['driverId'];
|
||||
if(!empty($driverId)){
|
||||
$data = ['isactive' => 0,'updated_by' => $this->session->get('userId')];
|
||||
$this->driver_model->useDriverTable()->update($driverId, $data);
|
||||
$message = ($this->driver_model->affectedRows() > 0) ? "Driver Deleted Successfully." : "Driver already Deleted States";
|
||||
}else{
|
||||
$message = "Driver details Not Avalable";
|
||||
}
|
||||
$this->session->setFlashdata('success', $message);
|
||||
return redirect()->route('DriverListing');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check Driver mobile number Exsiting or not
|
||||
*/
|
||||
function checkDriver(){
|
||||
|
||||
$data = $this->request->getPost();
|
||||
|
||||
$Id = $data['DriverId'];
|
||||
$Mobile = $data['DriverMobile'];
|
||||
$mobile = str_replace(' ', '', $Mobile);
|
||||
$results = $this->driver_model->useDriverTable()
|
||||
->select('driver_mobile, driver_name, isactive')
|
||||
->where('driver_id !=', $Id)
|
||||
->where('REPLACE(driver_mobile, " ", "")', $mobile)
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
return $this->response->setJSON($results);
|
||||
}
|
||||
|
||||
public function loadDriverAttendance()
|
||||
{
|
||||
|
||||
|
||||
|
||||
// $input_driver_id = $this->request->getGet('driverId') ? $this->request->getGet('driverId') : '';
|
||||
$input_driver_id = $this->request->getPost('driver_id') ? $this->request->getPost('driver_id') : $this->request->getGet('driverId');
|
||||
// echo($input_driver_id);
|
||||
$input_month_year = $this->request->getPost('monthyear') ? $this->request->getPost('monthyear') : date('M-Y');
|
||||
list($month, $year) = explode('-', $input_month_year);
|
||||
|
||||
$month_in_number = get_date_time_dynamical_format('M','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");
|
||||
$indian_date = get_date_time_dynamical_format('d-m-Y','d-m-Y',"$get_last_date_of_the_month-$month_in_number-$year");
|
||||
$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['invoice_info'] = $this->driver_model->getInvoiceInfo();
|
||||
$data['datefordropdown'] = $input_month_year;
|
||||
$data['gobal_driver_id'] = $input_driver_id;
|
||||
|
||||
$this->global['pageTitle'] = 'Driver Attendance List';
|
||||
$this->loadViews("driverAttendance", $this->global, $data, NULL);
|
||||
}
|
||||
|
||||
public function fetchDriverAttendanceDetails(){
|
||||
$userId = $this->session->get('userId');
|
||||
|
||||
$id = $this->request->getPost('driver_attendance_id');
|
||||
$date = $this->request->getPost('date');
|
||||
$driver_id = $this->request->getPost('driver_id');
|
||||
$inv = $this->request->getPost('invoice_number');
|
||||
$veh = $this->request->getPost('vehicle_number');
|
||||
$load = $this->request->getPost('load_type');
|
||||
$sal = $this->request->getPost('salary_amount');
|
||||
$food = $this->request->getPost('food_amount');
|
||||
|
||||
|
||||
|
||||
$data = ['status' => false, 'message' => 'An error occurred while creating driver Trip details'];
|
||||
|
||||
if ((int)$id == 0) {
|
||||
log_message('error', 'LAST DriverID : ' . $id);
|
||||
$driver_details = [
|
||||
'date' => $date,
|
||||
'driver_id' =>$driver_id,
|
||||
'invoice_number' =>$inv,
|
||||
'vehicle_number' =>$veh,
|
||||
'load_type' =>$load,
|
||||
'salary_amount' => $sal,
|
||||
'food_amount' =>$food,
|
||||
'created_by' => $userId,
|
||||
];
|
||||
$this->driver_model->useDriverAttendanceTable()->insert($driver_details);
|
||||
$insertedId = $this->driver_model->insertID();
|
||||
if ($insertedId > 0) {
|
||||
$data = ['status' => true, 'message' => 'Successfully created driver Trip details'];
|
||||
}
|
||||
} else {
|
||||
$driver_details = [
|
||||
|
||||
'driver_attendance_id' => $id,
|
||||
'date' => $date,
|
||||
'driver_id' =>$driver_id,
|
||||
'invoice_number' =>$inv,
|
||||
'vehicle_number' =>$veh,
|
||||
'load_type' =>$load,
|
||||
'salary_amount' => $sal,
|
||||
'food_amount' =>$food,
|
||||
'updated_by' => $userId,
|
||||
];
|
||||
$this->driver_model->useDriverAttendanceTable()->update($id, $driver_details);
|
||||
|
||||
if ($this->driver_model->affectedRows() > 0) {
|
||||
$data = ['status' => true, 'message' => 'Successfully updated driver Trip details'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->response->setJSON($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* reactive the driver Attendance details isactive - 0 into 1
|
||||
*/
|
||||
public function reActivateDriverAttendance(){
|
||||
|
||||
$driverAttendanceId = $_GET['driverAttendanceId'];
|
||||
$driverId = $_GET['driverId'];
|
||||
if(!empty($driverAttendanceId)){
|
||||
$data = ['isactive' => 1,'updated_by' => $this->session->get('userId')];
|
||||
$this->driver_model->useDriverAttendanceTable()->update($driverAttendanceId, $data);
|
||||
if ($this->driver_model->affectedRows() > 0) {
|
||||
// $data = ['status' => true, 'message' => 'Successfully updated Driver Trip details'];
|
||||
$message = 'Successfully Updated Driver Trip details';
|
||||
}
|
||||
}else{
|
||||
$message = "Driver Trip details Not Avalable";
|
||||
}
|
||||
|
||||
|
||||
$this->session->setFlashdata('success', $message);
|
||||
return redirect()->to(current_url());
|
||||
// return redirect()->route('loadDriverAttendance');
|
||||
// return redirect()->to(base_url('loadDriverAttendance?driverId=' . $driverId));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* delete the driver Attendance details
|
||||
*/
|
||||
function deleteDriverAttendance()
|
||||
{
|
||||
$driverId = $this->request->getGet('driverId') ? $this->request->getGet('driverId') : '';
|
||||
$driverAttendanceId = $this->request->getGet('driverAttendanceId') ? $this->request->getGet('driverAttendanceId') : '';
|
||||
// echo "*****";
|
||||
// echo $driverAttendanceId."**";
|
||||
// echo "-------------";
|
||||
// die;
|
||||
if(!empty($driverAttendanceId)){
|
||||
$data = ['isactive' => 0,'updated_by' => $this->session->get('userId')];
|
||||
$this->driver_model->useDriverAttendanceTable()->update($driverAttendanceId, $data);
|
||||
$message = ($this->driver_model->affectedRows() > 0) ? "Driver Trip Deleted Successfully." : "Driver Trip already Deleted States";
|
||||
}else{
|
||||
$message = "Driver Trip details Not Avalable";
|
||||
}
|
||||
$this->session->setFlashdata('success', $message);
|
||||
// return redirect()->to(current_url());
|
||||
return redirect()->route('loadDriverAttendance');
|
||||
// return redirect()->to(base_url('loadDriverAttendance?driverId=' . $driverId));
|
||||
|
||||
}
|
||||
|
||||
function gatheredCustAndQty(){
|
||||
$data = $this->request->getPost();
|
||||
$invoice = $data['invoiceNumber'];
|
||||
$results = $this->driver_model->gatheredCustAndQty($invoice);
|
||||
return $this->response->setJSON($results);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -400,9 +400,9 @@ class Inwardgateregister extends BaseController
|
||||
$IsThisOpenOrderPO = $this->request->getPost('hiddenIsOpenOrder');
|
||||
$DeliveryChellanOrInvoiceNo = $this->request->getPost('InvoiceNo');
|
||||
$DeliveryChellan = (string)$this->request->getPost('InvoiceDate');
|
||||
$DeliveryChellanDate = get_date_time_dynamical_format('d-m-Y',$DeliveryChellan);
|
||||
$DeliveryChellanDate = get_date_time_dynamical_format('d-m-Y','',$DeliveryChellan);
|
||||
$Mat_Rcvd_Dt = (string)$this->request->getPost('MaterialRcvdDate');
|
||||
$MaterialRcvdDt = get_date_time_dynamical_format('d-m-Y',$Mat_Rcvd_Dt);
|
||||
$MaterialRcvdDt = get_date_time_dynamical_format('d-m-Y','',$Mat_Rcvd_Dt);
|
||||
$VehicleNo = $this->request->getPost('VehicleNo');
|
||||
$TransporterId = $this->request->getPost('TransporterId');
|
||||
$DriverName = $this->request->getPost('DriverName');
|
||||
|
||||
@ -33,10 +33,14 @@ if (!function_exists('get_date_time_format')) {
|
||||
}
|
||||
|
||||
if (!function_exists('get_date_time_dynamical_format')) {
|
||||
function get_date_time_dynamical_format($format,$val)
|
||||
{
|
||||
$date = \DateTime::createFromFormat($format, $val, new \DateTimeZone('Asia/Kolkata'));
|
||||
return $date->format('Y-m-d H:i:s');
|
||||
function get_date_time_dynamical_format($inputformat, $outputformat, $val)
|
||||
{
|
||||
$format = !empty($outputformat) ? $outputformat : 'Y-m-d H:i:s';
|
||||
$date = \DateTime::createFromFormat($inputformat, $val, new \DateTimeZone('Asia/Kolkata'));
|
||||
if (!$date) {
|
||||
return "Invalid Date: $val (Expected format: $inputformat)";
|
||||
}
|
||||
return $date->format($format);
|
||||
}
|
||||
}
|
||||
|
||||
@ -257,6 +261,7 @@ if (!function_exists('get_pre_financial_years')) {
|
||||
return $fiscalYears;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!function_exists('generate_pos_number')) {
|
||||
|
||||
96
app/Models/Driver_model.php
Executable file
96
app/Models/Driver_model.php
Executable file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
namespace App\Models;
|
||||
|
||||
use CodeIgniter\Model;
|
||||
|
||||
class Driver_model extends Model
|
||||
{
|
||||
protected $table;
|
||||
protected $primaryKey;
|
||||
protected $allowedFields;
|
||||
|
||||
public function useDriverTable()
|
||||
{
|
||||
$this->table = 't_driver';
|
||||
$this->primaryKey = 'driver_id';
|
||||
$this->allowedFields = ['driver_id', 'driver_name', 'driver_mobile','created_on','created_by','updated_on','updated_by','isactive'];
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function useDriverAttendanceTable()
|
||||
{
|
||||
$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'];
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDriverList()
|
||||
{
|
||||
if (empty($this->allowedFields)) { return []; }
|
||||
$fields = implode(', ', array_map(function($field) {
|
||||
return $this->table . '.' . $field;
|
||||
}, $this->allowedFields));
|
||||
|
||||
|
||||
$selectFields = "CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName, t_employee_details.IsActive as employee_isactive, " . $fields;
|
||||
|
||||
return $this->select($selectFields)
|
||||
->join('tbl_users', 'tbl_users.userId = ' . $this->table . '.created_by', 'left')
|
||||
->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left')
|
||||
->findAll();
|
||||
}
|
||||
|
||||
public function getDriverAttendanceList($driver_id,$from,$to){
|
||||
if (empty($this->allowedFields)) { return []; }
|
||||
$fields = implode(', ', array_map(function($field) {
|
||||
return $this->table . '.' . $field;
|
||||
}, $this->allowedFields));
|
||||
|
||||
$selectFields = "CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName, t_employee_details.IsActive as employee_isactive, t_driver.driver_name,ip_clients.client_name as customer,ip_invoices.received_qty as quantity," . $fields;
|
||||
|
||||
return $this->select($selectFields)
|
||||
->join('t_driver', 't_driver.driver_id = ' . $this->table . '.driver_id', 'left')
|
||||
->join('tbl_users', 'tbl_users.userId = ' . $this->table . '.created_by', 'left')
|
||||
->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left')
|
||||
->join('ip_invoices', 'ip_invoices.invoice_number = ' . $this->table . '.invoice_number', 'left')
|
||||
->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id', 'left')
|
||||
->where($this->table.'.date BETWEEN "'.$from.'" AND "'.$to.'"')
|
||||
->where($this->table . '.driver_id', $driver_id)
|
||||
->findAll();
|
||||
|
||||
}
|
||||
function getInvoiceInfo()
|
||||
{
|
||||
$builder = $this->db->table('ip_invoices')
|
||||
->select('invoice_number,invoice_id');
|
||||
$query = $builder->get();
|
||||
return $query->getResult();
|
||||
}
|
||||
|
||||
function getDriverName($id)
|
||||
{
|
||||
$builder = $this->db->table('t_driver')
|
||||
->select('driver_name')
|
||||
->where('driver_id', $id);
|
||||
|
||||
$query = $builder->get()->getRow();
|
||||
|
||||
$driver_name = $query ? $query->driver_name : null;
|
||||
|
||||
return $driver_name;
|
||||
}
|
||||
|
||||
function gatheredCustAndQty($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')
|
||||
->where('invoice_number', $invoice);
|
||||
$query = $builder->get();
|
||||
return $query->getRowArray() ?: [];
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
@ -416,10 +416,22 @@ class Inwardgateregister_model extends Model
|
||||
->join('t_transporter trans', 'igr.TransporterId = trans.id', 'left')
|
||||
->join('t_igr_details IGRD', 'igr.IGRNo = IGRD.IGRNo')
|
||||
->where('igr.IGRStatus !=', MRIR_CREATED)
|
||||
->where('Date(igr.CreatedDate) >=', "$fromDate")
|
||||
->where('Date(igr.CreatedDate) <=', "$toDate")
|
||||
->groupBy('IGRD.IGRNo')
|
||||
->orderBy('igr.CreatedDate', 'desc');
|
||||
->groupBy('IGRD.IGRNo');
|
||||
if(session()->get('roleText') == 'Auditor'){
|
||||
|
||||
$builder->where('Date(igr.DeliveryChellanDate) >=', "$fromDate")
|
||||
->where('Date(igr.DeliveryChellanDate) <=', "$toDate")
|
||||
->orderBy('igr.DeliveryChellanDate', 'desc');
|
||||
}else{
|
||||
$builder->where('Date(igr.CreatedDate) >=', "$fromDate")
|
||||
->where('Date(igr.CreatedDate) <=', "$toDate")
|
||||
->orderBy('igr.CreatedDate', 'desc');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$query = $builder->get();
|
||||
$result = $query->getResult();
|
||||
|
||||
519
app/Views/driverAttendance.php
Executable file
519
app/Views/driverAttendance.php
Executable file
@ -0,0 +1,519 @@
|
||||
<?php
|
||||
$datefordropdown = format_date($datefordropdown, 0, 'M-Y');
|
||||
?>
|
||||
<style>
|
||||
|
||||
|
||||
</style>
|
||||
<script>
|
||||
$('html').bind('keypress', function(e) {
|
||||
//alert('Key Pressed');
|
||||
if (e.keyCode == 13) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.num {
|
||||
text-align: right;
|
||||
}
|
||||
</style>
|
||||
<div class="content-wrapper"></div>
|
||||
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Driver</a></li>
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Driver Attendance</a></li>
|
||||
<li class="breadcrumb-item active">
|
||||
<h4 class="page-title"><?php echo $page_driver_name;?></h4>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="box">
|
||||
<div class="box-header">
|
||||
<div class="box-tools"></div>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<form action="<?= base_url('loadDriverAttendance'); ?>" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<?php $today = date('M-Y'); ?>
|
||||
<input type="text" name="monthyear" id="monthyear" value="<?php echo $datefordropdown; ?>" class="form-control" data-provide="datepicker" data-date-format="M-yyyy" data-date-min-view-mode="1">
|
||||
<input type="hidden" name="gobal_driver_id" id="gobal_driver_id" value="<?php echo $gobal_driver_id; ?>" >
|
||||
</div>
|
||||
|
||||
<div class="col-4">
|
||||
<input type="submit" value="Change Month" class="btn btn-success" style="margin-top:0px;">
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<h4><strong><?php echo $page_driver_name." ( ".$datefordropdown." )"; ?></strong></h4>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="col-4 text-right" id="savebutton">
|
||||
<button type="button" style="margin-top:0px;" class="btn btn-success" data-target="#attendanceModal" data-id="0" data-toggle="modal">
|
||||
Add Trip details
|
||||
</button>
|
||||
</div>
|
||||
</div></br>
|
||||
|
||||
<div class="table-responsive" style="overflow-x:scroll;">
|
||||
<table id="driver_att_listing" class="table dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Create Date</th>
|
||||
<th>Create By</th>
|
||||
<th>Driver Name</th>
|
||||
<th>Date</th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Vehicle Number</th>
|
||||
<th>Salary Amount</th>
|
||||
<th>Food Amount</th>
|
||||
<th>Load Type</th>
|
||||
<th>Customer</th>
|
||||
<th>Quantity</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (!empty($driver_attendance_list)) :
|
||||
foreach ($driver_attendance_list as $record) {
|
||||
$createdat = new DateTime($record['created_on']);
|
||||
$date = $createdat->format('d-m-Y');
|
||||
$time = $createdat->format('h:i A');
|
||||
$attendancedate = new DateTime($record['date']);
|
||||
$attdate = $attendancedate->format('d-m-Y');
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?= esc($date) ?></td>
|
||||
<td><?= esc($record['FullName']) ?></td>
|
||||
<td><?= esc($record['driver_name']) ?></td>
|
||||
<td><?= esc($attdate) ?></td>
|
||||
<td><?= esc($record['invoice_number']) ?></td>
|
||||
<td><?= esc($record['vehicle_number']) ?></td>
|
||||
<td><?= esc($record['salary_amount']) ?></td>
|
||||
<td><?= esc($record['food_amount']) ?></td>
|
||||
<td><?= esc($record['load_type']) ?></td>
|
||||
<td><?= esc($record['customer']) ?></td>
|
||||
<td><?= esc($record['quantity']) ?></td>
|
||||
<td><?= $record['isactive'] == 1 ? 'Active' : 'InActive' ?></td>
|
||||
<td><?php if ($record['isactive'] == 0) { ?>
|
||||
|
||||
<?php }else{ ?>
|
||||
<a data-toggle="modal" href="#attendanceModal" data-arr='<?php echo json_encode($record); ?>' data-id='<?= esc($record['driver_attendance_id']) ?>'>
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
</a>
|
||||
<!-- <a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&driverId='.esc($record['driver_id']); ?>">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a> -->
|
||||
</a>
|
||||
<!-- <a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriverAttendance?driverAttendanceId=' . esc($record['driver_attendance_id']).'&driverId='.esc($record['driver_id']); ?>">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a> -->
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
<p> </p>
|
||||
<div class="row">
|
||||
<!-- <div class="col-md-12 text-right" id="savebutton">
|
||||
<input type="button" id="submit" value="Save" class="btn btn-success"
|
||||
onclick="getAllData();">
|
||||
</div> -->
|
||||
</div>
|
||||
</div><!-- /.box-body -->
|
||||
|
||||
</div><!-- /.box -->
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- container -->
|
||||
</div> <!-- content -->
|
||||
</div>
|
||||
|
||||
<!-- attendance entries modal -->
|
||||
<div class="modal fade" id="attendanceModal" tabindex="-1" role="dialog" aria-labelledby="attendanceTitle" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl" style="width:900px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="attendanceTitle">Add Attendance</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<form id="attendanceForm" class="form-horizontal" role="form">
|
||||
<!--first row -->
|
||||
<input type="hidden" class="form-control" id="driver_attendance_id" name="driver_attendance_id">
|
||||
<input type="hidden" class="form-control" id="driver_id" name="driver_id">
|
||||
<?php $calendarStartDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('first day of this month')->format('Y-m-d');?>
|
||||
<?php $calendarEndDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('last day of this month')->format('Y-m-d');?>
|
||||
<?php $calendarCurrDate = DateTime::createFromFormat('M-Y', $datefordropdown)->modify('today')->format('Y-m-d');?>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<label class="form" for="date">Date</label>
|
||||
<input type="date" class="form-control" id="date" name="date" value="<?= $calendarCurrDate?>" min="<?= $calendarStartDate?>" max="<?= $calendarEndDate?>" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form" for="driver_name">Driver Name</label>
|
||||
<input type="text" class="form-control" id="driver_name" name="driver_name" readonly>
|
||||
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
|
||||
<label class="form" for="invoice_number">Invoice Number</label>
|
||||
<input type="text" class="form-control" id="invoice_number" name="invoice_number" onchange="customerandquantity();">
|
||||
<!-- <select class="form-control" id="invoice_number" name="invoice_number">
|
||||
<option value="">Select</option>
|
||||
<?php foreach ($invoice_info as $key => $value) { ?>
|
||||
<option value="<?= $value->invoice_id; ?>"> <?= $value->invoice_number; ?> </option>
|
||||
<?php } ?>
|
||||
</select> -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- second row -->
|
||||
<div class="row mt-2">
|
||||
<div class="col-md-6">
|
||||
<label class="form" for="customer">Customer</label>
|
||||
<input type="text" class="form-control" id="customer" name="customer" readonly>
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form" for="quantity">Quantity</label>
|
||||
<input type="text" class="form-control" id="quantity" name="quantity" readonly>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt-2">
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form" for="vehicle_number">Vechile Number</label>
|
||||
<input type="text" class="form-control" id="vehicle_number" name="vehicle_number">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label class="form" for="load_type">Load Type</label>
|
||||
<select class="form-control" id="load_type" name="load_type" onchange="salary();">
|
||||
<option value="">Select</option>
|
||||
<option value="Load">Load</option>
|
||||
<option value="Waste Core">Waste Core</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- third row -->
|
||||
<div class="row mt-2">
|
||||
<div class="col-md-4">
|
||||
<label class="form" for="salary_amount">Salary Amount</label>
|
||||
<input type="text" class="form-control" id="salary_amount" name="salary_amount" onkeypress="return isNumber(event);" onchange="salary();">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form" for="food_amount">Food Amount</label>
|
||||
<input type="text" class="form-control" id="food_amount" name="food_amount" onkeypress="return isNumber(event);" onchange="salary();">
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form" for="food_amount">Total Amount</label>
|
||||
<input type="text" class="form-control" id="total_amount" name="total_amount" onkeypress="return isNumber(event);" readonly>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal"
|
||||
value="Cancel">Cancel</button>
|
||||
<button type="button" class="btn btn-info waves-effect waves-light tempClick"
|
||||
id="tempClick">Submit</button>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$('#monthyear').attr('class', 'form-control');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
|
||||
$("#driver_name").val("<?php echo $page_driver_name; ?>");
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
let gobal_driver_id = urlParams.get("driverId");
|
||||
if (gobal_driver_id !== null) {
|
||||
$("#gobal_driver_id").val(gobal_driver_id);
|
||||
$("#driver_id").val(gobal_driver_id);
|
||||
}
|
||||
else {
|
||||
$("#gobal_driver_id").val("<?php echo $gobal_driver_id; ?>");
|
||||
$("#driver_id").val("<?php echo $gobal_driver_id; ?>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
$("#attendanceModal").on("shown.bs.modal", function (e) {
|
||||
|
||||
var id = $(e.relatedTarget).data('id');
|
||||
let fields = ['invoice_number', 'vehicle_number', 'load_type', 'salary_amount', 'food_amount','customer','quantity'];
|
||||
|
||||
fields.forEach(function(field) {
|
||||
$("#" + field).val("");
|
||||
});
|
||||
|
||||
if (id == 0) {
|
||||
$('#attendanceTitle').html("Add Driver Trip");
|
||||
$("#driver_attendance_id").val(0);
|
||||
} else {
|
||||
$("#driver_attendance_id").val(id);
|
||||
var arr = $(e.relatedTarget).data('arr');
|
||||
|
||||
fields.forEach(function(field) {
|
||||
$("#" + field).val(arr && arr[field] ? arr[field] : "");
|
||||
if(field == 'date'){
|
||||
$("#date").val(arr && arr['date']);
|
||||
}
|
||||
if(field == 'driver_id'){
|
||||
$("#driver_id").val(arr && arr['driver_id']);
|
||||
}
|
||||
if(field == 'salary_amount' || field == 'food_amount') {
|
||||
var ttl = parseFloat(arr['salary_amount']) + parseFloat(arr['food_amount']);
|
||||
$('#total_amount').val(ttl.toFixed(2));
|
||||
}
|
||||
});
|
||||
$('#attendanceTitle').html("Edit Driver Trip");
|
||||
}
|
||||
});
|
||||
$('#tempClick').click(function () {
|
||||
|
||||
if ($('#invoice_number').val() === '') {
|
||||
alert('Please Enter the Valid Invoice Number');
|
||||
return;
|
||||
}
|
||||
if ($('#food_amount').val() === '') {
|
||||
alert('Please Enter the Food Amount');
|
||||
return;
|
||||
}
|
||||
if ($('#customer').val() === '') {
|
||||
alert('Please Enter the Valid Invoice Number because Customer Value Not Fetched');
|
||||
return;
|
||||
}
|
||||
if ($('#quantity').val() === '') {
|
||||
alert('Please Enter the Valid Invoice Number because Quantity Value Not Fetched');
|
||||
return;
|
||||
}
|
||||
|
||||
if ($('#load_type').val() === '') {
|
||||
alert('Please Select the Load Type');
|
||||
return;
|
||||
}
|
||||
if ($('#salary_amount').val() === '') {
|
||||
alert('Please Enter Salary Amount');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var formData = {
|
||||
driver_attendance_id:$('#driver_attendance_id').val() ? $('#driver_attendance_id').val() : 0,
|
||||
date: $('#date').val(),
|
||||
driver_id: $('#driver_id').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(),
|
||||
};
|
||||
|
||||
console.log(formData);
|
||||
$('#loader').show();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "<?php echo base_url(); ?>fetchDriverAttendanceDetails",
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
$('#loader').hide();
|
||||
|
||||
if (response.status) {
|
||||
alert(response.message);
|
||||
// $('#ddwizard').modal('hide');
|
||||
location.reload();
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
$('#loader').hide();
|
||||
console.error('An error occurred: ' + error);
|
||||
},
|
||||
complete: function () {
|
||||
$('#loader').hide();
|
||||
console.log("ajax call completed");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
$.fn.dataTable.ext.type.order['date-eu-pre'] = function (date) {
|
||||
var dateSplit = date.split('-');
|
||||
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
|
||||
};
|
||||
|
||||
// Initialize the DataTable
|
||||
var table = $('#driver_att_listing').DataTable({
|
||||
dom: 'Blfrtip',
|
||||
buttons: [
|
||||
'excel', 'pdf'
|
||||
],
|
||||
pageLength: 10,
|
||||
lengthMenu: [
|
||||
[10, 20, 30, 50, -1],
|
||||
[10, 20, 30, 50, "All"]
|
||||
],
|
||||
responsive: false,
|
||||
order: false,
|
||||
language: {
|
||||
paginate: {
|
||||
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
||||
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
$(window).on('load', function () {
|
||||
function flashMessage() {
|
||||
|
||||
// Fetch the flash data from PHP and encode it for JavaScript
|
||||
let message = <?= json_encode(session()->getFlashdata('success')) ?>;
|
||||
if (message) {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
flashMessage();
|
||||
|
||||
})
|
||||
|
||||
|
||||
function confirmDelete(event) {
|
||||
let result = confirm(` Do you Confirm to Delete the Driver Trip Detail?`);
|
||||
if (result) { return result; } else { event.preventDefault(); }
|
||||
}
|
||||
|
||||
function confirmReActivate(event) {
|
||||
let result = confirm(` Do you Confirm to Re-activate the Driver Trip Detail?`);
|
||||
if (result) { return result; } else { event.preventDefault(); }
|
||||
}
|
||||
|
||||
function salary() {
|
||||
|
||||
var type = $('#load_type').val();
|
||||
|
||||
if(type == 'Load'){
|
||||
var value = parseFloat(1300);
|
||||
$('#salary_amount').val(value);
|
||||
}else if(type == 'Waste Core'){
|
||||
var value = parseFloat(1050);
|
||||
$('#salary_amount').val(value);
|
||||
}
|
||||
var sa = parseFloat($('#salary_amount').val()) || 0;
|
||||
var fa = parseFloat($('#food_amount').val()) || 0;
|
||||
var ttl = sa + fa;
|
||||
|
||||
$('#total_amount').val(ttl.toFixed(2));
|
||||
|
||||
}
|
||||
|
||||
function customerandquantity(){
|
||||
if ($('#invoice_number').val() === '') {
|
||||
alert('Please Enter the Valid Invoice Number');
|
||||
return;
|
||||
}else{
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "<?php echo base_url(); ?>gatheredCustAndQty",
|
||||
data: {
|
||||
invoiceNumber : $('#invoice_number').val()
|
||||
},
|
||||
success: function (data) {
|
||||
console.log('got the result: ' + data);
|
||||
if (data) {
|
||||
$('#customer').val(data['customer']);
|
||||
$('#quantity').val(data['quantity']);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
console.log('An error occurred: ' + error);
|
||||
},
|
||||
complete: function () {
|
||||
console.log("ajax call completed");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
307
app/Views/driverListing.php
Executable file
307
app/Views/driverListing.php
Executable file
@ -0,0 +1,307 @@
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
<!-- Start Content-->
|
||||
<div class="container-fluid">
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
<div class="page-title-box page-title-box-alt">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
<li class="breadcrumb-item"><a href="javascript: void(0);">Master Details</a></li>
|
||||
<li class="breadcrumb-item active">
|
||||
<h4 class="page-title">Driver Details</h4>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<a data-toggle="modal" href="#ddwizard" data-id="0" data-name="" class="btn btn-success">Add Driver Details </a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
|
||||
<div class="card-body" style="overflow-x:scroll;">
|
||||
|
||||
<table id="driver_listing" class="table dt-responsive nowrap w-100">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Create Date</th>
|
||||
<th>Driver Name</th>
|
||||
<th>Driver Mobile </th>
|
||||
<th>Create By</th>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if (!empty($driver_list)) :
|
||||
foreach ($driver_list as $record) {
|
||||
$createdat = new DateTime($record['created_on']);
|
||||
$date = $createdat->format('d-m-Y');
|
||||
$time = $createdat->format('h:i A');
|
||||
?>
|
||||
<tr>
|
||||
<td><?= esc($date) ?></td>
|
||||
<td><?= esc($record['driver_name']) ?></td>
|
||||
<td><?= esc($record['driver_mobile']) ?></td>
|
||||
<td><?= esc($record['FullName']) ?></td>
|
||||
<td><?= $record['isactive'] == 1 ? 'Active' : 'InActive' ?></td>
|
||||
<td><?php if ($record['isactive'] == 0) { ?>
|
||||
<a onclick="confirmReActivate(event)" style="cursor:pointer;" href="<?php echo base_url() . 'reActivateDriver?driverId=' . esc($record['driver_id']); ?>">
|
||||
<i class="fa fa-key" style="color:#02a8b5;"></i>
|
||||
</a>
|
||||
<?php }else{ ?>
|
||||
<a data-toggle="modal" href="#ddwizard" data-id="<?php echo $record['driver_id']; ?>" data-name="<?php echo $record['driver_name']; ?>" data-mobile="<?php echo $record['driver_mobile']; ?>">
|
||||
<i class="fas fa-edit"></i>
|
||||
</a>
|
||||
<a onclick="confirmDelete(event)" style="cursor:pointer;" href="<?php echo base_url() . 'deleteDriver?driverId=' . $record['driver_id']; ?>">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
<a style="cursor:pointer;" href="<?= base_url() . 'loadDriverAttendance?driverId=' . $record['driver_id']; ?>">
|
||||
<i class="fas fa-user-clock"></i>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div> <!-- end card body-->
|
||||
</div> <!-- end card -->
|
||||
</div><!-- end col-->
|
||||
</div>
|
||||
|
||||
</div> <!-- container -->
|
||||
</div> <!-- content -->
|
||||
</div>
|
||||
<!-- for Add and edit Modal -->
|
||||
<div id="ddwizard" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
|
||||
style="display: none;">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title"></h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body p-4">
|
||||
<form id="transporterForm" class="form-horizontal" role="form">
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-2">
|
||||
<label class="col-form-label">Drive Name: </label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="driver_name" id="driver_name" class="form-control">
|
||||
<input type="hidden" name="driver_id" id="driver_id" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-2">
|
||||
<label class="col-form-label">Drive Mobile: </label>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="driver_mobile" id="driver_mobile" class="form-control" onkeypress="return isNumber(event);" maxlength="10">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary waves-effect" data-dismiss="modal"
|
||||
value="Cancel">Cancel</button>
|
||||
<button type="button" class="btn btn-info waves-effect waves-light tempClick"
|
||||
id="tempClick">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.modal -->
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#ddwizard").on("shown.bs.modal", function (e) {
|
||||
var id = $(e.relatedTarget).data('id');
|
||||
var name = $(e.relatedTarget).data('name');
|
||||
var mobile = $(e.relatedTarget).data('mobile');
|
||||
$('#driver_name').val('');
|
||||
$('#driver_mobile').val('');
|
||||
$('#driver_id').val(id);
|
||||
if (id == 0) {
|
||||
$('.modal-title').html("Add Driver");
|
||||
} else {
|
||||
$('.modal-title').html("Edit Driver");
|
||||
$('#driver_name').val(name);
|
||||
$('#driver_mobile').val(mobile);
|
||||
}
|
||||
});
|
||||
|
||||
$('#tempClick').click(function () {
|
||||
if ($('#driver_name').val() === '') {
|
||||
alert('Please Enter the Driver Name');
|
||||
return;
|
||||
}
|
||||
if ($('#driver_mobile').val() === '') {
|
||||
alert('Please Enter the Driver Mobile');
|
||||
return;
|
||||
}
|
||||
|
||||
var formData = {
|
||||
driver_id: $('#driver_id').val(),
|
||||
driver_name: $('#driver_name').val(),
|
||||
driver_mobile: $('#driver_mobile').val(),
|
||||
};
|
||||
|
||||
console.log(formData);
|
||||
$('#loader').show();
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "<?php echo base_url(); ?>checkDriver",
|
||||
data: {
|
||||
DriverId : $('#driver_id').val(),
|
||||
DriverMobile: $('#driver_mobile').val().trim()
|
||||
},
|
||||
success: function (data) {
|
||||
$('#loader').hide();
|
||||
let isactive =data[0]?.isactive;
|
||||
|
||||
if (data && data.length > 0) {
|
||||
|
||||
if(isactive == 1){
|
||||
alert("Mobile Number Exists..!!");
|
||||
}else{
|
||||
alert("Mobile NUmber Existing in the deleted section ..!!");
|
||||
}
|
||||
$('#ddwizard').modal('hide');
|
||||
|
||||
} else {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: "<?php echo base_url(); ?>fetchDriverDetails",
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function (response) {
|
||||
$('#loader').hide();
|
||||
|
||||
if (response.status) {
|
||||
alert(response.message);
|
||||
$('#ddwizard').modal('hide');
|
||||
location.reload();
|
||||
} else {
|
||||
alert(response.message);
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
$('#loader').hide();
|
||||
console.error('An error occurred: ' + error);
|
||||
},
|
||||
complete: function () {
|
||||
$('#loader').hide();
|
||||
console.log("ajax call completed");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
error: function (xhr, status, error) {
|
||||
$('#loader').hide();
|
||||
console.error('An error occurred: ' + error);
|
||||
},
|
||||
complete: function () {
|
||||
$('#loader').hide();
|
||||
console.log("ajax call completed");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$.fn.dataTable.ext.type.order['date-eu-pre'] = function (date) {
|
||||
var dateSplit = date.split('-');
|
||||
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
|
||||
};
|
||||
|
||||
// Initialize the DataTable
|
||||
var table = $('#driver_listing').DataTable({
|
||||
dom: 'Blfrtip',
|
||||
buttons: [
|
||||
'excel', 'pdf'
|
||||
],
|
||||
pageLength: 10,
|
||||
lengthMenu: [
|
||||
[10, 20, 30, 50, -1],
|
||||
[10, 20, 30, 50, "All"]
|
||||
],
|
||||
responsive: false,
|
||||
order: false,
|
||||
language: {
|
||||
paginate: {
|
||||
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
||||
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
<script>
|
||||
|
||||
$(window).on('load', function () {
|
||||
function flashMessage() {
|
||||
|
||||
// Fetch the flash data from PHP and encode it for JavaScript
|
||||
let message = <?= json_encode(session()->getFlashdata('success')) ?>;
|
||||
if (message) {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
flashMessage();
|
||||
|
||||
})
|
||||
|
||||
function confirmDelete(event) {
|
||||
let result = confirm(` Do you Confirm to Delete the Driver Detail?`);
|
||||
if (result) { return result; } else { event.preventDefault(); }
|
||||
}
|
||||
|
||||
function confirmReActivate(event) {
|
||||
let result = confirm(` Do you Confirm to Re-activate the Driver Detail?`);
|
||||
if (result) { return result; } else { event.preventDefault(); }
|
||||
}
|
||||
|
||||
function isNumber(evt) {
|
||||
var iKeyCode = (evt.which) ? evt.which : evt.keyCode
|
||||
if (iKeyCode != 46 && iKeyCode > 31 && (iKeyCode < 48 || iKeyCode > 57)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$(document).on('keydown', function(event) {
|
||||
if (event.key === 'Enter') {
|
||||
event.preventDefault(); // Prevent default Enter key behavior
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
@ -790,6 +790,7 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<a href="<?php echo base_url(); ?>DriverListing" class="dropdown-item"><i class="ri-file-settings-line align-middle mr-1"></i>Driver Details</a>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user