Invoice Fixes : ps

This commit is contained in:
VE10-Sanjeev 2023-11-17 17:10:48 +05:30
parent 32b69272aa
commit 6b1fd05d14
2 changed files with 56 additions and 32 deletions

View File

@ -173,10 +173,10 @@ class Invoice extends BaseController
'tax' => (int)$this->request->getPost('invoice_tax'), 'tax' => (int)$this->request->getPost('invoice_tax'),
'discount' => (int)$this->request->getPost('discount'), 'discount' => (int)$this->request->getPost('discount'),
'total_amount' => (int)$this->request->getPost('grand_total'), 'total_amount' => (int)$this->request->getPost('grand_total'),
'shipping_charge' => (int)$this->request->getPost('shippingCharges'), 'shipping_charge' => ((int)$invoiceType === 1) ? (int)$this->request->getPost('shippingCharges') : NULL,
'shipping_label' =>$this->request->getPost('shippingChargesLabel'), 'shipping_label' => ((int)$invoiceType === 1) ? $this->request->getPost('shippingChargesLabel') : NULL,
'order_number' => $this->request->getPost('order_number'), 'order_number' => $this->request->getPost('order_number'),
'payment_method' =>$this->request->getPost('payment_method'), // "Credit Card," "Cash on Delivery," "PayPal","PayTm","Gpay" 'payment_method' => $invoice_status !== 'Draft' ? $this->request->getPost('payment_method') : NULL, // "Credit Card," "Cash on Delivery," "PayPal","PayTm","Gpay"
'payment_status' => 'Pending', //"Paid," "Pending," "Failed," "Refunded," "Canceled," "Authorized," and "Completed." 'payment_status' => 'Pending', //"Paid," "Pending," "Failed," "Refunded," "Canceled," "Authorized," and "Completed."
'event_id' => (int)$this->request->getPost('event_id'), 'event_id' => (int)$this->request->getPost('event_id'),
'business_id' => (int)get_business_id(), 'business_id' => (int)get_business_id(),
@ -327,6 +327,7 @@ class Invoice extends BaseController
$invoiceitem_arr = []; $invoiceitem_arr = [];
if ($count > 0) { if ($count > 0) {
for ($x = 0; $x < $count; $x++) { for ($x = 0; $x < $count; $x++) {
if(!empty($requestData['item_details'][$x])){
$invoiceitem_arr[$x]['invoice_id'] = $id; $invoiceitem_arr[$x]['invoice_id'] = $id;
$invoiceitem_arr[$x]['product'] = (int)$requestData['item_details'][$x]; $invoiceitem_arr[$x]['product'] = (int)$requestData['item_details'][$x];
$invoiceitem_arr[$x]['quantity'] = (int)$requestData['quantity'][$x]; $invoiceitem_arr[$x]['quantity'] = (int)$requestData['quantity'][$x];
@ -347,6 +348,7 @@ class Invoice extends BaseController
$invoiceitem_arr[$x]['isactive'] = 1; $invoiceitem_arr[$x]['isactive'] = 1;
$invoiceitem_arr[$x]['invoice_child_id'] = $itemid[$x]; $invoiceitem_arr[$x]['invoice_child_id'] = $itemid[$x];
} }
}
$statement = $model->saveInvoiceItemDetails($invoiceitem_arr); $statement = $model->saveInvoiceItemDetails($invoiceitem_arr);
} }
return $statement; return $statement;

View File

