Merge branch 'main' of bitbucket.org:venbainformationtechnology/the_mechanic into main
This commit is contained in:
commit
38783d6957
@ -63,6 +63,7 @@ $routes->post("get_models", "Products::get_models");
|
||||
$routes->get("get_makes", "Products::get_makes");
|
||||
$routes->post("save_make", "Products::save_make");
|
||||
$routes->post("save_model", "Products::save_model");
|
||||
$routes->get("product_list_for_service", "Products::product_list_for_service");
|
||||
//end products//
|
||||
|
||||
//Sales order //
|
||||
@ -146,6 +147,8 @@ $routes->get('dashboard', 'Users::dashboard');
|
||||
$routes->post("add_service", "Service::add_service");
|
||||
$routes->post("get_models_service", "Service::get_models");
|
||||
$routes->get("delete_service/(:any)", "Service::delete_service/$1");
|
||||
$routes->post("get_product_by_models", "Service::get_product_by_models");
|
||||
|
||||
// Service End's//
|
||||
|
||||
|
||||
|
||||
@ -219,6 +219,7 @@ class Products extends BaseController
|
||||
{
|
||||
foreach ($Vendors as $vendorsKey => $vendorsValue)
|
||||
{
|
||||
print_r($vendorsValue);die;
|
||||
$modelsArray = json_decode($vendorsValue['model'], true);
|
||||
if (is_array($modelsArray))
|
||||
{
|
||||
@ -371,4 +372,13 @@ class Products extends BaseController
|
||||
|
||||
return $this->response->setJSON($response);
|
||||
}
|
||||
|
||||
|
||||
public function product_list_for_service(){
|
||||
$ProductModel = new ProductModel();
|
||||
$products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll();
|
||||
|
||||
return $this->response->setJSON($products);
|
||||
}
|
||||
|
||||
}
|
||||
@ -85,6 +85,8 @@ class Sales extends BaseController
|
||||
$encodedMakeId = json_encode([$makeId]);
|
||||
$encodedModelId = json_encode([$modelId]);
|
||||
|
||||
// print_r("aadhavan");
|
||||
// print_r($encodedMakeId);die;
|
||||
// Load the ProductModel
|
||||
$productModel = new ProductModel();
|
||||
|
||||
|
||||
@ -150,6 +150,7 @@ class Service extends BaseController
|
||||
'service_name' => $this->request->getPost('servicename'),
|
||||
'category' => $this->request->getPost('category'),
|
||||
'product_id' => json_encode($this->request->getPost('product_id')),
|
||||
'sub_service_id' => json_encode($this->request->getPost('sub_service_id')),
|
||||
'cgst' => $tax,
|
||||
'sgst' => $tax,
|
||||
'tax' => $this->request->getPost('tax'),
|
||||
@ -222,7 +223,20 @@ class Service extends BaseController
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_product_by_models(){
|
||||
$make_id = $this->request->getPost('make_id');
|
||||
$model_ids = $this->request->getPost('model_ids');
|
||||
|
||||
$ProductModel = new ProductModel();
|
||||
|
||||
$encodedModelId = json_encode($model_ids);
|
||||
// print_r("heloooo");
|
||||
// print_r($encodedModelId);die;
|
||||
|
||||
$product = $ProductModel->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
|
||||
->findAll();
|
||||
return $this->response->setJSON($product);
|
||||
}
|
||||
|
||||
|
||||
public function get_models()
|
||||
|
||||
@ -155,7 +155,7 @@
|
||||
|
||||
<li>
|
||||
<a href="#sidebarLayouts2" data-toggle="collapse">
|
||||
<i class="mdi mdi-sale"></i>
|
||||
<i class="fa fa-wrench"></i>
|
||||
<span> Job Card </span>
|
||||
<span class="menu-arrow"></span>
|
||||
</a>
|
||||
|
||||
@ -216,24 +216,25 @@ $(document).ready(function() {
|
||||
|
||||
$(document).ready(function() {
|
||||
$('#model').change(function() {
|
||||
var make_id = $(this).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
|
||||
|
||||
// AJAX request to get vendors based on the selected model ID
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('get_vendors_by_model') ?>', // URL to your CodeIgniter controller method
|
||||
url: '<?php echo base_url('get_product_by_models') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { make_id: make_id, model_ids: model_ids }, // Send the selected make ID and model IDs to the controller
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
// Update vendor dropdown based on the response
|
||||
if (response) {
|
||||
// Clear existing options
|
||||
$('#vendor').empty();
|
||||
$('#productSelect').empty();
|
||||
// Append new options
|
||||
$('#vendor').append('<option value>"hello"</option>');
|
||||
$.each(response, function(index, vendor) {
|
||||
$('#vendor').append('<option value="' + vendor.vendor_id + '">' + vendor.vendor_name + '</option>');
|
||||
$('#productSelect').append('<option value>Select Product</option>');
|
||||
$.each(response, function(index, product) {
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name + '</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
@ -268,6 +269,32 @@ document.getElementById('category').addEventListener('change', function() {
|
||||
$('#model_hide').css('display' ,'none');
|
||||
makeSelect.removeAttribute('required');
|
||||
modelSelect.removeAttribute('required');
|
||||
|
||||
$.ajax({
|
||||
url: '<?php echo base_url('product_list_for_service') ?>', // URL to your CodeIgniter controller method
|
||||
type: 'GET',
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
// Update vendor dropdown based on the response
|
||||
if (response) {
|
||||
// Clear existing options
|
||||
$('#productSelect').empty();
|
||||
// Append new options
|
||||
$('#productSelect').append('<option value>Select Product</option>');
|
||||
$.each(response, function(index, product) {
|
||||
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_name + '</option>');
|
||||
});
|
||||
} else {
|
||||
// Handle case when no vendors are found for the selected model
|
||||
console.log('No vendors found for the selected model');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error
|
||||
console.error(xhr.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user