Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic
This commit is contained in:
commit
f4a5ab80ef
@ -306,9 +306,12 @@ public function delete_sales_product()
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Attempt to insert the client data
|
// Attempt to insert the client data
|
||||||
if ($ClientModel->insert($data)) {
|
$id = $ClientModel->insert($data);
|
||||||
|
if ($id) {
|
||||||
|
$clientData = $ClientModel->where('client_id',$id)->first();
|
||||||
|
|
||||||
// If insertion succeeds, return success response
|
// If insertion succeeds, return success response
|
||||||
return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.']);
|
return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.','clientData'=>$clientData]);
|
||||||
} else {
|
} else {
|
||||||
// If insertion fails, return error response
|
// If insertion fails, return error response
|
||||||
return $this->response->setJSON(['success' => false, 'message' => 'Failed to save client.']);
|
return $this->response->setJSON(['success' => false, 'message' => 'Failed to save client.']);
|
||||||
|
|||||||
@ -4,20 +4,33 @@ namespace App\Controllers;
|
|||||||
use App\Models\VehicleModel;
|
use App\Models\VehicleModel;
|
||||||
use App\Models\ClientModel;
|
use App\Models\ClientModel;
|
||||||
use App\Models\RoleModel;
|
use App\Models\RoleModel;
|
||||||
|
use App\Models\BikemakeModel;
|
||||||
|
use App\Models\BikemodelsModel;
|
||||||
|
|
||||||
|
|
||||||
class Vehicle extends BaseController
|
class Vehicle extends BaseController
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
public $session;
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->session = session();
|
||||||
|
$this->bikeMakeModel = new BikemakeModel();
|
||||||
|
$this->bikeModelsModel = new BikemodelsModel();
|
||||||
|
}
|
||||||
|
|
||||||
public function vehicle_index()
|
public function vehicle_index()
|
||||||
{
|
{
|
||||||
|
|
||||||
$VehicleModel = new VehicleModel();
|
$VehicleModel = new VehicleModel();
|
||||||
$vehicle=$VehicleModel->getCustomerandVehicle();
|
$vehicle = $VehicleModel->getCustomerandVehicle($this->session->get('logged_user_branch_id'));
|
||||||
$data['vehicle']=$vehicle;
|
$data['vehicle'] = $vehicle;
|
||||||
|
|
||||||
$ClientModel = new ClientModel();
|
$ClientModel = new ClientModel();
|
||||||
$client=$ClientModel->findAll();
|
$client = $ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
|
||||||
$data['client']=$client;
|
$data['client']=$client;
|
||||||
|
|
||||||
return view('vehicle_list',$data);
|
return view('vehicle_list',$data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,19 +43,25 @@ class Vehicle extends BaseController
|
|||||||
$ClientModel = new ClientModel();
|
$ClientModel = new ClientModel();
|
||||||
$data['vehicle'] = [];
|
$data['vehicle'] = [];
|
||||||
$data['page_name']="Add vehicle";
|
$data['page_name']="Add vehicle";
|
||||||
$client=$ClientModel->findAll();
|
$client = $ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
|
||||||
$data['client']=$client;
|
$data['client']=$client;
|
||||||
|
|
||||||
} else if ($vehicle_id !== '0') {
|
} else if ($vehicle_id !== '0') {
|
||||||
|
|
||||||
$data['page_name']="Edit vehicle";
|
$data['page_name']="Edit vehicle";
|
||||||
$VehicleModel = new VehicleModel();
|
$VehicleModel = new VehicleModel();
|
||||||
$vehicle=$VehicleModel->where('vehicle_id', $vehicle_id)->get()->getRowArray();
|
$vehicle= $VehicleModel->select('vehicle.*, model.model_name as model_name')
|
||||||
|
->join('model', 'model.model_id = vehicle.model')
|
||||||
|
->where('vehicle.vehicle_id', $vehicle_id)
|
||||||
|
->where('vehicle.branch_id', $this->session->get('logged_user_branch_id'))
|
||||||
|
->get()->getRowArray();
|
||||||
$data['vehicle']=$vehicle;
|
$data['vehicle']=$vehicle;
|
||||||
$ClientModel = new ClientModel();
|
$ClientModel = new ClientModel();
|
||||||
$client=$ClientModel->findAll();
|
$client=$ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
|
||||||
$data['client']=$client;
|
$data['client']=$client;
|
||||||
}
|
}
|
||||||
$data['vehicle_id'] = $vehicle_id;
|
$data['vehicle_id'] = $vehicle_id;
|
||||||
|
$data['makeData'] =$this->bikeMakeModel->findAll();
|
||||||
|
|
||||||
return view('vehicle_form',$data);
|
return view('vehicle_form',$data);
|
||||||
}
|
}
|
||||||
@ -62,12 +81,12 @@ class Vehicle extends BaseController
|
|||||||
'city' => $this->request->getPost('city'),
|
'city' => $this->request->getPost('city'),
|
||||||
'state' => $this->request->getPost('state'),
|
'state' => $this->request->getPost('state'),
|
||||||
'postal_code' => $this->request->getPost('postalcode'),
|
'postal_code' => $this->request->getPost('postalcode'),
|
||||||
'country' => $this->request->getPost('country'),
|
|
||||||
'make' => $this->request->getPost('make'),
|
'make' => $this->request->getPost('make'),
|
||||||
'model' => $this->request->getPost('model'),
|
'model' => $this->request->getPost('model'),
|
||||||
'reg_no' => $this->request->getPost('regno'),
|
'reg_no' => $this->request->getPost('regno'),
|
||||||
'colour' => $this->request->getPost('colour'),
|
'colour' => $this->request->getPost('colour'),
|
||||||
|
'year_of_manufacturing' => $this->request->getPost('year_of_manufacturing'),
|
||||||
|
'branch_id' => $this->session->get('logged_user_branch_id'),
|
||||||
'isactive' => 1 // Assuming this is a default value or handled separately
|
'isactive' => 1 // Assuming this is a default value or handled separately
|
||||||
];
|
];
|
||||||
// print_r($data);die;
|
// print_r($data);die;
|
||||||
|
|||||||
@ -3,16 +3,20 @@ namespace App\Models;
|
|||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
class VehicleModel extends Model
|
class VehicleModel extends Model
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
protected $table = 'vehicle';
|
protected $table = 'vehicle';
|
||||||
protected $primaryKey = 'vehicle_id';
|
protected $primaryKey = 'vehicle_id';
|
||||||
protected $allowedFields = ['vehicle_id','make','model','reg_no','colour','client_id','address','country','state','city','email','postal_code','mobile_no','isactive'];
|
protected $allowedFields = ['branch_id','vehicle_id','make','model','reg_no','year_of_manufacturing','colour','client_id','address','country','state','city','email','postal_code','mobile_no','isactive'];
|
||||||
|
|
||||||
public function getCustomerandVehicle()
|
public function getCustomerandVehicle($branch_id)
|
||||||
{
|
{
|
||||||
// Select required fields from both tables
|
// Select required fields from both tables
|
||||||
$this->select('vehicle.*, client.client_name');
|
$this->select('vehicle.*, client.client_name , make.make as make_name , model.model_name as model_name');
|
||||||
$this->join('client', 'client.client_id = vehicle.client_id');
|
$this->join('client', 'client.client_id = vehicle.client_id');
|
||||||
// Add condition to fetch only active sales orders
|
$this->join('make', 'make.make_id = vehicle.make');
|
||||||
|
$this->join('model', 'model.model_id = vehicle.model');
|
||||||
|
$this->where('vehicle.branch_id', $branch_id);
|
||||||
$this->where('vehicle.isactive', 1);
|
$this->where('vehicle.isactive', 1);
|
||||||
|
|
||||||
// Get the results
|
// Get the results
|
||||||
|
|||||||
@ -35,7 +35,7 @@
|
|||||||
<!-- /Right-bar -->
|
<!-- /Right-bar -->
|
||||||
|
|
||||||
<!-- Right bar overlay-->
|
<!-- Right bar overlay-->
|
||||||
<div class="rightbar-overlay"></div>
|
|
||||||
|
|
||||||
<!-- Vendor js -->
|
<!-- Vendor js -->
|
||||||
<script src="<?php echo base_url(); ?>/assets/js/vendor.min.js"></script>
|
<script src="<?php echo base_url(); ?>/assets/js/vendor.min.js"></script>
|
||||||
|
|||||||
@ -98,10 +98,11 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
<?php if(session()->get('logged_user_role') == 'Floor Manager' ||
|
||||||
session()->get('logged_user_role') == 'Job Card Manager') { ?>
|
session()->get('logged_user_role') == 'Job Card Manager' ||
|
||||||
|
session()->get('logged_user_role') == 'Store Manager') { ?>
|
||||||
<li>
|
<li>
|
||||||
<a href="<?php echo base_url('vehicle_index') ?>">
|
<a href="<?php echo base_url('vehicle_index') ?>">
|
||||||
<i class="ri-message-2-line"></i>
|
<i class="mdi mdi-motorbike"></i>
|
||||||
<span> Vehicle </span>
|
<span> Vehicle </span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@ -487,10 +487,6 @@ function initializeSelect2() {
|
|||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Show the modal when the "add-circle-button" is clicked
|
|
||||||
$('#add-circle-button').click(function() {
|
|
||||||
$('#addClientModal').modal('show');
|
|
||||||
});
|
|
||||||
|
|
||||||
// AJAX request to save client
|
// AJAX request to save client
|
||||||
$('#saveClientBtn').click(function() {
|
$('#saveClientBtn').click(function() {
|
||||||
|
|||||||
@ -4,9 +4,8 @@
|
|||||||
<div class="page-title-box page-title-box-alt">
|
<div class="page-title-box page-title-box-alt">
|
||||||
<h4 class="page-title"><?php echo $page_name?></h4>
|
<h4 class="page-title"><?php echo $page_name?></h4>
|
||||||
<div class="page-title-right">
|
<div class="page-title-right">
|
||||||
|
<a href="<?= base_url() . "vehicle_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||||
<ol class="breadcrumb m-0">
|
<ol class="breadcrumb m-0">
|
||||||
|
|
||||||
</li>
|
|
||||||
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
|
<!-- <li class="breadcrumb-item"><a href="javascript: void(0);">Tables</a></li>
|
||||||
<li class="breadcrumb-item active">Datatables</li> -->
|
<li class="breadcrumb-item active">Datatables</li> -->
|
||||||
</ol>
|
</ol>
|
||||||
@ -25,15 +24,34 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Make</label>
|
<label for="inputPassword4" class="col-form-label">Make</label>
|
||||||
<input type="text" class="form-control" name="make" placeholder="Make"value="<?= isset($vehicle['make']) ? $vehicle['make'] : '' ?>" required>
|
<select class="form-control SelExample" name="make" id="make" <?= isset($vehicle['make']) ? '' : 'required' ?>>
|
||||||
|
<?= isset($vehicle['make']) ? '' : '<option value="">Select a Make</option>' ?>
|
||||||
|
<?php foreach ($makeData as $value) : ?>
|
||||||
|
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||||
|
<option value="<?= $value["make_id"] ?>" <?= isset($vehicle['make']) && $vehicle['make'] == $value["make_id"] ? 'selected' : '' ?>>
|
||||||
|
<?= $value["make"]; ?>
|
||||||
|
</option>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Model</label>
|
<label for="inputPassword4" class="col-form-label">Model</label>
|
||||||
<input type="text" class="form-control" name="model" placeholder="Model"value="<?= isset($vehicle['model']) ? $vehicle['model'] : '' ?>" required>
|
<select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>>
|
||||||
|
<?php if (isset($vehicle["model_name"])) : ?>
|
||||||
|
<option value="<?= $vehicle["model"] ?>" >
|
||||||
|
<?= $vehicle["model_name"]; ?>
|
||||||
|
</option>
|
||||||
|
<?php endif; ?>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
||||||
<input type="text" class="form-control" name="regno" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
<input type="text" class="form-control" name="regno" id="regno" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-4">
|
||||||
|
<label for="inputPassword4" class="col-form-label">Year of Manufacturing</label>
|
||||||
|
<input type="text" class="form-control" name="year_of_manufacturing" placeholder="Manufacturing Year" value="<?= isset($vehicle['year_of_manufacturing']) ? $vehicle['year_of_manufacturing'] : '' ?>" maxlength="4" minlength="4"onkeypress = "return onlyNumbers(event)">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Colour</label>
|
<label for="inputPassword4" class="col-form-label">Colour</label>
|
||||||
@ -44,7 +62,8 @@
|
|||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputEmail4" class="col-form-label">Client Name</label>
|
<label for="inputEmail4" class="col-form-label">Client Name</label>
|
||||||
<select class="form-control cleint-select" name="client_name" required data-toggle="select2" >
|
<?= isset($vehicle['client_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addClientModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addClientModal" title="Add Client"></i>' ?>
|
||||||
|
<select class="form-control cleint-select SelExample" id="clientData" name="client_name" required data-toggle="select2" >
|
||||||
<option value="">Select a Client</option>
|
<option value="">Select a Client</option>
|
||||||
<?php foreach ($client as $value) : ?>
|
<?php foreach ($client as $value) : ?>
|
||||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||||
@ -53,39 +72,35 @@
|
|||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputEmail4" class="col-form-label">Email</label>
|
<label for="inputEmail4" class="col-form-label">Email</label>
|
||||||
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($vehicle['email']) ? $vehicle['email'] : '' ?>" readonly>
|
<input type="email" class="form-control" name="email" placeholder="Email" value="<?= isset($vehicle['email']) ? $vehicle['email'] : '' ?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputAddress" class="col-form-label">Mobile</label>
|
<label for="inputAddress" class="col-form-label">Mobile</label>
|
||||||
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($vehicle['mobile_no']) ? $vehicle['mobile_no'] : '' ?>" required maxlength="10" minlength="10"readonly>
|
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($vehicle['mobile_no']) ? $vehicle['mobile_no'] : '' ?>" required maxlength="10" minlength="10">
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">Address</label>
|
<label for="inputPassword4" class="col-form-label">Address</label>
|
||||||
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($vehicle['address']) ? $vehicle['address'] : '' ?>" readonly>
|
<input type="text" class="form-control" name="address" placeholder="Address"value="<?= isset($vehicle['address']) ? $vehicle['address'] : '' ?>" >
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<input type="hidden" id="vehicle_id" name="vehicle_id" value="<?= isset($vehicle['vehicle_id']) ? $vehicle['vehicle_id'] : '' ?>"readonly>
|
<input type="hidden" id="vehicle_id" name="vehicle_id" value="<?= isset($vehicle['vehicle_id']) ? $vehicle['vehicle_id'] : '' ?>">
|
||||||
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">City</label>
|
<label for="inputPassword4" class="col-form-label">City</label>
|
||||||
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($vehicle['city']) ? $vehicle['city'] : '' ?>" readonly>
|
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($vehicle['city']) ? $vehicle['city'] : '' ?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">State</label>
|
<label for="inputPassword4" class="col-form-label">State</label>
|
||||||
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($vehicle['state']) ? $vehicle['state'] : '' ?>" readonly>
|
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($vehicle['state']) ? $vehicle['state'] : '' ?>" >
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-3">
|
||||||
<label for="inputPassword4" class="col-form-label">Postal Code</label>
|
<label for="inputPassword4" class="col-form-label">Pin Code</label>
|
||||||
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($vehicle['postal_code']) ? $vehicle['postal_code'] : '' ?>" readonly maxlength="6" minlength="6">
|
<input type="text" class="form-control" name="postalcode" placeholder="Pin Code"value="<?= isset($vehicle['postal_code']) ? $vehicle['postal_code'] : '' ?>" maxlength="6" minlength="6">
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-4">
|
|
||||||
<label for="inputPassword4" class="col-form-label">Country</label>
|
|
||||||
<input type="text" class="form-control" name="country" placeholder="Country"value="<?= isset($vehicle['country']) ? $vehicle['country'] : '' ?>" readonly>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -98,6 +113,37 @@
|
|||||||
|
|
||||||
<?php include('layout/footer.php'); ?>
|
<?php include('layout/footer.php'); ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="modal fade" id="addClientModal" tabindex="-1" role="dialog" aria-labelledby="addClientModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="addClientModalLabel">Add New Client</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form id="addClientForm">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientName">Client Name</label>
|
||||||
|
<input type="text" class="form-control" id="clientName" placeholder="Enter client name"required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientMobile">Mobile</label>
|
||||||
|
<input type="text" class="form-control" id="clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="saveClientBtn">Save Client</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@ -115,16 +161,122 @@ $(document).ready(function() {
|
|||||||
$('input[name="address"]').val(selectedClient.address);
|
$('input[name="address"]').val(selectedClient.address);
|
||||||
$('input[name="city"]').val(selectedClient.city);
|
$('input[name="city"]').val(selectedClient.city);
|
||||||
$('input[name="state"]').val(selectedClient.state);
|
$('input[name="state"]').val(selectedClient.state);
|
||||||
$('input[name="country"]').val(selectedClient.country);
|
|
||||||
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
|
$('input[name="mobile_no"]').val(selectedClient.mobile_no);
|
||||||
$('input[name="email"]').val(selectedClient.email);
|
$('input[name="email"]').val(selectedClient.email);
|
||||||
$('input[name="postalcode"]').val(selectedClient.postal_code);
|
$('input[name="postalcode"]').val(selectedClient.postal_code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$(".SelExample").select2();
|
||||||
|
|
||||||
|
// Event listener for change in make select dropdown
|
||||||
|
$("#make").on('change', function() {
|
||||||
|
var selected_makes = $(this).val(); // Get an array of selected make IDs
|
||||||
|
// AJAX request to fetch models based on selected make IDs
|
||||||
|
$.ajax({
|
||||||
|
url: '<?= base_url("fetch_models") ?>', // URL to your controller method for fetching models
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: { selected_makes: [selected_makes] },
|
||||||
|
success: function(response) {
|
||||||
|
// Clear existing options in model select dropdown
|
||||||
|
$("#model").empty();
|
||||||
|
$("#model").append('<option value=""> Select a Model </option>');
|
||||||
|
// Populate model select dropdown with fetched models
|
||||||
|
$.each(response, function(index, model) {
|
||||||
|
$("#model").append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Refresh select2 to reflect changes
|
||||||
|
$("#model").trigger('change');
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(error); // Log any errors to the console
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
document.getElementById('regno').addEventListener('input', function(event) {
|
||||||
|
var inputText = event.target.value;
|
||||||
|
event.target.value = inputText.toUpperCase();
|
||||||
|
});
|
||||||
|
|
||||||
|
function onlyNumbers(event){
|
||||||
|
var charcode;
|
||||||
|
charcode = event.which || event.keyCode;
|
||||||
|
if(charcode>= 48 && charcode <= 57)return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$('#saveClientBtn').click(function() {
|
||||||
|
|
||||||
|
|
||||||
|
var clientName = $('#clientName').val();
|
||||||
|
var clientMobile = $('#clientMobile').val();
|
||||||
|
if(clientName != '' && clientMobile != ''){
|
||||||
|
|
||||||
|
// Send AJAX request to save the client
|
||||||
|
$.ajax({
|
||||||
|
url: '<?php echo base_url().'save_client'?>', // URL to your save_client method
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
client_name: clientName,
|
||||||
|
mobile_no: clientMobile
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
// Check if the operation was successful
|
||||||
|
if (response.success) {
|
||||||
|
// Client saved successfully, close the modal and do any additional actions
|
||||||
|
$('#addClientModal').modal('hide');
|
||||||
|
// Optionally, you can update the client dropdown or show a success message
|
||||||
|
toastr.success("Client saved successfully!");
|
||||||
|
console.log(response.clientData);
|
||||||
|
$("#clientData").append('<option value="' + response.clientData.client_id + '">' + response.clientData.client_name + '</option>');
|
||||||
|
// Manually select the newly added option
|
||||||
|
$("#clientData").val(response.clientData.client_id).trigger('change');
|
||||||
|
} else {
|
||||||
|
// Client save operation failed, display error message
|
||||||
|
toastr.warning("Failed to save client. Please try again");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// AJAX request failed, display error message
|
||||||
|
console.error('Error occurred while saving client:', error);
|
||||||
|
toastr.warning("Failed to save client. Please try again");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
toastr.warning("Please Fill Name and Mobile data");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// Define the clients array and populate it with data
|
// Define the clients array and populate it with data
|
||||||
var clients = <?php echo json_encode($client); ?>;
|
var clients = <?php echo json_encode($client); ?>;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.select2-container--default .select2-results__option--highlighted[aria-selected]{
|
||||||
|
color:#ffffff;
|
||||||
|
background: #526dee!important;
|
||||||
|
}
|
||||||
|
.select2-container .select2-selection--single{
|
||||||
|
height: 36px;
|
||||||
|
border:1px solid #ced4da;
|
||||||
|
}
|
||||||
|
.select2-container--default .select2-selection--single .select2-selection__rendered{
|
||||||
|
line-height: 36px;
|
||||||
|
}
|
||||||
|
.select2-container--default .select2-selection--single .select2-selection__arrow{
|
||||||
|
top:4px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -29,14 +29,12 @@
|
|||||||
<thead>
|
<thead>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<th>Client Name</th>
|
|
||||||
<th>Mobile</th>
|
|
||||||
<th>Email</th>
|
|
||||||
<th>Make</th>
|
|
||||||
<th>Model</th>
|
|
||||||
<th>Reg No</th>
|
<th>Reg No</th>
|
||||||
<th>Colour</th>
|
<th>Make & Model</th>
|
||||||
|
<th>Manf Year</th>
|
||||||
|
<th>Colour</th>
|
||||||
|
<th>Client Name</th>
|
||||||
|
<th>Mobile</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
@ -47,14 +45,12 @@
|
|||||||
<?php foreach ($vehicle as $value) :
|
<?php foreach ($vehicle as $value) :
|
||||||
if ($value['isactive'] == 1) : ?>
|
if ($value['isactive'] == 1) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?= $value['reg_no']; ?></td>
|
||||||
|
<td><?= $value['make_name'].' '.$value['model_name']; ?></td>
|
||||||
|
<td><?= $value['year_of_manufacturing']; ?></td>
|
||||||
|
<td><?= $value['colour']; ?></td>
|
||||||
<td><?= $value['client_name']; ?></td>
|
<td><?= $value['client_name']; ?></td>
|
||||||
<td><?= $value['mobile_no']; ?></td>
|
<td><?= $value['mobile_no']; ?></td>
|
||||||
<td><?= $value['email']; ?></td>
|
|
||||||
<td><?= $value['make']; ?></td>
|
|
||||||
<td><?= $value['model']; ?></td>
|
|
||||||
|
|
||||||
<td><?= $value['reg_no']; ?></td>
|
|
||||||
<td><?= $value['colour']; ?></td>
|
|
||||||
<td>
|
<td>
|
||||||
<a href="<?= "new_vehicle/" . $value['vehicle_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
<a href="<?= "new_vehicle/" . $value['vehicle_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||||
<a href="<?= "delete_vehicle/" . $value['vehicle_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
<a href="<?= "delete_vehicle/" . $value['vehicle_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user