Issue fixes (email,invoice cust-subscribe) : ps

This commit is contained in:
VE10-Sanjeev 2023-12-18 17:48:41 +05:30
parent 7921bdf005
commit bc29e10d7f
15 changed files with 212 additions and 153 deletions

View File

@ -28,17 +28,17 @@ class Email extends BaseConfig
/**
* SMTP Server Address
*/
public string $SMTPHost = 'smtp.sendgrid.net';
public string $SMTPHost = 'smtp.zoho.in';
/**
* SMTP Username
*/
public string $SMTPUser = 'apikey';
public string $SMTPUser = 'web@vijayabharathambooks.com';
/**
* SMTP Password
*/
public string $SMTPPass = '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';
public string $SMTPPass = 'Sz9VueQ2iLgH';
/**
* SMTP Port
@ -59,7 +59,7 @@ class Email extends BaseConfig
* SMTP Encryption. Either tls or ssl
*/
public string $SMTPCrypto = 'tls';
/**
* Enable word-wrap
*/

View File

@ -18,7 +18,7 @@ class ApiIntegration extends ResourceController
public function __construct()
{
$this->global_variable_business_id = 1;
$this->global_variable_business_id = 2;
$this->global_variable_role = "Online";
$api_model = new ApiIntegrationModel();
$table = 'users';

View File

@ -46,7 +46,7 @@ class Customer extends BaseController
$data['customer'] = [];
$data['customer_billing'] = [];
$data['customer_shipping'] = [];
$data['subscriptionData'] = [];
$data['subscriptions'] = [];
$data['invoices'] = [];
} else if ($id !== '0') {
// Edit Customer
@ -63,7 +63,7 @@ class Customer extends BaseController
// Retrieve subscriber data based on the customer ID
$subscriberData = $customerModel->getSubscriberDataByCustomerId($id);
$data['subscriptionData'] = $subscriberData;
$data['subscriptions'] = $subscriberData;
// Fetch invoice data for the customer
$CustomerModel = new CustomerModel();
$invoices = $CustomerModel->getInvoicesByCustomerId($id);

View File

@ -48,7 +48,7 @@ class Invoice extends BaseController
$data['customers'] = $model->getData('customers', $where);
$data['events'] = $model->getData('events', $where);
$data['invoice_number_formatting'] = $model->getData('invoice_number_formatting', $where);
$data['books'] = $model->getNonMembershipCategoryBooks('books', $where);
$data['books'] = $model->getCategoryBooks(1); // Invocie type = 2 (invoice)
if ($id === '0') {
$this->logger->info("Book Invoice: In Add Details");
@ -79,7 +79,7 @@ class Invoice extends BaseController
// Get customer names for the dropdown, events details, and subscription books details
$data['customers'] = $model->getData('customers', $where);
$data['events'] = $model->getData('events', $where);
$data['books'] = $model->getCategoryBooks('books', $where);
$data['books'] = $model->getCategoryBooks(2); // Invocie type = 2 (subscription)
$data['invoice_number_formatting'] = $model->getData('invoice_number_formatting', $where);
if ($id === '0') {
$this->logger->info("Subscription Invoice: In Add Page");
@ -159,15 +159,13 @@ class Invoice extends BaseController
## Declarions
helper('session');
$model = new InvoiceModel();
// Array ( [customer_name] => 1 [shipping_address] => 2 [event_next_id] => 134 [event_id] => 1 [invoice_number] => NBF2023-INV-00133 [order_number] => 12 [invoice_date] => 2023-09-07 [due_date] => 2023-09-07 [item_details] => Array ( [0] => 1 ) [quantity] => Array ( [0] => 2 [1] => 2 ) [rate] => Array ( [0] => 3 [1] => 3 ) [tax] => [amount] => Array ( [0] => 5 [1] => 5 ) [itemDetails] => Array ( [0] => 1 ) [subtotal] => [discount] => 9 [total] => [terms] => i don't like... )
$duedate = $this->request->getVar('due_date');
$invdate = $this->request->getVar('invoice_date');
$invoice_status = $this->request->getPost('status');
// echo 'Hi';
// echo($this->request->getPost('invoice_number'));die();
$invoice_id = (!empty($this->request->getPost('invoice_id'))) ? $this->request->getPost('invoice_id') : "";
$customer_id = (int)$this->request->getPost('customer_name');
$invoiceType = $this->request->getPost('invoice_type');
## Array Formation For Invoice Details..
$data = [
'invoice_number' => $this->request->getPost('invoice_number'),
@ -194,6 +192,7 @@ class Invoice extends BaseController
'status' => $invoice_status,
'isactive' => 1
];
## Based on the invoice ID, we designated Insert or Update on Details...
if (empty($invoice_id)) {
$data['created_by'] = (int)get_logged_user_id();
@ -223,51 +222,55 @@ class Invoice extends BaseController
$requestData = $this->request->getPost();
if($this->request->getPost('next_id')){
## Array Formation For Events Details And Updating Events also Here..
$update_events = [
## Array Formation For Invoice Numbering Format Details..
$update_invoice_numbering = [
'id' => 1,
'next_id' => (int)$this->request->getPost('next_id'),
'business_id' => (int)get_business_id(),
'updated_by' => get_logged_user_id()
];
$this->update_number_formatting($update_events);}
$this->update_number_formatting($update_invoice_numbering);}
## For Invoice Item Details Insert/Update..
$this->save_invoice_item($invoice_id, $requestData, (int)$this->request->getVar('product'));
$invoiceItems = $this->get_invoice_item($invoice_id);
if ($invoiceType === '2') {
// Extract necessary data
$customerId = (int)$this->request->getPost('customer_name');
$invoiceId = $invoice_id; // You have this value already
## Subscription..
if ((int)$invoiceType === 2) {
// Loop through invoice items and store them in the 'subscription' table
$subscriptionModel = new InvoiceModel(); // Replace with your actual model
$invoiceItems = $this->get_invoice_item($invoice_id);
foreach ($invoiceItems as $item) {
$productId = $item['product'];
$fromsub=$item['from_subscription'];
$tosub=$item['to_subscription'];
$product_id = $item['product'];
$from_sub_date = $item['from_subscription'];
$to_sub_date = $item['to_subscription'];
// Assuming 'product' is the field name in the invoice item table
// Create an array for subscription data
$subscriptionData = [
'customer_id' => $customerId,
'invoice_id' => $invoiceId,
'scheme_id' => $productId,
'from_subscription'=>$fromsub,
'to_subscription'=> $tosub,
$subscription_data = [
'customer_id' => (int)$customer_id,
'invoice_id' => $invoice_id,
'scheme_id' => $product_id,
'from_subscription'=>$from_sub_date,
'to_subscription'=> $to_sub_date,
'business_id' => get_business_id(),
'created_by' =>get_logged_user_id(),
// Add other subscription-specific data here
];
// Insert the subscription data into the 'subscription' table
$subscriptionModel->insertSubscriptionData($subscriptionData);
$subscription_where = ['scheme_id' => $product_id,'customer_id' => $customer_id,'invoice_id' => $invoice_id];
$subscription_details = $model->getData('subscription', $subscription_where);
if(count($subscription_details)==0){
$subscriptionModel->insertSubscriptionData($subscription_data);
}else{
unset($subscription_data['created_by']);
$subscription_data['updated_by'] =get_logged_user_id();
$subscription_where = ['sub_id' => (int)$subscription_details[0]->sub_id];
$subscriptionModel->updateData('subscription', $subscription_data, $subscription_where);
}
}
}
## Notification For Approve..
if ($invoice_status == 'Approved' && !$invoice_id) {
$this->approve_notifications((int)$invoice_id);

View File

@ -17,22 +17,42 @@ class Users extends BaseController
$session_bid = get_business_id();
if (!empty($session_role) && $session_role !== "sadmin") {
$this->logger->info("Users: Listing In admin role . BID = ".$session_bid);
$where = ['users.business_id' => (int)$session_bid, 'users.isactive' => 1];
} else {
$this->logger->info("Users: Listing In Super-admin role .");
$where = ['users.isactive !=' => NULL];
}
switch ($session_role) {
case "sadmin":
$this->logger->info("Users: Listing In Super-admin role .");
$where = ['users.isactive !=' => NULL];
break;
case "admin":
$this->logger->info("Users: Listing In ".$session_role." role . BID = ".$session_bid);
$where = ['users.business_id' => (int)$session_bid, 'users.isactive !=' => NULL,'LOWER(users.role) !='=>strtolower("online")];
break;
case "manager":
$this->logger->info("Users: Listing In ".$session_role." role . BID = ".$session_bid);
$where = ['users.business_id' => $session_bid, 'users.isactive' => 1,'LOWER(users.role) !='=>strtolower("online") ];
break;
default:
$data['page_name'] = 'Page Not Found';
$where = [];
$render_page_name = 'pages_404';
}
if(!empty($where)){
$model = new UsersModel();
$model->setTable('users');
$user_details = $model->select('users.*,business.title as company_name')->where($where)->join('business', 'business.business_id = users.business_id','left')->orderBy('user_id', 'DESC')->findAll();
$this->logger->info("Users: Listing Count .".count($user_details));
$data['page_name'] = 'User Details';
$data['details'] = $user_details;
$render_page_name = 'user_list';
}
$model = new UsersModel();
$model->setTable('users');
$user_details = $model->select('users.*,business.title as company_name')->where($where)->join('business', 'business.business_id = users.business_id','left')->orderBy('user_id', 'DESC')->findAll();
$this->logger->info("Users: Listing Count .".count($user_details));
$data['page_name'] = 'User Details';
$data['details'] = $user_details;
$data['session_role'] = $session_role;
$this->render_page('user_list', $data);
$this->render_page($render_page_name, $data);
}
## To Load User Add/Update page
@ -62,14 +82,14 @@ class Users extends BaseController
$data['page_name'] = 'Edit User';
break;
case "admin":
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
$where = ['users.user_id' => $id, 'users.isactive !=' => NULL,'users.business_id' => $session_bid];
$edit_user_details = $model->where($where)->first();
$business_details = [];
$render_page_name = 'user_form';
$data['page_name'] = 'Edit User';
break;
case "manager":
$where = ['users.user_id' => $id, 'users.isactive =' => 1];
$where = ['users.user_id' => $id, 'users.isactive' => 1 ,'users.business_id' => $session_bid];
$edit_user_details = $model->where($where)->first();
$business_details = [];
if($session_uid === $id && $session_role === "manager"){
@ -87,6 +107,7 @@ class Users extends BaseController
}
$data['details'] = $edit_user_details;
}
echo count($data['details']);die;
$data['business_details'] = $business_details;
$data['session_bid'] = $session_bid;
$data['session_role'] = $session_role;

View File

@ -18,17 +18,18 @@ class NotificationHelper
public function sendEmail($records)
{
$this->logger->info('Helper : Email Request Data type = '.gettype($records));
$cc = isset($records['carboncopy']) ? $records['carboncopy'] : '';
$cc = isset($records['carboncopy']) ? $records['carboncopy'] : 'contact@vijayabharathambooks.com';
$bcc = isset($records['blindcarboncopy']) ? $records['blindcarboncopy'] : '';
try {
$this->email->clear();
if($records['recipient_email'] == "" && $records['subject'] == ""){
throw new \Exception("Email and Subject are Must Please Try again..");
}
$this->email->setTo($records['recipient_email']);
$this->logger->info('Helper : Email recipient = '.$records['recipient_email']);
$this->email->setFrom('no-reply@tripapprovaltool.com', isset($records['company'])?$records['company']:"VBP");
$this->email->setFrom('web@vijayabharathambooks.com', isset($records['company'])?$records['company']:"VB");
$this->email->setSubject($records['subject']);
$this->logger->info('Helper : Email subject = '.$records['subject']);
$this->email->setMessage($records['description']);
@ -44,50 +45,53 @@ class NotificationHelper
// }
if (!empty($cc)) {
$ccRecipients = explode(',', $cc);
$this->logger->info('Helper : Email carboncopy CC recipient = '.$ccRecipients);
foreach ($ccRecipients as $ccRecipient) {
$this->email->setCC(trim($ccRecipient));
if ($cc !== '') {
$ccRecipients = explode(',', trim($cc));
$this->logger->info('Helper : Email carboncopy CC recipient = ' . implode(',', $ccRecipients));
if(!empty($ccRecipients)) {
$this->email->setCC($ccRecipients);
}
}
if (!empty($bcc)) {
$bccRecipients = explode(',', $bcc);
$this->logger->info('Helper : Email blindcarboncopy BCC recipient = '.$bccRecipients);
foreach ($bccRecipients as $bccRecipient) {
$this->email->setBCC(trim($bccRecipient));
if ($bcc !== '') {
$bccRecipients = explode(',', trim($bcc));
$this->logger->info('Helper : Email blindcarboncopy BCC recipient = ' . implode(',', $bccRecipients));
if(!empty($bccRecipients)) {
$this->email->setBCC($bccRecipients);
}
}
if ($this->email->send()) {
$message['success'] = 'Email sent successfully';
$this->logger->info('Helper : Email = sent successfully');
$this->logger->info('Helper : Email Status = sent successfully');
} else {
throw new \Exception('Email sending failed.');
}
} catch (\Exception $e) {
$this->logger->error('Helper : Email Error: ' . $e->getMessage());
$this->logger->error('Helper : Email Error = ' . $e->getMessage());
$message['error'] = 'Email Exception Occur : ' . $e->getMessage();
}
return $message;
}
public function sendWhatsAppMessage($url,$method,$data)
public function sendWhatsAppMessage($url, $method, $data)
{
try{
$this->logger->info('Helper : Whatsapp');
$curl = curl_init();
$final_result = ""; // Initialize outside try-catch block
try {
$this->logger->info('Helper : Whatsapp');
$curl = curl_init();
$headers = array('Content-Type:application/json');
$jsonencoded = json_encode($data);
curl_setopt( $curl,CURLOPT_URL, $url);
$this->logger->info('Helper : Whatsapp url = '.$url);
curl_setopt($curl, CURLOPT_URL, $url);
$this->logger->info('Helper : Whatsapp url = ' . $url);
switch ($method) {
case "POST":
curl_setopt( $curl,CURLOPT_POST, true );
curl_setopt($curl, CURLOPT_POST, true);
if ($data) {
$this->logger->info('Helper : Whatsapp jsonencoded = '.$jsonencoded);
curl_setopt( $curl,CURLOPT_POSTFIELDS, $jsonencoded);
$this->logger->info('Helper : Whatsapp jsonencoded = ' . $jsonencoded);
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonencoded);
}
break;
case "PUT":
@ -95,37 +99,46 @@ class NotificationHelper
break;
default:
if ($data) {
// print_r($data);die();
$url = sprintf("%s?%s", $url, http_build_query((array)$data));
}
}
curl_setopt( $curl,CURLOPT_HTTPHEADER, $headers );
curl_setopt( $curl,CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl,CURLOPT_SSL_VERIFYPEER, true );
$curl_exec = curl_exec($curl);
$this->logger->info('Helper : Whatsapp Reponse = '.$curl_exec);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true);
$curl_exec = curl_exec($curl);
$this->logger->info('Helper : Whatsapp Reponse = ' . $curl_exec);
$http_status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($http_status === 200) {
$result = json_decode($curl_exec);
if ($result->status === "error") {
$this->logger->error('Helper : Whatsapp Err occur = '.$result->message);
$this->logger->error('Helper : Whatsapp Err occur = ' . $result->message);
throw new \Exception($result->message);
}
if ($result->status === "success") {
$final_result = isset($result->message) ? ((strtolower(gettype($result->message)) === 'string') ? $result->message : "Sended Success") : " Message Not Sent. ";
$final_result = isset($result->message) ? (
(strtolower(gettype($result->message)) === 'string') ?
$result->message : "Sended Success"
) : " Message Not Sent. ";
}
}else{
$curl_errno= curl_errno($curl);
$this->logger->error('Helper : Whatsapp curl error occur = '.$curl_errno);
throw new \Exception(" Errno returned ".$curl_errno);
} else {
$curl_errno = curl_errno($curl);
$this->logger->error('Helper : Whatsapp curl error occur = ' . $curl_errno);
throw new \Exception(" Errno returned " . $curl_errno);
}
curl_close($curl);
}catch (\Exception $e) {
curl_close($curl);
} catch (\Exception $e) {
$this->logger->error('Helper : Whatsapp Exception Occur = ' . $e->getMessage());
$final_result = "Exception Errno returned ".$e->getMessage()." <br/>";
$final_result = "Exception Errno returned " . $e->getMessage() . " <br/>";
}
return $final_result;
}
}
?>

View File

@ -111,6 +111,7 @@ public function getSubscriberDataByCustomerId($customerId)
// Add a where condition to filter results based on customer ID.
$builder->where('subscription.customer_id', $customerId);
$builder->where('invoice.invoice_type = "2"'); // Default type is 2 (subscription).
$builder->groupBy('subscription.sub_id');
// Execute the query and return the result as an array of objects.
return $builder->get()->getResult();
}

View File

@ -51,7 +51,7 @@ class HomeModel extends Model
// $query = $this->db->table('category AS C')
// ->select('C.id,C.name,LEFT(C.name, 1) AS first_letter, COUNT(BC.category_id) AS count')
// ->join('book_categories AS BC', 'C.id = BC.category_id', 'left')
// ->where(['C.isactive'=>1,'C.business_id'=>1])
// ->where(['C.isactive'=>1,'C.business_id'=>2])
// ->groupBy('C.id');
// $results = $query->get()->getResultArray();
// return $results;
@ -66,8 +66,8 @@ class HomeModel extends Model
->join('book_categories AS BC', 'BC.book_id = S.scheme_id AND BC.isactive = 1', 'left')
->join('category AS CM', 'CM.id = BC.category_id AND C.isactive = 1', 'left')
->join('book_images AS BI', 'BI.book_id = S.scheme_id AND BI.isactive = 1', 'left')
->where('LOWER(CM.name)', strtolower("Membership"))
->where(['S.business_id' => 1,'BK.isactive' => 1])
// ->where('LOWER(CM.name)', strtolower("Membership"))
->where(['S.business_id' => 2,'BK.isactive' => 1])
->groupBy('S.scheme_id');
$results = $query->get()->getResultArray();
return $results;

View File

@ -199,29 +199,25 @@ public function updateData($table, $data, $where)
return $data;
}
public function getCategoryBooks()
{
return $this->db->table('books')
->join('book_categories', 'book_categories.book_id= books.book_id', 'left')
->join('category','category.id=book_categories.category_id')
->where('category.name', 'membership')
->get()
->getResult();
}
public function getNonMembershipCategoryBooks()
{
$data = $this->db->table('books')
->select('books.*')
->join('book_categories', 'book_categories.book_id= books.book_id', 'left')
->join('category','category.id=book_categories.category_id')
->where('category.name !=', 'membership')
->groupBy('books.book_id')
->get()
->getResult();
return $data;
public function getCategoryBooks($type)
{
$where = ($type == 1) ? ['LOWER(category.name) !=' => strtolower('Membership')] : ['LOWER(category.name)' => strtolower('Membership')];
$data = $this->db->table('books')
->select('books.book_id,books.business_id,books.wp_api_product_id,books.title,books.publication_date,books.publisher,books.author,books.genre,books.language,books.description,books.short_description,books.page_count,books.price,books.isbn_code,books.tax,books.sku,books.category,books.isactive')
->join('book_categories', 'book_categories.book_id= books.book_id', 'left')
->join('category','category.id=book_categories.category_id')
->where($where)
->groupBy('books.book_id')
->get()
->getResult();
// print_r($this->db->getLastQuery());die;
return $data;
}
}
public function insertSubscriptionData($data)
{
return $this->db->table('subscription')->insert($data);

View File

@ -21,7 +21,7 @@
<!-- Customer Details Tab -->
<div class="tab-pane fade show active" id="customerDetails" role="tabpanel" aria-labelledby="customerDetails-tab">
<!-- Customer details form fields -->
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm">
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?= base_url() . "insert_customer"; ?>" id="myForm" name="myForm" onsubmit="myFunction(event)">
<!-- <img src="<?= base_url() . "public/assets/images/plugins/loading.gif" ?>" alt="loader1" style="display:none; height:30px; width:auto;" id="loaderImg"> -->
<div class="form-row">
<div class="form-group col-md-4">
@ -258,7 +258,7 @@
<!-- Subscription Details Tab -->
<div class="tab-pane fade show " id="subscriptionDetails" role="tabpanel" aria-labelledby="subscriptionDetails-tab">
<?php if (!empty($subscriptionData)) : ?>
<?php if (!empty($subscriptions)) : ?>
<table class="table table-bordered">
<thead>
<tr>
@ -268,7 +268,7 @@
</tr>
</thead>
<tbody>
<?php foreach ($subscriptionData as $subscription) : ?>
<?php foreach ($subscriptions as $subscription) : ?>
<tr>
<td><?= $subscription->title ?></td>
<td><?= $subscription->formatted_from_subscription ?></td>
@ -512,14 +512,13 @@
<script>
document.getElementById('myForm').addEventListener('submit', function(event) {
var form = event.target;
if (form.checkValidity() === false) {
form.reportValidity(); // Display validation error messages
event.preventDefault(); // Prevent form submission if it's not valid
$('#submitBtn').prop('disabled', false);
} else {
alert("i am true");
$('#submitBtn').prop('disabled', true);
}
});

View File

@ -586,7 +586,16 @@ function restriction(event,temporary_flag) {
event.preventDefault(); // Prevent form submission if it's not valid
$('#save').prop('disabled', false);
} else {
$('#save').prop('disabled', true);
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
var counter = table.rows.length;
if(counter == 0){
event.preventDefault(); // Prevent form submission if it's not valid
alert('At least one row should contain a values.');
$('#save').prop('disabled', false);
}else{
$('#save').prop('disabled', true);
}
}
});
</script>

View File

@ -1,4 +1,4 @@
<?php if ($business_id == 1 && $loggedin_person_role !== 'manager') : ?>
<?php if ($business_id == 2 && $loggedin_person_role !== 'manager') : ?>
<!-- <div class="row">
<div class="col-xl-6">
<div class="card bg-info border-info">

View File

@ -106,7 +106,8 @@
<th>Tax</th>
<th>Amount </th>
<th style="text-align: center !important" colspan="2">Discount</th>
<th>Actions</th>
<th hidden></th>
<?php if ($invoice_type === '1') : ?> <th>Actions</th> <?php endif; ?>
</tr>
</thead>
<tbody>
@ -116,7 +117,8 @@
<tr>
<td><select class="form-control book-select" id="<?= "book" . $inx; ?>" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2" style="width: 249px !important;">
<option value="">Select a book</option>
<?php foreach ($books as $book) : ?>
<?php foreach ($books as $book) : ?>
<?php echo $book->book_id; ?>
<option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?>>
<?= $book->title ?></option>
<?php endforeach; ?>
@ -139,11 +141,13 @@
<option value="%" <?php if (isset($ii_details['discount_type']) && $ii_details['discount_type'] === '%') echo "selected"; ?>>
%</option>
</select>
</td>
<td><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'] : '' ?>" />
<center><i class="fa fa-trash remove-item "></i></center>
</td>
<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>
</td>
<?php endif; ?>
</tr>
<?php endforeach;
@ -170,12 +174,15 @@
<select class="form-control item-discount-type" id="<?= "discount_type0"; ?>" name="discount_type[]" oninput="calculateInvoice(this,0)">
<option value=""></option>
<option value="%">%</option>
</select>
</td>
<td><input type="hidden" class="form-control" id="hiddenInvoiceChildId0" name="invoice_child_id[]" value="" placeholder="hidden for invoice child/item id" />
<center><i class="fa fa-trash remove-item "></i></center>
</select>
</td>
<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>
</td>
<?php endif; ?>
</tr>
<?php } ?>
<!-- You can add more rows as needed using JavaScript -->
@ -808,15 +815,25 @@
$('#saveapproved').prop('disabled', false);
}
} else {
if (status == "Draft") {
$('#saveDraftButton').prop('disabled', true);
$('#saveApprovedButton').prop('disabled', true);
$('#saveapproved').prop('disabled', true);
}
if (status == "Approved") {
$('#saveDraftButton').prop('disabled', true);
$('#saveApprovedButton').prop('disabled', true);
$('#saveapproved').prop('disabled', true);
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
var counter = table.rows.length;
if(counter == 0){
event.preventDefault(); // Prevent form submission if it's not valid
alert('At least one row should contain a values.');
$('#saveDraftButton').prop('disabled', false);
$('#saveApprovedButton').prop('disabled', false);
$('#saveapproved').prop('disabled', false);
}else{
if (status == "Draft") {
$('#saveDraftButton').prop('disabled', true);
$('#saveApprovedButton').prop('disabled', true);
$('#saveapproved').prop('disabled', true);
}
if (status == "Approved") {
$('#saveDraftButton').prop('disabled', true);
$('#saveApprovedButton').prop('disabled', true);
$('#saveapproved').prop('disabled', true);
}
}
}
});

