CHANGE_QUICK ADD CUSTOMERS VALIDATION IN SALES MODULE

This commit is contained in:
Srinivas-Saravanan 2024-11-29 15:16:47 +05:30
parent 7278e85d6b
commit 45986e50bd
2 changed files with 285 additions and 294 deletions

View File

@ -97,7 +97,8 @@ class Invoice extends BaseController
$data['customer_shipping_arr'] = $this->get_customer_address($where, $select);
$data['invoice_item_details'] = $this->get_invoice_item($id);
}
// print_r($data['invoice_details']);die;
$country = new Customer();
$data['country_details'] = $country->get_country_details(); // print_r($data['invoice_details']);die;
$this->render_page('invoice_form', $data);
}

View File

@ -561,136 +561,6 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
</div>
</div>
<!-- Customer Quick Add Modal -->
<div class="modal fade" id="customerModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customerModalLabel">Add New Customer</h5>
<button type="button" class="close closeCustomerModal" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-row">
<div class="form-group col-md-6">
<label for="cus_first_name" class="col-form-label">First Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cus_first_name" placeholder="First Name" />
</div>
<div class="form-group col-md-6">
<label for="cus_last_name" class="col-form-label">Last Name</label>
<input type="text" class="form-control" id="cus_last_name" placeholder="Last name" />
</div>
<!-- <div class="form-group col-md-4">
<label for="cus_date_of_birth" class="col-form-label">Date Of Birth</label>
<input type="date" id="cus_date_of_birth" class="form-control" max="<?= date('Y-m-d', strtotime('-18 years')); ?>" placeholder="Date Of Birth" />
</div> -->
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="cus_email" class="col-form-label">Email</label>
<input type="text" class="form-control" id="cus_email" placeholder="Email" onkeyup="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cus_email')" />
<span id="emailValidationMessage"></span>
</div>
<div class="form-group col-md-6">
<label for="cus_mobile_no" class="col-form-label">Mobile<span class="text-danger"> *</span></label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">+91</div>
</div>
<input type="text" class="form-control" id="cus_mobile_no" placeholder="Mobile Number (Enter only numbers)" maxlength="10" onkeypress="return restriction(event)" onchange="checkExisting(this.value,'mobile_no','cus_mobile_no')" />
</div>
<span id="mobileValidationMessage"></span>
</div>
<div class="form-group col-md-6">
<label for="baddress1" class="col-form-label">Billing Address 1<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="baddress1" name="baddress1" placeholder="Address (eg : 1234 Main St)" />
</div>
<!-- Address 2 -->
<div class="form-group col-md-6">
<label for="baddress2" class="col-form-label">Billing Address 2</label>
<input type="text" class="form-control" id="baddress2" name="baddress2" placeholder="Address (eg : 1234 Main St)" />
</div>
<div class="form-group col-md-6">
<label for="bcountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcountry" name="bcountry" placeholder="Country" />
</div>
<div class="form-group col-md-6">
<label for="bstate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bstate" name="bstate" placeholder="State" />
</div>
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcity" name="bcity" placeholder="City" />
</div>
<div class="form-group col-md-6">
<label for="bpincode" class="col-form-label">Pincode<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bpincode" name="bpincode" minlength="6" maxlength="6" placeholder="Pincode" />
</div>
<div class="form-row">
<!-- Checkbox for Copy -->
<div class="form-group col-md-12 text-right checkbox checkbox-purple">
<input type="checkbox" id="addressCopiedAsShipping" />
<label for="addressCopiedAsShipping"> Is the above address same as the shipping address?</label>
</div>
</div>
<div class="after-shipping-addr-add-more">
<div class="form-group">
<div class="form-row">
<!-- Shipping Address 1 -->
<div class="form-group col-md-6">
<label for="saddress1" class="col-form-label">Shipping Address 1<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="saddress1" name="saddress1" placeholder="Address (eg : 1234 Main St)" />
</div>
<!-- Shipping Address 2 -->
<div class="form-group col-md-6">
<label for="saddress2" class="col-form-label">Shipping Address 2</label>
<input type="text" class="form-control" id="saddress2" name="saddress2" placeholder="Address (eg : 1234 Main St)" />
</div>
<!-- Country -->
<div class="form-group col-md-6">
<label for="scountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="scountry" name="scountry" placeholder="Country" />
</div>
<!-- State -->
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">State</label>
<input type="text" class="form-control" id="sstate" name="sstate" placeholder="State" />
</div>
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="scity" name="scity" placeholder="City" />
</div>
<!-- Pincode -->
<div class="form-group col-md-6">
<label for="spincode" class="col-form-label">Pincode<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="spincode" name="spincode" minlength="6" maxlength="6" placeholder="Pincode" />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary closeCustomerModal" data-dismiss="modal" id="closeCustomerModal">Close</button>
<button type="button" class="btn btn-primary save-invoice-customer" onclick="saveInvoiceCustomer()">Save Customer</button>
</div>
<!-- Country, State, City, Postal Code, etc. fields for Shipping Address -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : 'Draft' ?>">
<input type="hidden" id="hiddenInvoiceId" name="invoice_id" placeholder="hidden for invoice id" value="<?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>" />
<input type="hidden" id="invoice_type" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
@ -753,7 +623,151 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
</div>
</div>
</div>
<!-- Add Customer Modal -->
<!-- Customer Quick Add Modal -->
<div class="modal fade" id="customerModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="customerModalLabel">Add New Customer</h5>
<button type="button" class="close closeCustomerModal" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<form class="needs-validation" novalidate id="addCustomerForm">
<div class="modal-body">
<div class="form-row">
<div class="form-group col-md-6">
<label for="cus_first_name" class="col-form-label">First Name<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="cus_first_name" placeholder="First Name" required/>
</div>
<div class="form-group col-md-6">
<label for="cus_last_name" class="col-form-label">Last Name</label>
<input type="text" class="form-control" id="cus_last_name" placeholder="Last name" />
</div>
<!-- <div class="form-group col-md-4">
<label for="cus_date_of_birth" class="col-form-label">Date Of Birth</label>
<input type="date" id="cus_date_of_birth" class="form-control" max="<?= date('Y-m-d', strtotime('-18 years')); ?>" placeholder="Date Of Birth" />
</div> -->
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="cus_email" class="col-form-label">Email</label>
<input type="text" class="form-control" id="cus_email" placeholder="Email" onkeyup="validateEmail(this.value)" onchange="checkExisting(this.value,'email','cus_email')" />
<span id="emailValidationMessage"></span>
</div>
<div class="form-group col-md-6">
<label for="cus_mobile_no" class="col-form-label">Mobile<span class="text-danger"> *</span></label>
<div class="input-group mb-2">
<div class="input-group-prepend">
<div class="input-group-text">+91</div>
</div>
<input type="text" class="form-control" id="cus_mobile_no" placeholder="Mobile Number (Enter only numbers)" maxlength="10" onkeypress="return restriction(event)" onchange="checkExisting(this.value,'mobile_no','cus_mobile_no')" required/>
</div>
<span id="mobileValidationMessage"></span>
</div>
<div class="form-group col-md-6">
<label for="baddress1" class="col-form-label">Billing Address 1<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="baddress1" name="baddress1" placeholder="Address (eg : 1234 Main St)" required/>
</div>
<!-- Address 2 -->
<div class="form-group col-md-6">
<label for="baddress2" class="col-form-label">Billing Address 2</label>
<input type="text" class="form-control" id="baddress2" name="baddress2" placeholder="Address (eg : 1234 Main St)" />
</div>
<div class="form-group col-md-6">
<label for="bcountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<select class="form-control" id="bcountry" name="bcountry[]"placeholder="Choose Your Country" required>
<option value="">Choose your Country</option>
<?php foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_short_name']; ?>">
<?php echo $value['country_name']; ?>
</option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-6">
<label for="bstate" class="col-form-label">State</label>
<input type="text" class="form-control" id="bstate" name="bstate" placeholder="State" />
</div>
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bcity" name="bcity" placeholder="City" required/>
</div>
<div class="form-group col-md-6">
<label for="bpincode" class="col-form-label">Pincode<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="bpincode" name="bpincode" minlength="6" maxlength="6" placeholder="Pincode" required/>
</div>
<div class="form-row">
<!-- Checkbox for Copy -->
<div class="form-group col-md-12 text-right checkbox checkbox-purple">
<input type="checkbox" id="addressCopiedAsShipping" />
<label for="addressCopiedAsShipping"> Is the above address same as the shipping address?</label>
</div>
</div>
<div class="after-shipping-addr-add-more">
<div class="form-group">
<div class="form-row">
<!-- Shipping Address 1 -->
<div class="form-group col-md-6">
<label for="saddress1" class="col-form-label">Shipping Address 1<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="saddress1" name="saddress1" placeholder="Address (eg : 1234 Main St)" required/>
</div>
<!-- Shipping Address 2 -->
<div class="form-group col-md-6">
<label for="saddress2" class="col-form-label">Shipping Address 2</label>
<input type="text" class="form-control" id="saddress2" name="saddress2" placeholder="Address (eg : 1234 Main St)" />
</div>
<!-- Country -->
<div class="form-group col-md-6">
<label for="scountry" class="col-form-label">Country<span class="text-danger"> *</span></label>
<select class="form-control" id="scountry" name="scountry[]"placeholder="Choose Your Country" required>
<option value="">Choose your Country</option>
<?php foreach ($country_details as $value) { ?>
<option value="<?php echo $value['country_short_name']; ?>">
<?php echo $value['country_name']; ?>
</option>
<?php } ?>
</select>
</div>
<!-- State -->
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">State</label>
<input type="text" class="form-control" id="sstate" name="sstate" placeholder="State" />
</div>
<div class="form-group col-md-6">
<label for="sstate" class="col-form-label">City<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="scity" name="scity" placeholder="City" required/>
</div>
<!-- Pincode -->
<div class="form-group col-md-6">
<label for="spincode" class="col-form-label">Pincode<span class="text-danger"> *</span></label>
<input type="text" class="form-control" id="spincode" name="spincode" minlength="6" maxlength="6" placeholder="Pincode" required />
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary closeCustomerModal" data-dismiss="modal" id="closeCustomerModal">Close</button>
<button type="submit" class="btn btn-primary save-invoice-customer">Save Customer</button>
</div>
<!-- Country, State, City, Postal Code, etc. fields for Shipping Address -->
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Add Book Modal -->
<div class="modal fade" id="addBookModal" tabindex="-1" role="dialog" aria-labelledby="addBookModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
@ -1318,7 +1332,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
global_billid = "";
$(document).ready(function() {
var invoice_type = "<?php echo isset($invoice_type) ? $invoice_type : ''; ?>";
if (invoice_type !== 2){
if (invoice_type !== '2'){
$('#membership_id_div').hide();
}
var iid_arr = <?php echo json_encode($invoice_item_details); ?>;
@ -1331,6 +1345,7 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
ship_addrid = "<?= isset($invoice_details['shipping_address_id']) ? $invoice_details['shipping_address_id'] : ""; ?>";
var bill_addrid = "<?= isset($invoice_details['billing_address_id']) ? $invoice_details['billing_address_id'] : ""; ?>";
var cust_ship_arr = <?= isset($customer_shipping_arr) ? json_encode($customer_shipping_arr) : "[]"; ?>;
console.log(cust_ship_arr);
if (cust_ship_arr.length > 0) {
$.each(cust_ship_arr, function(k, v) {
$('#loadShippingDropdown').append($('<option>', {
@ -1913,175 +1928,151 @@ if (isset($invoice_item_details[0]['to_subscription']) && !empty($invoice_item_d
}
}
</script>
<script>
function saveInvoiceCustomer() {
var cus_first_name = document.getElementById("cus_first_name");
var cus_last_name = document.getElementById("cus_last_name");
var cus_email = document.getElementById("cus_email");
var cus_mobile_no = document.getElementById("cus_mobile_no");
<script>
$(document).ready(function () {
$('#addCustomerForm').submit(function (e) {
e.preventDefault(); // Prevent default form submission
const cus_first_name = $("#cus_first_name").val();
const cus_last_name = $("#cus_last_name").val();
const cus_email = $("#cus_email").val();
const cus_mobile_no = $("#cus_mobile_no").val();
var baddress1 = document.getElementById("baddress1");
var baddress2 = document.getElementById("baddress2");
var bcountry = document.getElementById("bcountry");
var bstate = document.getElementById("bstate");
var bcity = document.getElementById("bcity");
var bzip = document.getElementById("bpincode");
const baddress1 = $("#baddress1").val();
const baddress2 = $("#baddress2").val();
const bcountry = $("#bcountry").val();
const bstate = $("#bstate").val();
const bcity = $("#bcity").val();
const bzip = $("#bpincode").val();
var saddress1 = document.getElementById("saddress1");
var saddress2 = document.getElementById("saddress2");
var scountry = document.getElementById("scountry");
var sstate = document.getElementById("sstate");
var scity = document.getElementById("scity");
var szip = document.getElementById("spincode");
$("#storeBillingAddress").val("");
$("#storeShippingAddress").val("");
let missingFieldsMessage = '';
const saddress1 = $("#saddress1").val();
const saddress2 = $("#saddress2").val();
const scountry = $("#scountry").val();
const sstate = $("#sstate").val();
const scity = $("#scity").val();
const szip = $("#spincode").val();
// Custom checks for required fields
if (!cus_first_name.value) {
missingFieldsMessage += "Name\n";
}
if (!cus_mobile_no.value) {
missingFieldsMessage += "Mobile No.\n";
}
if (!baddress1.value ) {
missingFieldsMessage += "Billing Address\n";
}
if (!bcountry.value) {
missingFieldsMessage += "Billing Country\n";
}
if (!bcity.value) {
missingFieldsMessage += "Billing City\n";
}
if (!bpincode.value) {
missingFieldsMessage += "Billing Pincode\n";
}
if (!saddress1.value ) {
missingFieldsMessage += "Billing Address\n";
}
if (!scountry.value) {
missingFieldsMessage += "Billing Country\n";
}
if (!scity.value) {
missingFieldsMessage += "Billing City\n";
}
if (!spincode.value) {
missingFieldsMessage += "Billing Pincode\n";
}
let missingFieldsMessage = '';
// Validate required fields
if (!cus_first_name) missingFieldsMessage += "Name\n";
if (!cus_mobile_no) missingFieldsMessage += "Mobile No.\n";
if (!baddress1 || !bcountry || !bcity || !bzip) missingFieldsMessage += "Billing Address Fields\n";
if (!saddress1 || !scountry || !scity || !szip) missingFieldsMessage += "Shipping Address Fields\n";
// If there are missing fields, show a single alert with all the missing fields
if (missingFieldsMessage) {
alert("Please fill in the following required fields:\n\n" + missingFieldsMessage);
return; // Stop the function execution
}
$('.save-invoice-customer').prop('disabled', true);
$.ajax({
type: "POST",
url: "<?= base_url() . 'save_invoice_customer' ?>",
data: {
cus_first_name: cus_first_name.value,
cus_last_name: cus_last_name.value,
cus_email: cus_email.value,
cus_mobile_no: cus_mobile_no.value,
baddress1: baddress1.value,
baddress2: baddress2.value,
bcountry: bcountry.value,
bstate: bstate.value,
bcity: bcity.value,
bzip: bzip.value,
saddress1: saddress1.value,
saddress2: saddress2.value,
scountry: scountry.value,
sstate: sstate.value,
scity: scity.value,
szip: szip.value
},
success: function(response) {
console.log(response['data']);
if (response['data']['status']) {
// Handle success response
alert(response['data']['message']);
// Append the customer's name to the dropdown
var customerName = response['data']['cus_name'];
var customerId = response['data']['cus_id'];
var bAddressId = response['data']['billing_addr_id'];
var sAddressId = response['data']['shipping_addr_id'];
if(bAddressId !== null ){
var ajax_billarr = "";
var ajax_billing_address_arr = [];
var fbstate = bstate.value ? bstate.value + "-" + bzip.value : bstate.value;
baddress1.value ? ajax_billing_address_arr.push(baddress1.value + " " + baddress2.value) : "";
bcity.value ? ajax_billing_address_arr.push(bcity.value) : "";
fbstate ? ajax_billing_address_arr.push(fbstate) : "";
bcountry.value ? ajax_billing_address_arr.push(bcountry.value) : "";
ajax_billarr = ajax_billing_address_arr.join(', \n') + ".";
$("#storeBillingAddress").val(ajax_billarr).prop("readonly", true);
$('#hiddenBillingAddressId').val(bAddressId);
}else{
console.log("editAddress checkbox valid - true");
$("#editAddressesCheckbox").prop("checked", false);
// $("#storeBillingAddress").val("").prop("readonly", false);
$("#storeBillingAddress").val("").prop("readonly", true);
$("#storeShippingAddress").prop("readonly", true);
$('#loadShippingDropdown').empty().append($('<option>', {value: "",text: "Select an address"}));
}
if(sAddressId !== null ){
var ajax_shiparr = "";
var ajax_shipping_address_arr = [];
var fsstate = sstate.value ? sstate.value + "-" + szip.value : sstate.value;
saddress1.value ? ajax_shipping_address_arr.push(saddress1.value + " " + saddress2.value) : "";
scity.value ? ajax_shipping_address_arr.push(scity.value) : "";
fsstate ? ajax_shipping_address_arr.push(fsstate) : "";
scountry.value ? ajax_shipping_address_arr.push(scountry.value) : "";
ajax_shiparr = ajax_shipping_address_arr.join(', \n') + ".";
var newShippingAddrOption = $('<option>', {
value: sAddressId,
text: saddress1.value + " " + saddress2.value,
selected: true // Optionally select the new option
});
$("#storeShippingAddress").val(ajax_shiparr).prop("readonly", true);
$('#loadShippingDropdown').empty().append(newShippingAddrOption);
}else{
// $("#storeShippingAddress").val("").prop("readonly", false);
$("#storeShippingAddress").val("").prop("readonly", true);
$('#loadShippingDropdown').empty().append($('<option>', {value: "",text: "Select an address"}));
}
// Create a new option element
var newOption = $('<option>', {
value: customerId,
text: customerName,
selected: true // Optionally select the new option
});
// Append the new option to the dropdown
$('#customerName').append(newOption);
$('#customerModal').modal('hide');
cus_first_name.value = "";cus_last_name.value = "";
cus_email.value = "";cus_mobile_no.value = "";
baddress1.value = "";baddress2.value = "";bcountry.value = "";bstate.value = "";bcity.value = "";bzip.value = "";
saddress1.value = "";saddress2.value = "";scountry.value = "";sstate.value = "";scity.value = "";szip.value = "";
document.getElementById("emailValidationMessage").textContent = "";
document.getElementById("mobileValidationMessage").textContent = "";
document.getElementById("addressCopiedAsShipping").checked = false;
$('.save-invoice-customer').prop('disabled', false);
// Reload the page and select the last appended value
// location.reload();
} else {
// Handle error response
alert(response['data']['message']);
}
},
error: function() {
alert("Error occurred while saving customer.");
// If there are missing fields, show an alert
if (missingFieldsMessage) {
alert("Please fill in the following required fields:\n\n" + missingFieldsMessage);
return; // Stop execution
}
$('.save-invoice-customer').prop('disabled', true);
// Perform AJAX request to save data
$.ajax({
type: "POST",
url: "<?= base_url() . 'save_invoice_customer' ?>",
data: {
cus_first_name,
cus_last_name,
cus_email,
cus_mobile_no,
baddress1,
baddress2,
bcountry,
bstate,
bcity,
bzip,
saddress1,
saddress2,
scountry,
sstate,
scity,
szip
},
success: function (response) {
if (response['data']['status']) {
alert(response['data']['message']);
// Extract response data
const customerName = response['data']['cus_name'];
const customerId = response['data']['cus_id'];
const bAddressId = response['data']['billing_addr_id'];
const sAddressId = response['data']['shipping_addr_id'];
// Append the customer to the dropdown
const newCustomerOption = $('<option>', {
value: customerId,
text: customerName,
selected: true
});
$('#customerName').append(newCustomerOption);
// Append billing address
if (bAddressId !== null) {
const formattedBillingAddress = [
baddress1 + " " + (baddress2 || ""),
bcity,
(bstate ? bstate + "-" + bzip : ""),
bcountry
]
.filter(Boolean) // Remove empty values
.join(", ");
$("#storeBillingAddress").val(formattedBillingAddress).prop("readonly", true);
$('#hiddenBillingAddressId').val(bAddressId);
}
storeShippingAddress
// Append shipping address
if (sAddressId !== null) {
const formattedShippingAddress = [
saddress1 + " " + (saddress2 || ""),
scity,
(sstate ? sstate + "-" + szip : ""),
scountry
]
.filter(Boolean)
.join(", ");
const newShippingOption = $('<option>', {
value: sAddressId,
text: formattedShippingAddress,
selected: true
});
$('#loadShippingDropdown').append(newShippingOption);
$('#storeShippingAddress').val(formattedShippingAddress);
} else {
// Reset dropdown if no shipping address
$('#loadShippingDropdown').empty().append(
$('<option>', {
value: "",
text: "Select an address"
})
);
}
// Clear form fields
$('#addCustomerForm').trigger("reset");
$('#customerModal').modal('hide');
$('.save-invoice-customer').prop('disabled', false);
} else {
alert(response['data']['message'] || "Error occurred while saving the customer.");
$('.save-invoice-customer').prop('disabled', false);
}
},
error: function () {
alert("Error occurred while saving the customer.");
$('.save-invoice-customer').prop('disabled', false);
}
});
});
}
});
</script>
<script>
$('.closeCustomerModal').click(function() {
// Reset customer dropdown value
@ -2112,7 +2103,6 @@ function saveInvoiceCustomer() {
<script>
// JavaScript code to handle form submission and AJAX request
$(document).ready(function() {
var form = $('#customerForm');
$('#addBookForm').submit(function(e) {
var Quickadd_bookName = $("#bookName").val();