address issue
This commit is contained in:
parent
eeca1f21b6
commit
5bb12d2aca
@ -548,38 +548,73 @@ class Customer extends BaseController
|
||||
|
||||
## For Ajax Call To Save Invoice Customer...
|
||||
public function save_invoice_customer()
|
||||
{
|
||||
helper('session');
|
||||
$session_bid = get_business_id();
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new CustomerModel();
|
||||
|
||||
$data = [
|
||||
'first_name' => $this->request->getPost('cus_first_name'),
|
||||
'last_name' => $this->request->getPost('cus_last_name'),
|
||||
'mobile_no' => $this->request->getPost('cus_mobile_no'),
|
||||
'email' => $this->request->getPost('cus_email'),
|
||||
'date_of_birth' => NULL,
|
||||
'type' => "customer",
|
||||
'mode' => "Offline",
|
||||
'business_id' => $session_bid,
|
||||
'isactive' => 1,
|
||||
'created_by' => $session_uid
|
||||
];
|
||||
|
||||
if ($model->insert($data)) {
|
||||
$this->logger->info("Invoice Customer : has been added successfully. Inserted ID = " . $model->insertID());
|
||||
$results = ['status' => true, 'message' => 'customer has been added successfully','cus_id' => $model->insertID()];
|
||||
}else {
|
||||
$this->logger->error("Invoice Customer: Err could not be added. Please try again.");
|
||||
$results = ['status' => false, 'message' => 'customer could not be added'];
|
||||
}
|
||||
{
|
||||
helper('session');
|
||||
$session_bid = get_business_id();
|
||||
$session_uid = get_logged_user_id();
|
||||
$model = new CustomerModel();
|
||||
|
||||
//get all customerss
|
||||
$CustomerModel = new CustomerModel();
|
||||
$where = ['isactive' => 1, 'business_id' => (int)$session_bid];
|
||||
$results['customers'] = $CustomerModel->where($where)->orderBy('customer_id', 'DESC')->findAll();
|
||||
return $this->response->setJSON(['data' => $results]);
|
||||
$data = [
|
||||
'first_name' => $this->request->getPost('cus_first_name'),
|
||||
'last_name' => $this->request->getPost('cus_last_name'),
|
||||
'mobile_no' => $this->request->getPost('cus_mobile_no'),
|
||||
'email' => $this->request->getPost('cus_email'),
|
||||
'date_of_birth' => NULL,
|
||||
'type' => "customer",
|
||||
'mode' => "Offline",
|
||||
'business_id' => $session_bid,
|
||||
'isactive' => 1,
|
||||
'created_by' => $session_uid
|
||||
];
|
||||
|
||||
if ($model->insert($data)) {
|
||||
$customerId = $model->insertID();
|
||||
|
||||
$this->logger->info("Invoice Customer : has been added successfully. Inserted ID = " . $customerId);
|
||||
|
||||
// Store both billing and shipping addresses
|
||||
$billingAddress = [
|
||||
'customer_id' => $customerId,
|
||||
'first_name' => $this->request->getPost('cus_first_name'),
|
||||
'last_name' => $this->request->getPost('cus_last_name'),
|
||||
'address_type' => 1, // Billing address type
|
||||
'billing_address1' => $this->request->getPost('baddress1'),
|
||||
'billing_address2' => $this->request->getPost('baddress2'),
|
||||
'billing_city' => $this->request->getPost('bcity'),
|
||||
'billing_state' => $this->request->getPost('bstate'),
|
||||
'billing_country' => $this->request->getPost('bcountry'),
|
||||
'billing_pincode' => $this->request->getPost('bzip')
|
||||
];
|
||||
|
||||
$shippingAddress = [
|
||||
'customer_id' => $customerId,
|
||||
'first_name' => $this->request->getPost('cus_first_name'),
|
||||
'last_name' => $this->request->getPost('cus_last_name'),
|
||||
'address_type' => 2, // Shipping address type
|
||||
'shipping_address1' => $this->request->getPost('saddress1'),
|
||||
'shipping_address2' => $this->request->getPost('saddress2'),
|
||||
'shipping_city' => $this->request->getPost('scity'),
|
||||
'shipping_state' => $this->request->getPost('sstate'),
|
||||
'shipping_country' => $this->request->getPost('scountry'),
|
||||
'shipping_pincode' => $this->request->getPost('szip')
|
||||
];
|
||||
|
||||
// Call the method to store both addresses
|
||||
$result = $model->storeCustomerAddresses($billingAddress, $shippingAddress);
|
||||
|
||||
if ($result) {
|
||||
// Success response
|
||||
$results = ['status' => true, 'message' => 'Customer and addresses saved successfully', 'cus_id' => $customerId];
|
||||
} else {
|
||||
// Error response
|
||||
$results = ['status' => false, 'message' => 'Failed to save customer and addresses'];
|
||||
}
|
||||
} else {
|
||||
$this->logger->error("Invoice Customer: Error could not be added. Please try again.");
|
||||
$results = ['status' => false, 'message' => 'Customer could not be added'];
|
||||
}
|
||||
|
||||
|
||||
return $this->response->setJSON(['data' => $results]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -753,7 +753,7 @@ $encodedUrl = urlencode($url);
|
||||
// Load required model
|
||||
$model = new InvoiceModel();
|
||||
$data = $model->getInvoiceData($id);
|
||||
|
||||
// print_r($data);die;
|
||||
$invoiceItems = $model->getInvoiceItems($id,'groupby');
|
||||
|
||||
foreach($invoiceItems as $index => $singleItem)
|
||||
|
||||
@ -174,6 +174,46 @@ return $this->db->table('customer_groups as CG' )
|
||||
->getResultArray();
|
||||
}
|
||||
|
||||
public function storeCustomerAddresses($billingAddress, $shippingAddress)
|
||||
{
|
||||
// $this->db->transStart(); // Begin transaction
|
||||
|
||||
// Insert billing address
|
||||
$billingData = [
|
||||
'customer_id' => $billingAddress['customer_id'],
|
||||
'first_name'=> $billingAddress['first_name'],
|
||||
'last_name'=> $billingAddress['last_name'],
|
||||
'address_1' => $billingAddress['billing_address1'],
|
||||
'address_2' => $billingAddress['billing_address2'],
|
||||
'city' => $billingAddress['billing_city'],
|
||||
'state' => $billingAddress['billing_state'],
|
||||
'country' => $billingAddress['billing_country'],
|
||||
'postal_code' => $billingAddress['billing_pincode'],
|
||||
'address_type' => 1 // Billing address type
|
||||
];
|
||||
$this->db->table('customer_addresses')->insert($billingData);
|
||||
|
||||
// Insert shipping address
|
||||
$shippingData = [
|
||||
'customer_id' => $shippingAddress['customer_id'],
|
||||
'first_name'=> $shippingAddress['first_name'],
|
||||
'last_name'=> $shippingAddress['last_name'],
|
||||
'address_1' => $shippingAddress['shipping_address1'],
|
||||
'address_2' => $shippingAddress['shipping_address2'],
|
||||
'city' => $shippingAddress['shipping_city'],
|
||||
'state' => $shippingAddress['shipping_state'],
|
||||
'country' => $shippingAddress['shipping_country'],
|
||||
'postal_code' => $shippingAddress['shipping_pincode'],
|
||||
'address_type' => 2 // Shipping address type
|
||||
];
|
||||
$this->db->table('customer_addresses')->insert($shippingData);
|
||||
return true; // Return true indicating successful insertion
|
||||
|
||||
// Rollback transaction in case of an error
|
||||
|
||||
|
||||
// Returns transaction status
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
@ -121,10 +121,9 @@ public function getSubscriptionInvoiceDetail($where)
|
||||
}
|
||||
|
||||
|
||||
public function getJoinedData($where)
|
||||
{
|
||||
|
||||
return $this->db->table($this->table.' as I' )
|
||||
public function getJoinedData($where)
|
||||
{
|
||||
$query = $this->db->table($this->table.' as I' )
|
||||
->join('customers as C', 'C.customer_id = I.customer_id', 'left')
|
||||
->join('subscription as S', 'S.invoice_id = I.invoice_id', 'left')
|
||||
->join('events as E', 'E.event_id = I.event_id', 'left')
|
||||
@ -136,12 +135,16 @@ public function getSubscriptionInvoiceDetail($where)
|
||||
// ->like('C.first_name',"%John%")
|
||||
->orderBy('I.invoice_id', 'DESC')
|
||||
->groupBy('I.invoice_id')
|
||||
->get()
|
||||
->getResultArray();
|
||||
// print_r($this->db->getLastQuery());die;
|
||||
|
||||
// I.shipping_address_id, I.billing_address_id,
|
||||
}
|
||||
->get();
|
||||
|
||||
$resultArray = $query->getResultArray();
|
||||
|
||||
// Print the last executed query
|
||||
// echo $this->db->getLastQuery();die;
|
||||
|
||||
return $resultArray;
|
||||
}
|
||||
|
||||
|
||||
## subscription_inactive
|
||||
public function subscription_inactive(){
|
||||
@ -236,8 +239,9 @@ public function getSubscriptionInvoiceDetail($where)
|
||||
->select('invoice.*,DATE_FORMAT(invoice.invoice_date, "%d/%m/%Y") AS formatted_invoice_date,DATE_FORMAT(invoice.due_date, "%d/%m/%Y") AS formatted_due_date ,concat(C.first_name," ",C.last_name) as customer_name,C.mobile_no,A.address_1, A.address_2,A.postal_code,A.city, A.state,C.mobile_no as customer_mobile')
|
||||
->select('B.title as company_name,B.business_logo,B.terms as company_terms,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.email as company_email,B.mobile_no as company_mobile_no')
|
||||
->select('COALESCE(NULLIF(states.state_name, ""), A.state) AS customer_bill_state')
|
||||
->select('concat(A.address_1," ", A.address_2) as customer_bill_address,A.postal_code as customer_bill_postal_code ,A.city as customer_bill_city, countries.country_name as customer_bill_country')
|
||||
->select('concat(S.address_1," ", S.address_2) as customer_ship_address,S.postal_code as customer_ship_postal_code ,S.city as customer_ship_city, countries.country_name as customer_ship_country')
|
||||
->select('COALESCE(NULLIF(states.state_name, ""), S.state) AS customer_ship_state')
|
||||
->select('concat(A.address_1," ", A.address_2) as customer_bill_address,A.postal_code as customer_bill_postal_code ,A.city as customer_bill_city, countries.country_name as customer_bill_country,A.country as bcountry,A.state as bstate')
|
||||
->select('concat(S.address_1," ", S.address_2) as customer_ship_address,S.postal_code as customer_ship_postal_code ,S.city as customer_ship_city, countries.country_name as customer_ship_country,S.country as scountry,S.state as sstate')
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@
|
||||
<td hidden><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>
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<td>
|
||||
<!-- <center><i class="fa fa-trash remove-item "></i></center> -->
|
||||
<center><i class="fa fa-trash remove-item "></i></center>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
</tr>
|
||||
@ -198,7 +198,7 @@
|
||||
<td hidden><input type="hidden" class="form-control" id="hiddenInvoiceChildId0" name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" /></td>
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<td>
|
||||
<!-- <center><i class="fa fa-trash remove-item "></i></center> -->
|
||||
<center><i class="fa fa-trash remove-item "></i></center>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
|
||||
@ -359,16 +359,91 @@
|
||||
</div>
|
||||
<span id="mobileValidationMessage"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<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 class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<!-- Address 2 -->
|
||||
<div class="form-group col-md-6">
|
||||
<label for="baddress2" class="col-form-label">Billing Address 2<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="baddress2" name="baddress2" placeholder="Address (eg : 1234 Main St)" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</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 class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="bstate" class="col-form-label">State<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="bstate" name="bstate" placeholder="State" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</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 class="invalid-feedback"> Please provide. </div>
|
||||
</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 class="invalid-feedback"> Please provide. </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 class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<!-- Shipping Address 2 -->
|
||||
<div class="form-group col-md-6">
|
||||
<label for="saddress2" class="col-form-label">Shipping Address 2<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="saddress2" name="saddress2" placeholder="Address (eg : 1234 Main St)" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</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 class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<!-- State -->
|
||||
<div class="form-group col-md-6">
|
||||
<label for="sstate" class="col-form-label">State<span class="text-danger"> *</span></label>
|
||||
<input type="text" class="form-control" id="sstate" name="sstate" placeholder="State" />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</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 class="invalid-feedback"> Please provide. </div>
|
||||
</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 class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal"id="closeCustomerModal">Close</button>
|
||||
<button type="button" class="btn btn-primary save-invoice-customer" onclick="saveInvoiceCustomer()">Save Customer</button>
|
||||
</div>
|
||||
</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'] : '' ?>" />
|
||||
<div class="form-group text-right m-b-0">
|
||||
@ -502,6 +577,7 @@
|
||||
var bookData=<?php echo json_encode($books); ?>;
|
||||
|
||||
localStorage.setItem('add_book_index', 0);
|
||||
document.querySelector("#itemTable tbody tr:first-child .remove-item").style.visibility = 'hidden';
|
||||
document.getElementById("addItem").addEventListener("click", function() {
|
||||
var bookArray = bookData;
|
||||
console.log(bookArray);
|
||||
@ -1161,88 +1237,91 @@ cell1.innerHTML=html;
|
||||
}
|
||||
}
|
||||
|
||||
function saveInvoiceCustomer(){
|
||||
function saveInvoiceCustomer() {
|
||||
var cus_first_name = document.getElementById("cus_first_name").value;
|
||||
var cus_last_name = document.getElementById("cus_last_name").value;
|
||||
var cus_email = document.getElementById("cus_email").value;
|
||||
var cus_mobile_no = document.getElementById("cus_mobile_no").value;
|
||||
|
||||
var cus_first_name = document.getElementById("cus_first_name");
|
||||
var cus_last_name = document.getElementById("cus_last_name");
|
||||
// var cus_date_of_birth = document.getElementById("cus_date_of_birth");
|
||||
var cus_email = document.getElementById("cus_email");
|
||||
var cus_mobile_no = document.getElementById("cus_mobile_no");
|
||||
if (cus_first_name.value === "") {
|
||||
cus_first_name.focus();
|
||||
alert("Customer First Name Required");
|
||||
} else if (cus_last_name.value === "") {
|
||||
cus_last_name.focus();
|
||||
alert("Customer Last Name Required");
|
||||
} else if (cus_email.value === "") {
|
||||
cus_email.focus();
|
||||
alert("Customer Email Required");
|
||||
} else if (cus_mobile_no.value === "") {
|
||||
cus_mobile_no.focus();
|
||||
alert("Customer Mobile Number Required");
|
||||
} else {
|
||||
$('.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
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
if (response['data']['status']) {
|
||||
cus_dropdown = response['data']['customers'];
|
||||
alert(response['data']['message']);
|
||||
if (cus_dropdown.length > 0) {
|
||||
$('#customerName').empty();
|
||||
$('#customerName').append($('<option>', {
|
||||
value: "",
|
||||
text: "Select a customer"
|
||||
}));
|
||||
$('#customerName').append($('<option>', {
|
||||
value: "0",
|
||||
text: "+ Add a customer"
|
||||
}));
|
||||
$.each(cus_dropdown, function(k, v) {
|
||||
$('#customerName').append($('<option>', {
|
||||
value: v.customer_id,
|
||||
text: v.first_name + ' ' + v.last_name,
|
||||
selected: (v.customer_id == response['data']['cus_id']) ? true : false
|
||||
}));
|
||||
});
|
||||
$('#editAddressesCheckbox').prop('checked', true);
|
||||
$("#storeBillingAddress").prop("readonly", false);
|
||||
$("#storeShippingAddress").prop("readonly", false);
|
||||
$('#hiddenBillingAddressId').val(0);
|
||||
}
|
||||
$('#customerModal').modal('hide');
|
||||
cus_first_name.value = "";
|
||||
cus_last_name.value = "";
|
||||
cus_email.value = "";
|
||||
cus_mobile_no.value = "";
|
||||
var baddress1 = document.getElementById("baddress1").value;
|
||||
var baddress2 = document.getElementById("baddress2").value;
|
||||
var bcountry = document.getElementById("bcountry").value;
|
||||
var bstate = document.getElementById("bstate").value;
|
||||
var bcity = document.getElementById("bcity").value;
|
||||
var bzip = document.getElementById("bpincode").value;
|
||||
|
||||
} else {
|
||||
alert(response['data']['message']);
|
||||
$('#editAddressesCheckbox').prop('checked', false);
|
||||
// $("#storeBillingAddress").prop("readonly", true);
|
||||
// $("#storeShippingAddress").prop("readonly", true);
|
||||
}
|
||||
$('.save-invoice-customer').prop('disabled', false);
|
||||
},
|
||||
|
||||
error: function() {
|
||||
alert("Error occur.");
|
||||
$('#editAddressesCheckbox').prop('checked', false);
|
||||
// $("#storeBillingAddress").prop("readonly", true);
|
||||
// $("#storeShippingAddress").prop("readonly", true);
|
||||
$('.save-invoice-customer').prop('disabled', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
var saddress1 = document.getElementById("saddress1").value;
|
||||
var saddress2 = document.getElementById("saddress2").value;
|
||||
var scountry = document.getElementById("scountry").value;
|
||||
var sstate = document.getElementById("sstate").value;
|
||||
var scity = document.getElementById("scity").value;
|
||||
var szip = document.getElementById("spincode").value;
|
||||
if (
|
||||
!cus_first_name || !cus_last_name || !cus_email || !cus_mobile_no ||
|
||||
!baddress1 || !baddress2 || !bcountry || !bstate || !bcity || !bzip ||
|
||||
!saddress1 || !saddress2 || !scountry || !sstate || !scity || !szip
|
||||
) {
|
||||
alert("Please fill in all required fields.");
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "<?= base_url() . 'save_invoice_customer' ?>",
|
||||
data: {
|
||||
cus_first_name: cus_first_name,
|
||||
cus_last_name: cus_last_name,
|
||||
cus_email: cus_email,
|
||||
cus_mobile_no: cus_mobile_no,
|
||||
baddress1: baddress1,
|
||||
baddress2: baddress2,
|
||||
bcountry: bcountry,
|
||||
bstate: bstate,
|
||||
bcity: bcity,
|
||||
bzip: bzip,
|
||||
saddress1: saddress1,
|
||||
saddress2: saddress2,
|
||||
scountry: scountry,
|
||||
sstate: sstate,
|
||||
scity: scity,
|
||||
szip: szip
|
||||
},
|
||||
success: function(response) {
|
||||
if (response['data']['status']) {
|
||||
// Handle success response
|
||||
alert(response['data']['message']);
|
||||
|
||||
// Append the customer's name to the dropdown
|
||||
var customerName = response['data']['customer_name'];
|
||||
var customerId = response['data']['cus_id'];
|
||||
|
||||
// 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);
|
||||
|
||||
// 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.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$('#closeCustomerModal').click(function() {
|
||||
// Reset customer dropdown value
|
||||
$('#customerName').val("").trigger('change');
|
||||
|
||||
@ -202,9 +202,10 @@ p {
|
||||
<?php foreach ($data as $value) : ?>
|
||||
<?= $value->customer_name ?><br>
|
||||
<?= $value->customer_ship_address." ," ?><br>
|
||||
<?= $value->customer_bill_city ?> <?= $value->customer_bill_state ? $value->customer_bill_state : "" ?>
|
||||
<?= $value->customer_bill_postal_code ? " - ".$value->customer_bill_postal_code :""; ?>
|
||||
<?= $value->customer_bill_country." ." ?><br>
|
||||
<?= $value->customer_ship_city ?> <?= $value->customer_ship_state ? $value->customer_bill_state :""?>
|
||||
<?= $value->customer_ship_postal_code ? " - ".$value->customer_ship_postal_code :""; ?>
|
||||
<?= $value->customer_ship_country ? $value->customer_ship_country . "." : $value->scountry ?><br>
|
||||
|
||||
<?= $value->mobile_no." ." ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
@ -215,7 +216,8 @@ p {
|
||||
<?= $value->customer_bill_address." ," ?><br>
|
||||
<?= $value->customer_bill_city ?> <?= $value->customer_bill_state ? $value->customer_bill_state : "" ?>
|
||||
<?= $value->customer_bill_postal_code ? " - ".$value->customer_bill_postal_code :""; ?>
|
||||
<?= $value->customer_bill_country." ." ?><br>
|
||||
<?= $value->customer_bill_country ? $value->customer_bill_country . "." : $value->bcountry ?><br>
|
||||
|
||||
<?= $value->mobile_no." ." ?>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user