diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 9ade4f0..4918b0d 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -65,7 +65,7 @@ class Products extends BaseController $ProductModel = new ProductModel(); $tax= $this->request->getPost('tax')/2; - + // print_r($this->request->getPost());die; $data = [ 'product_name' => $this->request->getPost('productname'), 'product_category' => $this->request->getPost('productcategory'), @@ -82,6 +82,8 @@ class Products extends BaseController 'vendor' => $this->request->getPost('vendor'), 'purchase_order_level' => $this->request->getPost('purchase_order_level'), 'quality' => $this->request->getPost('quality'), + 'make_id' => $this->request->getPost('make'), + 'models_id' => json_encode($this->request->getPost('model')), 'isactive' => 1 , 'branch_id' => $this->session->get('logged_user_branch_id') ]; @@ -124,26 +126,17 @@ class Products extends BaseController // Retrieve the make_id from the AJAX request public function get_vendors_by_model() { - $make_id = $this->request->getPost('make_id'); + $model_ids = $this->request->getPost('model_ids'); - // print_r( $model_ids);die; - - // If make_id or model_ids is not provided, return an empty response - - // Create an instance of VendorModel $vendorModel = new VendorModel(); - - // Call the get_vendors_by_model method from the model - $vendors = $vendorModel->get_vendors_by_model($make_id, $model_ids); - // print_r($vendors); - // Return the response as JSON - // return $this->response->setJSON(['success' => true, 'message' => 'Client saved successfully.']); + $vendors = $vendorModel->get_vendors_by_model( $model_ids); + if ($vendors) { - // Return the retrieved vendors as JSON response + return $this->response->setJSON($vendors); } else { - // If no vendors were found, return an empty response or handle the error accordingly + return $this->response->setJSON([]); } } diff --git a/app/Models/ProductModel.php b/app/Models/ProductModel.php index a0f7a1f..63c54ff 100644 --- a/app/Models/ProductModel.php +++ b/app/Models/ProductModel.php @@ -5,7 +5,7 @@ class ProductModel extends Model { protected $table = 'products'; protected $primaryKey = 'product_id'; - protected $allowedFields = ['product_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive']; + protected $allowedFields = ['product_id','make_id','models_id','quality','product_name','branch_id','search_tag','product_category','mfr_part_no','purchase_order_level','serial_no','unit_price','commision_rate','sgst','cgst','purchase_cost','usage_unit','vendor','qty_stock','reorder_level','handler','qty_in_demand','product_image','description','isactive']; public function getTax() diff --git a/app/Views/client_form.php b/app/Views/client_form.php index a8c072a..e962a9a 100644 --- a/app/Views/client_form.php +++ b/app/Views/client_form.php @@ -21,6 +21,7 @@
" method="post"> +

Client Details :

@@ -30,6 +31,16 @@
+
+ + +
@@ -38,23 +49,10 @@
-
- - -
- - - - +
-

Address Information :

+

Address Information :

diff --git a/app/Views/product_form.php b/app/Views/product_form.php index e79bb74..237b6aa 100644 --- a/app/Views/product_form.php +++ b/app/Views/product_form.php @@ -26,6 +26,7 @@
- - -
-
- - -
- + + +
+
+ + +
+
@@ -200,6 +201,7 @@ $(document).ready(function() { // Clear existing options $('#model').empty(); // Append new options + $("#model").append(''); $.each(response, function(index, model) { $('#model').append(''); }); @@ -218,7 +220,7 @@ $(document).ready(function() { $(document).ready(function() { $('#model').change(function() { - var make_id = $(this).val(); // Get the selected make ID + var model_ids = $('#model').val(); // Get the selected model IDs console.log(model_ids); @@ -227,14 +229,14 @@ console.log(model_ids); url: '', // 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 + data: { model_ids: model_ids }, // Send the selected make ID and model IDs to the controller success: function(response) { // Update vendor dropdown based on the response if (response) { // Clear existing options $('#vendor').empty(); // Append new options - $('#vendor').append(''); + $('#vendor').append(''); $.each(response, function(index, vendor) { $('#vendor').append(''); }); diff --git a/app/Views/vehicle_form.php b/app/Views/vehicle_form.php index 41b984d..588e1a2 100644 --- a/app/Views/vehicle_form.php +++ b/app/Views/vehicle_form.php @@ -20,10 +20,10 @@ " method="post"> -

Vehicle Details :


+

Vehicle Details :

- +
- +
- +
@@ -58,10 +58,11 @@
-

Client Details :


+
+

Client Details :

- + ' ?>
+
+ + +
-
- - -
+