From 17ebca64c9a7abae2e3274123e91e00cd2b3c4a5 Mon Sep 17 00:00:00 2001 From: Gowtham M Date: Sat, 4 Jan 2025 08:37:58 +0530 Subject: [PATCH] Changes in product : GWM --- app/Controllers/Products.php | 2 +- app/Models/AdditionalProductNameModal.php | 1 + app/Views/product_form.php | 181 +++++++++++++--------- 3 files changed, 112 insertions(+), 72 deletions(-) diff --git a/app/Controllers/Products.php b/app/Controllers/Products.php index 4992773..d3b345b 100755 --- a/app/Controllers/Products.php +++ b/app/Controllers/Products.php @@ -180,7 +180,7 @@ class Products extends BaseController if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); } - + dd($this->request->getPost()); $tax= $this->request->getPost('tax')/2; $ml = 0; $box = 0; $qty_per_box = 0; $barrel = 0; $ltr_per_barrel = 0; if ($this->request->getPost('per') == 'ml') { diff --git a/app/Models/AdditionalProductNameModal.php b/app/Models/AdditionalProductNameModal.php index b43a222..57bf17a 100644 --- a/app/Models/AdditionalProductNameModal.php +++ b/app/Models/AdditionalProductNameModal.php @@ -15,6 +15,7 @@ class AdditionalProductNameModal extends Model protected $allowedFields = [ 'product_names_id', 'product_id', + 'make_id_for_additional_name', 'additional_product_name', 'isactive', 'created_at', diff --git a/app/Views/product_form.php b/app/Views/product_form.php index 579880c..99e9c94 100755 --- a/app/Views/product_form.php +++ b/app/Views/product_form.php @@ -1,5 +1,36 @@ - + +
@@ -20,6 +51,7 @@
" id="productForm" method="post">

Product Details :


+
' ?> @@ -33,6 +65,7 @@
+
'; ?> @@ -47,10 +80,23 @@
+
+ +
+ +
+ + + +
+ +
+ +
' ?> @@ -237,8 +283,7 @@

-

Additional Product Names :


-
+
@@ -373,48 +418,76 @@ $(document).ready(function() { //---------VENKAT----------------------------------------------------------------------------------- // for Additional Product Name Edit Purpose - var additionalProductName = ; + // var additionalProductName = ; + // if (Array.isArray(additionalProductName) && additionalProductName.length > 0) { - // console.log(additionalProductName); - // console.log(additionalProductName.length); - - if (Array.isArray(additionalProductName) && additionalProductName.length > 0) { - - var firstProductName = ''; - console.log('firstProductName', firstProductName); - additionalProductName.forEach(function(item) { - if (firstProductName !== item.additional_product_name) { - addHTMLInput(item); // for if edit - } - }); - if(additionalProductName.length == 1){ - addHTMLInput() - } - } else { - addHTMLInput(); // for else add - } + // var firstProductName = ''; + // console.log('firstProductName', firstProductName); + // additionalProductName.forEach(function(item) { + // if (firstProductName !== item.additional_product_name) { + // addHTMLInput(item); // for if edit + // } + // }); + // if(additionalProductName.length == 1){ + // addHTMLInput() + // } + // } else { + // addHTMLInput(); // for else add + // } // end of Additional Product Name Edit Purpose //------------------------------------------------------------------------------------------------ }); -/** CALCULATE TOTAL AMOUNT ( UNIT PRICE + TAX ) */ -// $(document).ready(function() { -// function calculateTotalAmount() { -// var unitPrice = parseFloat($("input[name='unit_price']").val()); -// var tax = parseFloat($("select[name='tax']").val()); -// var totalAmount = unitPrice + (unitPrice * tax / 100); -// $("input[name='total_amount']").val(totalAmount.toFixed(2)); -// } +const $dynamicContainer = $("#dynamic-form-container"); -// $("input[name='unit_price'], select[name='tax']").change(function() { -// calculateTotalAmount(); -// }); +$("#model").change(function () { + const selectedOptions = $(this).find("option:selected"); -// calculateTotalAmount(); -// }); + // Loop through the selected options + selectedOptions.each(function () { + const modelId = $(this).val(); // Value of the make option + const modelName = $(this).text(); // Name of the make option + // Check if the field already exists + if (!$(`#field_${modelId}`).length) { + // Fields to append + const fieldSet = ` +
+ +
+ + +
+ +
+ + +
+
+ `; + + // Append the new field + $("#dynamic-form-container").append(fieldSet); + } + }); + + // Remove fields for deselected options + $("#dynamic-form-container").find(".form-row").each(function () { + const fieldId = $(this).attr("id"); + const modelId = fieldId.split("_")[1]; // Extract modelId from the field's id + + // If the model is no longer selected, remove the field + if (!$(`#model option[value='${modelId}']`).is(":selected")) { + $(this).remove(); + } + }); + + +}); $(document).ready(function() { // Check SGST checkbox by default @@ -525,26 +598,7 @@ $('#qty_in_stock').on('keyup change', function() { - + - +