diff --git a/app/Controllers/Invoice.php b/app/Controllers/Invoice.php index e61466b5..299f67bb 100644 --- a/app/Controllers/Invoice.php +++ b/app/Controllers/Invoice.php @@ -228,7 +228,8 @@ class Invoice extends BaseController $renewal = 1; } } - + $invdate_dbformat = (!empty($invdate)) ? \DateTime::createFromFormat('d/m/Y', $invdate)->format('Y-m-d') : NULL; + $duedate_dbformat = (!empty($duedate)) ? \DateTime::createFromFormat('d/m/Y', $duedate)->format('Y-m-d') : NULL; ## Array Formation For Invoice Details.. $data = [ 'invoice_number' => $this->request->getPost('invoice_number'), @@ -239,8 +240,8 @@ class Invoice extends BaseController 'shipping_address_id' => (int)$this->request->getPost('shipping_address_id'), 'shipping_address' => $this->request->getPost('shipping_address'), 'notes' => $this->request->getPost('notes'), - 'invoice_date' => (!empty($invdate)) ? date("Y-m-d", strtotime($invdate)) : NULL, - 'due_date' => (!empty($duedate)) ? date("Y-m-d", strtotime($duedate)) : NULL, + 'invoice_date' => $invdate_dbformat, + 'due_date' => $duedate_dbformat, 'subtotal' => (float)$this->request->getPost('sub_total'), 'tax' => (float)$this->request->getPost('invoice_tax'), 'dis_type' => $this->request->getPost('dis_type'), @@ -307,7 +308,6 @@ class Invoice extends BaseController // Loop through invoice items and store them in the 'subscription' table $subscriptionModel = new InvoiceModel(); // Replace with your actual model $invoiceItems = $this->get_invoice_item($invoice_id); - foreach ($invoiceItems as $item) { $product_id = $item['product']; @@ -438,12 +438,13 @@ class Invoice extends BaseController $invoiceitem_arr[$x]['discount_amount'] = (float)$requestData['discount_amount'][$x]; $invoiceitem_arr[$x]['discount_type'] = $requestData['discount_type'][$x]; if (!empty($requestData['from_subscription'])) { - $invoiceitem_arr[0]['from_subscription'] = $requestData['from_subscription']; + $invoiceitem_arr[0]['from_subscription'] = \DateTime::createFromFormat('d/m/Y', $requestData['from_subscription'])->format('Y-m-d'); } if (!empty($requestData['to_subscription'])) { - $invoiceitem_arr[0]['to_subscription'] = $requestData['to_subscription']; + $invoiceitem_arr[0]['to_subscription'] = \DateTime::createFromFormat('d/m/Y', $requestData['to_subscription'])->format('Y-m-d'); } + $invoiceitem_arr[$x]['created_by'] = (int)get_logged_user_id(); $invoiceitem_arr[$x]['updated_by'] = (int)get_logged_user_id(); $invoiceitem_arr[$x]['isactive'] = 1; diff --git a/app/Views/invoice_form.php b/app/Views/invoice_form.php index a3bdebe1..521abcc4 100644 --- a/app/Views/invoice_form.php +++ b/app/Views/invoice_form.php @@ -1,5 +1,24 @@ - +format('d/m/Y'); + } +} +$formattedfromsubdate = ''; +if (isset($invoice_item_details[0]['from_subscription']) && !empty($invoice_item_details[0]['from_subscription'])) { + $date = DateTime::createFromFormat('Y-m-d', $invoice_item_details[0]['from_subscription']); + if ($date !== false) { + $formattedfromsubdate = $date->format('d/m/Y'); + } +} +$formattedtosubdate = ''; +if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_details[0]['to_subscription'])) { + $date = DateTime::createFromFormat('Y-m-d', $invoice_item_details[0]['to_subscription']); + if ($date !== false) { + $formattedtosubdate = $date->format('d/m/Y'); + } +} +?>

@@ -56,7 +119,7 @@ input[type=number] {
-
+
-
+
Do you want to change addresses?)
-
+
-
+
+
- +
+ +
+ + + +
+
+ +
+
+ +
+ + + +
+
- + +
+ +
+ + + +
+
-
-
+

Item Details


