From a75f6fb3c0d8e235f62750a80a3a3f2f5b7afe39 Mon Sep 17 00:00:00 2001 From: aadhavan valli Date: Mon, 27 May 2024 08:50:21 +0530 Subject: [PATCH] CHANGE_JOB_CARD_PDF_OS_ : AADHAVAN --- app/Controllers/Jobcard.php | 30 ++++++- app/Controllers/Sales.php | 21 ++++- app/Views/bike_model_list.php | 2 +- app/Views/complaint_list.php | 126 +++++++++++++---------------- app/Views/job_card_form.php | 41 +++++----- app/Views/make_list.php | 48 +---------- app/Views/manufacturer_list.php | 4 +- app/Views/outsourcing_template.php | 2 +- app/Views/sales_order_form.php | 66 ++++++++------- 9 files changed, 166 insertions(+), 174 deletions(-) diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index de2156e..0576520 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -545,12 +545,24 @@ class Jobcard extends BaseController // $service = $ServiceModel->where('JSON_CONTAINS(makes_id, \'' . $encodedMakeId . '\')', null, false) // ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false) // ->findAll(); - $service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false) + $service1 = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false) ->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false) ->orWhere('category', 0) ->findAll(); + + $encodedMakeId1 = 0; + $encodedModelId1 = 0; + + $common_services = $ServiceModel->where('makes_id LIKE \'%"' . $encodedMakeId1 . '"%\'', null, false) + ->where('models_id LIKE \'%"' . $encodedModelId1 . '"%\'', null, false) + ->findAll(); + $service = array_merge($common_services, $service1); + + $data['product']=$product; $data['service']=$service; + // echo "
";
+            // print_r($service);die;
             $jobs_product= $JobcardCustomComplaintModel->where('job_card_id', $job_card_id)->findAll();
             $data['jobs_product']=$jobs_product;
             $jobs_service= $JobcardServiceModel->where('job_card_id', $job_card_id)->findAll();
@@ -1155,11 +1167,23 @@ class Jobcard extends BaseController
         $ServiceModel = new ServiceModel();
 
         // Query the database to find the service based on make_id and model_id
-        $service = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
+        $service1 = $ServiceModel->where('makes_id LIKE \'%"' . $makeId . '"%\'', null, false)
                         ->where('models_id LIKE \'%"' . $modelId . '"%\'', null, false)
-                        ->where('category',0)
+                        ->where('category',1)
                         ->findAll();
 
+        $encodedMakeId1 = 0;
+        $encodedModelId1 =0;
+    
+        $common_services = $ServiceModel->where('makes_id LIKE \'%"' . $encodedMakeId1 . '"%\'', null, false)
+                                        ->where('models_id LIKE \'%"' . $encodedModelId1 . '"%\'', null, false)
+                                        ->where('category',1)
+                                        ->findAll();
+
+        $service2 = $ServiceModel->where('category',0)
+                                        ->findAll();
+        $service = array_merge($common_services, $service1, $service2);
+
         $modelName = $this->BikemodelsModel->where('model_id',$modelId)->get()->getRow()->model_name;
         $makeName = $this->BikemakeModel->where('make_id',$makeId)->get()->getRow()->make;
 
diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php
index 5a189cf..e584780 100644
--- a/app/Controllers/Sales.php
+++ b/app/Controllers/Sales.php
@@ -97,11 +97,24 @@ class Sales extends BaseController
             $productModel = new ProductModel();
 
                 // Query the database to find the product based on make_id and model_id
-                $product = $productModel->select('products.*, manufacturer.manufacturer_name')
+                $makemodelproduct = $productModel->select('products.*, manufacturer.manufacturer_name')
                                     ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
                                     ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId . '\')', null, false)
                                     ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId . '\')', null, false)
                                     ->findAll();
+
+                $encodedMakeId1 = json_encode(['0']);
+                $encodedModelId1 = json_encode(['0']);
+            
+                $common_product = $productModel->select('products.*, manufacturer.manufacturer_name')
+                                        ->join('manufacturer', 'manufacturer.manufacturer_id = products.manufacturer_id')
+                                        ->where('JSON_CONTAINS(make_id, \'' . $encodedMakeId1 . '\')', null, false)
+                                        ->where('JSON_CONTAINS(models_id, \'' . $encodedModelId1 . '\')', null, false)
+                                        ->where('qty_stock >',0)
+                                        ->findAll();
+                $product = array_merge($common_product, $makemodelproduct);
+
+
                         $data['product']=$product;
                     $SalesProductOrderModel = new SalesOrderProductModel();
                     $sales_product=$SalesProductOrderModel->where('sales_order_id', $sales_order_id)->findAll();
@@ -451,6 +464,12 @@ public function getProducts()
 
     // Load the ProductModel
     $productModel = new ProductModel();