View File

@ -78,7 +78,7 @@
<td>
<!-- <a href="<?= base_url() . "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button" title="Approve the Invoice"><i class="ri-checkbox-circle-fill"></i></a>&nbsp; -->
<?php if ($row['invoice_type'] == 2) : ?>
<a href="<?= base_url() . "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp;
<a href="<?= base_url() . "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Subscription"></i></a>&nbsp;
<?php elseif ($row['invoice_type'] == 1) : ?>
<a href="<?= base_url() . "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button" title="Edit the Invoice"><i class="ri-pencil-line" title="Edit the Invoice"></i></a>&nbsp;
<?php endif; ?>

View File

@ -39,13 +39,13 @@
<li><a href="javascript: void(0);" class="border-danger text-danger"><i class="mdi mdi-email-variant"></i> <?= $company_email; ?> </a></li>
<li><a href="javascript: void(0);" class="border-secondary text-secondary"><i class="mdi mdi-badge-account-horizontal"><span class="text-center"> <?= $company_address; ?> </span></i></a></li>
</ul>
<?php if ((int)$bid == 1) : ?>
<?php if ((int)$bid == 2) : ?>
<div class="text-center">
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d1943.2153606988807!2d80.24498103526862!3d13.071866380546599!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x7dfd98350be12c35!2sVijayabharatham%20Prasuram!5e0!3m2!1sen!2sin!4v1640691535042!5m2!1sen!2sin" width="450" height="350" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
</div>
<?php endif; ?>
</div>
<?php if ((int)$bid == 1) : ?>
<?php if ((int)$bid == 2) : ?>
<div class="text-center mb-1">
<ul class="social-list list-inline mb-0">
<li class="list-inline-item">
@ -321,14 +321,14 @@
</div>
<div class="col-md-7">
<div class="text-md-right footer-links d-none d-sm-block">
<?php if ((int)$bid == 1) : ?>
<?php if ((int)$bid == 2) : ?>
<a style="margin-left : 0.45rem !important;font-size: 0.75rem !important;" data-toggle="modal" data-target="#about-us">About Us</a>
<a style="margin-left : 0.45rem !important;font-size: 0.75rem !important;" data-toggle="modal" data-target="#privacy-policy">Privacy Policy</a>
<a style="margin-left : 0.45rem !important;font-size: 0.75rem !important;" data-toggle="modal" data-target="#terms-conditions">Terms & Conditions</a>
<a style="margin-left : 0.45rem !important;font-size: 0.75rem !important;" data-toggle="modal" data-target="#delivery-payments-refunds">Delivery, Payments & Refunds</a>
<a style="margin-left : 0.45rem !important;font-size: 0.75rem !important;" data-toggle="modal" data-target="#contact-us">Contact Us</a>
<?php endif; ?>
<?php if ((int)$bid != 1) : ?>
<?php if ((int)$bid != 2) : ?>
<a data-toggle="modal" data-target="#about-us">About Us</a>
<a data-toggle="modal" data-target="#contact-us">Contact Us</a>
<?php endif; ?>