- +
- + - + @@ -199,30 +287,28 @@ input[type=number] { - + " name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" value="" /> - - - - - - + - + - - +
Item DetailsITEM DETAILS QUANTITY RATE TAXAMOUNT DISCOUNTAMOUNT
" name="quantity[]" oninput="calculateInvoice(this,)" value="" min="1" /> + " name="quantity[]" oninput="calculateInvoice(this,)" value="" min="1" /> " name="rate[]" oninput="calculateInvoice(this,)" value="" /> + " name="rate[]" oninput="calculateInvoice(this,)" value="" /> " name="tax[]" value="" readonly /> + " name="tax[]" value="" readonly /> " name="amount[]" value="" readonly /> - +
- " name="discount_amount[]" oninput="calculateInvoice(this,)" value="" min="0" step="0.001" /> - " name="discount_amount[]" oninput="calculateInvoice(this,)" value="" min="0" step="0.001" /> +
-
" name="amount[]" value="" readonly /> +
@@ -254,19 +340,19 @@ input[type=number] {
- +
- - +
+ @@ -279,6 +365,8 @@ input[type=number] {
+ +
@@ -291,10 +379,9 @@ input[type=number] {
-
-
-
+

Calculation

+
@@ -374,8 +461,9 @@ input[type=number] {
-
+
+
@@ -558,7 +646,7 @@ input[type=number] { - + @@ -793,13 +881,13 @@ input[type=number] { var cell2 = newRow.insertCell(1); cell2.style.width = "8%"; var cell3 = newRow.insertCell(2); - cell3.style.width = "12%"; + cell3.style.width = "20%"; var cell4 = newRow.insertCell(3); cell4.style.display = "none"; - var cell5 = newRow.insertCell(4); + cell5.style.width = "22%"; var cell6 = newRow.insertCell(5); - cell6.style.width = "25%"; + cell6.style.width = "15%"; var cell7 = newRow.insertCell(6); cell7.style.width = "5%"; cell7.className = "last-column"; @@ -826,8 +914,8 @@ input[type=number] { cell2.innerHTML = ''; cell3.innerHTML = ''; cell4.innerHTML = ''; - cell5.innerHTML = ''; - cell6.innerHTML = '
'; + cell5.innerHTML = '
'; + cell6.innerHTML = ''; cell7.innerHTML = '
'; $(newRow.querySelector('.book-select')).select2(); localStorage.setItem('add_book_index', counter); @@ -869,39 +957,41 @@ input[type=number] { } + function calculateInvoice(inputElement, counter) { + if (!inputElement.classList.contains('item-quantity') && !inputElement.classList.contains('book-select')) { $('#discount-type').hide(); $('#discount-type').removeAttr('name'); } - - - var row = inputElement.parentElement.parentElement; - var quantity = parseFloat(row.querySelector('#quantity' + counter).value); - var rate = parseFloat(row.querySelector('#rate' + counter).value); - var discountType = row.querySelector('select[name="discount_type[]"]').value; // Get the selected discount type + if(inputElement.classList.contains('item-discount-group')){ + var row = inputElement.parentElement.parentElement.parentElement; // now we added input group so 3 parent here.. + }else{ var row = inputElement.parentElement.parentElement; } + var quantity = row.querySelector('#quantity' + counter).value; + var rate = row.querySelector('#rate' + counter).value; + var discountType = row.querySelector('#item_discount_amount'+ counter).value; // Get the selected discount type if (!inputElement.classList.contains('item-quantity')) { - var discountAmount = parseFloat(row.querySelector('input[name="discount_amount[]"]').value) || 0; + var discountAmount = parseFloat(row.querySelector('#item_discount_amount'+ counter).value) || 0; } console.log(rate); if (!isNaN(quantity) && !isNaN(rate)) { var amount = quantity * rate; - + amount = parseFloat(amount).toFixed(2); if (discountType === '₹') { // Calculate discount based on ₹ var discountedAmount = parseFloat(amount - discountAmount); - row.querySelector('#amount' + counter).value = parseFloat(amount.toFixed(2)); + row.querySelector('#amount' + counter).value = parseFloat(amount).toFixed(2); } else if (discountType === '%') { // Calculate discount based on % var discountPercentage = discountAmount; var discountValue = parseFloat((amount * discountPercentage) / 100); var discountedAmount = parseFloat(amount - discountValue); - row.querySelector('#amount' + counter).value = parseFloat(amount.toFixed(2)); + row.querySelector('#amount' + counter).value = parseFloat(amount).toFixed(2); } else { // Invalid discount type - row.querySelector('#amount' + counter).value = parseFloat(amount.toFixed(2)); // No discount applied + row.querySelector('#amount' + counter).value = parseFloat(amount).toFixed(2); // No discount applied } } else { row.querySelector('#amount' + counter).value = ''; // Clear the amount if either quantity or rate is not a number @@ -1260,7 +1350,7 @@ input[type=number] { var customer_billing_addressDetails = []; if (cb.length > 0) { cb = [cb[0]]; - console.log("cbbbbbbbbb",cb); + console.log("cFAFAFAbbb",cb); $.each(cb, function(k, v) { var state = v.state_name ? v.state_name : v.state; state = v.postal_code ? state + "-" + v.postal_code : state; @@ -1425,7 +1515,10 @@ input[type=number] { function updateToDateMinDate(fromDateValue) { const toDateInput = document.getElementById('tosubcription'); - toDateInput.min = fromDateValue; + toDateInput.min = fromDateValue; + // toDateInput.setAttribute('data-date-end-date', fromDateValue); + toDateInput.setAttribute('data-date-start-date', fromDateValue); + $(toDateInput).datepicker('setStartDate', fromDateValue); } // function updateToDateMinDate(fromDateValue) { diff --git a/app/Views/template/header.php b/app/Views/template/header.php index fcd925dc..92434d1c 100644 --- a/app/Views/template/header.php +++ b/app/Views/template/header.php @@ -60,7 +60,9 @@ .icon-large { font-size: 1.5em; /* Adjust the font size as needed */ } - + .debug-bar-ndisplay { + display: none !important; + }