diff --git a/app/Controllers/Jobcard.php b/app/Controllers/Jobcard.php index a4d43ad..021321b 100644 --- a/app/Controllers/Jobcard.php +++ b/app/Controllers/Jobcard.php @@ -264,9 +264,17 @@ echo $html;die; $data['make_model'] = $make_name['make'].' ' . $model_name['model_name']; // Encode the modelId before searching $encodedModelId = json_encode([$makeId]); - // array_push($makeId, 0); - // array_push($modelId, 0); - $product = $productModel->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false)->where('qty_stock >',0)->findAll(); + $encoded_make_id = json_encode(['0']); + $product1 = $productModel + ->where('JSON_CONTAINS(make_id, \'' . $encodedModelId . '\')', null, false) + ->where('qty_stock >',0) + ->findAll(); + $product2 = $productModel + ->orWhere('JSON_CONTAINS(make_id, \'' . $encoded_make_id . '\')', null, false) + ->where('qty_stock >',0) + ->findAll(); + $product = array_merge($product1, $product2); + $data['product']=$product; $data['product']=$product; // echo json_encode($product);die; diff --git a/app/Views/job_card_form.php b/app/Views/job_card_form.php index 4e8cdd6..105412b 100644 --- a/app/Views/job_card_form.php +++ b/app/Views/job_card_form.php @@ -778,6 +778,7 @@ $(window).on('load', function() { var product = products.find(function(item) { return item.product_id == productId; }); + console.log(product,'product'); // Access unit price from product and set it as rate var unitPrice = parseFloat(product.unit_price); // Convert to float if necessary $(this).closest('tr').find('.rate-d-only').val(unitPrice);