From 0df5e1a01f9cc92a73616398332804cc206ba882 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 19 Jun 2024 17:18:09 +0530 Subject: [PATCH] CHANGE_TRACKER_ISSUE_RESOLVED : AADHAVAN --- app/Config/Routes.php | 2 ++ app/Controllers/Outsourcing.php | 16 +++++++++++++ app/Controllers/Products.php | 7 +++++- app/Controllers/ReturnOrder.php | 3 ++- app/Controllers/Sales.php | 4 ++++ app/Controllers/Service.php | 13 +++++++--- app/Controllers/Vehicle.php | 3 ++- app/Models/PurchaseOrderModel.php | 2 +- app/Views/edit_return_order.php | 4 ++-- app/Views/manufacturer_list.php | 8 +++---- app/Views/outsourcing_list.php | 25 +++++++++++-------- app/Views/product_form.php | 2 +- app/Views/purchase_form.php | 32 ++++++++++++++++++++----- app/Views/return_order_form.php | 3 +-- app/Views/return_order_liist.php | 6 ++--- app/Views/sales_order_form.php | 9 +++---- app/Views/service_form.php | 40 +++++++++++++++++++++---------- app/Views/vehicle_form.php | 16 +++++++++---- 18 files changed, 140 insertions(+), 55 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index e1720c0..e3e8baa 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -214,4 +214,6 @@ $routes->get('dashboard', 'Users::dashboard'); $routes->get('outsourcing_index', 'Outsourcing::outsourcing_index'); $routes->post('create_os', 'Outsourcing::create_os'); $routes->get('edit_os/(:any)', 'Outsourcing::edit_OS/$1'); + $routes->get("delete_outsource/(:any)", "Outsourcing::delete_outsource/$1"); + // Complaint End's diff --git a/app/Controllers/Outsourcing.php b/app/Controllers/Outsourcing.php index fe5b66b..f9d744c 100644 --- a/app/Controllers/Outsourcing.php +++ b/app/Controllers/Outsourcing.php @@ -75,5 +75,21 @@ class Outsourcing extends BaseController return json_encode($data); } + public function delete_outsource($id) + { + + if (!empty($id)) { + $OutsourceModel = new OutsourceModel(); + $data['is_active'] = 0; + if ($OutsourceModel->update($id, $data)) { + // Return success response + return redirect()->to('outsourcing_index'); + } + } + + // Return error response if deletion fails + return $this->response->setJSON(['success' => false]); + } + } ?> \ No newline at end of file diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 3f63340..d7b3dd0 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -429,7 +429,12 @@ class Products extends BaseController public function product_list_for_service(){ $ProductModel = new ProductModel(); - $products = $ProductModel->where('branch_id',$this->session->get('logged_user_branch_id'))->findAll(); + // Assuming you have a model for products and one for manufacturers + $products = $ProductModel + ->select('products.*, manufacturer.manufacturer_name') + ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id') + ->where('products.branch_id', $this->session->get('logged_user_branch_id')) + ->findAll(); return $this->response->setJSON($products); } diff --git a/app/Controllers/ReturnOrder.php b/app/Controllers/ReturnOrder.php index b5baf98..70ba8fe 100644 --- a/app/Controllers/ReturnOrder.php +++ b/app/Controllers/ReturnOrder.php @@ -37,6 +37,7 @@ class ReturnOrder extends BaseController $return = $this->returnModel->findAll(); $data['return']=$return; + // echo "
";
         // dd($data);
         return view('return_order_liist',$data);
     }
@@ -97,7 +98,7 @@ class ReturnOrder extends BaseController
             $purchase_product=$PurchaseOrderChildModel->where('purchase_order_id', $purchase_order_id)->where('received_qty >', 0)->where('is_selected', 1)->findAll();
             $data['purchase_product'] = $purchase_product;
 
