Bug fixes : ps
This commit is contained in:
parent
81d22eef40
commit
9348f0ee3f
@ -99,7 +99,7 @@ class Invoice extends BaseController
|
||||
public function load_details1()
|
||||
{
|
||||
$id = $this->request->getPost('selectedValue');
|
||||
$where = ['isactive' => 1, 'customer_id' => (int)$id];
|
||||
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$id];
|
||||
$where['address_type'] = 1;
|
||||
$data['customer_billing'] = $this->get_customer_address($where, []);
|
||||
$select = ["customer_address_id", "CONCAT(address_1,' ',address_2) as address"];
|
||||
@ -114,7 +114,7 @@ class Invoice extends BaseController
|
||||
{
|
||||
$customer_id = $this->request->getPost('customerValue');
|
||||
$address_id = $this->request->getPost('selectedValue');
|
||||
$where = ['isactive' => 1, 'customer_id' => (int)$customer_id, 'address_type' => 2, 'customer_address_id' => (int)$address_id];
|
||||
$where = ['customer_addresses.isactive' => 1, 'customer_addresses.customer_id' => (int)$customer_id, 'address_type' => 2, 'customer_address_id' => (int)$address_id];
|
||||
$data['customer_shipping'] = $this->get_customer_address($where, []);
|
||||
return $this->response->setJSON(['data' => $data]);
|
||||
}
|
||||
@ -124,11 +124,10 @@ class Invoice extends BaseController
|
||||
{
|
||||
$model = new CustomerModel();
|
||||
$model->setTable('customer_addresses');
|
||||
if (!empty($select)) {
|
||||
$address_details = $model->select($select)->where($where)->findAll();
|
||||
} else {
|
||||
$address_details = $model->where($where)->findAll();
|
||||
if (empty($select)) {
|
||||
$select = ["customer_addresses.customer_id","customer_addresses.customer_address_id","customer_addresses.first_name","customer_addresses.last_name ","customer_addresses.company","customer_addresses.email","customer_addresses.mobile_no","customer_addresses.address_type","customer_addresses.address_1","customer_addresses.address_2","customer_addresses.city","customer_addresses.state","customer_addresses.postal_code","customer_addresses.country","states.state_name","countries.country_name"];
|
||||
}
|
||||
$address_details = $model->select($select)->join('states', 'states.state_short_name = customer_addresses.state AND customer_addresses.country = "IN"', 'left')->join('countries', 'countries.country_short_name = customer_addresses.country', 'left')->where($where)->findAll();
|
||||
return $address_details;
|
||||
}
|
||||
|
||||
|
||||
@ -3,32 +3,26 @@
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<p class="sub-header"> </p>
|
||||
|
||||
<?php if ($page_name === 'Edit Customer Details') : ?>
|
||||
<ul class="nav nav-tabs" id="customerTabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
|
||||
<a class="nav-link active" id="customerDetails-tab" data-toggle="tab" href="#customerDetails" role="tab" aria-controls="customerDetails" aria-selected="true">Customer Details</a>
|
||||
</li>
|
||||
<?php if ($page_name === 'Edit Customer Details') : ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a>
|
||||
<a class="nav-link" id="subscriptionDetails-tab" data-toggle="tab" href="#subscriptionDetails" role="tab" aria-controls="subscriptionDetails" aria-selected="false">Subscription Details</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" id="invoiceDetails-tab" data-toggle="tab" href="#invoiceDetails" role="tab" aria-controls="invoiceDetails" aria-selected="false">Invoice Details</a>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
</ul>
|
||||
|
||||
<?php endif; ?>
|
||||
<div class="tab-content">
|
||||
<!-- <?php print_r($customer); ?> -->
|
||||
|
||||
<!-- Customer Details Tab -->
|
||||
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
|
||||
<!-- Customer details form fields -->
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm">
|
||||
<!-- <img src="<?= base_url() . "public/assets/images/plugins/loading.gif" ?>" alt="loader1" style="display:none; height:30px; width:auto;" id="loaderImg"> -->
|
||||
<div class="form-group">
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="cfname" class="col-form-label">First Name<span class="text-danger"> *</span></label>
|
||||
@ -72,7 +66,6 @@
|
||||
<div class="col-md-6 text-left">
|
||||
<h5> Billing Address </h5>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="after-add-more">
|
||||
@ -256,21 +249,12 @@
|
||||
<button type="button" class="btn btn-primary waves-effect mr-1" onclick="refreshPage()">Reset</button>
|
||||
<a href="<?= base_url() . "customer_list"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
|
||||
</div>
|
||||
<!-- Display Subscription Details -->
|
||||
|
||||
|
||||
<!-- Add subscription details content here -->
|
||||
<!-- You can fetch and display subscription details here -->
|
||||
|
||||
|
||||
|
||||
<!-- <div class="loader" style="display: none;">
|
||||
<img src="<?= base_url()."public/assets/images/plugins/loading.gif" ?>" alt="Loading...">
|
||||
</div> -->
|
||||
</form>
|
||||
|
||||
</div> <!-- end card-body-->
|
||||
</div><!-- end customer Details Tab -->
|
||||
|
||||
<!-- Subscription Details Tab -->
|
||||
<div class="tab-pane fade show " id="subscriptionDetails" role="tabpanel" aria-labelledby="subscriptionDetails-tab">
|
||||
<?php if (!empty($subscriptionData)) : ?>
|
||||
<table class="table table-bordered">
|
||||
@ -294,7 +278,9 @@
|
||||
<?php else : ?>
|
||||
<p>No subscriptions found for this customer.</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div><!-- end subscription Details Tab -->
|
||||
|
||||
<!-- Invoice Details Tab -->
|
||||
<div class="tab-pane fade" id="invoiceDetails" role="tabpanel" aria-labelledby="invoiceDetails-tab">
|
||||
<?php if (!empty($invoices)) : ?>
|
||||
<table class="table table-bordered">
|
||||
@ -317,15 +303,16 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<?php else : ?>
|
||||
<p>No subscriptions found for this customer.</p>
|
||||
<p>No invoice found for this customer.</p>
|
||||
<?php endif; ?>
|
||||
</div><!-- end invoice Details Tab -->
|
||||
|
||||
</div><!-- end tab-content-->
|
||||
</div><!-- end card-body-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#addressCopiedAsShipping").on("change", function() {
|
||||
if ($(this).is(":checked")) {
|
||||
@ -494,6 +481,7 @@
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function changeFields(element) {
|
||||
var selectedValue = $(element).val();
|
||||
var elementId = $(element).attr('id');
|
||||
@ -539,8 +527,7 @@ function validateEmail(email) {
|
||||
validationMessage.textContent = "";
|
||||
} else if (email == "") {
|
||||
validationMessage.textContent = "";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
validationMessage.textContent = "Invalid email address";
|
||||
validationMessage.style.color = "red";
|
||||
}
|
||||
|
||||
@ -1,3 +1,9 @@
|
||||
<!-- <style>
|
||||
/* Target the Select2 container and set the width */
|
||||
.select2-container .select2-dropdown {
|
||||
width: 249px !important;
|
||||
}
|
||||
</style> -->
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
@ -17,7 +23,9 @@
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<div class="invalid-feedback"> Please select customer. </div>
|
||||
<div class="subscribedetails" style="display: none"><div id="schemeName"></div></div>
|
||||
<div class="subscribedetails" style="display: none">
|
||||
<div id="schemeName"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-6">
|
||||
@ -101,16 +109,16 @@
|
||||
<?php if (!empty($invoice_item_details)) {
|
||||
foreach ($invoice_item_details as $inx => $ii_details) : ?>
|
||||
<tr>
|
||||
<td><select class="form-control" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2">
|
||||
<td><select class="form-control book-select" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2" style="width: 249px !important;">
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
|
||||
<?= $book->title ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<td style="width:10%;"><input type="number" class="form-control" id="<?= "quantity" . $inx; ?>" name="quantity[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['quantity']) ? $ii_details['quantity'] : '' ?>" />
|
||||
<td style="width:10%;"><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'] : '' ?>" />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="<?= "rate" . $inx; ?>" name="rate[]" oninput="calculateInvoice(this,<?= $inx; ?>)" value="<?= isset($ii_details['unit_price']) ? $ii_details['unit_price'] : '' ?>" readonly />
|
||||
<td style="width:10%;"><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="width:8%;"><input type="text" class="form-control item-tax" id="<?= "tax" . $inx; ?>" name="tax[]" value="<?= isset($ii_details['tax']) ? $ii_details['tax'] : '' ?>" readonly />
|
||||
</td>
|
||||
@ -136,16 +144,16 @@
|
||||
<?php endforeach;
|
||||
} else { ?>
|
||||
<tr>
|
||||
<td style="width:30%;"><select class="form-control" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required data-toggle="select2">
|
||||
<td style="width:30% !important;"><select class="form-control book-select" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required data-toggle="select2" style="width: 249px !important;">
|
||||
<option value="">Select a book</option>
|
||||
<?php foreach ($books as $book) : ?>
|
||||
<option value="<?= $book->book_id ?>"><?= $book->title ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select></td>
|
||||
<td style="width:10%;"><input type="number" class="form-control" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" />
|
||||
<td style="width:10%;"><input type="number" class="form-control item-quantity" id="quantity0" name="quantity[]" oninput="calculateInvoice(this,0)" />
|
||||
</td>
|
||||
<td style="width:10%;"><input type="text" class="form-control" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="width:10%;"><input type="text" class="form-control item-rate" id="rate0" name="rate[]" oninput="calculateInvoice(this,0)" /></td>
|
||||
<td style="width:8%;"><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>
|
||||
@ -312,40 +320,19 @@
|
||||
<option value="<?= $book->book_id ?>"><?= $book->title ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>`;
|
||||
|
||||
// cell1.innerHTML = '<input type="text" class="form-control" name="item_details[]">';
|
||||
cell2.innerHTML = '<input type="number" class="form-control" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell2.innerHTML = '<input type="number" class="form-control item-quantity" id="quantity' + counter + '" name="quantity[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell3.innerHTML = '<input type="text" class="form-control item-rate" id="rate' + counter + '" name="rate[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell4.innerHTML = '<input type="text" class="form-control item-tax" id="tax' + counter + '" name="tax[]">';
|
||||
cell5.innerHTML = '<input type="text" class="form-control item-amount" id="amount' + counter + '" name="amount[]">';
|
||||
cell6.innerHTML = '<input type="text" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]">';
|
||||
cell6.innerHTML = '<input type="text" class="form-control item-discount-amount" id="item_discount_amount' + counter + '" name="discount_amount[]" oninput="calculateInvoice(this,' + counter + ')">';
|
||||
cell7.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
|
||||
cell8.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
|
||||
|
||||
// Attach the calculateInvoice function to new input fields' change events
|
||||
// cell1.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
// cell2.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
// cell3.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
newRow.querySelector('.book-select').addEventListener("change", function() {
|
||||
displayBookTag(this, counter);
|
||||
});
|
||||
$(newRow.querySelector('.book-select')).select2();
|
||||
newRow.querySelector('.quantity-input').addEventListener("input", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.rate-input').addEventListener("input", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.discount-amount-input').addEventListener("input", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
newRow.querySelector('.discount-type-select').addEventListener("change", function() {
|
||||
calculateInvoice(this, counter);
|
||||
});
|
||||
});
|
||||
|
||||
// cell4.getElementsByTagName("input")[0].addEventListener("change", calculateInvoice);
|
||||
|
||||
|
||||
});
|
||||
|
||||
function displayBookTag(inputElement, counter) {
|
||||
var row = inputElement.parentElement.parentElement;
|
||||
@ -453,9 +440,6 @@
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Define a function to calculate the grand total
|
||||
// Define a function to calculate the grand total
|
||||
function calculateGrandTotal() {
|
||||
var invoiceItems = []; // Create an empty array to store item details
|
||||
@ -500,67 +484,6 @@
|
||||
document.getElementById("grandtotal").value = grandTotalElement;
|
||||
}
|
||||
|
||||
// the calculateOverallTotals function whenever you need to recalculate the totals, such as when a new item is added or an item is edited.
|
||||
|
||||
|
||||
|
||||
// function calculateSubTotal() {
|
||||
// var amountInputs = document.querySelectorAll('.amount-input');
|
||||
// var subTotal = 0;
|
||||
// var taxInputs = document.querySelectorAll('.tax-input');
|
||||
// var taxTotal = 0;
|
||||
// var discountAmountInputs = document.querySelectorAll('.discount-amount-input');
|
||||
// var discountTypeSelects = document.querySelectorAll('.discount-type-select');
|
||||
// var overallDiscount = 0;
|
||||
|
||||
// amountInputs.forEach(function (input, index) {
|
||||
// var amount = parseFloat(input.value) || 0;
|
||||
// subTotal += amount;
|
||||
|
||||
|
||||
// var tax = parseFloat(taxInputs[index].value) || 0;
|
||||
// taxTotal += tax;
|
||||
|
||||
// var discountType = discountTypeSelects[index].value;
|
||||
// var discountAmount = parseFloat(discountAmountInputs[index].value) || 0;
|
||||
|
||||
// if (discountType === '₹') {
|
||||
// // Calculate discount based on ₹
|
||||
// var discountedAmount = amount - discountAmount;
|
||||
// overallDiscount += discountAmount;
|
||||
// } else if (discountType === '%') {
|
||||
// // Calculate discount based on %
|
||||
// var discountPercentage = discountAmount;
|
||||
// var discountValue = (amount * discountPercentage) / 100;
|
||||
// var discountedAmount = amount - discountValue;
|
||||
// overallDiscount += discountValue;
|
||||
// }
|
||||
// });
|
||||
|
||||
// var subTotalElement = subTotal.toFixed(2);
|
||||
// $("#subtotal").val(subTotalElement);
|
||||
|
||||
// var taxElement = taxTotal.toFixed(2);
|
||||
// $("#invoicetax").val(taxElement);
|
||||
|
||||
// var overallDiscountElement = overallDiscount.toFixed(2);
|
||||
// $("#discount").val(overallDiscountElement);
|
||||
|
||||
// calculateGrandTotal(subTotal, taxTotal, overallDiscount);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// function calculateGrandTotal(subTotal, invoiceTax, discount) {
|
||||
// var grandTotal = 0;
|
||||
|
||||
// if (!isNaN(subTotal) && !isNaN(invoiceTax) && !isNaN(discount)) {
|
||||
// grandTotal = subTotal + invoiceTax - discount;
|
||||
// }
|
||||
|
||||
// var grandElement = grandTotal.toFixed(2);
|
||||
// $("#grandtotal").val(grandElement);
|
||||
// }
|
||||
</script>
|
||||
|
||||
<!-- JavaScript for removing a row from the table -->
|
||||
@ -569,7 +492,7 @@
|
||||
function removeItem(row) {
|
||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||
table.removeChild(row);
|
||||
calculateSubTotal(); // Call the calculation function to update the totals
|
||||
calculateOverallTotals(); // Call the calculation function to update the totals
|
||||
}
|
||||
|
||||
// Attach the removeItem function to the Remove buttons using event delegation
|
||||
@ -588,18 +511,17 @@
|
||||
var cust_id = "<?= isset($invoice_details['customer_id']) ? $invoice_details['customer_id'] : ""; ?>";
|
||||
var ship_addr_id = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
|
||||
if (cust_id != '') {
|
||||
|
||||
load_details1(ship_addr_id, cust_id);
|
||||
load_details2(ship_addr_id, cust_id);
|
||||
}
|
||||
var ship_addr = "";
|
||||
|
||||
var bill_addr = "";
|
||||
// $("#customerName").val(customer_id).change();
|
||||
|
||||
$("#customerName").change(function() {
|
||||
var cust_id = $(this).val();
|
||||
var ship_addr_id = "";
|
||||
load_details1(ship_addr_id, cust_id);
|
||||
$('#storeShippingAddress').val('');
|
||||
});
|
||||
|
||||
$("#loadShippingDropdown").change(function() {
|
||||
@ -644,12 +566,17 @@
|
||||
cm = response['data']['customer_membership'];
|
||||
$('#hiddenBillingAddressId').val('');
|
||||
customer_billing = "";
|
||||
var customer_billing_addressDetails = [];
|
||||
if (cb.length > 0) {
|
||||
$.each(cb, function(k, v) {
|
||||
customer_billing = v.address_1 + " " + v.address_2 + ",\n" + v
|
||||
.city + ",\n" + v.state + " - " + v.postal_code + ",\n" + v
|
||||
.country + "."
|
||||
customer_billing_id = v.customer_address_id
|
||||
var state = v.state_name ? v.state_name : v.state;
|
||||
state = v.postal_code ? state+"-"+v.postal_code : state;
|
||||
v.address_1 ? customer_billing_addressDetails.push(v.address_1 + " " + v.address_2):"";
|
||||
v.city ? customer_billing_addressDetails.push(v.city):"";
|
||||
state ? customer_billing_addressDetails.push(state):"";
|
||||
v.country_name ? customer_billing_addressDetails.push(v.country_name) :"";
|
||||
customer_billing_id = v.customer_address_id;
|
||||
|
||||
});
|
||||
}
|
||||
if (cm.length > 0) {
|
||||
@ -660,25 +587,17 @@
|
||||
$("#schemeName").text("No Earlier Membership found");
|
||||
}
|
||||
|
||||
|
||||
// var address_compare = bill_addr == customer_billing ? customer_billing : bill_addr
|
||||
//
|
||||
if ((bill_addr != "") && (bill_addr != customer_billing)) {
|
||||
$("#storeBillingAddress").val(bill_addr).prop("readonly", false);
|
||||
$('#editAddressesCheckbox').prop('checked', true);
|
||||
} else {
|
||||
$("#storeBillingAddress").val(customer_billing).prop("readonly", true);
|
||||
$("#storeBillingAddress").val(customer_billing_addressDetails.join(', \n')+".").prop("readonly", true);
|
||||
$('#editAddressesCheckbox').prop('checked', false);
|
||||
}
|
||||
|
||||
$('#hiddenBillingAddressId').val(customer_billing_id);
|
||||
if (cs.length > 0) {
|
||||
$('#loadShippingDropdown').empty();
|
||||
if (ship_addr != '') {
|
||||
$("#storeShippingAddress").val(ship_addr);
|
||||
} else {
|
||||
$('#storeShippingAddress').val('');
|
||||
}
|
||||
$('#loadShippingDropdown').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select an address"
|
||||
@ -691,9 +610,8 @@
|
||||
ship_addr_id) ?
|
||||
true : false
|
||||
}));
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
@ -714,15 +632,19 @@
|
||||
success: function(response) {
|
||||
cs = response['data']['customer_shipping'];
|
||||
customer_shipping = "";
|
||||
customer_shipping_addressDetails = [];
|
||||
if (cs.length > 0) {
|
||||
$.each(cs, function(k, v) {
|
||||
customer_shipping = v.address_1 + " " + v.address_2 + ",\n" + v
|
||||
.city + ",\n" + v.state + " - " + v.postal_code + ",\n" + v
|
||||
.country + "."
|
||||
var state = v.state_name ? v.state_name : v.state;
|
||||
state = v.postal_code ? state+"-"+v.postal_code : state;
|
||||
v.address_1 ? customer_shipping_addressDetails.push(v.address_1 + " " + v.address_2) : "";
|
||||
v.city ? customer_shipping_addressDetails.push(v.city) : "";
|
||||
state ? customer_shipping_addressDetails.push(state) :"";
|
||||
v.country_name ? customer_shipping_addressDetails.push(v.country_name):"";
|
||||
customer_shipping_id = v.customer_address_id;
|
||||
});
|
||||
}
|
||||
|
||||
$("#storeShippingAddress").val(customer_shipping);
|
||||
$("#storeShippingAddress").val(customer_shipping_addressDetails.join(', \n')+".");
|
||||
},
|
||||
error: function() {
|
||||
alert("Error fetching address.");
|
||||
@ -748,6 +670,9 @@
|
||||
return serial_number;
|
||||
}
|
||||
|
||||
bill_addr = "<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>";
|
||||
if (bill_addr != '') { $("#storeBillingAddress").val(bill_addr);}
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
@ -822,11 +747,19 @@
|
||||
if (form.checkValidity() === false) {
|
||||
form.reportValidity(); // Display validation error messages
|
||||
event.preventDefault(); // Prevent form submission if it's not valid
|
||||
if (status == "Draft" ){$('#saveDraftButton').prop('disabled', false);}
|
||||
if (status == "Approved" ){$('#saveapproved').prop('disabled', false);}
|
||||
if (status == "Draft") {
|
||||
$('#saveDraftButton').prop('disabled', false);
|
||||
}
|
||||
if (status == "Approved") {
|
||||
$('#saveapproved').prop('disabled', false);
|
||||
}
|
||||
} else {
|
||||
if (status == "Draft" ){$('#saveDraftButton').prop('disabled', true);}
|
||||
if (status == "Approved" ){$('#saveapproved').prop('disabled', true);}
|
||||
if (status == "Draft") {
|
||||
$('#saveDraftButton').prop('disabled', true);
|
||||
}
|
||||
if (status == "Approved") {
|
||||
$('#saveapproved').prop('disabled', true);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@ -6,20 +6,18 @@
|
||||
<!-- <?php if (session()->getFlashdata('success')) : ?>
|
||||
<div class="alert alert-success"><?= session()->getFlashdata('success') ?></div>
|
||||
<?php endif; ?> -->
|
||||
<form class="parsley-examples" action="<?= base_url() . "insert_users"; ?>" method="post" enctype="multipart/form-data">
|
||||
<form class="parsley-examples" action="<?= base_url() . "insert_users"; ?>" method="post" enctype="multipart/form-data" id="myForm">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="email" class="col-form-label">Email<span class="text-danger">*</span></label>
|
||||
<input type="email" class="form-control" id="email" name="email" placeholder="Email" value="<?= isset($details['email']) ? $details['email'] : '' ?>" required />
|
||||
|
||||
</div>
|
||||
|
||||
<?php if (empty($details)) { ?>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="password" class="col-form-label">Password<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="password" name="password" placeholder="Password" value="<?= isset($details['password']) ? $details['password'] : '' ?>" required />
|
||||
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
@ -36,16 +34,12 @@
|
||||
<label for="date_of_birth" class="col-form-label">Date Of Birth<span class="text-danger">*</span></label>
|
||||
<input type="date" class="form-control" id="date_of_birth" name="date_of_birth" placeholder="Date Of birth (format : DD/MM/YYYY)" data-toggle="input-mask" data-mask-format="00/00/0000" required />
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<div class="form-row">
|
||||
|
||||
<div class="form-group col-md-4">
|
||||
<label for="mobile_no" class="col-form-label">Mobile Number<span class="text-danger">*</span></label>
|
||||
<input type="text" class="form-control" id="mobile_no" name="mobile_no" placeholder="Mobile Number (Enter only numbers)" data-toggle="input-mask" data-mask-format="0000000000" value="<?= isset($details['mobile_no']) ? $details['mobile_no'] : '' ?>" autofocus required>
|
||||
</div>
|
||||
|
||||
<!-- ... (other form elements) ... -->
|
||||
<div class="form-group col-md-4">
|
||||
<label for="role" class="col-form-label">Role<span class="text-danger">*</span></label>
|
||||
<select id="role" name="role" class="form-control" required>
|
||||
@ -65,9 +59,6 @@
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ... (rest of the form) ... -->
|
||||
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-4">
|
||||
<label for="address" class="col-form-label">Address<span class="text-danger"></span></label>
|
||||
@ -171,6 +162,7 @@
|
||||
|
||||
// Set the min attribute of the date input field to "1965-01-01"
|
||||
document.getElementById('date_of_birth').setAttribute('min', '1965-01-01');
|
||||
|
||||
function validateFile(input) {
|
||||
const file = input.files[0];
|
||||
const errorMessage = document.getElementById("error_message");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user