FIX_Alignment Completed : ps
This commit is contained in:
parent
74924414a4
commit
6e120559e1
@ -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;
|
||||
|
||||
@ -1,5 +1,24 @@
|
||||
<style>
|
||||
|
||||
.selection .select2-selection__arrow{
|
||||
background-color: #37cde6 !important;
|
||||
height: 36px !important;
|
||||
border-radius: 2px !important;
|
||||
}
|
||||
.select2-container .select2-selection--single .select2-selection__arrow b{
|
||||
border-color: white transparent transparent transparent !important;
|
||||
}
|
||||
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b
|
||||
{
|
||||
border-color: transparent transparent white transparent !important;
|
||||
}
|
||||
tbody td.last-column { border: none !important; }
|
||||
.table thead th.last-column, .table tbody td.last-column {
|
||||
border: none !important;
|
||||
background-color: #fff !important;
|
||||
}
|
||||
.select2-selection.select2-selection--single{
|
||||
margin-right: 2px;
|
||||
}
|
||||
.fixed-width-select {
|
||||
width: 100px; /* Adjust width as needed */
|
||||
}
|
||||
@ -18,7 +37,7 @@
|
||||
border-right: none;
|
||||
}
|
||||
.last-column {
|
||||
border-right: none;
|
||||
border: none;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
@ -30,8 +49,18 @@
|
||||
align-items: center;
|
||||
color: red; /* Change to the desired color */
|
||||
}
|
||||
.btn-white {
|
||||
border-color: #37cde6;
|
||||
}
|
||||
.item-discount-type{
|
||||
background-color: #FAFAFA;
|
||||
}
|
||||
|
||||
/* For Webkit (Chrome, Safari, Opera) */
|
||||
.form-control[readonly] {
|
||||
background-color: white;
|
||||
}
|
||||
/* .select2-container--default .select2-selection--single .select2-selection__arrow b
|
||||
{ border-style: none; } */
|
||||
input[type=number]::-webkit-inner-spin-button,
|
||||
input[type=number]::-webkit-outer-spin-button {
|
||||
-webkit-appearance: none;
|
||||
@ -42,8 +71,42 @@ input[type=number]::-webkit-outer-spin-button {
|
||||
input[type=number] {
|
||||
-moz-appearance: textfield;
|
||||
}
|
||||
|
||||
|
||||
/* Hide the calendar icon in Chrome, Safari, and Edge */
|
||||
/* input[type="date"]::-webkit-calendar-picker-indicator {
|
||||
display: none;
|
||||
} */
|
||||
|
||||
/* Hide the calendar icon in Firefox */
|
||||
/* input[type="date"] {
|
||||
-moz-appearance: textfield;
|
||||
} */
|
||||
</style>
|
||||
<?php $flag_name = $invoice_type === '1' ? " Books" : " Scheme"; ?>
|
||||
<?php $flag_name = $invoice_type === '1' ? " Books" : " Scheme";
|
||||
|
||||
$formattedinvdate = date('d/m/Y');
|
||||
if (isset($invoice_details['invoice_date']) && !empty($invoice_details['invoice_date'])) {
|
||||
$date = DateTime::createFromFormat('Y-m-d', $invoice_details['invoice_date']);
|
||||
if ($date !== false) {
|
||||
$formattedinvdate = $date->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');
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<h4 class="header-title"><center><?= $page_name; ?></center></h4>
|
||||
@ -56,7 +119,7 @@ input[type=number] {
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-5">
|
||||
<?php
|
||||
$first_name ="";
|
||||
$last_name ="";
|
||||
@ -98,7 +161,7 @@ input[type=number] {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="loadShippingDropdown">Shipping Address</label>
|
||||
<select class="form-control" id="loadShippingDropdown" name="shipping_address_id" data-toggle="select2" onchange="get_customer_shipping_details(this.value)">
|
||||
<option value="">Select an address</option>
|
||||
@ -108,18 +171,18 @@ input[type=number] {
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="storeBillingAddress"> Billing Address  ( <input type="checkbox" id="editAddressesCheckbox" /> Do you want to change addresses?)</label>
|
||||
<input type="hidden" id="hiddenBillingAddressId" name="billing_address_id" placeholder="hidden for billing address id" value="<?= isset($invoice_details['billing_address_id']) ? $invoice_details['billing_address_id'] : '' ?>" />
|
||||
<textarea class="form-control" id="storeBillingAddress" name="billing_address" rows="2" readonly><?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : '' ?></textarea>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="storeShippingAddress">Shipping Address</label>
|
||||
<textarea class="form-control" id="storeShippingAddress" name="shipping_address" rows="2" readonly><?= isset($invoice_details['shipping_address']) ? $invoice_details['shipping_address'] : '' ?></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-12">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="event" class="col-form-label">Events</label>
|
||||
<select class="form-control" id="event" name="event_id" data-toggle="select2">
|
||||
<option value="">Select an Events</option>
|
||||
@ -137,9 +200,19 @@ input[type=number] {
|
||||
<input type="text" class="form-control" id="invoiceNumber" name="invoice_number" value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
|
||||
<input type="hidden" id="hiddenNextId" name="next_id" placeholder="hidden for next id" />
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="invoiceDate">Invoice Date<span class="text-danger"> *</span></label>
|
||||
<input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : date('Y-m-d') ?>" max="<?= date('Y-m-d'); ?>" required>
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true" id="invoiceDate" name="invoice_date" value="<?= $formattedinvdate; ?>" data-date-end-date="<?= date('d/m/Y'); ?>" required>
|
||||
<div class="input-group-append" style="margin-left: -11px;">
|
||||
<span class="input-group-text" style="background-color: #37cde6;color:#fff;">
|
||||
<i class="ri-calendar-event-fill" style="position: relative;left: 4px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div><!-- input-group -->
|
||||
|
||||
<!-- <input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>" max="<?= date('d/m/Y'); ?>" required> -->
|
||||
</div>
|
||||
|
||||
<!-- <div class="form-group col-md-4">
|
||||
@ -149,28 +222,43 @@ input[type=number] {
|
||||
<?php if ($invoice_type === '2') : ?>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="fromsubcription">From Subscription<span class="text-danger"> *</span></label>
|
||||
<input type="date" class="form-control" id="fromsubcription" name="from_subscription" value="<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : '' ?>" required onchange="updateToDateMinDate(this.value)">
|
||||
<!-- <input type="date" class="form-control" id="fromsubcription" name="from_subscription" value="<?= $formattedfromsubdate; ?>" required onchange="updateToDateMinDate(this.value)"> -->
|
||||
<div class="input-group">
|
||||
<input type="text" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true" class="form-control" id="fromsubcription" name="from_subscription" value="<?= $formattedfromsubdate; ?>" required onchange="updateToDateMinDate(this.value)">
|
||||
<div class="input-group-append" style="margin-left: -11px;">
|
||||
<span class="input-group-text" style="background-color: #37cde6;color:#fff;">
|
||||
<i class="ri-calendar-event-fill" style="position: relative;left: 4px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div><!-- input-group -->
|
||||
</div>
|
||||
<div class="form-group col-md-4">
|
||||
<label for="tosubcription">To Subscription<span class="text-danger"> *</span></label>
|
||||
<input type="date" class="form-control" id="tosubcription" name="to_subscription" value="<?= isset($invoice_item_details[0]['to_subscription']) ? $invoice_item_details[0]['to_subscription'] : '' ?>" required>
|
||||
<!-- <input type="date" class="form-control" id="tosubcription" name="to_subscription" value="<?= $formattedtosubdate; ?>" required> -->
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control" id="tosubcription" name="to_subscription" value="<?= $formattedtosubdate; ?>" data-provide="datepicker" data-date-format="dd/mm/yyyy" data-date-autoclose="true">
|
||||
<div class="input-group-append" style="margin-left: -11px;">
|
||||
<span class="input-group-text" style="background-color: #37cde6;color:#fff;">
|
||||
<i class="ri-calendar-event-fill" style="position: relative;left: 4px;"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div><!-- input-group -->
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="form-row" id="itemTableContainer">
|
||||
<div class="form-group col-md-12">
|
||||
<div class="col-md-12 mt-1" style="overflow: auto;">
|
||||
<h4>Item Details</h4>
|
||||
<br />
|
||||
|
||||
<table class="table table-bordered" id="itemTable">
|
||||
<table class="table table-bordered" id="itemTable" style="border: white!important;">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>Item Details</th>
|
||||
<th>ITEM DETAILS</th>
|
||||
<th class="text-right">QUANTITY</th>
|
||||
<th class="text-right">RATE</th>
|
||||
<th style="display:none;">TAX</th>
|
||||
<th class="text-right">AMOUNT</th>
|
||||
<th class="text-right">DISCOUNT</th>
|
||||
<th class="text-right">AMOUNT</th>
|
||||
<?php if ($invoice_type === '1') : ?> <th class="last-column"></th><?php endif; ?>
|
||||
</tr>
|
||||
</thead>
|
||||
@ -199,30 +287,28 @@ input[type=number] {
|
||||
</select>
|
||||
<!-- <textarea name="description[]" class="form-control" placeholder="Enter Description" id="<?= "description" . $inx; ?>" cols="26" rows="2" style="margin-top: 16px;border-color: lightgray;width:247px;"><?= isset($ii_details['description']) ? $ii_details['description'] : '' ?></textarea> -->
|
||||
<span> </span>
|
||||
<textarea name="description[]" class="form-control" placeholder="Enter Description" id="<?= "description" . $inx; ?>" rows="2" style="border: 1px dashed #ddd"><?= isset($ii_details['description']) ? $ii_details['description'] : '' ?></textarea>
|
||||
<textarea name="description[]" class="form-control" placeholder="Enter Description" id="<?="description".$inx;?>" rows="2" style="border: 1px dashed #ddd"><?= isset($ii_details['description']) ? $ii_details['description'] : '' ?></textarea>
|
||||
<input type="hidden" class="form-control" id="<?= "hiddenInvoiceChildId" . $inx; ?>" name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" value="<?= isset($ii_details['invoice_child_id']) ? $ii_details['invoice_child_id'] : '' ?>" />
|
||||
</td>
|
||||
<td style="width:8%;"><input type="number" class="form-control item-quantity" id="<?= "quantity" . $inx; ?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" min="1" />
|
||||
<td style="width:8%;"><input type="number" class="form-control item-quantity" id="<?="quantity".$inx;?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" min="1" />
|
||||
</td>
|
||||
<td style="width:12%;"><input type="text" class="form-control item-rate" id="<?= "rate" . $inx; ?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" /> <!-- readonly /> -->
|
||||
<td style="width:20%;"><input type="text" class="form-control item-rate" id="<?="rate".$inx;?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" /> <!-- readonly /> -->
|
||||
</td>
|
||||
<td style="display:none;"><input type="number" class="form-control item-tax" id="<?= "tax" . $inx; ?>" name="tax[]" value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" readonly />
|
||||
<td style="display:none;"><input type="number" class="form-control item-tax" id="<?="tax".$inx;?>" name="tax[]" value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" readonly />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="number" class="form-control item-amount" id="<?= "amount" . $inx; ?>" name="amount[]" value="<?= isset($ii_details['subtotal']) ? $ii_details['subtotal'] : '' ?>" readonly />
|
||||
</td>
|
||||
<td style="width:25%;">
|
||||
<td style="width:22%;">
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control item-discount-amount" id="<?= "item_discount_amount" . $inx; ?>" name="discount_amount[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['discount_amount']) ? $ii_details['discount_amount'] : '' ?>" min="0" step="0.001" />
|
||||
<select class="item-discount-type custom-select" id="<?= "discount_type" . $inx; ?>" name="discount_type[]" oninput="calculateInvoice(this,<?= $inx; ?>)">
|
||||
<input type="number" style="width: 41%;" class="form-control item-discount-amount item-discount-group" id="<?="item_discount_amount".$inx;?>" name="discount_amount[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['discount_amount']) ? $ii_details['discount_amount'] : '' ?>" min="0" step="0.001" />
|
||||
<select class="item-discount-type custom-select item-discount-group" id="<?="discount_type".$inx;?>" name="discount_type[]" oninput="calculateInvoice(this,<?= $inx; ?>)">
|
||||
<option value="%" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '%') echo "selected"; ?>>
|
||||
%</option>
|
||||
<option value="₹" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '₹') echo "selected"; ?>>
|
||||
₹</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
</td>
|
||||
|
||||
<td style="width:15%;"><input type="number" class="form-control item-amount" id="<?="amount".$inx;?>" name="amount[]" value="<?= isset($ii_details['subtotal']) ? $ii_details['subtotal'] : '' ?>" readonly />
|
||||
</td>
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<td class="last-column" style="width:5%">
|
||||
<span class="icon"><center><i class="fa fa-trash remove-item "></i></center></span>
|
||||
@ -254,19 +340,19 @@ input[type=number] {
|
||||
|
||||
<td style="width:8%;"><input type="number" class="form-control item-quantity" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" min="1" />
|
||||
</td>
|
||||
<td style="width:12%;"><input type="text" class="form-control item-rate" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="width:20%;"><input type="text" class="form-control item-rate" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="display:none"><input type="text" class="form-control item-tax" id="tax0" name="tax[]" /></td>
|
||||
<td style="width:12%;"><input type="text" class="form-control item-amount" id="amount0" name="amount[]" />
|
||||
</td>
|
||||
<td style="width:25%;">
|
||||
<td style="width:22%;">
|
||||
<div class="input-group">
|
||||
<input type="number" class="form-control item-discount-amount" id="item_discount_amount0" name="discount_amount[]" oninput="calculateInvoice(this,0)" min="0" step="0.001" />
|
||||
<select class="item-discount-type custom-select" id="<?= "discount_type0"; ?>" name="discount_type[]" oninput="calculateInvoice(this,0)">
|
||||
<input type="number" style="width: 41%;" class="form-control item-discount-amount item-discount-group" id="item_discount_amount0" name="discount_amount[]" oninput="calculateInvoice(this,0)" min="0" step="0.001" />
|
||||
<select class="item-discount-type custom-select item-discount-group" id="<?= "discount_type0"; ?>" name="discount_type[]" oninput="calculateInvoice(this,0)">
|
||||
<option value="%">%</option>
|
||||
<option value="₹">₹</option>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
<td style="width:15%;"><input type="text" class="form-control item-amount" id="amount0" name="amount[]" />
|
||||
</td>
|
||||
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<td class="last-column" style="width:5%">
|
||||
@ -279,6 +365,8 @@ input[type=number] {
|
||||
<!-- You can add more rows as needed using JavaScript -->
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="form-group m-b-0">
|
||||
<?php if ($invoice_type !== '2') : ?>
|
||||
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
|
||||
@ -291,10 +379,9 @@ input[type=number] {
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="offset-md-6 col-md-6 card" style="background-color: #f1f5f7;">
|
||||
<div class="offset-md-5 col-md-7">
|
||||
<h4><center>Calculation</center></h4>
|
||||
<div class="card" style="background-color: #FAFAFA;">
|
||||
<div class="card-body">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
@ -374,8 +461,9 @@ input[type=number] {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-5">
|
||||
<label for="payment_note">Payment Notes</label>
|
||||
@ -558,7 +646,7 @@ input[type=number] {
|
||||
<?php endif; ?>
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
||||
<!-- Show the "Save as Draft" button only if the status is not "Approved" -->
|
||||
<button type="submit" class="btn btn-primary waves-effect mr-1" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
||||
<button type="submit" class="btn btn-white waves-effect waves-light" name="saveas" value="Draft" id="saveDraftButton">Save as Draft</button>
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="void" value="Void" id="voidButton">Void</button>
|
||||
<?php endif; ?>
|
||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
||||
@ -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 = '<input type="number" class="form-control item-quantity" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')" min="1">';
|
||||
cell3.innerHTML = '<input type="number" class="form-control item-rate" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.001">';
|
||||
cell4.innerHTML = '<input type="hidden" type="number" class="form-control item-tax" id="tax' + counter + '" name="tax[]" min="0" step="0.001">';
|
||||
cell5.innerHTML = '<input type="number" class="form-control item-amount" id="amount' + counter + '" name="amount[]" min="0" step="0.001">';
|
||||
cell6.innerHTML = '<div class="input-group"><input type="number" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.001"><select class="item-discount-type custom-select" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="%">%</option><option value="₹">₹</option></select></div>';
|
||||
cell5.innerHTML = '<div class="input-group"><input type="number" style="width: 41%;" class="form-control item-discount-amount item-discount-group" id="item_discount_amount' + counter + '" name="discount_amount[]" oninput="calculateInvoice(this,' + counter + ')" min="0" step="0.001"><select class="item-discount-type custom-select item-discount-group" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="%">%</option><option value="₹">₹</option></select></div>';
|
||||
cell6.innerHTML = '<input type="number" class="form-control item-amount" id="amount' + counter + '" name="amount[]" min="0" step="0.001">';
|
||||
cell7.innerHTML = '<span class="icon"><center><i class="fa fa-trash remove-item "></i></center></span>';
|
||||
$(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) {
|
||||
|
||||
@ -60,7 +60,9 @@
|
||||
.icon-large {
|
||||
font-size: 1.5em; /* Adjust the font size as needed */
|
||||
}
|
||||
|
||||
.debug-bar-ndisplay {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user