-      
+            
            echo view('return_order_form',$data);
     }
 
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index e584780..5b0f9c6 100644
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -60,6 +60,7 @@ class Sales extends BaseController
                                 ->join('manufacturer', 'products.manufacturer_id = manufacturer.manufacturer_id')
                                 ->where('products.isactive', 1)
                                 ->where('products.branch_id', $this->session->get('logged_user_branch_id'))
+                                ->where('products.isactive', 1)
                                 ->findAll();
             // echo "
";
             // print_r($product);die;
@@ -111,6 +112,7 @@ class Sales extends BaseController
                                         ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId1 . '\')', null, false)
                                         ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId1 . '\')', null, false)
                                         ->where('qty_stock >',0)
+                                        ->where('products.isactive',1)
                                         ->findAll();
                 $product = array_merge($common_product, $makemodelproduct);
 
@@ -477,6 +479,7 @@ public function getProducts()
                             ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
                             ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
                             ->where('qty_stock >',0)
+                            ->where('products.isactive', 1)
                             ->findAll();
    
     $encodedMakeId = json_encode(['0']);
@@ -487,6 +490,7 @@ public function getProducts()
                             ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
                             ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
                             ->where('qty_stock >',0)
+                            ->where('products.isactive', 1)
                             ->findAll();
     $product = array_merge($common_product, $makeproduct);
 
diff --git a/app/Controllers/Service.php b/app/Controllers/Service.php
index b60b71f..8932f83 100644
--- a/app/Controllers/Service.php
+++ b/app/Controllers/Service.php
@@ -239,8 +239,15 @@ class Service extends BaseController
         $products = [];
         array_push($model_ids,'0');
         foreach ($model_ids as $modelId) {
-            $product = $ProductModel->where('JSON_CONTAINS(models_id, \'["' . $modelId . '"]\')', null, false)
-                                    ->findAll();
+            // Assuming $ProductModel is your Product model class
+            // and you have a Manufacturer model class for the manufacturers table
+
+             $product = $ProductModel->select('products.*, manufacturer.manufacturer_name AS manufacturer_name')
+                                    ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
+                                    ->where('products.isactive', 1)
+                                ->where('JSON_CONTAINS(products.models_id, \'["' . $modelId . '"]\')', null, false)
+                                ->findAll();
+
             $products = array_merge($products, $product);
         }
     
@@ -282,7 +289,7 @@ class Service extends BaseController
                 }
             }
         }
-        
+        // print_r($formatted_models);die;
         // Send the formatted models as JSON response back to the client
         return $this->response->setJSON($formatted_models);
     }
diff --git a/app/Controllers/Vehicle.php b/app/Controllers/Vehicle.php
index 560d9db..6ce20e8 100644
--- a/app/Controllers/Vehicle.php
+++ b/app/Controllers/Vehicle.php
@@ -62,8 +62,9 @@ class Vehicle extends BaseController
             $client=$ClientModel->where('branch_id', $this->session->get('logged_user_branch_id'))->findAll();
             $data['client']=$client;       
         }
+        // dd($vehicle);
             $data['vehicle_id'] = $vehicle_id;
-            $data['makeData'] =$this->bikeMakeModel->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
+            $data['makeData'] =$this->bikeMakeModel->where('make_id', $vehicle['make'])->where('business_id', $this->session->get('logged_user_business_id'))->findAll();
    
         return view('vehicle_form',$data);
     }
