CHANGES-in-client-vehicle-quick-creation:GWM
This commit is contained in:
parent
048e291e8a
commit
d60b29c15f
@ -124,6 +124,7 @@ class Client extends BaseController
|
|||||||
$data = [
|
$data = [
|
||||||
'client_name' => $this->request->getPost('client_name'),
|
'client_name' => $this->request->getPost('client_name'),
|
||||||
'mobile_no' => $this->request->getPost('mobile_no'),
|
'mobile_no' => $this->request->getPost('mobile_no'),
|
||||||
|
'client_type' => $this->request->getPost('client_type'),
|
||||||
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||||
'city'=>'Chennai',
|
'city'=>'Chennai',
|
||||||
'state'=>'Tamil Nadu',
|
'state'=>'Tamil Nadu',
|
||||||
|
|||||||
@ -6,7 +6,8 @@ use App\Models\SalesOrderModel;
|
|||||||
use App\Models\SalesOrderProductModel;
|
use App\Models\SalesOrderProductModel;
|
||||||
use App\Models\ProductModel;
|
use App\Models\ProductModel;
|
||||||
use App\Models\ClientModel;
|
use App\Models\ClientModel;
|
||||||
use App\Models\BikeMakeModel;
|
use App\Models\BikemodelsModel;
|
||||||
|
use App\Models\BikemakeModel;
|
||||||
use App\Models\VehicleModel;
|
use App\Models\VehicleModel;
|
||||||
use Mpdf\Mpdf;
|
use Mpdf\Mpdf;
|
||||||
class Sales extends BaseController
|
class Sales extends BaseController
|
||||||
@ -16,8 +17,10 @@ class Sales extends BaseController
|
|||||||
{
|
{
|
||||||
|
|
||||||
$this->session = session();
|
$this->session = session();
|
||||||
|
$this->BikemodelsModel = new BikemodelsModel();
|
||||||
|
$this->BikemakeModel = new BikemakeModel();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sales_order_index()
|
public function sales_order_index()
|
||||||
{
|
{
|
||||||
@ -322,13 +325,38 @@ public function delete_sales_product()
|
|||||||
// Load ClientModel
|
// Load ClientModel
|
||||||
$VehicleModel = new VehicleModel();
|
$VehicleModel = new VehicleModel();
|
||||||
|
|
||||||
// Validate inputs
|
if($this->request->getPost('formType') == 'create')
|
||||||
|
{
|
||||||
|
$ClientModel = new ClientModel();
|
||||||
|
|
||||||
|
$client['client_name'] = $this->request->getPost('createclientName');
|
||||||
|
$client['mobile_no'] = $this->request->getPost('createclientMobile');
|
||||||
|
$client['client_type'] = $this->request->getPost('createclientType');
|
||||||
|
$client['branch_id'] = $this->session->get('logged_user_branch_id');
|
||||||
|
|
||||||
|
$client_id = $ClientModel->insert($client);
|
||||||
|
|
||||||
|
if($client_id){
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'client_id' => $client_id,
|
||||||
|
'mobile_no' => $this->request->getPost('createclientMobile'),
|
||||||
|
'reg_no' => $this->request->getPost('reg_no'),
|
||||||
|
'model' => $this->request->getPost('model'),
|
||||||
|
'make' => $this->request->getPost('make'),
|
||||||
|
'branch_id'=> $this->session->get('logged_user_branch_id'),
|
||||||
|
'city'=>'Chennai',
|
||||||
|
'state'=>'Tamil Nadu',
|
||||||
|
'isactive' => 1
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// If validation passes, proceed to save the client
|
}else{
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'client_id' => $this->request->getPost('client_id'),
|
'client_id' => $this->request->getPost('client_id'),
|
||||||
|
|
||||||
'mobile_no' => $this->request->getPost('mobile_no'),
|
'mobile_no' => $this->request->getPost('mobile_no'),
|
||||||
'reg_no' => $this->request->getPost('reg_no'),
|
'reg_no' => $this->request->getPost('reg_no'),
|
||||||
'model' => $this->request->getPost('model'),
|
'model' => $this->request->getPost('model'),
|
||||||
@ -339,6 +367,12 @@ public function delete_sales_product()
|
|||||||
'isactive' => 1
|
'isactive' => 1
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Attempt to insert the client data
|
// Attempt to insert the client data
|
||||||
$id = $VehicleModel->insert($data);
|
$id = $VehicleModel->insert($data);
|
||||||
if ($id) {
|
if ($id) {
|
||||||
@ -359,7 +393,7 @@ public function get_vehicle_products(){
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getProducts()
|
public function getProducts()
|
||||||
{
|
{
|
||||||
// Retrieve make_id and model_id from the request
|
// Retrieve make_id and model_id from the request
|
||||||
$makeId = $this->request->getPost('make_id');
|
$makeId = $this->request->getPost('make_id');
|
||||||
@ -376,13 +410,14 @@ public function get_vehicle_products(){
|
|||||||
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||||
->findAll();
|
->findAll();
|
||||||
|
|
||||||
|
$modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
|
||||||
if($product){
|
$makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
|
||||||
|
if($product){
|
||||||
// Send JSON response
|
// Send JSON response
|
||||||
return $this->response->setJSON($product);
|
return $this->response->setJSON(['product'=>$product , 'modelName'=>$modelName ,'makeName'=>$makeName] );
|
||||||
} else {
|
} else {
|
||||||
// If product is not found, return an empty response or appropriate message
|
// If product is not found, return an empty response or appropriate message
|
||||||
return $this->response->setJSON([]);
|
return $this->response->setJSON(['product'=>[] , 'modelName'=>$modelName ,'makeName'=>$makeName]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Check if product exists
|
// Check if product exists
|
||||||
|
|||||||
@ -28,37 +28,43 @@
|
|||||||
<label for="inputEmail4" class="col-form-label">Vehicle<span class="text-danger">*</span></label>
|
<label for="inputEmail4" class="col-form-label">Vehicle<span class="text-danger">*</span></label>
|
||||||
<?= isset($sales['vehicle_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addVehicleModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addVehicleModal" title="Add Client"></i>' ?>
|
<?= isset($sales['vehicle_id']) ? '' : '<i type="button" class="fe-plus-circle" id="addVehicleModalButton" style="font-size: 18px;" data-toggle="modal" data-target="#addVehicleModal" title="Add Client"></i>' ?>
|
||||||
|
|
||||||
|
|
||||||
<select class="form-control vehicle-select SelExample" name="vehicle_id" <?= isset($sales['vehicle_id']) ? '' : 'required' ?>>
|
<select class="form-control vehicle-select SelExample" name="vehicle_id" <?= isset($sales['vehicle_id']) ? '' : 'required' ?>>
|
||||||
|
|
||||||
<?= isset($sales['vehicle_id']) ? '' : '<option value="">Select a vehicle</option>' ?>
|
<?= isset($sales['vehicle_id']) ? '' : '<option value="">Select a vehicle</option>' ?>
|
||||||
<?php foreach ($vehicle as $value) : ?>
|
<?php foreach ($vehicle as $value) : ?>
|
||||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||||
<option value="<?= $value["vehicle_id"] ?>" <?= isset($sales['vehicle_id']) && $sales['vehicle_id'] == $value["vehicle_id"] ? 'selected' : '' ?>>
|
<option value="<?= $value["vehicle_id"] ?>" <?= isset($sales['vehicle_id']) && $sales['vehicle_id'] == $value["vehicle_id"] ? 'selected' : '' ?>>
|
||||||
<?= $value["reg_no"]?>
|
<?= $value["reg_no"]?>
|
||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
|
<label for="inputPassword4" class="col-form-label">Make and Model</label>
|
||||||
|
<input type="text" class="form-control" id="makeAndModel" readonly>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Client Name<span class="text-danger"></span></label>
|
<label for="inputPassword4" class="col-form-label">Client Name<span class="text-danger"></span></label>
|
||||||
<input type="text" class="form-control" name="client_id" placeholder="Client"value="<?= isset($sales['client_name']) ? $sales['client_name'] : '' ?>" readonly>
|
<input type="text" class="form-control" name="client_id" placeholder="Client"value="<?= isset($sales['client_name']) ? $sales['client_name'] : '' ?>" readonly>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Mobile No<span class="text-danger">*</span></label>
|
<label for="inputPassword4" class="col-form-label">Mobile No<span class="text-danger">*</span></label>
|
||||||
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($sales['mobile_no']) ? $sales['mobile_no'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" readonly>
|
<input type="text" class="form-control" name="mobile_no" placeholder="Mobile" value="<?= isset($sales['mobile_no']) ? $sales['mobile_no'] : '' ?>" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" readonly>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-4">
|
||||||
<label for="inputPassword4" class="col-form-label">Status<span class="text-danger">*</span></label>
|
<label for="inputPassword4" class="col-form-label">Status<span class="text-danger">*</span></label>
|
||||||
<select class="form-control status-select" name="status" required data-toggle="select2" >
|
<select class="form-control status-select" name="status" required data-toggle="select2" >
|
||||||
<!-- <option value="">Select a Status</option> -->
|
<!-- <option value="">Select a Status</option> -->
|
||||||
<option value="Created" <?= isset($sales['status']) && $sales['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
|
<option value="Created" <?= isset($sales['status']) && $sales['status'] === 'Created' ? 'selected' : '' ?>>Created</option>
|
||||||
<option value="Paid" <?= isset($sales['status']) && $sales['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
|
<option value="Paid" <?= isset($sales['status']) && $sales['status'] === 'Paid' ? 'selected' : '' ?>>Paid</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div><br>
|
||||||
|
|
||||||
|
|
||||||
</div><br>
|
|
||||||
<h4 class="header-title">Billing Address Details :</h4><br>
|
<h4 class="header-title">Billing Address Details :</h4><br>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-3">
|
<div class="form-group col-md-3">
|
||||||
@ -228,63 +234,90 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<form id="addClientForm">
|
<form >
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<!-- <div class="form-group"> -->
|
<!-- <div class="form-group"> -->
|
||||||
|
|
||||||
<label for="inputPassword4" class="col-form-label">Make</label>
|
<label for="inputPassword4" class="col-form-label">Make</label>
|
||||||
<select class="form-control SelExample" name="make" id="make" <?= isset($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>' ?>
|
<?= isset($vehicle['make']) ? '' : '<option value="">Select a Make</option>' ?>
|
||||||
<?php foreach ($makeData as $value) : ?>
|
<?php foreach ($makeData as $value) : ?>
|
||||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
<?php if ((int)$value["isactive"] === 1) : ?>
|
||||||
<option value="<?= $value["make_id"] ?>" <?= isset($vehicle['make']) && $vehicle['make'] == $value["make_id"] ? 'selected' : '' ?>>
|
<option value="<?= $value["make_id"] ?>" <?= isset($vehicle['make']) && $vehicle['make'] == $value["make_id"] ? 'selected' : '' ?>>
|
||||||
<?= $value["make"]; ?>
|
<?= $value["make"]; ?>
|
||||||
</option>
|
</option>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="inputPassword4" class="col-form-label">Model</label>
|
|
||||||
<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-row">
|
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-6">
|
||||||
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
<label for="inputPassword4" class="col-form-label">Model</label>
|
||||||
<input type="text" class="form-control" name="reg_no" id="reg_no" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
<select class="form-control SelExample" name="model" id="model" <?= isset($vehicle['model']) ? '' : 'required' ?>>
|
||||||
</div>
|
<?php if (isset($vehicle["model_name"])) : ?>
|
||||||
|
<option value="<?= $vehicle["model"] ?>" >
|
||||||
|
<?= $vehicle["model_name"]; ?>
|
||||||
|
</option>
|
||||||
|
<?php endif; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
<div class="form-row">
|
||||||
<div class="form-row">
|
<div class="form-group col-md-12">
|
||||||
<div class="form-group col-md-12">
|
<label for="inputPassword4" class="col-form-label">Reg Number</label>
|
||||||
<!-- <div class="form-group"> -->
|
<input type="text" class="form-control" name="reg_no" id="reg_no" placeholder="Reg Number"value="<?= isset($vehicle['reg_no']) ? $vehicle['reg_no'] : '' ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
|
||||||
|
<input type="text" value="select" id="formType" hidden>
|
||||||
|
|
||||||
|
<div class="form-group col-md-12 select">
|
||||||
<label for="clientName">Client Name</label>
|
<label for="clientName">Client Name</label>
|
||||||
<select class="form-control cleint-select SelExample" name="client_id" id=clientName <?= isset($sales['client_id']) ? '' : 'required' ?>>
|
<i type="button" class="fe-user-plus" id="createClient" style="font-size: 18px;" ></i>
|
||||||
|
<select class="form-control cleint-select SelExample" id="clientName" required>
|
||||||
|
<option value="">Select a Client</option>
|
||||||
|
<?php foreach ($client as $value) : ?>
|
||||||
|
<option value="<?= $value["client_id"] ?>">
|
||||||
|
<?= $value["mobile_no"] .' - '. $value["client_name"]; ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?= isset($sales['client_id']) ? '' : '<option value="">Select a Client</option>' ?>
|
<div class="form-group col-md-12 select">
|
||||||
<?php foreach ($client as $value) : ?>
|
|
||||||
<?php if ((int)$value["isactive"] === 1) : ?>
|
|
||||||
<option value="<?= $value["client_id"] ?>" <?= isset($sales['client_id']) && $sales['client_id'] == $value["client_id"] ? 'selected' : '' ?>>
|
|
||||||
<?= $value["client_name"]; ?>
|
|
||||||
</option>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group col-md-12">
|
|
||||||
<label for="clientMobile">Mobile</label>
|
<label for="clientMobile">Mobile</label>
|
||||||
<input type="text" class="form-control" id="mobile" name="mobile"placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
<input type="text" class="form-control" id="clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="form-group col-md-12 create" style="display:none;">
|
||||||
|
<label for="create-clientName">Client Name</label>
|
||||||
|
<i type="button" class="fe-user-check" id="selectClient" style="font-size: 18px;" ></i>
|
||||||
|
<input type="text" class="form-control" id="create-clientName" placeholder="Enter client name" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6 create" style="display:none;">
|
||||||
|
<label for="create-clientMobile">Mobile</label>
|
||||||
|
<input type="text" class="form-control" id="create-clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10"onkeypress = "return onlyNumbers(event)"required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group col-md-6 create" style="display:none;">
|
||||||
|
<label for="create-clientType">Client Type</label>
|
||||||
|
<select class="form-control status-select" id="create-clientType" required >
|
||||||
|
<option value="">Select a Type</option>
|
||||||
|
<option value="Direct" >Direct</option>
|
||||||
|
<option value="Mechanic" >Mechanic</option>
|
||||||
|
<option value="Exp" >Exp</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -329,7 +362,10 @@ $(document).ready(function() {
|
|||||||
vehicle_id: vehicleId
|
vehicle_id: vehicleId
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
productarray = response;
|
console.log(response);
|
||||||
|
productarray = response.product;
|
||||||
|
makeAndModel = response.makeName+' '+response.modelName;
|
||||||
|
$('#makeAndModel').val(makeAndModel);
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
// Handle error
|
// Handle error
|
||||||
@ -547,14 +583,13 @@ $(document).ready(function() {
|
|||||||
$('.vehicle-select').change(function() {
|
$('.vehicle-select').change(function() {
|
||||||
|
|
||||||
var vehicleId = $(this).val();
|
var vehicleId = $(this).val();
|
||||||
// console.log(vehicleId);
|
|
||||||
if (vehicleId !== '') {
|
if (vehicleId !== '') {
|
||||||
// Find the selected client in the client data
|
// Find the selected client in the client data
|
||||||
var selectedClient = vehicles.find(function(vehicle) {
|
var selectedClient = vehicles.find(function(vehicle) {
|
||||||
return vehicle.vehicle_id == vehicleId;
|
return vehicle.vehicle_id == vehicleId;
|
||||||
});
|
});
|
||||||
// console.log(selectedClient);
|
|
||||||
// Populate the billing address, city, state, country, and postal code fields
|
|
||||||
|
|
||||||
$('input[name="client_id"]').val(selectedClient.client_name);
|
$('input[name="client_id"]').val(selectedClient.client_name);
|
||||||
$('input[name="billing_address"]').val(selectedClient.address);
|
$('input[name="billing_address"]').val(selectedClient.address);
|
||||||
@ -581,11 +616,11 @@ $(document).ready(function() {
|
|||||||
var selectedClients = clients.find(function(client) {
|
var selectedClients = clients.find(function(client) {
|
||||||
return client.client_id == clientId;
|
return client.client_id == clientId;
|
||||||
});
|
});
|
||||||
console.log(selectedClients);
|
|
||||||
// Populate the billing address, city, state, country, and postal code fields
|
// Populate the billing address, city, state, country, and postal code fields
|
||||||
|
|
||||||
|
|
||||||
$('input[name="mobile"]').val(selectedClients.mobile_no);
|
$('input[id="clientMobile"]').val(selectedClients.mobile_no);
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -625,13 +660,30 @@ $(document).ready(function() {
|
|||||||
// AJAX request to save client
|
// AJAX request to save client
|
||||||
$('#saveVehcileBtn').click(function() {
|
$('#saveVehcileBtn').click(function() {
|
||||||
|
|
||||||
|
var formType = $('#formType').val();
|
||||||
|
console.log(formType);
|
||||||
|
|
||||||
var clientName = $('#clientName').val();
|
|
||||||
var clientMobile = $('#mobile').val();
|
|
||||||
var reg_no = $('#reg_no').val();
|
var reg_no = $('#reg_no').val();
|
||||||
var model = $('#model').val();
|
var model = $('#model').val();
|
||||||
var make = $('#make').val();
|
var make = $('#make').val();
|
||||||
if(clientName != '' && clientMobile != ''&®_no != '' && model != '' && make != ''){
|
|
||||||
|
var clientName = $('#clientName').val();
|
||||||
|
var clientMobile = $('#clientMobile').val();
|
||||||
|
|
||||||
|
var createclientName = $('#create-clientName').val();
|
||||||
|
var createclientMobile = $('#create-clientMobile').val();
|
||||||
|
var createclientType = $('#create-clientType').val();
|
||||||
|
|
||||||
|
if (formType == 'select')
|
||||||
|
{
|
||||||
|
var ifStatementCondition = "clientName !== '' && clientMobile !== '' && reg_no !== '' && model !== '' && make !== ''";
|
||||||
|
} else {
|
||||||
|
var ifStatementCondition = "createclientName !== '' && createclientMobile !== '' && createclientType !== '' && reg_no !== '' && model !== '' && make !== ''";
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(ifStatementCondition);
|
||||||
|
|
||||||
|
if( eval(ifStatementCondition) ){
|
||||||
|
|
||||||
// Send AJAX request to save the client
|
// Send AJAX request to save the client
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -642,24 +694,24 @@ $(document).ready(function() {
|
|||||||
mobile_no: clientMobile,
|
mobile_no: clientMobile,
|
||||||
reg_no:reg_no,
|
reg_no:reg_no,
|
||||||
model:model,
|
model:model,
|
||||||
make:make
|
make:make,
|
||||||
|
createclientName:createclientName,
|
||||||
|
createclientMobile:createclientMobile,
|
||||||
|
createclientType:createclientType,
|
||||||
|
formType:formType,
|
||||||
|
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
// Check if the operation was successful
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
// Client saved successfully, close the modal and do any additional actions
|
|
||||||
$('#addVehicleModal').modal('hide');
|
$('#addVehicleModal').modal('hide');
|
||||||
// Optionally, you can update the client dropdown or show a success message
|
|
||||||
toastr.success("Vehicle saved successfully!");
|
toastr.success("Vehicle saved successfully!");
|
||||||
window.location.reload(); // Reload the page
|
window.location.reload();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Client save operation failed, display error message
|
|
||||||
toastr.warning("Failed to save vehicle. Please try again");
|
toastr.warning("Failed to save vehicle. Please try again");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
// AJAX request failed, display error message
|
|
||||||
console.error('Error occurred while saving vehicle:', error);
|
console.error('Error occurred while saving vehicle:', error);
|
||||||
toastr.warning("Failed to save vehicle. Please try again");
|
toastr.warning("Failed to save vehicle. Please try again");
|
||||||
}
|
}
|
||||||
@ -712,7 +764,27 @@ document.getElementById('reg_no').addEventListener('input', function(event) {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '#createClient', function() {
|
||||||
|
$('.create').show();
|
||||||
|
$('.select').hide();
|
||||||
|
$('#formType').val('create');
|
||||||
|
|
||||||
|
$('#clientName').val('');
|
||||||
|
$('#clientMobile').val('');
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
$(document).on('click', '#selectClient', function() {
|
||||||
|
$('.select').show();
|
||||||
|
$('.create').hide();
|
||||||
|
$('#formType').val('select');
|
||||||
|
|
||||||
|
$('#create-clientName').val('');
|
||||||
|
$('#create-clientMobile').val('');
|
||||||
|
$('#create-clientType').val('');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="clientMobile">Mobile</label>
|
<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>
|
<input type="text" class="form-control" id="clientMobile" placeholder="Enter mobile number" maxlength="10" minlength="10" onkeypress = "return onlyNumbers(event)" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="clientType">Client Type</label>
|
||||||
|
<select class="form-control status-select" id="clientType" required >
|
||||||
|
<option value="">Select a Type</option>
|
||||||
|
<option value="Direct" >Direct</option>
|
||||||
|
<option value="Mechanic" >Mechanic</option>
|
||||||
|
<option value="Exp" >Exp</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
@ -225,7 +234,8 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
var clientName = $('#clientName').val();
|
var clientName = $('#clientName').val();
|
||||||
var clientMobile = $('#clientMobile').val();
|
var clientMobile = $('#clientMobile').val();
|
||||||
if(clientName != '' && clientMobile != ''){
|
var clientType = $('#clientType').val();
|
||||||
|
if(clientName != '' && clientMobile != '' && clientType != ''){
|
||||||
|
|
||||||
// Send AJAX request to save the client
|
// Send AJAX request to save the client
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -233,7 +243,8 @@ $(document).ready(function() {
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: {
|
data: {
|
||||||
client_name: clientName,
|
client_name: clientName,
|
||||||
mobile_no: clientMobile
|
mobile_no: clientMobile,
|
||||||
|
client_type : clientType,
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
// Check if the operation was successful
|
// Check if the operation was successful
|
||||||
@ -259,7 +270,7 @@ $(document).ready(function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
toastr.warning("Please Fill Name and Mobile data");
|
toastr.warning("Please Fill All Datas");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user