From 6b25c16edf01bb6cbabca4277fdf24d9686edc19 Mon Sep 17 00:00:00 2001 From: sriramv Date: Tue, 7 May 2024 14:48:39 +0530 Subject: [PATCH] CHANGE_add_common_product:ss --- app/Controllers/Jobcard.php | 12 +++--------- app/Controllers/Products.php | 2 +- app/Controllers/Sales.php | 14 ++++++++++++-- app/Controllers/Service.php | 2 +- app/Views/job_card_form.php | 4 ++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index 6af85c8..d80634b 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -264,15 +264,9 @@ echo $html;die; $data['make_model'] = $make_name['make'].' ' . $model_name['model_name']; // Encode the modelId before searching $encodedModelId = json_encode([$makeId]); -// echo $encodedModelId;die; - // Load the ProductModel - - - // Query the database to find the product based on make_id and model_id - $product = $productModel - // ->where('make_id', $makeId) - ->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false) - ->findAll(); + // array_push($makeId, 0); + // array_push($modelId, 0); + $product = $productModel->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)->findAll(); $data['product']=$product; // echo json_encode($product);die; diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 6708cfe..2677335 100644 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -155,7 +155,7 @@ class Products extends BaseController 'mfr_part_no' => $this->request->getPost('mfr_part_no'), 'unit_price' => $this->request->getPost('unit_price'), - 'commision_rate' => $this->request->getPost('commision_rate'), + // 'commision_rate' => $this->request->getPost('commision_rate'), 'sgst' => $tax, 'cgst' => $tax, 'purchase_cost' => $this->request->getPost('purchase_cost'), diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index fe841cd..5a189cf 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -453,13 +453,23 @@ public function getProducts() $productModel = new ProductModel(); // Query the database to find the product based on make_id and model_id - $product = $productModel->select('products.*, manufacturer.manufacturer_name') + $makeproduct = $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) ->where('qty_stock >',0) ->findAll(); - // print_r($product);die; + + $encodedMakeId = json_encode(['0']); + $encodedModelId = json_encode(['0']); + + $common_product = $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) + ->where('qty_stock >',0) + ->findAll(); + $product = array_merge($common_product, $makeproduct); $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/Service.php b/app/Controllers/Service.php index bb82189..57becd9 100644 --- a/app/Controllers/Service.php +++ b/app/Controllers/Service.php @@ -229,7 +229,7 @@ class Service extends BaseController $ProductModel = new ProductModel(); $products = []; - + array_push($model_ids,'0'); foreach ($model_ids as $modelId) { $product = $ProductModel->where('JSON_CONTAINS(models_id, \'["' . $modelId . '"]\')', null, false) ->findAll(); diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php index f386c03..e08d74b 100644 --- a/app/Views/job_card_form.php +++ b/app/Views/job_card_form.php @@ -921,7 +921,7 @@ $(window).on('load', function() { const labourcost = async (cost,tax,tr,cls) => { total_wih_tax = parseInt(cost) + (parseInt(cost) * (tax / 100)); total_tax_amt = total_wih_tax - parseInt(cost); - var newRow = '' + + var newRow = '' + '' + '' + '' + @@ -1239,7 +1239,7 @@ $(window).on('load', function() { '' + ''; - newRow += '' + + newRow += '' + '' + '' + '' +