@ -222,7 +222,7 @@
<div class="form-group"> <div class="form-group">
<span style="<?= $shippingChargesStyle ?>"> <span style="<?= $shippingChargesStyle ?>">
<label for="shippingCharges">Charge Amount </label> <label for="shippingCharges">Charge Amount </label>
<input type="number" class="form-control" id="shippingCharges" name="shippingCharges" placeholder="Charges Amount" value="<?= isset($invoice_details['shipping_charge']) ? $invoice_details['shipping_charge'] : 0 ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> min="1" > <input type="number" class="form-control" id="shippingCharges" name="shippingCharges" placeholder="Charges Amount" value="<?= isset($invoice_details['shipping_charge']) ? $invoice_details['shipping_charge'] : 0 ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> min="0" >
</span> </span>
</div> </div>
@ -268,6 +268,7 @@
<div class="modal-body"> <div class="modal-body">
<!-- Add your mode of payment options here --> <!-- Add your mode of payment options here -->
<select class="form-control" id="paymentMode" name="payment_method"> <select class="form-control" id="paymentMode" name="payment_method">
<option value="">Select a mode</option>
<option value="credit">Credit Card</option> <option value="credit">Credit Card</option>
<option value="debit">Debit Card</option> <option value="debit">Debit Card</option>
<option value="cash">Cash</option> <option value="cash">Cash</option>
@ -684,10 +685,26 @@
<!-- bill_addr = "<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>"; --> <!-- bill_addr = "<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>"; -->
<!-- if (bill_addr != '') { $("#storeBillingAddress").val(bill_addr);} --> <!-- if (bill_addr != '') { $("#storeBillingAddress").val(bill_addr);} -->
<script> <script>
document.getElementById('saveapproved').addEventListener('click', function() { document.getElementById('saveapproved').addEventListener('click', function(event) {
var paymentMode = document.getElementById('paymentMode').value;
if(paymentMode !== ""){
// Get the balance amount
var balanceAmount = parseFloat(document.getElementById('balanceAmount').value) || 0;
// Replicate the balance amount value to the paid amount
document.getElementById('paidAmount').value = balanceAmount;
// Set the status field to 'Draft' before submitting // Set the status field to 'Draft' before submitting
document.getElementById('status').value = 'Approved'; document.getElementById('status').value = 'Approved';
}); }
else{
// Prevent the form submission
// document.getElementById('paymentMode').focus();
alert("Choose Your payment Mode ");
event.preventDefault(); // Pass the event parameter here
}
});
</script> </script>
<script> <script>
// Get the Invoice Date input element by its ID // Get the Invoice Date input element by its ID
@ -745,15 +762,12 @@
// Close the modal // Close the modal
$('#paymentModal').modal('hide'); $('#paymentModal').modal('hide');
document.getElementById('paymentMode').value = "";
}); });
</script> // Add event listener for the "Close" button
<script> document.getElementById('paymentModal').addEventListener('hidden.bs.modal', function () {
document.getElementById('saveapproved').addEventListener('click', function() { // Reset the payment_method value to an empty string
// Get the balance amount document.getElementById('paymentMode').value = "";
var balanceAmount = parseFloat(document.getElementById('balanceAmount').value) || 0;
// Replicate the balance amount value to the paid amount
document.getElementById('paidAmount').value = balanceAmount;
}); });
</script> </script>
<script> <script>
@ -765,15 +779,23 @@
event.preventDefault(); // Prevent form submission if it's not valid event.preventDefault(); // Prevent form submission if it's not valid
if (status == "Draft") { if (status == "Draft") {
$('#saveDraftButton').prop('disabled', false); $('#saveDraftButton').prop('disabled', false);
$('#saveApprovedButton').prop('disabled', false);
$('#saveapproved').prop('disabled', false);
} }
if (status == "Approved") { if (status == "Approved") {
$('#saveDraftButton').prop('disabled', false);
$('#saveApprovedButton').prop('disabled', false);
$('#saveapproved').prop('disabled', false); $('#saveapproved').prop('disabled', false);
} }
} else { } else {
if (status == "Draft") { if (status == "Draft") {
$('#saveDraftButton').prop('disabled', true); $('#saveDraftButton').prop('disabled', true);
$('#saveApprovedButton').prop('disabled', true);
$('#saveapproved').prop('disabled', true);
} }
if (status == "Approved") { if (status == "Approved") {
$('#saveDraftButton').prop('disabled', true);
$('#saveApprovedButton').prop('disabled', true);
$('#saveapproved').prop('disabled', true); $('#saveapproved').prop('disabled', true);
} }
} }