GWM assigned in model , service : ps

This commit is contained in:
VE10-Sanjeev 2025-02-19 12:17:28 +00:00
parent 2b1526b886
commit a221412a5f
8 changed files with 224 additions and 159 deletions

View File

@ -173,9 +173,9 @@ $routes->get('dashboard', 'Users::dashboard');
$routes->get('service_index', 'Service::service_index'); $routes->get('service_index', 'Service::service_index');
$routes->get("new_service/(:any)", "Service::new_service/$1"); $routes->get("new_service/(:any)", "Service::new_service/$1");
$routes->post("add_service", "Service::add_service"); $routes->post("add_service", "Service::add_service");
$routes->post("get_models_service", "Service::get_models"); // $routes->post("get_models_service", "Service::get_models");
$routes->get("delete_service/(:any)", "Service::delete_service/$1"); $routes->get("delete_service/(:any)", "Service::delete_service/$1");
$routes->post("get_product_by_models", "Service::get_product_by_models"); // $routes->post("get_product_by_models", "Service::get_product_by_models");
$routes->post('status_service', 'Service::status_service'); $routes->post('status_service', 'Service::status_service');

View File

@ -4,6 +4,7 @@ namespace App\Controllers;
use App\Models\BikemodelsModel; use App\Models\BikemodelsModel;
use App\Models\BikemakeModel; use App\Models\BikemakeModel;
use App\Models\ComplaintModel;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
@ -15,29 +16,36 @@ class Model extends BaseController
use ResponseTrait; use ResponseTrait;
public $BikemodelsModel; public $BikemodelsModel;
public $BikemakeModel; public $BikemakeModel;
public $ComplaintModel;
public function __construct() public function __construct()
{ {
$this->session = session(); $this->session = session();
$this->BikemodelsModel = new BikemodelsModel(); $this->BikemodelsModel = new BikemodelsModel();
$this->BikemakeModel = new BikemakeModel(); $this->BikemakeModel = new BikemakeModel();
$this->ComplaintModel = new ComplaintModel();
} }
public function index($make_id) public function index($make_id)
{ {
$BikemodelsModel = new BikemodelsModel(); $make_value = $this->BikemakeModel->where('make_id',$make_id)->select('make_id,make')->find();
$BikemakeModel = new BikemakeModel();
$make_value = $BikemakeModel->where('make_id',$make_id)->select('make_id,make')->find();
$make_name= $make_value[0]['make']; $make_name= $make_value[0]['make'];
$make_id= $make_value[0]['make_id']; $make_id= $make_value[0]['make_id'];
$model = $BikemodelsModel->orderBy('model_name')->where('make_id',$make_id)->findAll(); $model = $this->BikemodelsModel->select('model.*, cubic_capacity.value')
->join('cubic_capacity', 'cubic_capacity.id = model.cubic_capacity_id', 'left')
->where('make_id',$make_id)->orderBy('model_name')
->findAll();
$data['model']=$model; $data['model']=$model;
$data['make_name'] =$make_name; $data['make_name'] =$make_name;
$data['make_id'] =$make_id; $data['make_id'] =$make_id;
$cubiccapacity = $this->ComplaintModel->getCubicCapacityName();
$data['cubiccapacity']=$cubiccapacity;
// dd($model);
return view('bike_model_list',$data); return view('bike_model_list',$data);
} }
@ -64,6 +72,7 @@ class Model extends BaseController
try { try {
$make_id = $this->request->getPost('make_id'); $make_id = $this->request->getPost('make_id');
$model_name = $this->request->getPost('modelname'); $model_name = $this->request->getPost('modelname');
$cubic_capacity = $this->request->getPost('cubiccapacity');
$BikemodelsModel = new BikemodelsModel(); $BikemodelsModel = new BikemodelsModel();
//they check model name already exist or not here. //they check model name already exist or not here.
@ -83,7 +92,8 @@ class Model extends BaseController
$data = [ $data = [
'make_id' => $make_id, 'make_id' => $make_id,
'model_name' => $model_name 'model_name' => $model_name,
'cubic_capacity_id'=>$cubic_capacity
]; ];
// print_r($model_id);die; // print_r($model_id);die;

View File

@ -8,6 +8,7 @@ use App\Models\VendorModel;
use App\Models\BikemodelsModel; use App\Models\BikemodelsModel;
use App\Models\ProductModel; use App\Models\ProductModel;
use App\Models\AdditionalProductNameModal; use App\Models\AdditionalProductNameModal;
use App\Models\ComplaintModel;
use CodeIgniter\API\ResponseTrait; use CodeIgniter\API\ResponseTrait;
class Service extends BaseController class Service extends BaseController
@ -20,6 +21,7 @@ class Service extends BaseController
protected $vendorModel; protected $vendorModel;
protected $BikemodelsModel; protected $BikemodelsModel;
protected $ProductModel; protected $ProductModel;
protected $ComplaintModel;
use ResponseTrait; use ResponseTrait;
public function __construct() public function __construct()
@ -32,6 +34,7 @@ class Service extends BaseController
$this->vendorModel = new VendorModel(); $this->vendorModel = new VendorModel();
$this->BikemodelsModel = new BikemodelsModel(); $this->BikemodelsModel = new BikemodelsModel();
$this->ProductModel = new ProductModel(); $this->ProductModel = new ProductModel();
$this->ComplaintModel = new ComplaintModel();
} }
public function service_index() public function service_index()
@ -89,6 +92,7 @@ class Service extends BaseController
->findAll(); ->findAll();
$data['tax'] = $this->ServiceModel->getTax(); $data['tax'] = $this->ServiceModel->getTax();
$data['cubiccapacity']= $this->ComplaintModel->getCubicCapacityName();
if ($service_id === '0') { if ($service_id === '0') {
@ -135,11 +139,11 @@ class Service extends BaseController
// print $final_price; // print $final_price;
// print_r($this->request->getPost()); // print_r($this->request->getPost());
$make_ids = $this->request->getPost('make'); // $make_ids = $this->request->getPost('make');
$model_ids = $this->request->getPost('model'); // $model_ids = $this->request->getPost('model');
$model_json = json_encode($model_ids); // $model_json = json_encode($model_ids);
$make_json = json_encode($make_ids); // $make_json = json_encode($make_ids);
$data = [ $data = [
'service_name' => $this->request->getPost('servicename'), 'service_name' => $this->request->getPost('servicename'),
'category' => $this->request->getPost('category'), 'category' => $this->request->getPost('category'),
@ -151,10 +155,11 @@ class Service extends BaseController
'labour_cost' => $this->request->getPost('labour_cost'), 'labour_cost' => $this->request->getPost('labour_cost'),
'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'), 'labour_cost_with_cost' => $this->request->getPost('labour_cost_with_cost'),
'price' => $final_price, 'price' => $final_price,
'makes_id' => $make_json, // 'makes_id' => $make_json,
'models_id' => $model_json, // 'models_id' => $model_json,
'description' => $this->request->getPost('description'), 'description' => $this->request->getPost('description'),
'isactive' => 1 , 'isactive' => 1 ,
'cubic_capacity_id' => $this->request->getPost('cubiccapacity'),
]; ];
$service_id = $this->request->getPost('service_id'); $service_id = $this->request->getPost('service_id');
@ -208,64 +213,64 @@ class Service extends BaseController
} }
public function get_product_by_models(){ // public function get_product_by_models(){
$make_id = $this->request->getPost('make_id'); // $make_id = $this->request->getPost('make_id');
$model_ids = $this->request->getPost('model_ids'); // $model_ids = $this->request->getPost('model_ids');
$products = []; // $products = [];
array_push($model_ids,'0'); // array_push($model_ids,'0');
foreach ($model_ids as $modelId) { // foreach ($model_ids as $modelId) {
$product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name') // $product = $this->additionalProductNameModal->select('products.*, manufacturer.manufacturer_name, product_names.product_names_id, product_names.additional_product_name')
->join('products', 'products.product_id = product_names.product_id') // ->join('products', 'products.product_id = product_names.product_id')
->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') // ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false) // ->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false)
->where('products.isactive', 1) // ->where('products.isactive', 1)
->findAll(); // ->findAll();
$products = array_merge($products, $product); // $products = array_merge($products, $product);
} // }
$products = array_unique($products, SORT_REGULAR); // $products = array_unique($products, SORT_REGULAR);
return $this->response->setJSON($products); // return $this->response->setJSON($products);
} // }
public function get_models() // public function get_models()
{ // {
$selected_makes = $this->request->getPost('selected_makes'); // $selected_makes = $this->request->getPost('selected_makes');
// Initialize an empty array to store formatted model data // // Initialize an empty array to store formatted model data
$formatted_models = []; // $formatted_models = [];
// Iterate over each selected make ID // // Iterate over each selected make ID
if ($selected_makes) { // if ($selected_makes) {
foreach ($selected_makes as $make_id) { // foreach ($selected_makes as $make_id) {
// Fetch models based on the selected make ID // // Fetch models based on the selected make ID
$models = $this->BikemodelsModel->where('make_id', $make_id)->where('business_id', $this->session->get('logged_user_business_id'))->findAll(); // $models = $this->BikemodelsModel->where('make_id', $make_id)->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
// Iterate over each fetched model and format it as needed // // Iterate over each fetched model and format it as needed
foreach ($models as $model) { // foreach ($models as $model) {
// Create an associative array with 'model_id' and 'model_name' properties // // Create an associative array with 'model_id' and 'model_name' properties
$formatted_model = [ // $formatted_model = [
'make_id' => $model['make_id'], // 'make_id' => $model['make_id'],
'model_id' => $model['model_id'], // 'model_id' => $model['model_id'],
'model_name' => $model['model_name'] // 'model_name' => $model['model_name']
// Add other properties if needed // // Add other properties if needed
]; // ];
// Push the formatted model into the array // // Push the formatted model into the array
$formatted_models[] = $formatted_model; // $formatted_models[] = $formatted_model;
} // }
} // }
} // }
// print_r($formatted_models);die; // // print_r($formatted_models);die;
// Send the formatted models as JSON response back to the client // // Send the formatted models as JSON response back to the client
return $this->response->setJSON($formatted_models); // return $this->response->setJSON($formatted_models);
} // }
public function status_service() public function status_service()

