Auto Fetched Invoice Issues Fixes : ps
This commit is contained in:
parent
041c435acd
commit
9efa3d22b9
@ -556,7 +556,7 @@ class Customer extends BaseController
|
|||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'first_name' => $this->request->getPost('cus_first_name'),
|
'first_name' => $this->request->getPost('cus_first_name'),
|
||||||
'last_name' => $this->request->getPost('cus_last_name'),
|
'last_name' => $this->request->getPost('cus_last_name') ? $this->request->getPost('cus_last_name') : '',
|
||||||
'mobile_no' => $this->request->getPost('cus_mobile_no'),
|
'mobile_no' => $this->request->getPost('cus_mobile_no'),
|
||||||
'email' => $this->request->getPost('cus_email'),
|
'email' => $this->request->getPost('cus_email'),
|
||||||
'date_of_birth' => NULL,
|
'date_of_birth' => NULL,
|
||||||
@ -576,7 +576,7 @@ class Customer extends BaseController
|
|||||||
$billingAddress = [
|
$billingAddress = [
|
||||||
'customer_id' => $customerId,
|
'customer_id' => $customerId,
|
||||||
'first_name' => $this->request->getPost('cus_first_name'),
|
'first_name' => $this->request->getPost('cus_first_name'),
|
||||||
'last_name' => $this->request->getPost('cus_last_name'),
|
'last_name' => $this->request->getPost('cus_last_name') ? $this->request->getPost('cus_last_name') : '',
|
||||||
'address_type' => 1, // Billing address type
|
'address_type' => 1, // Billing address type
|
||||||
'billing_address1' => $this->request->getPost('baddress1'),
|
'billing_address1' => $this->request->getPost('baddress1'),
|
||||||
'billing_address2' => $this->request->getPost('baddress2'),
|
'billing_address2' => $this->request->getPost('baddress2'),
|
||||||
@ -589,7 +589,7 @@ class Customer extends BaseController
|
|||||||
$shippingAddress = [
|
$shippingAddress = [
|
||||||
'customer_id' => $customerId,
|
'customer_id' => $customerId,
|
||||||
'first_name' => $this->request->getPost('cus_first_name'),
|
'first_name' => $this->request->getPost('cus_first_name'),
|
||||||
'last_name' => $this->request->getPost('cus_last_name'),
|
'last_name' => $this->request->getPost('cus_last_name') ? $this->request->getPost('cus_last_name') : '',
|
||||||
'address_type' => 2, // Shipping address type
|
'address_type' => 2, // Shipping address type
|
||||||
'shipping_address1' => $this->request->getPost('saddress1'),
|
'shipping_address1' => $this->request->getPost('saddress1'),
|
||||||
'shipping_address2' => $this->request->getPost('saddress2'),
|
'shipping_address2' => $this->request->getPost('saddress2'),
|
||||||
@ -601,10 +601,18 @@ class Customer extends BaseController
|
|||||||
|
|
||||||
// Call the method to store both addresses
|
// Call the method to store both addresses
|
||||||
$result = $model->storeCustomerAddresses($billingAddress, $shippingAddress);
|
$result = $model->storeCustomerAddresses($billingAddress, $shippingAddress);
|
||||||
|
if($customerId){
|
||||||
|
$cus_first_name = $this->request->getPost('cus_first_name');
|
||||||
|
$cus_last_name = $this->request->getPost('cus_last_name');
|
||||||
|
$name = $cus_first_name;
|
||||||
|
if ($cus_last_name !== null) {
|
||||||
|
$name .= ' ' . $cus_last_name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($customerId) {
|
||||||
// Success response
|
// Success response
|
||||||
$results = ['status' => true, 'message' => 'Customer and addresses saved successfully', 'cus_id' => $customerId];
|
$results = ['status' => true, 'message' => 'Customer and addresses saved successfully', 'cus_id' => $customerId,'cus_name'=>$name,"billing_addr_id"=>$result['billing_addr_id'],"shipping_addr_id"=>$result['shipping_addr_id']];
|
||||||
} else {
|
} else {
|
||||||
// Error response
|
// Error response
|
||||||
$results = ['status' => false, 'message' => 'Failed to save customer and addresses'];
|
$results = ['status' => false, 'message' => 'Failed to save customer and addresses'];
|
||||||
|
|||||||
@ -179,6 +179,7 @@ public function storeCustomerAddresses($billingAddress, $shippingAddress)
|
|||||||
// $this->db->transStart(); // Begin transaction
|
// $this->db->transStart(); // Begin transaction
|
||||||
|
|
||||||
// Insert billing address
|
// Insert billing address
|
||||||
|
if(!empty($billingAddress['billing_address1'])){
|
||||||
$billingData = [
|
$billingData = [
|
||||||
'customer_id' => $billingAddress['customer_id'],
|
'customer_id' => $billingAddress['customer_id'],
|
||||||
'first_name'=> $billingAddress['first_name'],
|
'first_name'=> $billingAddress['first_name'],
|
||||||
@ -192,7 +193,12 @@ public function storeCustomerAddresses($billingAddress, $shippingAddress)
|
|||||||
'address_type' => 1 // Billing address type
|
'address_type' => 1 // Billing address type
|
||||||
];
|
];
|
||||||
$this->db->table('customer_addresses')->insert($billingData);
|
$this->db->table('customer_addresses')->insert($billingData);
|
||||||
|
$billing_addr_id = $this->db->insertID();
|
||||||
|
}else{
|
||||||
|
$billing_addr_id = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($shippingAddress['shipping_address1'])){
|
||||||
// Insert shipping address
|
// Insert shipping address
|
||||||
$shippingData = [
|
$shippingData = [
|
||||||
'customer_id' => $shippingAddress['customer_id'],
|
'customer_id' => $shippingAddress['customer_id'],
|
||||||
@ -207,12 +213,11 @@ public function storeCustomerAddresses($billingAddress, $shippingAddress)
|
|||||||
'address_type' => 2 // Shipping address type
|
'address_type' => 2 // Shipping address type
|
||||||
];
|
];
|
||||||
$this->db->table('customer_addresses')->insert($shippingData);
|
$this->db->table('customer_addresses')->insert($shippingData);
|
||||||
return true; // Return true indicating successful insertion
|
$shipping_addr_id = $this->db->insertID();
|
||||||
|
}else{
|
||||||
// Rollback transaction in case of an error
|
$shipping_addr_id = NULL;
|
||||||
|
}
|
||||||
|
return ["billing_addr_id"=>$billing_addr_id,"shipping_addr_id"=>$shipping_addr_id]; // Return true indicating successful insertion
|
||||||
// Returns transaction status
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -235,16 +235,16 @@ public function getJoinedData($where, $orderby = [])
|
|||||||
->where('invoice_id', $id)
|
->where('invoice_id', $id)
|
||||||
->join('customers as C','C.customer_id= invoice.customer_id','left')
|
->join('customers as C','C.customer_id= invoice.customer_id','left')
|
||||||
->join('business as B','B.business_id = invoice.business_id','left')
|
->join('business as B','B.business_id = invoice.business_id','left')
|
||||||
->join('customer_addresses as A','A.customer_address_id=invoice.shipping_address_id','left')
|
->join('customer_addresses as A','A.customer_address_id=invoice.billing_address_id AND A.address_type = 1','left')
|
||||||
->join('customer_addresses as S','S.customer_address_id=invoice.billing_address_id','left')
|
->join('customer_addresses as S','S.customer_address_id=invoice.shipping_address_id AND S.address_type = 2','left')
|
||||||
->join('states', 'states.state_short_name = A.state AND A.country = "IN"', 'left')
|
->join('states', 'states.state_short_name = A.state AND A.country = "IN"', 'left')
|
||||||
->join('countries', 'countries.country_short_name = A.country', 'left')
|
->join('countries', 'countries.country_short_name = A.country', 'left')
|
||||||
->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('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('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('COALESCE(NULLIF(states.state_name, ""), A.state) AS customer_bill_state')
|
||||||
->select('COALESCE(NULLIF(states.state_name, ""), S.state) AS customer_ship_state')
|
->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(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,A.customer_address_id as baddr_id')
|
||||||
->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')
|
->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,S.customer_address_id as saddr_id')
|
||||||
->get()
|
->get()
|
||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
|
|||||||
@ -92,18 +92,18 @@ public function getAllCustomerDetailsBySchemeName($schemeName)
|
|||||||
$builder = $this->db->table('subscription');
|
$builder = $this->db->table('subscription');
|
||||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title as business_name,business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name');
|
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name,customer_addresses.mobile_no, customer_addresses.address_1,customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code,business.title as business_name,business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name');
|
||||||
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
||||||
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
|
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id AND customer_addresses.address_type = 2','left');
|
||||||
$builder->join('business', 'business.business_id = subscription.business_id');
|
$builder->join('business', 'business.business_id = subscription.business_id');
|
||||||
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
||||||
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
||||||
$builder->where('books.title', $schemeName);
|
$builder->where('books.title', $schemeName);
|
||||||
$builder->where('subscription.to_subscription >=', $currentDate);
|
$builder->where('subscription.to_subscription >=', $currentDate);
|
||||||
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
// $builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
||||||
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
||||||
|
|
||||||
// Fetch the query result
|
// Fetch the query result
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
// print_r($query);die;
|
|
||||||
$customerDetails = [];
|
$customerDetails = [];
|
||||||
|
|
||||||
if ($query->getNumRows() > 0) {
|
if ($query->getNumRows() > 0) {
|
||||||
@ -159,15 +159,15 @@ public function getAllActiveCustomerDetails($selectedScheme)
|
|||||||
$builder = $this->db->table('subscription');
|
$builder = $this->db->table('subscription');
|
||||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.mobile_no, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, business.title as business_name, books.title, from_subscription, to_subscription, business.mobile_no as business_mobile_no, business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name');
|
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.mobile_no, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, business.title as business_name, books.title, from_subscription, to_subscription, business.mobile_no as business_mobile_no, business.address as business_address,business.city as business_city,business.state as business_state,business.postal_code as business_postal_code,books.title,from_subscription,to_subscription,business.title as business_name,business.mobile_no as business_mobile_no,states.state_name');
|
||||||
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
||||||
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
|
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id And customer_addresses.address_type = 2','left');
|
||||||
$builder->join('business', 'business.business_id = subscription.business_id');
|
$builder->join('business', 'business.business_id = subscription.business_id');
|
||||||
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
||||||
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
||||||
// Active subscriptions only
|
// Active subscriptions only
|
||||||
$builder->where('books.title', $schemeName);
|
$builder->where('books.title', $schemeName);
|
||||||
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
// $builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
||||||
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
||||||
|
$builder->groupBy('subscription.sub_id');
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
|
|
||||||
$activeCustomerDetails = [];
|
$activeCustomerDetails = [];
|
||||||
@ -223,15 +223,15 @@ public function getAllExpiredCustomerDetailsByScheme($schemeName)
|
|||||||
$builder = $this->db->table('subscription');
|
$builder = $this->db->table('subscription');
|
||||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.mobile_no, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, business.title as business_name, books.title, from_subscription, to_subscription, business.mobile_no as business_mobile_no, states.state_name');
|
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.mobile_no, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, business.title as business_name, books.title, from_subscription, to_subscription, business.mobile_no as business_mobile_no, states.state_name');
|
||||||
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
||||||
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
|
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id And customer_addresses.address_type = 2','left');
|
||||||
$builder->join('business', 'business.business_id = subscription.business_id');
|
$builder->join('business', 'business.business_id = subscription.business_id');
|
||||||
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
||||||
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
$builder->join('states', 'states.state_short_name = customer_addresses.state','left');
|
||||||
$builder->where('books.title', $schemeName);
|
$builder->where('books.title', $schemeName);
|
||||||
$builder->where('subscription.to_subscription <', $currentDate); // Expired subscriptions only
|
$builder->where('subscription.to_subscription <', $currentDate); // Expired subscriptions only
|
||||||
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
// $builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
||||||
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
||||||
|
$builder->groupBy('subscription.sub_id');
|
||||||
// Fetch the query result
|
// Fetch the query result
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
|
|
||||||
@ -281,18 +281,19 @@ public function getAllExpiredCustomerDetailsByScheme($schemeName)
|
|||||||
public function getBothDetailsSchemeName($schemeName)
|
public function getBothDetailsSchemeName($schemeName)
|
||||||
{
|
{
|
||||||
$builder = $this->db->table('subscription');
|
$builder = $this->db->table('subscription');
|
||||||
$builder->select('customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.mobile_no, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, business.title as business_name, books.title, from_subscription, to_subscription, business.mobile_no as business_mobile_no, business.address as business_address, business.city as business_city, business.state as business_state, business.postal_code as business_postal_code, books.title, states.state_name');
|
$builder->select('subscription.sub_id,customers.customer_id, CONCAT(customers.first_name, " ", customers.last_name) as customer_name, customer_addresses.mobile_no, customer_addresses.address_1, customer_addresses.address_2, customer_addresses.city, customer_addresses.state, customer_addresses.postal_code, business.title as business_name, books.title, from_subscription, to_subscription, business.mobile_no as business_mobile_no, business.address as business_address, business.city as business_city, business.state as business_state, business.postal_code as business_postal_code, books.title, states.state_name');
|
||||||
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
$builder->join('customers', 'customers.customer_id = subscription.customer_id');
|
||||||
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id');
|
$builder->join('customer_addresses', 'customer_addresses.customer_id = customers.customer_id','left');
|
||||||
$builder->join('business', 'business.business_id = subscription.business_id');
|
$builder->join('business', 'business.business_id = subscription.business_id');
|
||||||
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
$builder->join('books', 'books.book_id = subscription.scheme_id');
|
||||||
$builder->join('states', 'states.state_short_name = customer_addresses.state');
|
$builder->join('states', 'states.state_short_name = customer_addresses.state','left');
|
||||||
$builder->where('books.title', $schemeName);
|
$builder->where('books.title', $schemeName);
|
||||||
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
$builder->where('customer_addresses.address_type', 2); // Filter by address_type 2
|
||||||
|
$builder->groupBy('subscription.sub_id');
|
||||||
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
$builder->orderBy('customers.customer_id', 'ASC'); // Order by customer_id to group by customers
|
||||||
|
|
||||||
$query = $builder->get();
|
$query = $builder->get();
|
||||||
|
// print_r($this->db->getLastQuery());die;
|
||||||
$customerDetails = [];
|
$customerDetails = [];
|
||||||
|
|
||||||
if ($query->getNumRows() > 0) {
|
if ($query->getNumRows() > 0) {
|
||||||
|
|||||||
@ -51,12 +51,15 @@
|
|||||||
<div class="invoice">
|
<div class="invoice">
|
||||||
<div class="bill-details">
|
<div class="bill-details">
|
||||||
<?= $value->customer_name ?><br>
|
<?= $value->customer_name ?><br>
|
||||||
<?= $value->customer_bill_address." ," ?><br>
|
<?php if($value->customer_ship_address && ($value->saddr_id !== null || $value->saddr_id !== '')){ ?>
|
||||||
<?= $value->customer_bill_city ?> <?= $value->customer_bill_state ? $value->customer_bill_state : "" ?>
|
<?= $value->customer_ship_address ? $value->customer_ship_address." ," : "" ?><br>
|
||||||
<?= $value->customer_bill_postal_code ? " - ".$value->customer_bill_postal_code :""; ?>
|
<?= $value->customer_ship_city ? $value->customer_ship_city : "" ?> <?= $value->customer_ship_state ? $value->customer_bill_state : "" ?>
|
||||||
<?= $value->customer_bill_country." ." ?><br>
|
<?= $value->customer_ship_postal_code ? " - " . $value->customer_ship_postal_code : ""; ?>
|
||||||
<?= $value->mobile_no." ." ?>
|
<?= $value->customer_ship_country ? $value->customer_ship_country . "." : $value->scountry ?><br>
|
||||||
|
<?php }else if ($value->saddr_id === null || $value->saddr_id === '') {
|
||||||
|
echo $value->shipping_address ? '<p style="white-space: pre-line">'.$value->shipping_address.'</p>' : '';
|
||||||
|
} ?>
|
||||||
|
<?= $value->mobile_no ? $value->mobile_no." ." : "" ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
|||||||
@ -235,62 +235,65 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h4>Calculation</h4>
|
<h4>Calculation</h4>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="subtotal">Subtotal</label>
|
<label for="subtotal">Subtotal</label>
|
||||||
<input type="number" class="form-control" id="subtotal" name="sub_total" value="<?= isset($invoice_details['subtotal']) ? (float)$invoice_details['subtotal'] : 0 ?>" readonly>
|
<input type="number" class="form-control" id="subtotal" name="sub_total" readonly value="<?= isset($invoice_details['subtotal']) ? (float)$invoice_details['subtotal'] : 0 ?>">
|
||||||
</div>
|
|
||||||
<div class="form-group" style="display: none;">
|
|
||||||
<label for="invoicetax">Tax Amount</label>
|
|
||||||
<input type="hidden" class="form-control" id="invoicetax" name="invoice_tax" value="<?= isset($invoice_details['tax']) ? (float)$invoice_details['tax'] : 0 ?>" readonly>
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="discount">Discount</label>
|
|
||||||
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" value="<?= isset($invoice_details['discount']) ? (float)$invoice_details['discount'] : 0 ?>" min="0" step="0.01">
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-group" style="display: none;">
|
||||||
<?php
|
<label for="invoicetax">Tax Amount</label>
|
||||||
// Check if it's a subscription invoice
|
<input type="hidden" class="form-control" id="invoicetax" name="invoice_tax" readonly value="<?= isset($invoice_details['tax']) ? (float)$invoice_details['tax'] : 0 ?>">
|
||||||
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
|
|
||||||
|
|
||||||
// Conditionally set the "hidden" attribute for the fields
|
|
||||||
|
|
||||||
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
|
|
||||||
|
|
||||||
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
|
||||||
?>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<span style="<?= $shippingChargesStyle ?>">
|
|
||||||
<label for="shippingChargesLabel">Charge Name </label>
|
|
||||||
<input type="text" class="form-control" id="shippingChargesLabel" name="shippingChargesLabel" placeholder="Shipping Charges Label" value="<?= isset($invoice_details['shipping_label']) ? $invoice_details['shipping_label'] : 'Shipping Charge' ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?>>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<span style="<?= $shippingChargesStyle ?>">
|
|
||||||
<label for="shippingCharges">Charge Amount </label>
|
|
||||||
<input type="number" class="form-control" id="shippingCharges" name="shippingCharges" placeholder="Charges Amount" value="<?= isset($invoice_details['shipping_charge']) ? (float)$invoice_details['shipping_charge'] : 0 ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> step="0.01">
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="discount">Discount</label>
|
||||||
|
<input type="number" class="form-control" id="discount" name="discount" onchange="calculateGrandTotal(this.value)" value="<?= isset($invoice_details['discount']) ? $invoice_details['discount'] : 0 ?>" min="0">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
// Check if it's a subscription invoice
|
||||||
|
$isSubscriptionInvoice = ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details');
|
||||||
|
|
||||||
|
// Conditionally set the "hidden" attribute for the fields
|
||||||
|
|
||||||
|
$shippingChargesHidden = $isSubscriptionInvoice ? 'hidden' : '';
|
||||||
|
|
||||||
|
$shippingChargesStyle = $isSubscriptionInvoice ? 'display: none;' : '';
|
||||||
|
?>
|
||||||
|
<div class="form-row" <?= $shippingChargesHidden ?> >
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<span style="<?= $shippingChargesStyle ?>">
|
||||||
|
<label for="shippingChargesLabel">Charge Name </label>
|
||||||
|
<input type="text" class="form-control" id="shippingChargesLabel" name="shippingChargesLabel" placeholder="Shipping Charges Label" value="<?= isset($invoice_details['shipping_label']) ? $invoice_details['shipping_label'] : 'Shipping Charge' ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?>>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<span style="<?= $shippingChargesStyle ?>">
|
||||||
|
<label for="shippingCharges">Charge Amount </label>
|
||||||
|
<input type="number" class="form-control" id="shippingCharges" name="shippingCharges" placeholder="Charges Amount" value="<?= isset($invoice_details['shipping_charge']) ? $invoice_details['shipping_charge'] : 0 ?>" oninput="calculateOverallTotals()" <?= $shippingChargesHidden ?> min="0">
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="exacttotal">Total</label>
|
<label for="exacttotal">Total</label>
|
||||||
<input type="number" class="form-control" id="exacttotal" name="exact_total_amount" value="<?= isset($invoice_details['total_amount']) ? (float)$invoice_details['exact_total_amount'] : 0 ?>" readonly>
|
<input type="number" class="form-control" id="exacttotal" name="exact_total_amount" value="<?= isset($invoice_details['total_amount']) ? (float)$invoice_details['exact_total_amount'] : 0 ?>" readonly>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="grandtotal">Total (Round-off)</label>
|
<label for="grandtotal">Total (Round-off)</label>
|
||||||
<input type="number" class="form-control" id="grandtotal" name="grand_total" value="<?= isset($invoice_details['total_amount']) ? (int)$invoice_details['total_amount'] : 0 ?>" readonly>
|
<input type="number" class="form-control" id="grandtotal" name="grand_total" readonly value="<?= isset($invoice_details['total_amount']) ? (int)$invoice_details['total_amount'] : 0 ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="balanceAmount">Balance Amount</label>
|
<label for="balanceAmount">Balance Amount</label>
|
||||||
<input type="number" class="form-control" id="balanceAmount" name="balanceAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Draft') ? (isset($invoice_details['total_amount']) ? (float)$invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
<input type="number" class="form-control" id="balanceAmount" name="balanceAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Draft') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="paidAmount">Paid Amount</label>
|
<div class="form-group col-md-6">
|
||||||
<input type="number" class="form-control" id="paidAmount" name="paidAmount" value="<?= (isset($invoice_details['status']) && (float)$invoice_details['status'] === 'Approved') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
<label for="paidAmount">Paid Amount</label>
|
||||||
</div>
|
<input type="number" class="form-control" id="paidAmount" name="paidAmount" value="<?= (isset($invoice_details['status']) && $invoice_details['status'] === 'Approved') ? (isset($invoice_details['total_amount']) ? $invoice_details['total_amount'] : '') : '0' ?>" oninput="calculateOverallTotals()" readonly>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -308,31 +311,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : 'Draft' ?>">
|
<!-- Payment Modal -->
|
||||||
<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="modal fade" id="paymentModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true">
|
||||||
<div class="form-group text-right m-b-0">
|
|
||||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] == 'Approved') : ?>
|
|
||||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="cancel" value="Cancel" id="cancelButton">Cancel</button>
|
|
||||||
<?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="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') : ?>
|
|
||||||
<!-- Show the "Save as Approved" button only if the status is not "Approved" -->
|
|
||||||
<button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Payment Modal -->
|
|
||||||
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog" aria-labelledby="paymentModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog" role="document">
|
<div class="modal-dialog" role="document">
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
@ -366,8 +346,8 @@
|
|||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title" id="customerModalLabel">Add New Customer</h5>
|
<h5 class="modal-title" id="customerModalLabel">Add New Customer</h5>
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
<button type="button" class="close closeCustomerModal" data-dismiss="modal" aria-label="Close">
|
||||||
<!-- <span aria-hidden="true">×</span> -->
|
<span aria-hidden="true">×</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
@ -377,7 +357,7 @@
|
|||||||
<input type="text" class="form-control" id="cus_first_name" placeholder="First Name" />
|
<input type="text" class="form-control" id="cus_first_name" placeholder="First Name" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="cus_last_name" class="col-form-label">Last Name<span class="text-danger"> *</span></label>
|
<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" />
|
<input type="text" class="form-control" id="cus_last_name" placeholder="Last name" />
|
||||||
</div>
|
</div>
|
||||||
<!-- <div class="form-group col-md-4">
|
<!-- <div class="form-group col-md-4">
|
||||||
@ -392,7 +372,7 @@
|
|||||||
<span id="emailValidationMessage"></span>
|
<span id="emailValidationMessage"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="cus_mobile_no" class="col-form-label">Mobile<span class="text-danger"> *</span></label>
|
<label for="cus_mobile_no" class="col-form-label">Mobile</label>
|
||||||
<div class="input-group mb-2">
|
<div class="input-group mb-2">
|
||||||
<div class="input-group-prepend">
|
<div class="input-group-prepend">
|
||||||
<div class="input-group-text">+91</div>
|
<div class="input-group-text">+91</div>
|
||||||
@ -402,9 +382,6 @@
|
|||||||
</div>
|
</div>
|
||||||
<span id="mobileValidationMessage"></span>
|
<span id="mobileValidationMessage"></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<!-- Address 1 -->
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="baddress1" class="col-form-label">Billing Address 1</label>
|
<label for="baddress1" class="col-form-label">Billing Address 1</label>
|
||||||
<input type="text" class="form-control" id="baddress1" name="baddress1" placeholder="Address (eg : 1234 Main St)" />
|
<input type="text" class="form-control" id="baddress1" name="baddress1" placeholder="Address (eg : 1234 Main St)" />
|
||||||
@ -413,186 +390,215 @@
|
|||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="baddress2" class="col-form-label">Billing Address 2</label>
|
<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)" />
|
<input type="text" class="form-control" id="baddress2" name="baddress2" placeholder="Address (eg : 1234 Main St)" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<!-- Country -->
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="bcountry" class="col-form-label">Country</label>
|
<label for="bcountry" class="col-form-label">Country</label>
|
||||||
<input type="text" class="form-control" id="bcountry" name="bcountry" placeholder="Country" />
|
<input type="text" class="form-control" id="bcountry" name="bcountry" placeholder="Country" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- State -->
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="bstate" class="col-form-label">State</label>
|
<label for="bstate" class="col-form-label">State</label>
|
||||||
<input type="text" class="form-control" id="bstate" name="bstate" placeholder="State" />
|
<input type="text" class="form-control" id="bstate" name="bstate" placeholder="State" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<!-- City -->
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="bcity" class="col-form-label">City</label>
|
<label for="sstate" class="col-form-label">City</label>
|
||||||
<input type="text" class="form-control" id="bcity" name="bcity" placeholder="City" />
|
<input type="text" class="form-control" id="bcity" name="bcity" placeholder="City" />
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Pincode -->
|
|
||||||
<div class="form-group col-md-6">
|
<div class="form-group col-md-6">
|
||||||
<label for="bpincode" class="col-form-label">Pincode</label>
|
<label for="bpincode" class="col-form-label">Pincode</label>
|
||||||
<input type="text" class="form-control" id="bpincode" name="bpincode" minlength="6" maxlength="6" placeholder="Pincode" />
|
<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>
|
|
||||||
<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="form-row">
|
|
||||||
<!-- Shipping Address 1 -->
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="saddress1" class="col-form-label">Shipping Address 1</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>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<!-- Country -->
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="scountry" class="col-form-label">Country</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>
|
|
||||||
<div class="form-row">
|
|
||||||
<!-- City -->
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="scity" class="col-form-label">City</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</label>
|
|
||||||
<input type="text" class="form-control" id="spincode" name="spincode" minlength="6" maxlength="6" placeholder="Pincode" />
|
|
||||||
</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>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Reason for Void Modal -->
|
|
||||||
<div class="modal fade" id="voidReasonModal" tabindex="-1" role="dialog" aria-labelledby="voidReasonModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog" role="document">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="voidReasonModalLabel">Reason for Void</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<textarea class="form-control" id="voidReason" rows="3" placeholder="Enter reason for voiding..." required></textarea>
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
||||||
<button type="button" class="btn btn-primary" id="submitVoidReason">Submit</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- </div>
|
|
||||||
</div> -->
|
|
||||||
|
|
||||||
<!-- Reason for Cancel Modal -->
|
|
||||||
<div class="modal fade" id="cancelReasonModal" tabindex="-1" role="dialog" aria-labelledby="voidReasonModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog" role="document">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="cancelReasonModalLabel">Reason for Cancel</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<textarea class="form-control" id="cancelReason" rows="3" placeholder="Enter reason for cancel..."></textarea>
|
|
||||||
<!-- <input type="hidden" id="invoiceId" name="invoiceId"> -->
|
|
||||||
</div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
||||||
<button type="button" class="btn btn-primary" id="submitCancelReason">Submit</button>
|
|
||||||
</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">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="addBookModalLabel">Add Book</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<form id="addBookForm">
|
|
||||||
<div class="modal-body">
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="bookName">Book Name<span class="text-danger"> *</span></label>
|
|
||||||
<input type="text" class="form-control" id="bookName" name="bookName" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="bookPrice">Price<span class="text-danger"> *</span></label>
|
|
||||||
<input type="number" class="form-control" id="bookPrice" name="bookPrice" required min="1">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row">
|
||||||
<div class="form-group col-md-6">
|
<!-- Checkbox for Copy -->
|
||||||
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"> *</span></label>
|
<div class="form-group col-md-12 text-right checkbox checkbox-purple">
|
||||||
<input type="date" class="form-control" id="publication_date" name="publication_date" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required placeholder="Publication Date">
|
<input type="checkbox" id="addressCopiedAsShipping" />
|
||||||
<div class="invalid-feedback"> Please provide. </div>
|
<label for="addressCopiedAsShipping"> Is the above address same as the shipping address?</label>
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="isbn_code" class="col-form-label">ISBN Code</label>
|
|
||||||
<input type="text" class="form-control" id="isbn_code" name="isbn_code" placeholder="ISBN Code" />
|
|
||||||
<div class="invalid-feedback"> Please provide. </div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="publisher" class="col-form-label">Publisher Name</label>
|
|
||||||
<input type="text" class="form-control" id="publisher" name="publisher" placeholder="Publisher Name" value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" />
|
|
||||||
<div class="invalid-feedback"> Please provide. </div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="publishers_code" class="col-form-label">Publisher Code<span class="text-danger"> *</span></label>
|
|
||||||
<input type="text" class="form-control" id="publishers_code" name="publishers_code" placeholder="Publisher Code" required />
|
|
||||||
</div>
|
</div>
|
||||||
</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</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</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</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</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 class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Add Book</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</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">
|
||||||
|
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] == 'Approved') : ?>
|
||||||
|
<button type="button" class="btn btn-primary waves-effect mr-1" name="cancel" value="Cancel" id="cancelButton">Cancel</button>
|
||||||
|
<?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="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') : ?>
|
||||||
|
<!-- Show the "Save as Approved" button only if the status is not "Approved" -->
|
||||||
|
<button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Reason for Void Modal -->
|
||||||
|
<div class="modal fade" id="voidReasonModal" tabindex="-1" role="dialog" aria-labelledby="voidReasonModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="voidReasonModalLabel">Reason for Void</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<textarea class="form-control" id="voidReason" rows="3" placeholder="Enter reason for voiding..." required></textarea>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="submitVoidReason">Submit</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- </div>
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Reason for Cancel Modal -->
|
||||||
|
<div class="modal fade" id="cancelReasonModal" tabindex="-1" role="dialog" aria-labelledby="voidReasonModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="cancelReasonModalLabel">Reason for Cancel</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<textarea class="form-control" id="cancelReason" rows="3" placeholder="Enter reason for cancel..."></textarea>
|
||||||
|
<!-- <input type="hidden" id="invoiceId" name="invoiceId"> -->
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button type="button" class="btn btn-primary" id="submitCancelReason">Submit</button>
|
||||||
|
</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">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="addBookModalLabel">Add Book</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form id="addBookForm">
|
||||||
|
<div class="modal-body">
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="bookName">Book Name<span class="text-danger"> *</span></label>
|
||||||
|
<input type="text" class="form-control" id="bookName" name="bookName" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="bookPrice">Price<span class="text-danger"> *</span></label>
|
||||||
|
<input type="number" class="form-control" id="bookPrice" name="bookPrice" required min="0">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="publication_date" class="col-form-label">Publication Date<span class="text-danger"> *</span></label>
|
||||||
|
<input type="date" class="form-control" id="publication_date" name="publication_date" value="<?= isset($details['publication_date']) ? $details['publication_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required placeholder="Publication Date">
|
||||||
|
<div class="invalid-feedback"> Please provide. </div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="isbn_code" class="col-form-label">ISBN Code</label>
|
||||||
|
<input type="text" class="form-control" id="isbn_code" name="isbn_code" placeholder="ISBN Code" />
|
||||||
|
<div class="invalid-feedback"> Please provide. </div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="publisher" class="col-form-label">Publisher Name</label>
|
||||||
|
<input type="text" class="form-control" id="publisher" name="publisher" placeholder="Publisher Name" value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" />
|
||||||
|
<div class="invalid-feedback"> Please provide. </div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="publishers_code" class="col-form-label">Publisher Code<span class="text-danger"> *</span></label>
|
||||||
|
<input type="text" class="form-control" id="publishers_code" name="publishers_code" placeholder="Publisher Code" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
<button type="submit" class="btn btn-primary">Add Book</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -757,7 +763,6 @@
|
|||||||
var totalElement = Math.round(total);
|
var totalElement = Math.round(total);
|
||||||
$("#exacttotal").val(parseFloat(total.toFixed(2)));
|
$("#exacttotal").val(parseFloat(total.toFixed(2)));
|
||||||
$("#grandtotal").val(totalElement);
|
$("#grandtotal").val(totalElement);
|
||||||
|
|
||||||
var status = document.getElementById('status').value;
|
var status = document.getElementById('status').value;
|
||||||
|
|
||||||
// $("#balanceAmount").val(totalElement);
|
// $("#balanceAmount").val(totalElement);
|
||||||
@ -814,8 +819,6 @@
|
|||||||
var grandTotalElement = parseFloat(grandTotal.toFixed(2));
|
var grandTotalElement = parseFloat(grandTotal.toFixed(2));
|
||||||
document.getElementById("exacttotal").value = grandTotalElement;
|
document.getElementById("exacttotal").value = grandTotalElement;
|
||||||
document.getElementById("grandtotal").value = Math.round(grandTotalElement);
|
document.getElementById("grandtotal").value = Math.round(grandTotalElement);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -929,7 +932,7 @@
|
|||||||
|
|
||||||
if (cust_id == '0') {
|
if (cust_id == '0') {
|
||||||
$('#customerModal').modal('show');
|
$('#customerModal').modal('show');
|
||||||
} else {
|
}else if(cust_id != ''){
|
||||||
$('#editAddressesCheckbox').prop('checked', false);
|
$('#editAddressesCheckbox').prop('checked', false);
|
||||||
$("#storeBillingAddress").prop("readonly", false);
|
$("#storeBillingAddress").prop("readonly", false);
|
||||||
$("#storeShippingAddress").prop("readonly", false);
|
$("#storeShippingAddress").prop("readonly", false);
|
||||||
@ -938,6 +941,11 @@
|
|||||||
$('#cus_first_name').val("");
|
$('#cus_first_name').val("");
|
||||||
$('#cus_last_name').val("");
|
$('#cus_last_name').val("");
|
||||||
$('#cus_email').val("");
|
$('#cus_email').val("");
|
||||||
|
$('#baddress1').val("");$('#baddress2').val("");$('#bcountry').val("");$('#bstate').val("");$('#bcity').val("");$('#bzip').val("");
|
||||||
|
$('#saddress1').val("");$('#saddress2').val("");$('#scountry').val("");$('#sstate').val("");$('#scity').val("");$('#szip').val("");
|
||||||
|
$("#emailValidationMessage").text("");
|
||||||
|
$("#mobileValidationMessage").text("");
|
||||||
|
$('#addressCopiedAsShipping').prop('checked', false);
|
||||||
$('.save-invoice-customer').prop('disabled', false);
|
$('.save-invoice-customer').prop('disabled', false);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
@ -1031,6 +1039,7 @@
|
|||||||
|
|
||||||
// membership ajax call
|
// membership ajax call
|
||||||
function get_customer_membership_details(cust_id) {
|
function get_customer_membership_details(cust_id) {
|
||||||
|
if (parseInt(cust_id) > 0) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?= base_url() . 'get_customer_membership_details' ?>",
|
url: "<?= base_url() . 'get_customer_membership_details' ?>",
|
||||||
@ -1056,6 +1065,7 @@
|
|||||||
alert("Error fetching address.");
|
alert("Error fetching address.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<!-- bill_addr = "<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>"; -->
|
<!-- bill_addr = "<?= isset($invoice_details['billing_address']) ? $invoice_details['billing_address'] : ""; ?>"; -->
|
||||||
@ -1260,51 +1270,55 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
</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");
|
||||||
|
|
||||||
function saveInvoiceCustomer() {
|
var baddress1 = document.getElementById("baddress1");
|
||||||
var cus_first_name = document.getElementById("cus_first_name").value;
|
var baddress2 = document.getElementById("baddress2");
|
||||||
var cus_last_name = document.getElementById("cus_last_name").value;
|
var bcountry = document.getElementById("bcountry");
|
||||||
var cus_email = document.getElementById("cus_email").value;
|
var bstate = document.getElementById("bstate");
|
||||||
var cus_mobile_no = document.getElementById("cus_mobile_no").value;
|
var bcity = document.getElementById("bcity");
|
||||||
|
var bzip = document.getElementById("bpincode");
|
||||||
|
|
||||||
var baddress1 = document.getElementById("baddress1").value;
|
var saddress1 = document.getElementById("saddress1");
|
||||||
var baddress2 = document.getElementById("baddress2").value;
|
var saddress2 = document.getElementById("saddress2");
|
||||||
var bcountry = document.getElementById("bcountry").value;
|
var scountry = document.getElementById("scountry");
|
||||||
var bstate = document.getElementById("bstate").value;
|
var sstate = document.getElementById("sstate");
|
||||||
var bcity = document.getElementById("bcity").value;
|
var scity = document.getElementById("scity");
|
||||||
var bzip = document.getElementById("bpincode").value;
|
var szip = document.getElementById("spincode");
|
||||||
|
$("#storeBillingAddress").val("");
|
||||||
var saddress1 = document.getElementById("saddress1").value;
|
$("#storeShippingAddress").val("");
|
||||||
var saddress2 = document.getElementById("saddress2").value;
|
if (!cus_first_name.value) {
|
||||||
var scountry = document.getElementById("scountry").value;
|
// alert("Please fill in all required fields.");
|
||||||
var sstate = document.getElementById("sstate").value;
|
alert("Please fill the Name.");
|
||||||
var scity = document.getElementById("scity").value;
|
|
||||||
var szip = document.getElementById("spincode").value;
|
|
||||||
if (!cus_first_name || !cus_last_name || !cus_mobile_no) {
|
|
||||||
alert("Please fill in all required fields.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$('.save-invoice-customer').prop('disabled', true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "<?= base_url() . 'save_invoice_customer' ?>",
|
url: "<?= base_url() . 'save_invoice_customer' ?>",
|
||||||
data: {
|
data: {
|
||||||
cus_first_name: cus_first_name,
|
cus_first_name: cus_first_name.value,
|
||||||
cus_last_name: cus_last_name,
|
cus_last_name: cus_last_name.value,
|
||||||
cus_email: cus_email,
|
cus_email: cus_email.value,
|
||||||
cus_mobile_no: cus_mobile_no,
|
cus_mobile_no: cus_mobile_no.value,
|
||||||
baddress1: baddress1,
|
baddress1: baddress1.value,
|
||||||
baddress2: baddress2,
|
baddress2: baddress2.value,
|
||||||
bcountry: bcountry,
|
bcountry: bcountry.value,
|
||||||
bstate: bstate,
|
bstate: bstate.value,
|
||||||
bcity: bcity,
|
bcity: bcity.value,
|
||||||
bzip: bzip,
|
bzip: bzip.value,
|
||||||
saddress1: saddress1,
|
saddress1: saddress1.value,
|
||||||
saddress2: saddress2,
|
saddress2: saddress2.value,
|
||||||
scountry: scountry,
|
scountry: scountry.value,
|
||||||
sstate: sstate,
|
sstate: sstate.value,
|
||||||
scity: scity,
|
scity: scity.value,
|
||||||
szip: szip
|
szip: szip.value
|
||||||
},
|
},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
if (response['data']['status']) {
|
if (response['data']['status']) {
|
||||||
@ -1312,9 +1326,47 @@
|
|||||||
alert(response['data']['message']);
|
alert(response['data']['message']);
|
||||||
|
|
||||||
// Append the customer's name to the dropdown
|
// Append the customer's name to the dropdown
|
||||||
var customerName = response['data']['customer_name'];
|
var customerName = response['data']['cus_name'];
|
||||||
var customerId = response['data']['cus_id'];
|
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", true);
|
||||||
|
$("#storeBillingAddress").val("").prop("readonly", false);
|
||||||
|
$('#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);
|
||||||
|
$('#loadShippingDropdown').empty().append($('<option>', {value: "",text: "Select an address"}));
|
||||||
|
}
|
||||||
// Create a new option element
|
// Create a new option element
|
||||||
var newOption = $('<option>', {
|
var newOption = $('<option>', {
|
||||||
value: customerId,
|
value: customerId,
|
||||||
@ -1324,9 +1376,17 @@
|
|||||||
|
|
||||||
// Append the new option to the dropdown
|
// Append the new option to the dropdown
|
||||||
$('#customerName').append(newOption);
|
$('#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
|
// Reload the page and select the last appended value
|
||||||
location.reload();
|
// location.reload();
|
||||||
} else {
|
} else {
|
||||||
// Handle error response
|
// Handle error response
|
||||||
alert(response['data']['message']);
|
alert(response['data']['message']);
|
||||||
@ -1338,11 +1398,10 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$('.closeCustomerModal').click(function() {
|
||||||
|
|
||||||
$('#closeCustomerModal').click(function() {
|
|
||||||
// Reset customer dropdown value
|
// Reset customer dropdown value
|
||||||
$('#customerName').val("").trigger('change');
|
$('#customerName').val("").trigger('change');
|
||||||
// Optionally, reset input fields
|
// Optionally, reset input fields
|
||||||
@ -1350,6 +1409,22 @@
|
|||||||
$('#cus_last_name').val("");
|
$('#cus_last_name').val("");
|
||||||
$('#cus_email').val("");
|
$('#cus_email').val("");
|
||||||
$('#cus_mobile_no').val("");
|
$('#cus_mobile_no').val("");
|
||||||
|
$('#baddress1').val("");
|
||||||
|
$('#baddress2').val("");
|
||||||
|
$('#bcountry').val("");
|
||||||
|
$('#bstate').val("");
|
||||||
|
$('#bcity').val("");
|
||||||
|
$('#bzip').val("");
|
||||||
|
$('#saddress1').val("");
|
||||||
|
$('#saddress2').val("");
|
||||||
|
$('#scountry').val("");
|
||||||
|
$('#sstate').val("");
|
||||||
|
$('#scity').val("");
|
||||||
|
$('#szip').val("");
|
||||||
|
$("#emailValidationMessage").text("");
|
||||||
|
$("#mobileValidationMessage").text("");
|
||||||
|
$('#editAddressesCheckbox').prop('checked', false);
|
||||||
|
$("#addressCopiedAsShipping").prop("checked", false);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script>
|
<script>
|
||||||
@ -1419,8 +1494,7 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Handle clicking on the "Void" button
|
// Handle clicking on the "Void" button
|
||||||
$('#voidButton').click(function() {
|
$('#voidButton').click(function() {
|
||||||
var invoiceId = <?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>;
|
var invoiceId = <?= json_encode(isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '') ?>; $('#voidReasonModal').modal('show');
|
||||||
$('#voidReasonModal').modal('show');
|
|
||||||
$('#submitVoidReason').data('invoiceId', invoiceId); // Set the invoice_id in the modal
|
$('#submitVoidReason').data('invoiceId', invoiceId); // Set the invoice_id in the modal
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1467,7 +1541,7 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
// Handle clicking on the "Cancel" button
|
// Handle clicking on the "Cancel" button
|
||||||
$('#cancelButton').click(function() {
|
$('#cancelButton').click(function() {
|
||||||
var invoiceIds = <?= isset($invoice_details['invoice_id']) ? json_encode($invoice_details['invoice_id']) : '' ?>; // Get the invoice_id(s)
|
var invoiceIds = <?= json_encode(isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '') ?>;
|
||||||
$('#cancelReasonModal').modal('show');
|
$('#cancelReasonModal').modal('show');
|
||||||
$('#cancelReasonModal').find('#cancelReason').data('invoiceIds', invoiceIds); // Set the invoice_id(s) in the modal
|
$('#cancelReasonModal').find('#cancelReason').data('invoiceIds', invoiceIds); // Set the invoice_id(s) in the modal
|
||||||
});
|
});
|
||||||
@ -1554,33 +1628,33 @@
|
|||||||
console.log('Save as Approved button clicked');
|
console.log('Save as Approved button clicked');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$("#addressCopiedAsShipping").on("change", function() {
|
$("#addressCopiedAsShipping").on("change", function() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($(this).is(":checked")) {
|
if ($(this).is(":checked")) {
|
||||||
var customerAddress1 = $("#baddress1").val();
|
var customerAddress1 = $("#baddress1").val();
|
||||||
var customerAddress2 = $("#baddress2").val();
|
var customerAddress2 = $("#baddress2").val();
|
||||||
var customerCountry = $("#bcountry").val();
|
var customerCountry = $("#bcountry").val();
|
||||||
var customerState = $("#bstate").val();
|
var customerState = $("#bstate").val();
|
||||||
var customerCity = $("#bcity").val();
|
var customerCity = $("#bcity").val();
|
||||||
var customerPostalCode = $("#bpincode").val();
|
var customerPostalCode = $("#bpincode").val();
|
||||||
|
|
||||||
$("#saddress1").val(customerAddress1).prop("readonly", false);
|
$("#saddress1").val(customerAddress1).prop("readonly", false);
|
||||||
$("#saddress2").val(customerAddress2).prop("readonly", false);
|
$("#saddress2").val(customerAddress2).prop("readonly", false);
|
||||||
$("#scountry").val(customerCountry).prop("readonly", false);
|
$("#scountry").val(customerCountry).prop("readonly", false);
|
||||||
$("#sstate").val(customerState).prop("readonly", false);
|
$("#sstate").val(customerState).prop("readonly", false);
|
||||||
$("#scity").val(customerCity).prop("readonly", false);
|
$("#scity").val(customerCity).prop("readonly", false);
|
||||||
$("#spincode").val(customerPostalCode).prop("readonly", false);
|
$("#spincode").val(customerPostalCode).prop("readonly", false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Clear the billing address fields when the checkbox is unchecked
|
// Clear the billing address fields when the checkbox is unchecked
|
||||||
$("#saddress1").val("").prop("readonly", false);
|
$("#saddress1").val("").prop("readonly", false);
|
||||||
$("#saddress2").val("").prop("readonly", false);
|
$("#saddress2").val("").prop("readonly", false);
|
||||||
$("#scountry").val("").prop("readonly", false);
|
$("#scountry").val("").prop("readonly", false);
|
||||||
$("#sstate").val("").prop("readonly", false);
|
$("#sstate").val("").prop("readonly", false);
|
||||||
$("#scity").val("").prop("readonly", false);
|
$("#scity").val("").prop("readonly", false);
|
||||||
$("#spincode").val("").prop("readonly", false);
|
$("#spincode").val("").prop("readonly", false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@ -219,28 +219,30 @@
|
|||||||
<td class="billing-address">
|
<td class="billing-address">
|
||||||
<?php foreach ($data as $value) : ?>
|
<?php foreach ($data as $value) : ?>
|
||||||
<?= $value->customer_name ?><br>
|
<?= $value->customer_name ?><br>
|
||||||
<?php if($value->customer_bill_address){ ?>
|
<?php if($value->customer_bill_address && ($value->baddr_id !== null || $value->baddr_id !== '')){ ?>
|
||||||
<?= $value->customer_bill_address ? $value->customer_bill_address." ," : ""?><br>
|
<?= $value->customer_bill_address ? $value->customer_bill_address." ," : ""?><br>
|
||||||
<?= $value->customer_bill_city ? $value->customer_bill_city : "" ?> <?= $value->customer_bill_state ? $value->customer_bill_state : "" ?>
|
<?= $value->customer_bill_city ? $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_postal_code ? " - " . $value->customer_bill_postal_code : ""; ?>
|
||||||
<?= $value->customer_bill_country ? $value->customer_bill_country . "." : $value->bcountry ?><br>
|
<?= $value->customer_bill_country ? $value->customer_bill_country . "." : $value->bcountry ?><br>
|
||||||
<?= $value->mobile_no ? $value->mobile_no." ." : "" ?>
|
<?php }else if ($value->baddr_id === null || $value->baddr_id === '') {
|
||||||
<?php }else{
|
|
||||||
echo $value->billing_address ? '<p style="white-space: pre-line">'.$value->billing_address.'</p>' : '';
|
echo $value->billing_address ? '<p style="white-space: pre-line">'.$value->billing_address.'</p>' : '';
|
||||||
echo $value->mobile_no ? $value->mobile_no." ." : ""; } endforeach; ?>
|
} ?>
|
||||||
|
<?= $value->mobile_no ? $value->mobile_no." ." : "" ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="shipping-address">
|
<td class="shipping-address">
|
||||||
<?php foreach ($data as $value) : ?>
|
<?php foreach ($data as $value) : ?>
|
||||||
<?= $value->customer_name ?><br>
|
<?= $value->customer_name ?><br>
|
||||||
<?php if($value->customer_ship_address){ ?>
|
<?php if($value->customer_ship_address && ($value->saddr_id !== null || $value->saddr_id !== '')){ ?>
|
||||||
<?= $value->customer_ship_address ? $value->customer_ship_address." ," : "" ?><br>
|
<?= $value->customer_ship_address ? $value->customer_ship_address." ," : "" ?><br>
|
||||||
<?= $value->customer_ship_city ? $value->customer_ship_city : "" ?> <?= $value->customer_ship_state ? $value->customer_bill_state : "" ?>
|
<?= $value->customer_ship_city ? $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_postal_code ? " - " . $value->customer_ship_postal_code : ""; ?>
|
||||||
<?= $value->customer_ship_country ? $value->customer_ship_country . "." : $value->scountry ?><br>
|
<?= $value->customer_ship_country ? $value->customer_ship_country . "." : $value->scountry ?><br>
|
||||||
<?= $value->mobile_no ? $value->mobile_no." ." : "" ?>
|
<?php }else if ($value->saddr_id === null || $value->saddr_id === '') {
|
||||||
<?php }else{
|
|
||||||
echo $value->shipping_address ? '<p style="white-space: pre-line">'.$value->shipping_address.'</p>' : '';
|
echo $value->shipping_address ? '<p style="white-space: pre-line">'.$value->shipping_address.'</p>' : '';
|
||||||
echo $value->mobile_no ? $value->mobile_no." ." : ""; } endforeach; ?>
|
} ?>
|
||||||
|
<?= $value->mobile_no ? $value->mobile_no." ." : "" ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user