diff --git a/app/Models/PurchaseOrderModel.php b/app/Models/PurchaseOrderModel.php
index aab9f6e..61d920f 100644
--- a/app/Models/PurchaseOrderModel.php
+++ b/app/Models/PurchaseOrderModel.php
@@ -10,7 +10,7 @@ class PurchaseOrderModel extends Model
     public function getPurchaseOrdersWithProducts($logged_user_branch_id)
     {
         // Select required fields from both tables
-        $this->select('purchase_order.*, COUNT(purchase_order_child.purchase_order_id) AS product_count,vendor.vendor_name,SUM(purchase_order_child.qty) AS purchase_qty ');
+        $this->select('purchase_order.*, COUNT(purchase_order_child.purchase_order_id) AS product_count,vendor.vendor_name,SUM(purchase_order_child.qty) AS purchase_qty, purchase_order_child.received_qty');
         
         // Join the sales_order_product table based on sales_order_id
         $this->join('purchase_order_child', 'purchase_order_child.purchase_order_id = purchase_order.purchase_order_id');
diff --git a/app/Views/edit_return_order.php b/app/Views/edit_return_order.php
index bd03259..633d53d 100644
--- a/app/Views/edit_return_order.php
+++ b/app/Views/edit_return_order.php
@@ -125,7 +125,7 @@
                                                 
                                                     
                                                     
@@ -80,14 +80,14 @@
                     
- +
@@ -98,7 +98,7 @@
- +
@@ -125,10 +125,14 @@ } - function submitComplaint(params) { - if (!$('#name').val() || !$('#labour_cost').val()) { + function submitComplaint(params, event) { + if (!$('#name').val() || !$('#labour_cost').val() ) { return false; } + if(!$('#cost_with_tax').val()){ + return false; + } + var formData = { id: $('#id').val(), name: $('#name').val(), @@ -137,16 +141,17 @@ cost_with_tax: $('#cost_with_tax').val(), description: $('#description').val(), }; - + $('#outsource_submit_button').attr('disabled', 'true'); $.ajax({ type: 'POST', url: '', data: formData, dataType: 'json', success: function(response) { + // $('#outsource_submit_button').removeAttr('disabled'); console.log(response); // Reload the page after successful submission - // window.location.reload(); + window.location.reload(); }, error: function(xhr, status, error) { // Handle error response here @@ -190,7 +195,7 @@ function clearDetials(params) { $('#form_add_edit').text('Add Complaint'); - $('#model_form_data')[0].reset(); + $('#outsource_form')[0].reset(); } diff --git a/app/Views/product_form.php b/app/Views/product_form.php index bb81040..80e4bc2 100644 --- a/app/Views/product_form.php +++ b/app/Views/product_form.php @@ -102,7 +102,7 @@
- + + '; + console.log(productarray); + + var valuesArray = $('.purchase_order_product').map(function() { + return $(this).val(); + }).get(); + + console.log(valuesArray); + var newRow = '' + '' + '' + @@ -610,6 +619,17 @@ $('#editaddbutton').click(function(event) { $(this).prev('input[type="hidden"]').val('unchecked'); // Set value to '0' } }); + + + $(".purchase_order_product_edit").next(".select2-container").css({ + 'pointer-events': 'none', + }); + // $('#select2-insurer-container').css({ + // 'background-color': '#ebebe0', + // }); }); + + + diff --git a/app/Views/return_order_form.php b/app/Views/return_order_form.php index 7957652..b5aa80f 100644 --- a/app/Views/return_order_form.php +++ b/app/Views/return_order_form.php @@ -546,10 +546,9 @@ $('#editaddbutton').click(function(event) { $('#vendor_id').prop('disabled', false); if ($('.return_order_product:checked').length > 0) { - alert('At least one checkbox is checked.'); } else { event.preventDefault(); - alert('No checkboxes are checked.'); + toastr.warning("Please Check at least one Product."); } }); diff --git a/app/Views/return_order_liist.php b/app/Views/return_order_liist.php index b5d4e02..46e3a47 100644 --- a/app/Views/return_order_liist.php +++ b/app/Views/return_order_liist.php @@ -61,7 +61,7 @@ + if ($value['status'] =='Received' && $value['received_qty'] > 0) : ?> @@ -86,8 +86,8 @@ " class="edit-button" title="Create Purchase Return">      - " class="delete-button" title="Delete">      - " class="edit-button" title="Download"> + + diff --git a/app/Views/sales_order_form.php b/app/Views/sales_order_form.php index 452e079..a57b9fd 100644 --- a/app/Views/sales_order_form.php +++ b/app/Views/sales_order_form.php @@ -450,7 +450,7 @@ $(document).ready(function() { general: 1 }, success: function(response) { - console.log(response); + // console.log(response); // Populate make and model in the input field var makeAndModel = response.makeName + ' ' + response.modelName; $('#makeAndModel').val(makeAndModel); @@ -571,12 +571,13 @@ $(document).ready(function() { var quantity = $(this).closest('tr').find('.item-quantity').val(1); - + console.log(products); + console.log(productId); // Find product details from JSON var product = products.find(function(item) { return item.product_id == productId; }); - + console.log(product); var cgst = parseInt(product.cgst); var sgst = parseInt(product.sgst); var totalTax = cgst + sgst; @@ -699,7 +700,7 @@ $(document).ready(function() { var rowProductid = $(this).val(); selected_pr.push(rowProductid); }); - + console.log(productarray); if(productarray == 'No Product'){ toastr.warning("First Add the Product!"); }else if (productarray.length > 0) { diff --git a/app/Views/service_form.php b/app/Views/service_form.php index 51fcde0..1ce3092 100644 --- a/app/Views/service_form.php +++ b/app/Views/service_form.php @@ -73,7 +73,7 @@
> - @@ -91,13 +91,13 @@
- - + @@ -109,12 +109,12 @@ if(isset($services['labour_cost'])){ $labour_cost = ($services['labour_cost'] / 100) * $tax; - $labour_cost = $labour_cost + $services['labour_cost']; + $labour_cost = round($labour_cost + $services['labour_cost']); }else{ - $labour_cost = 0; + $labour_cost = ''; } ?> - +
@@ -127,7 +127,7 @@
- +

@@ -141,7 +141,7 @@ - + @@ -197,7 +197,7 @@ $(document).ready(function() { $('#make').change(function() { var selected_makes = $(this).val(); // Get the selected make ID - // console.log(selected_makes); + console.log(selected_makes); var models_id = $('#model').val(); // AJAX request to get models based on the selected make ID $.ajax({ @@ -214,6 +214,7 @@ $(document).ready(function() { // Iterate through response and models_id $.each(response, function(index, model) { var count =0; + // $('#model').empty(); $.each(models_id, function(index, model_id) { if (model.model_id == model_id) { // Append option for the model @@ -247,7 +248,9 @@ $(document).ready(function() { var model_ids = $('#model').val(); // Get the selected model IDs // AJAX request to get vendors based on the selected model ID - $.ajax({ + console.log(model_ids); + if (model_ids.length > 0) { + $.ajax({ url: '', // URL to your CodeIgniter controller method type: 'POST', dataType: 'json', @@ -273,6 +276,7 @@ $(document).ready(function() { console.error(xhr.responseText); } }); + } }); }); @@ -292,7 +296,7 @@ document.getElementById('category').addEventListener('change', function() { $('#service_hide').css('display' ,'block'); makeSelect.setAttribute('required', 'required'); modelSelect.setAttribute('required', 'required'); - serviceSelected.setAttribute('required', 'required'); + // serviceSelected.setAttribute('required', 'required'); } else { // customFields.style.display = 'none'; $('#make_hide').css('display' , 'none'); @@ -315,7 +319,7 @@ document.getElementById('category').addEventListener('change', function() { // Append new options $('#productSelect').append(''); $.each(response, function(index, product) { - $('#productSelect').append(''); + $('#productSelect').append(''); }); } else { // Handle case when no vendors are found for the selected model @@ -456,6 +460,16 @@ document.getElementById('category').addEventListener('change', function() { }); + + $('#service_form_submit').click(function (event) { + + // if(!$('#LabourCostWithTax').val()){ + // // event.preventDefault(); + + // $('form').serialize(); + // } + + }) @@ -478,5 +492,7 @@ document.getElementById('category').addEventListener('change', function() { font-weight: 500; border-bottom: 1px solid #747474; } + + diff --git a/app/Views/vehicle_form.php b/app/Views/vehicle_form.php index d438174..6b03bc8 100644 --- a/app/Views/vehicle_form.php +++ b/app/Views/vehicle_form.php @@ -83,7 +83,7 @@
- +
@@ -443,14 +443,22 @@ $('#saveModelBtn').click(function() {