+    $bikemodelsModel = new BikemodelsModel();
+    $BikemakeModel = new BikemakeModel();
+
+    $makeGeneral = $BikemakeModel->where('make' , 'General')->first();
+    $modelGeneral = $bikemodelsModel->where('model_name' , 'General')->first();
+
 
     // Query the database to find the product based on make_id and model_id
     $makeproduct = $productModel->select('products.*, manufacturer.manufacturer_name')
diff --git a/app/Views/bike_model_list.php b/app/Views/bike_model_list.php
index b534914..67f0806 100644
--- a/app/Views/bike_model_list.php
+++ b/app/Views/bike_model_list.php
@@ -234,7 +234,7 @@
 
         $('#form_add_edit').text('Edit Models');
 
-        var full_div = $(params).parent().parent()[0];
+        var full_div = $(params).closest('tr')[0];
 
         $('#modelname').val($(full_div).find('.model_name').text());
     }
diff --git a/app/Views/complaint_list.php b/app/Views/complaint_list.php
index c7ceb47..e08b367 100644
--- a/app/Views/complaint_list.php
+++ b/app/Views/complaint_list.php
@@ -25,7 +25,6 @@
                                 Labour Charge
                                 Status
                                 Actions
-                                
                             
                         
                         
@@ -105,22 +104,20 @@
 
 
 
 
-
-
diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php
index 23c6978..3c3b496 100644
--- a/app/Views/job_card_form.php
+++ b/app/Views/job_card_form.php
@@ -494,7 +494,7 @@ $(document).ready(async function() {
     var edit_ccomplaint_data = ;
     if(edit_ccomplaint_data.length > 0) {
         for (const value of edit_ccomplaint_data) {
-            var newRow = ' ' +
+            var newRow = ' ' +
                     '' +
                     '' +
                     '';
@@ -753,6 +753,7 @@ $(window).on('load', function() {
                             vehicle_id: vehicleId
                         },
                         success: function(response) {
+                            console.log("111111111111111111");
                             console.log(response);
                             servicearray = response.service;
                             makeAndModel =  response.makeName+' '+response.modelName;
@@ -833,8 +834,7 @@ $(window).on('load', function() {
             else if(className == 'custom_complaint_lb') {
                 previousRow = $(this).closest('tr').prevAll(".custom_complaint_class").first();
                 labour_rate = previousRow.find('.labour_cost');
-                // labour_rate.val(actual_amount.toFixed(2));
-                labour_rate.val(parseInt(actual_amount, 10));
+                labour_rate.val(actual_amount.toFixed(2));
 
                 item_rate = previousRow.find('.item-rate1');
                 item_rate.val(actual_amount.toFixed(2));
@@ -1595,10 +1595,10 @@ $(window).on('load', function() {
                     selected_pr.push(rowProductid);
                 });
 
-                if(servicearray.length == 0)
-                {
-                    servicearray = ;
-                }
+                // if(servicearray.length == 0)
+                // {
+                //     servicearray = ;
+                // }
                 console.log(servicearray);
                 var newRow = ' ' +
+            var newRow = ' ' +
                     '' +
                     '' +
                     '' +
@@ -1746,7 +1746,7 @@ $(window).on('load', function() {
                 var $targetField = $previousRow.find('.item-rate1');
                 $targetField.val(enteredValue);
                 var $targetField2 = $previousRow.find('.labour_cost');
-                $targetField2.val(int(enteredValue));
+                $targetField2.val(enteredValue);
                 updateCalculations();
             });
             /** TAX FIELD */
@@ -1874,16 +1874,17 @@ $(window).on('load', function() {
             }
 
             if ($closestTR.attr('class') !== "product" && $closestTR.attr('class') !== "sub_service") {
-                while ($closestTR.next().length > 0 ) {
-                    if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class') || $closestTR.next().hasClass('os_class')) {
-                        break; 
-                    }
-                    // Remove the next row
-                    $closestTR.next().remove();
-                }
-                // Remove the clicked row
-            }
-            $closestTR.remove();
+    while ($closestTR.next().length > 0 ) {
+        if ($closestTR.next().hasClass('service_class') || $closestTR.next().hasClass('complaint_class') || $closestTR.next().hasClass('custom_complaint_class') || $closestTR.next().hasClass('os_class')) {
+            break; 
+        }
+        // Remove the next row
+        $closestTR.next().remove();
+    }
+    // Remove the clicked row
+}
+$closestTR.remove();
+
             updateCalculations(); 
         });
 
@@ -2081,7 +2082,7 @@ $(window).on('load', function() {
                             $('#addVehicleModal').modal('hide');
                             toastr.success("Vehicle saved successfully!"); 
                             localStorage.setItem('vehicle_id',response.vehicle_id)
-                            window.location.reload(); 
+                            // window.location.reload(); 
 
                             } else {
                                 toastr.warning("Failed to save vehicle. Please try again"); 
diff --git a/app/Views/make_list.php b/app/Views/make_list.php
index ea59e4d..3f3de23 100644
--- a/app/Views/make_list.php
+++ b/app/Views/make_list.php
@@ -183,66 +183,26 @@
             toastr.error('Please enter a Make Name.', 'Error');
             return; // Stop further execution of the function
         }
-
         var formData = {
             makename: $('#bike_make_name').val()
         };
-
         var edit_make_id = $('#edit_make_id').val();
-
         if (!edit_make_id) {
             edit_make_id =0;
         }
-
         $.ajax({
             type: 'POST',
             url: 'create_make/'+edit_make_id, 
             data: formData,
             dataType: 'json',
             success: function(response) {
-                console.log(response);
-
-
                 if (response.status == "failed") {
                     toastr.warning(response.data, 'Warning');
                 }else{
                     $('#bike_make_login-modal').modal('hide');
                     $('#bike_make_name').val('');
                     toastr.success(response.data, 'Success');
-
-                    // $('tbody').html('');
-
                     window.location.reload();
-
-                    // $.each(response.make_list, function(index, item) {
-                    //     var row = '' +
-                    //     '' + item.make + '' +
-                    //     '';
-
-                    //     if (item.isactive == 1) {
-                    //         row += 'Active';
-                    //     } else if (item.isactive == 0) {
-                    //         row += 'Inactive';
-                    //     }
-
-                    //     row += '';
-
-                    //     // Check the isactive status and set the icon color accordingly
-                    //     row += '';
-
-                    //     row +='';
-                    //     row +='';
-                    //     if (item.isactive == 1) {
-                    //         row += '';
-                    //     } else if (item.isactive == 0) {
-                    //         row += '';
-                    //     }
-
-                    //     row += '';
-
-                    //     // Append the row to the tbody
-                    //     $('tbody').append(row);
-                    // });
                 }
 
             },
@@ -253,24 +213,18 @@
         });
     }
 
-
     function editMake(params) {
-
         $('#edit_make_id').val($(params).data('value'));
         $('#form_add_edit').text('Edit Bike Make');
-
-        var full_div = $(params).parent().parent()[0];
-        console.log($(full_div));
+        var full_div = $(params).closest('tr')[0];
         $('#bike_make_name').val($(full_div).find('.make').text());
     }
 
     function clearDetials(params) {
         $('#form_add_edit').text('Add Bike Make');
-
         $('#bike_make_name').val('');
     }
 
-
     function statusChange(params) {
         var status = params.getAttribute('data-isactive');
         var make_id = params.getAttribute('data-id');
diff --git a/app/Views/manufacturer_list.php b/app/Views/manufacturer_list.php
index 814e098..9d0e4b6 100644
--- a/app/Views/manufacturer_list.php
+++ b/app/Views/manufacturer_list.php
@@ -136,11 +136,9 @@
     }
 
     function editManufacturer(params) {
-
         $('#manufacturer_id').val($(params).data('value'));
         $('#form_add_edit').text('Edit Manufacturer');
-        var full_div = $(params).parent().parent()[0];
-
+        var full_div = $(params).closest('tr')[0];
         $('#manufacturer_name').val($(full_div).find('.manufacturer_name').text());
         $('#quality').val($(full_div).find('.quality').text());
     }
diff --git a/app/Views/outsourcing_template.php b/app/Views/outsourcing_template.php
index 8c2b32b..7adfb52 100644
--- a/app/Views/outsourcing_template.php
+++ b/app/Views/outsourcing_template.php
@@ -196,7 +196,7 @@ p {
                                 
-
color
-
+ delivery date
diff --git a/app/Views/sales_order_form.php b/app/Views/sales_order_form.php index d42d0bc..6d113d4 100644 --- a/app/Views/sales_order_form.php +++ b/app/Views/sales_order_form.php @@ -436,7 +436,8 @@ $(document).ready(function() { dataType: 'json', data: { make_id: makeId, - model_id: modelId + model_id: modelId, + general: 1 }, success: function(response) { console.log(response); @@ -444,7 +445,6 @@ $(document).ready(function() { var makeAndModel = response.makeName + ' ' + response.modelName; $('#makeAndModel').val(makeAndModel); - console.log(response); productarray = response.product; @@ -455,6 +455,7 @@ $(document).ready(function() { } }); } else { + productarray = []; console.error('Make ID or Model ID not found for the selected vehicle'); } } @@ -664,38 +665,43 @@ $(document).ready(function() { // Event listener for "Add More Item" button $('#addItem').click(function() { - // console.log(productarray); - var newRow = '' + + console.log(productarray.length); + if (productarray.length > 0) { + var newRow = '' + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + '' + + ''; + + + $('#itemTable tbody').append(newRow); + initializeSelect2(); + updateCalculations(); + initializeRowCalculations(row); + + }else{ + toastr.warning("First Choose the Vehicle!"); } - - newRow += '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - '' + - ''; - - - $('#itemTable tbody').append(newRow); - initializeSelect2(); - updateCalculations(); - initializeRowCalculations(row); - + }); // Event listener for removing item