View File

@ -5,5 +5,5 @@ class BikemodelsModel extends Model
{ {
protected $table = 'model'; protected $table = 'model';
protected $primaryKey = 'model_id'; protected $primaryKey = 'model_id';
protected $allowedFields = ['model_id','business_id','make_id','model_name','isactive']; protected $allowedFields = ['model_id','business_id','make_id','model_name','isactive','cubic_capacity_id'];
} }

View File

@ -5,7 +5,7 @@ class ServiceModel extends Model
{ {
protected $table = 'services'; protected $table = 'services';
protected $primaryKey = 'service_id'; protected $primaryKey = 'service_id';
protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','labour_cost_with_cost','description','makes_id','models_id','product_id','sub_service_id','isactive']; protected $allowedFields = ['service_id','branch_id','category','service_name','labour_cost','cgst','sgst','price','tax','labour_cost_with_cost','description','makes_id','models_id','product_id','sub_service_id','isactive','cubic_capacity_id'];
public function getTax() public function getTax()

View File

@ -5,7 +5,7 @@ class ServicesModel extends Model
{ {
protected $table = 'services'; protected $table = 'services';
protected $primaryKey = 'service_id'; protected $primaryKey = 'service_id';
protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive']; protected $allowedFields = ['service_id','service_name','price','commission_rate','cgst','sgst','purchase_cost','description','isactive','cubic_capacity_id'];
} }

View File

@ -25,6 +25,7 @@
<thead> <thead>
<tr> <tr>
<th>Model Name</th> <th>Model Name</th>
<th>Cubic Capacity</th>
<th>Status</th> <th>Status</th>
<th>Action</th> <th>Action</th>
</tr> </tr>
@ -33,6 +34,7 @@
<?php foreach ($model as $index => $item): ?> <?php foreach ($model as $index => $item): ?>
<tr class="model_tr_<?php echo $index+1;?>"> <tr class="model_tr_<?php echo $index+1;?>">
<td class="model_name"><?php echo $item['model_name']; ?></td> <td class="model_name"><?php echo $item['model_name']; ?></td>
<td class="cubic_capacity"><?php echo $item['value']; ?></td>
<td> <td>
<?php if($item['isactive'] == 1): ?> <?php if($item['isactive'] == 1): ?>
<span style="color:green">Active</span> <span style="color:green">Active</span>
@ -77,11 +79,27 @@
<div class="form-group"> <div class="form-group">
<input type="text" id="edit_model_id" hidden> <input type="text" id="edit_model_id" hidden>
<input type="text" id="cubic_capacity_id" hidden>
<div class="form-group">
<input class="form-control" type="text" id="make_id" required="" value="<?php echo $make_id; ?>" placeholder="Make Name...." style="display:none;"> <input class="form-control" type="text" id="make_id" required="" value="<?php echo $make_id; ?>" placeholder="Make Name...." style="display:none;">
<label for="makename">Make Name </label> <label for="makename">Make Name </label>
<input class="form-control" type="text" id="makename" required="" value="<?php echo $make_name; ?>" placeholder="Make Name...." disabled> <input class="form-control" type="text" id="makename" required="" value="<?php echo $make_name; ?>" placeholder="Make Name...." disabled>
</div>
<div class="form-group">
<label for="cubiccapacity">Cubic capacity</label>
<select class="form-control" id="cubiccapacity" required data-toggle="select2">
<option value="0">Select Cubic capacity</option>
<?php foreach ($cubiccapacity as $item): ?>
<option value="<?= $item['id'] ?>"><?= $item['value'] ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="form-group">
<label for="modelname">Model Name </label> <label for="modelname">Model Name </label>
<input class="form-control" type="text" id="modelname" required="" placeholder="Model Name...."> <input class="form-control" type="text" id="modelname" required="" placeholder="Model Name....">
</div>
</div> </div>
<div class="form-group text-center"> <div class="form-group text-center">
@ -98,8 +116,6 @@
<script> <script>
function submitModels(params) { function submitModels(params) {
// console.log( $('#modelname').val());
var edit_model_id = $('#edit_model_id').val(); var edit_model_id = $('#edit_model_id').val();
if (!edit_model_id) { if (!edit_model_id) {
edit_model_id =0; edit_model_id =0;
@ -107,7 +123,8 @@
var formData = { var formData = {
make_id: $('#make_id').val(), make_id: $('#make_id').val(),
modelname: $('#modelname').val() modelname: $('#modelname').val(),
cubiccapacity: $('#cubiccapacity').val()
}; };
$.ajax({ $.ajax({
type: 'POST', type: 'POST',
@ -122,6 +139,8 @@
$('#bike_model_login-modal_1').modal('hide'); $('#bike_model_login-modal_1').modal('hide');
$('#makename').val(''); $('#makename').val('');
$('#modelname').val(''); $('#modelname').val('');
$('#cubiccapacity').val('');
toastr.success(response.data, 'Success'); toastr.success(response.data, 'Success');
// $('tbody').html(''); // $('tbody').html('');
@ -236,14 +255,31 @@
$('#form_add_edit').text('Edit Models'); $('#form_add_edit').text('Edit Models');
var full_div = $(params).closest('tr')[0]; var full_div = $(params).closest('tr')[0];
$('#modelname').val($(full_div).find('.model_name').text()); $('#modelname').val($(full_div).find('.model_name').text());
var cubicCapacity = $(full_div).find('.cubic_capacity').text();
console.log(cubicCapacity);
$('#cubiccapacity option').each(function() {
if ($(this).text().trim() === cubicCapacity.trim()) {
$(this).prop('selected', true).trigger('change');
}
});
// var cc_id = $(full_div).find('.cubic_capacity_id').text();
// var selectElementForCC = document.getElementById('cubiccapacity');
// var ccOptions = selectElementForCC.options;
// for (var j = 0; j < ccOptions.length; j++) {
// if (ccOptions[j].value === cc_id) {
// ccOptions[j].selected = true;
// break;
// }
// }
} }
function clearDetials(params) { function clearDetials(params) {
$('#form_add_edit').text('Add Models'); $('#form_add_edit').text('Add Models');
$('#modelname').val(''); $('#modelname').val('');
$('#cubiccapacity').val('');
} }
function deleteModel(params) { function deleteModel(params) {

View File

@ -29,17 +29,26 @@
<option value="1" <?= (isset($services['category']) && $services['category'] == 1) ? 'selected' : '' ?> >Standalone Service</option> <option value="1" <?= (isset($services['category']) && $services['category'] == 1) ? 'selected' : '' ?> >Standalone Service</option>
</select> </select>
</div> </div>
<div class="form-group col-md-3" id="make_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>> <div class="form-group col-md-3" id="cc_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>>
<label for="cubiccapacity" class="col-form-label">Cubic capacity<span class="text-danger">*</span></label>
<select class="form-control" id="cubiccapacity" name="cubiccapacity" style="height:32px" required>
<option value="">Select</option>
<?php foreach ($cubiccapacity as $item): ?>
<option value="<?= $item['id'] ?>" <?php if (isset($services['cubic_capacity_id']) && (($services['cubic_capacity_id'] === $item['id']))) echo "selected"; ?>><?= $item['value'] ?></option>
<?php endforeach; ?>
</select>
</div>
<!-- <div class="form-group col-md-3" id="make_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>>
<label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label> <label for="inputPassword4" class="col-form-label">Make<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="make" name="make[]" multiple> <select class="form-control SelExample" id="make" name="make[]" multiple>
<!-- Options for make --> <!- Options for make ->
<!-- <option value="0">Custom</option> --> <!- <option value="0">Custom</option> ->
<?php foreach ($make as $value): ?> <?php foreach ($make as $value): ?>
<option value="<?= $value['make_id'] ?>" <?= isset($services['makes_id']) && in_array($value['make_id'], $services['makes_id']) ? 'selected' : '' ?>><?= $value['make'] ?></option> <option value="<?= $value['make_id'] ?>" <?= isset($services['makes_id']) && in_array($value['make_id'], $services['makes_id']) ? 'selected' : '' ?>><?= $value['make'] ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div> -->
<div class="form-group col-md-3" id="model_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>> <!-- <div class="form-group col-md-3" id="model_hide" <?= (!isset($services['category']) || $services['category'] == 0) ? 'style="display: none;"' : '' ?>>
<label for="model" class="col-form-label">Model<span class="text-danger">*</span></label> <label for="model" class="col-form-label">Model<span class="text-danger">*</span></label>
<select class="form-control SelExample" id="model" name="model[]" multiple> <select class="form-control SelExample" id="model" name="model[]" multiple>
<option value="0">Custom</option> <option value="0">Custom</option>
@ -49,7 +58,7 @@
<?php endforeach; ?> <?php endforeach; ?>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div> -->
<div class="form-group col-md-3"> <div class="form-group col-md-3">
<label for="inputEmail4" class="col-form-label">Service Name<span class="text-danger">*</span></label> <label for="inputEmail4" class="col-form-label">Service Name<span class="text-danger">*</span></label>
<input type="text" class="form-control" name="servicename" style="height:32px" placeholder="Service Name" value="<?= isset($services['service_name']) ? $services['service_name'] : '' ?>" required> <input type="text" class="form-control" name="servicename" style="height:32px" placeholder="Service Name" value="<?= isset($services['service_name']) ? $services['service_name'] : '' ?>" required>
@ -192,90 +201,90 @@ $(document).ready(function(){
$(document).ready(function() { $(document).ready(function() {
$('#make').change(function() { // $('#make').change(function() {
var selected_makes = $(this).val(); // Get the selected make ID // var selected_makes = $(this).val(); // Get the selected make ID
console.log(selected_makes); // console.log(selected_makes);
var models_id = $('#model').val(); // var models_id = $('#model').val();
// AJAX request to get models based on the selected make ID // // AJAX request to get models based on the selected make ID
$.ajax({ // $.ajax({
url: '<?php echo base_url('get_models_service') ?>', // URL to your CodeIgniter controller method // url: '<?php // echo base_url('get_models_service') ?>', // URL to your CodeIgniter controller method
type: 'POST', // type: 'POST',
dataType: 'json', // dataType: 'json',
data: { selected_makes: selected_makes }, // Send the selected make ID to the controller // data: { selected_makes: selected_makes }, // Send the selected make ID to the controller
success: function(response) { // success: function(response) {
// console.log(response); // // console.log(response);
// Update models dropdown based on the response // // Update models dropdown based on the response
if (response.length > 0) { // if (response.length > 0) {
// Clear existing options // // Clear existing options
$('#model').empty(); // $('#model').empty();
// Iterate through response and models_id // // Iterate through response and models_id
$.each(response, function(index, model) { // $.each(response, function(index, model) {
var count =0; // var count =0;
// $('#model').empty(); // // $('#model').empty();
$.each(models_id, function(index, model_id) { // $.each(models_id, function(index, model_id) {
if (model.model_id == model_id) { // if (model.model_id == model_id) {
// Append option for the model // // Append option for the model
$('#model').append('<option value="' + model.model_id + '" selected>' + model.model_name + '</option>'); // $('#model').append('<option value="' + model.model_id + '" selected>' + model.model_name + '</option>');
count =1; // count =1;
} // }
}); // });
if (count == 0) { // if (count == 0) {
$('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>'); // $('#model').append('<option value="' + model.model_id + '">' + model.model_name + '</option>');
} // }
}); // });
} else { // } else {
// Handle case when no models are found // // Handle case when no models are found
$('#model').empty().append('<option value="">No models found</option>'); // $('#model').empty().append('<option value="">No models found</option>');
} // }
}, // },
error: function(xhr, status, error) { // error: function(xhr, status, error) {
// Handle error // // Handle error
console.error(xhr.responseText); // console.error(xhr.responseText);
} // }
}); // });
}); // });
}); });
$(document).ready(function() { $(document).ready(function() {
$('#model').change(function() { // $('#model').change(function() {
var make_id = $('#make').val(); // Get the selected make ID // var make_id = $('#make').val(); // Get the selected make ID
var model_ids = $('#model').val(); // Get the selected model IDs // var model_ids = $('#model').val(); // Get the selected model IDs
// AJAX request to get vendors based on the selected model ID // // AJAX request to get vendors based on the selected model ID
console.log(model_ids); // console.log(model_ids);
if (model_ids.length > 0) { // if (model_ids.length > 0) {
$.ajax({ // $.ajax({
url: '<?php echo base_url('get_product_by_models') ?>', // URL to your CodeIgniter controller method // url: '<?php // echo base_url('get_product_by_models') ?>', // URL to your CodeIgniter controller method
type: 'POST', // type: 'POST',
dataType: 'json', // dataType: 'json',
data: { make_id: make_id, model_ids: model_ids }, // Send the selected make ID and model IDs to the controller // data: { make_id: make_id, model_ids: model_ids }, // Send the selected make ID and model IDs to the controller
success: function(response) { // success: function(response) {
console.log(response); // console.log(response);
// Update vendor dropdown based on the response // // Update vendor dropdown based on the response
if (response) { // if (response) {
// Clear existing options // // Clear existing options
$('#productSelect').empty(); // $('#productSelect').empty();
// Append new options // // Append new options
$('#productSelect').append('<option value>Select Product</option>'); // $('#productSelect').append('<option value>Select Product</option>');
$.each(response, function(index, product) { // $.each(response, function(index, product) {
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - '+ product.manufacturer_name + '</option>'); // $('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name +' - '+ product.manufacturer_name + '</option>');
}); // });
} else { // } else {
// Handle case when no vendors are found for the selected model // // Handle case when no vendors are found for the selected model
console.log('No vendors found for the selected model'); // console.log('No vendors found for the selected model');
} // }
}, // },
error: function(xhr, status, error) { // error: function(xhr, status, error) {
// Handle error // // Handle error
console.error(xhr.responseText); // console.error(xhr.responseText);
} // }
}); // });
} // }
}); // });
data = <?php echo json_encode($product) ?>; data = <?php echo json_encode($product) ?>;
servicedata = <?php echo json_encode($service) ?>; servicedata = <?php echo json_encode($service) ?>;
@ -292,24 +301,29 @@ $(document).ready(function() {
<script> <script>
document.getElementById('category').addEventListener('change', function() { document.getElementById('category').addEventListener('change', function() {
// var customFields = document.getElementById('customFields'); // var customFields = document.getElementById('customFields');
var makeSelect = document.getElementById('make'); // var makeSelect = document.getElementById('make');
var modelSelect = document.getElementById('model'); // var modelSelect = document.getElementById('model');
var ccSelect = document.getElementById('cubiccapacity');
var serviceSelected = document.getElementById('serviceSelected'); var serviceSelected = document.getElementById('serviceSelected');
if (this.value == '1') { if (this.value == '1') {
// customFields.style.display = 'block'; // customFields.style.display = 'block';
$('#make_hide').css('display' , 'block'); // $('#make_hide').css('display' , 'block');
$('#model_hide').css('display' ,'block'); // $('#model_hide').css('display' ,'block');
$('#cc_hide').css('display' , 'block');
$('#service_hide').css('display' ,'block'); $('#service_hide').css('display' ,'block');
makeSelect.setAttribute('required', 'required'); ccSelect.setAttribute('required', 'required');
modelSelect.setAttribute('required', 'required'); // makeSelect.setAttribute('required', 'required');
// modelSelect.setAttribute('required', 'required');
// serviceSelected.setAttribute('required', 'required'); // serviceSelected.setAttribute('required', 'required');
} else { } else {
// customFields.style.display = 'none'; // customFields.style.display = 'none';
$('#make_hide').css('display' , 'none'); // $('#make_hide').css('display' , 'none');
$('#model_hide').css('display' ,'none'); // $('#model_hide').css('display' ,'none');
$('#cc_hide').css('display' , 'none');
$('#service_hide').css('display' ,'none'); $('#service_hide').css('display' ,'none');
makeSelect.removeAttribute('required'); ccSelect.removeAttribute('required');
modelSelect.removeAttribute('required'); // makeSelect.removeAttribute('required');
// modelSelect.removeAttribute('required');
serviceSelected.removeAttribute('required'); serviceSelected.removeAttribute('required');
$.ajax({ $.ajax({