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->get("get_makes", "Products::get_makes");
|
||||||
$routes->post("save_make", "Products::save_make");
|
$routes->post("save_make", "Products::save_make");
|
||||||
$routes->post("save_model", "Products::save_model");
|
$routes->post("save_model", "Products::save_model");
|
||||||
|
$routes->get("product_list_for_service", "Products::product_list_for_service");
|
||||||
//end products//
|
//end products//
|
||||||
|
|
||||||
//Sales order //
|
//Sales order //
|
||||||
@ -146,6 +147,8 @@ $routes->get('dashboard', 'Users::dashboard');
|
|||||||
$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");
|
||||||
|
|
||||||
// Service End's//
|
// Service End's//
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -219,6 +219,7 @@ class Products extends BaseController
|
|||||||
{
|
{
|
||||||
foreach ($Vendors as $vendorsKey => $vendorsValue)
|
foreach ($Vendors as $vendorsKey => $vendorsValue)
|
||||||
{
|
{
|
||||||
|
print_r($vendorsValue);die;
|
||||||
$modelsArray = json_decode($vendorsValue['model'], true);
|
$modelsArray = json_decode($vendorsValue['model'], true);
|
||||||
if (is_array($modelsArray))
|
if (is_array($modelsArray))
|
||||||
{
|
{
|
||||||
@ -371,4 +372,13 @@ class Products extends BaseController
|
|||||||
|
|
||||||
return $this->response->setJSON($response);
|
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]);
|
$encodedMakeId = json_encode([$makeId]);
|
||||||
$encodedModelId = json_encode([$modelId]);
|
$encodedModelId = json_encode([$modelId]);
|
||||||
|
|
||||||
|
// print_r("aadhavan");
|
||||||
|
// print_r($encodedMakeId);die;
|
||||||
// Load the ProductModel
|
// Load the ProductModel
|
||||||
$productModel = new ProductModel();
|
$productModel = new ProductModel();
|
||||||
|
|
||||||
|
|||||||
@ -150,6 +150,7 @@ class Service extends BaseController
|
|||||||
'service_name' => $this->request->getPost('servicename'),
|
'service_name' => $this->request->getPost('servicename'),
|
||||||
'category' => $this->request->getPost('category'),
|
'category' => $this->request->getPost('category'),
|
||||||
'product_id' => json_encode($this->request->getPost('product_id')),
|
'product_id' => json_encode($this->request->getPost('product_id')),
|
||||||
|
'sub_service_id' => json_encode($this->request->getPost('sub_service_id')),
|
||||||
'cgst' => $tax,
|
'cgst' => $tax,
|
||||||
'sgst' => $tax,
|
'sgst' => $tax,
|
||||||
'tax' => $this->request->getPost('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()
|
public function get_models()
|
||||||
|
|||||||
@ -155,7 +155,7 @@
|
|||||||
|
|
||||||
<li>
|
<li>
|
||||||
<a href="#sidebarLayouts2" data-toggle="collapse">
|
<a href="#sidebarLayouts2" data-toggle="collapse">
|
||||||
<i class="mdi mdi-sale"></i>
|
<i class="fa fa-wrench"></i>
|
||||||
<span> Job Card </span>
|
<span> Job Card </span>
|
||||||
<span class="menu-arrow"></span>
|
<span class="menu-arrow"></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@ -216,24 +216,25 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#model').change(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
|
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
|
||||||
$.ajax({
|
$.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',
|
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);
|
||||||
// Update vendor dropdown based on the response
|
// Update vendor dropdown based on the response
|
||||||
if (response) {
|
if (response) {
|
||||||
// Clear existing options
|
// Clear existing options
|
||||||
$('#vendor').empty();
|
$('#productSelect').empty();
|
||||||
// Append new options
|
// Append new options
|
||||||
$('#vendor').append('<option value>"hello"</option>');
|
$('#productSelect').append('<option value>Select Product</option>');
|
||||||
$.each(response, function(index, vendor) {
|
$.each(response, function(index, product) {
|
||||||
$('#vendor').append('<option value="' + vendor.vendor_id + '">' + vendor.vendor_name + '</option>');
|
$('#productSelect').append('<option value="' + product.product_id + '">' + product.product_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
|
||||||
@ -268,6 +269,32 @@ document.getElementById('category').addEventListener('change', function() {
|
|||||||
$('#model_hide').css('display' ,'none');
|
$('#model_hide').css('display' ,'none');
|
||||||
makeSelect.removeAttribute('required');
|
makeSelect.removeAttribute('required');
|
||||||
modelSelect.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>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user