changes made in invoice,subscription,business
This commit is contained in:
parent
330f9a19bb
commit
05a1311161
@ -84,7 +84,7 @@ $routes->post("insert_scheme/", "Scheme::insert_scheme");
|
||||
$routes->get("delete_scheme/(:any)", "Scheme::delete_scheme/$1");
|
||||
#subscription Routes
|
||||
$routes->get("subscribers_list/", "Subscription::index");
|
||||
$routes->get("new_subscription/", "Subscription::new_subscription/");
|
||||
$routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1");
|
||||
$routes->post("add_subscription/", "Subscription::add_subscription/");
|
||||
$routes->post('subscription/download_details', 'Subscription::download_details');
|
||||
|
||||
@ -99,7 +99,9 @@ $routes->get("new_event/(:any)", "Event::new_event/$1");
|
||||
$routes->post("insert_event/", "Event::insert_event");
|
||||
#invoices
|
||||
$routes->get("invoice_list/", "Invoice::index");
|
||||
$routes->get("new_invoice/(:any)", "Invoice::new_invoice/$1");
|
||||
$routes->get("new_book_invoice/(:any)", "Invoice::new_book_invoice/$1");
|
||||
$routes->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1");
|
||||
|
||||
$routes->post("load_details1/", "Invoice::load_details1/");
|
||||
$routes->post("load_details2/", "Invoice::load_details2/");
|
||||
$routes->post("save_invoice/", "Invoice::save_invoice/");
|
||||
|
||||
@ -76,6 +76,7 @@ abstract class BaseController extends Controller
|
||||
$data['company_email'] = $details[0]['company_email'];
|
||||
$data['loggedin_person'] = $session_uname;
|
||||
$data['loggedin_person_id'] = $session_uid;
|
||||
|
||||
$data['loggedin_person_role'] = $details[0]['role'];
|
||||
$data['favicon'] = !empty($details[0]['favicon']) && file_exists(FCPATH."public/uploads/".$details[0]['favicon']) ? base_url("public/uploads/".$details[0]['favicon']) : base_url("public/uploads/default.ico");
|
||||
$data['profile_picture'] = !empty($details[0]['profile_picture']) && file_exists(FCPATH."public/uploads/".$details[0]['profile_picture']) ? base_url("public/uploads/" . $details[0]['profile_picture']) : base_url("public/assets/images/users/avatar-9.jpg");
|
||||
@ -84,6 +85,9 @@ abstract class BaseController extends Controller
|
||||
$data['browser_title'] = $data['company_name'] . ' | ' . $data['company_short_name'] . ' ' . $data['page_name'];
|
||||
$data['heading'] = $data['page_name'] === "Dashboard" ? 'Welcome to ' . $data['company_name'] : "";
|
||||
$data['loggedin_person'] = $session_uname;
|
||||
$session_bid = get_business_id();
|
||||
$data['bid'] = $session_bid;
|
||||
|
||||
|
||||
echo view('template/header.php', $data);
|
||||
echo view('template/topbar.php', $data);
|
||||
|
||||
@ -34,6 +34,7 @@ class Business extends BaseController
|
||||
## To Load Business Form (Add/Update)
|
||||
public function new_bussiness($id)
|
||||
{
|
||||
|
||||
if ($id === '0') {
|
||||
$data['page_name'] = 'Add Business';
|
||||
$data['businesses'] = [];
|
||||
@ -45,6 +46,7 @@ class Business extends BaseController
|
||||
|
||||
$data['businesses'] = $edit_user_details;
|
||||
}
|
||||
// print_r($data);//die();
|
||||
$this->render_page('business_form', $data);
|
||||
}
|
||||
|
||||
@ -102,10 +104,11 @@ class Business extends BaseController
|
||||
'city' => $this->request->getPost('bcity'),
|
||||
'state' => $this->request->getPost('bstate'),
|
||||
'postal_code' => $this->request->getPost('bzip'),
|
||||
'terms'=>$this->request->getPost('bterms'),
|
||||
'business_logo' => $fileName
|
||||
];
|
||||
$business_id = $this->request->getPost('business_id'); // Get the business ID for update
|
||||
|
||||
|
||||
if (empty($business_id)) {
|
||||
// It's an insert operation
|
||||
$data['isactive'] = 1;
|
||||
@ -119,6 +122,7 @@ class Business extends BaseController
|
||||
$data['updated_by'] = $session_uid;
|
||||
$BusinessModel->update($business_id, $data);
|
||||
}
|
||||
|
||||
return redirect()->route('business_list');
|
||||
}
|
||||
|
||||
|
||||
@ -38,30 +38,62 @@ class Invoice extends BaseController
|
||||
}
|
||||
|
||||
## To Load Invoice ADD/EDIT page...
|
||||
public function new_invoice($id)
|
||||
public function new_book_invoice($id = '0')
|
||||
{
|
||||
helper('session');
|
||||
$model = new InvoiceModel();
|
||||
$where = ['business_id' => (int)get_business_id()];
|
||||
|
||||
## Get customer-names for the dropdown , events-details and books-details
|
||||
|
||||
// Get customer names for the dropdown, events details, and books details
|
||||
$data['customers'] = $model->getData('customers', $where);
|
||||
$data['events'] = $model->getData('events', $where);
|
||||
$data['books'] = $model->getData('books', $where);
|
||||
|
||||
$data['books'] = $model->getNonMembershipCategoryBooks('books', $where);
|
||||
|
||||
if ($id === '0') {
|
||||
$this->logger->info("Invoice: In Add Page");
|
||||
$data['page_name'] = 'Add Invoice Details';
|
||||
$this->logger->info("Book Invoice: In Add Page");
|
||||
$data['page_name'] = 'Add Book Invoice Details';
|
||||
$data['invoice_type'] = '2';
|
||||
$data['invoice_details'] = [];
|
||||
$data['invoice_item_details'] = [];
|
||||
} else if ($id !== '0') {
|
||||
$this->logger->info("Invoice: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Invoice Details';
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->info("Book Invoice: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Book Invoice Details';
|
||||
$data['invoice_type'] ='2';
|
||||
$data['invoice_details'] = $model->where(['invoice_id' => $id, 'isactive' => 1])->first();
|
||||
$data['invoice_item_details'] = $this->get_invoice_item($id);
|
||||
}
|
||||
|
||||
$this->render_page('invoice_form', $data);
|
||||
}
|
||||
|
||||
public function new_subscription_invoice($id = '0')
|
||||
{
|
||||
helper('session');
|
||||
$model = new InvoiceModel();
|
||||
$where = ['business_id' => (int)get_business_id()];
|
||||
|
||||
// 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);
|
||||
|
||||
if ($id === '0') {
|
||||
$this->logger->info("Subscription Invoice: In Add Page");
|
||||
$data['page_name'] = 'Add Subscription Invoice Details';
|
||||
$data['invoice_type'] ='1';
|
||||
$data['invoice_details'] = [];
|
||||
$data['invoice_item_details'] = [];
|
||||
} elseif ($id !== '0') {
|
||||
$this->logger->info("Subscription Invoice: In Edit Page ID =" . $id);
|
||||
$data['page_name'] = 'Edit Subscription Invoice Details';
|
||||
$data['invoice_type'] ='1';
|
||||
$data['invoice_details'] = $model->where(['invoice_id' => $id, 'isactive' => 1])->first();
|
||||
$data['invoice_item_details'] = $this->get_invoice_item($id);
|
||||
}
|
||||
|
||||
$this->render_page('invoice_form', $data);
|
||||
}
|
||||
|
||||
|
||||
## For Ajax Call To Fetch/Retrive All Address Details Based On Customer...
|
||||
public function load_details1()
|
||||
@ -114,15 +146,17 @@ class Invoice extends BaseController
|
||||
$invoice_status = $this->request->getPost('status');
|
||||
$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'),
|
||||
'invoice_type'=> $this->request->getPost('invoice_type'),
|
||||
'customer_id' => $customer_id,
|
||||
'billing_address_id' => (int)$this->request->getPost('billing_address_id'),
|
||||
'billing_address' => $this->request->getPost('billing_address'),
|
||||
'shipping_address_id' => (int)$this->request->getPost('shipping_address_id'),
|
||||
'shipping_address' => $this->request->getPost('shipping_address'),
|
||||
'notes'=>$this->request->getPost('notes'),
|
||||
'invoice_date' => (!empty($invdate)) ? date("Y-m-d", strtotime($invdate)) : NULL,
|
||||
'due_date' => (!empty($duedate)) ? date("Y-m-d", strtotime($duedate)) : NULL,
|
||||
'subtotal' => (int)$this->request->getPost('sub_total'),
|
||||
@ -141,15 +175,18 @@ class Invoice extends BaseController
|
||||
## Based on the invoice ID, we designated Insert or Update on Details...
|
||||
if (empty($invoice_id)) {
|
||||
$data['created_by'] = (int)get_logged_user_id();
|
||||
if ($model->insert($data)) {
|
||||
if ($model->insert($data, 'invoices')) {
|
||||
$invoice_id = $model->insertID();
|
||||
|
||||
session()->setFlashdata('success', 'Invoice has been added successfully.');
|
||||
$this->logger->info("Invoice: has been added successfully. Inserted ID = " . $invoice_id);
|
||||
|
||||
// If it's a subscription invoice, also store data in the 'subscription' table
|
||||
|
||||
} else {
|
||||
session()->setFlashdata('error', 'Invoice could not be added. Please try again.');
|
||||
$this->logger->error("Invoice: Err Occur could not be added. Please try again.");
|
||||
}
|
||||
|
||||
} else {
|
||||
$data['updated_by'] = (int)get_logged_user_id();
|
||||
if ($model->update($invoice_id, $data)) {
|
||||
@ -174,8 +211,40 @@ class Invoice extends BaseController
|
||||
|
||||
|
||||
## For Invoice Item Details Insert/Update..
|
||||
$this->save_invoice_item($invoice_id, $requestData);
|
||||
|
||||
$this->save_invoice_item($invoice_id, $requestData, (int)$this->request->getVar('product'));
|
||||
$invoiceItems = $this->get_invoice_item($invoice_id);
|
||||
|
||||
|
||||
if ($invoiceType === '1') {
|
||||
// Extract necessary data
|
||||
$customerId = (int)$this->request->getPost('customer_name');
|
||||
$invoiceId = $invoice_id; // You have this value already
|
||||
|
||||
// Loop through invoice items and store them in the 'subscription' table
|
||||
$subscriptionModel = new InvoiceModel(); // Replace with your actual model
|
||||
foreach ($invoiceItems as $item) {
|
||||
$productId = $item['product'];
|
||||
$fromsub=$item['from_subscription'];
|
||||
$tosub=$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,
|
||||
'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);
|
||||
}
|
||||
}
|
||||
## Notification For Approve..
|
||||
if ($invoice_status == 'Approved' && !$invoice_id) {
|
||||
$this->approve_notifications((int)$invoice_id);
|
||||
@ -184,6 +253,8 @@ class Invoice extends BaseController
|
||||
$this->logger->error("Invoice: Err Occur =" . $e->getMessage());
|
||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
return redirect()->route('invoice_list');
|
||||
}
|
||||
|
||||
@ -245,6 +316,13 @@ class Invoice extends BaseController
|
||||
$invoiceitem_arr[$x]['subtotal'] = (int)$requestData['amount'][$x];
|
||||
$invoiceitem_arr[$x]['discount_amount'] = (int)$requestData['discount_amount'][$x];
|
||||
$invoiceitem_arr[$x]['discount_type'] =$requestData['discount_type'][$x];
|
||||
if (!empty($requestData['from_subscription'])) {
|
||||
$invoiceitem_arr[0]['from_subscription'] = $requestData['from_subscription'];
|
||||
}
|
||||
|
||||
if (!empty($requestData['to_subscription'])) {
|
||||
$invoiceitem_arr[0]['to_subscription'] = $requestData['to_subscription'];
|
||||
}
|
||||
$invoiceitem_arr[$x]['created_by'] = (int)get_logged_user_id();
|
||||
$invoiceitem_arr[$x]['updated_by'] = (int)get_logged_user_id();
|
||||
$invoiceitem_arr[$x]['isactive'] = 1;
|
||||
@ -429,7 +507,10 @@ class Invoice extends BaseController
|
||||
$model = new InvoiceModel();
|
||||
$data = $model->getInvoiceData($id);
|
||||
$invoiceItems = $model->getInvoiceItems($id);
|
||||
|
||||
$invoiceTerms=$model->getInvoiceData($id);
|
||||
// print_r($invoiceTerms);die()
|
||||
$invoice_type = $data[0]->invoice_type;
|
||||
|
||||
// print_r($invoiceItems);die();
|
||||
|
||||
// Create an mPDF object
|
||||
@ -448,7 +529,7 @@ class Invoice extends BaseController
|
||||
}
|
||||
|
||||
// Generate the PDF content (HTML) with data
|
||||
$html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems]);
|
||||
$html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems,'invoice_type' => $invoice_type,'invoiceTerms'=>$invoiceTerms]);
|
||||
|
||||
// Load HTML into the mPDF instance
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
@ -9,7 +9,7 @@ class BusinessModel extends Model
|
||||
{
|
||||
protected $table = 'business';
|
||||
protected $primaryKey = 'business_id';
|
||||
protected $allowedFields = ['business_id','title','email','mobile_no','address','city','state','postal_code' ,'business_logo','isactive'];
|
||||
protected $allowedFields = ['business_id','title','email','mobile_no','terms','address','city','state','postal_code' ,'business_logo','isactive'];
|
||||
|
||||
public function insertBusiness($data)
|
||||
{
|
||||
|
||||
@ -8,7 +8,7 @@ class InvoiceModel extends Model
|
||||
protected $table = 'invoice';
|
||||
protected $primaryKey = 'invoice_id';
|
||||
// protected $allowedFields = ['invoice_id','invoice_number','customer_id','invoice_date','event_id','business_id','created_on','business_id'];
|
||||
protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','total_amount', 'payment_status', 'order_number', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by', 'isactive','billing_address','shipping_address','status'];
|
||||
protected $allowedFields = ['invoice_id', 'invoice_number', 'customer_id','notes', 'invoice_date', 'due_date', 'subtotal', 'tax', 'discount', 'shipping_charge','total_amount', 'payment_status', 'order_number','invoice_type', 'payment_method', 'event_id', 'business_id', 'shipping_address_id', 'billing_address_id', 'created_on', 'created_by', 'updated_on', 'updated_by','category','isactive','billing_address','shipping_address','status'];
|
||||
|
||||
public function saveInvoiceItemDetails($data){
|
||||
$i = 0;
|
||||
@ -53,7 +53,7 @@ public function updateData($table, $data, $where)
|
||||
->join('business as B', 'B.business_id = I.business_id', 'left')
|
||||
->join('users as U1', 'U1.user_id = I.created_by', 'left')
|
||||
->join('users as U2', 'U2.user_id = I.updated_by', 'left')
|
||||
->select('I.invoice_id, I.invoice_number, I.customer_id,concat(C.first_name," ",C.last_name) as customer_name , I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method, I.event_id,E.event_name, I.business_id,B.title as business_name, I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name, I.updated_on, I.updated_by,concat(U2.first_name," ",U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address')
|
||||
->select('I.invoice_id, I.invoice_number, I.customer_id,concat(C.first_name," ",C.last_name) as customer_name , I.invoice_date, I.due_date, I.subtotal, I.tax, I.discount, I.total_amount,I.status, I.payment_status, I.order_number, I.payment_method,I.invoice_type, I.event_id,E.event_name, I.business_id,B.title as business_name, I.created_on, I.created_by,concat(U1.first_name," ",U1.last_name) as created_by_name, I.updated_on, I.updated_by,concat(U2.first_name," ",U2.last_name) as updated_by_name, I.isactive,C.email as customer_email,C.mobile_no as customer_mobile,I.shipping_address_id,I.shipping_address,I.billing_address_id,I.billing_address')
|
||||
->where($where)
|
||||
->get()
|
||||
->getResultArray();
|
||||
@ -118,7 +118,7 @@ public function updateData($table, $data, $where)
|
||||
->join('customers as C','C.customer_id= invoice.customer_id','left')
|
||||
->join('business as B','B.business_id = invoice.business_id','left')
|
||||
->join('customer_addresses as A','A.customer_id=invoice.customer_id and A.address_type=1','left')
|
||||
->select('invoice.*,concat(C.first_name," ",C.last_name) as customer_name,A.address_1, A.address_2,A.postal_code,A.city, A.state,C.mobile_no,B.title,B.business_logo,B.address,B.city,B.state,B.postal_code,B.email,B.mobile_no')
|
||||
->select('invoice.*,concat(C.first_name," ",C.last_name) as customer_name,A.address_1, A.address_2,A.postal_code,A.city, A.state,C.mobile_no,B.title,B.business_logo,B.terms,B.address,B.city,B.state,B.postal_code,B.email,B.mobile_no')
|
||||
|
||||
->get()
|
||||
->getResult();
|
||||
@ -134,6 +134,27 @@ public function updateData($table, $data, $where)
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
public function getCategoryBooks()
|
||||
{
|
||||
return $this->db->table('books')
|
||||
->join('category', 'books.category= category.id', 'left')
|
||||
->where('category.name', 'membership')
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
}
|
||||
public function getNonMembershipCategoryBooks()
|
||||
{
|
||||
return $this->db->table('books')
|
||||
->join('category', 'books.category = category.id', 'left')
|
||||
->where('category.name !=', 'membership')
|
||||
->get()
|
||||
->getResult();
|
||||
}
|
||||
public function insertSubscriptionData($data)
|
||||
{
|
||||
return $this->db->table('subscription')->insert($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ class SubscriptionModel extends Model
|
||||
{
|
||||
protected $table = 'subscription';
|
||||
protected $primaryKey = 'sub_id';
|
||||
protected $allowedFields = ['sub_id','scheme_id','customer_id','to_subscription','from_subscription','mode','created_on','business_id'];
|
||||
protected $allowedFields = ['sub_id','scheme_id','customer_id','to_subscription','from_subscription','mode','created_on','created_by','business_id'];
|
||||
|
||||
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
<div class="card-body">
|
||||
<h4 class="header-title"><?= $page_name; ?></h4>
|
||||
<p class="sub-header"> </p>
|
||||
|
||||
<form class="needs-validation" novalidate method="POST" enctype="multipart/form-data" action="<?php echo base_url(); ?>insert_business">
|
||||
<div class="form-group">
|
||||
<div class="form-row">
|
||||
@ -79,6 +80,13 @@
|
||||
<input type="text" class="form-control" name="bzip" value="<?= isset($businesses['postal_code']) ? $businesses['postal_code'] : '' ?>" placeholder="Postal Code (Eg: Pincode)" required />
|
||||
<div class="invalid-feedback"> Please provide. </div>
|
||||
</div>
|
||||
<div class="form-group col-md-12">
|
||||
<label for="bterms" class="col-form-label">Terms & Condition<span class="text-danger">*</span></label>
|
||||
<textarea class="form-control" id="terms" name="bterms" rows="5" cols="50">
|
||||
<?php echo ($businesses['terms']);?>
|
||||
</textarea>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php if (!empty($businesses['business_logo'])) { ?>
|
||||
<div class="form-group col-md-12">
|
||||
@ -92,6 +100,9 @@
|
||||
<input type="file" class="form-control" style="border: 0px !important;" id="bfile" name="bfile" value="<?= isset($businesses['business_logo']) ? $businesses['business_logo'] : '' ?>" multiple />
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<input type="hidden" id="business_id" name="business_id" placeholder="hidden for business id" value="<?= isset($businesses['business_id']) ? $businesses['business_id'] : '' ?>" />
|
||||
|
||||
|
||||
@ -98,14 +98,16 @@
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<?php if ($invoice_type === '1'): ?>
|
||||
<label for="fromsubcription">From Subcription</label>
|
||||
<input type="date" class="form-control" id="fromsubcription" name="from_subcription">
|
||||
|
||||
<input type="date" class="form-control" id="fromsubcription" name="from_subscription" value="<?= isset($invoice_item_details[0]['from_subscription']) ? $invoice_item_details[0]['from_subscription'] : '' ?>">
|
||||
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="tosubcription">To Subcription</label>
|
||||
<input type="date" class="form-control" id="to_subcription" name="due_date"
|
||||
value="<?= isset($invoice_details['due_date']) ? $invoice_details['due_date'] : '' ?>">
|
||||
<input type="date" class="form-control" id="to_subcription" name="to_subscription"value="<?= isset($invoice_item_details[0]['to_subscription']) ? $invoice_item_details[0]['to_subscription'] : '' ?>">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -210,9 +212,12 @@
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="form-group text-right m-b-0">
|
||||
<a class="btn" id="addItem">
|
||||
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add More Item</h4>
|
||||
</a>
|
||||
<?php if ($invoice_type !== '1'): ?>
|
||||
<!-- Show the "Add More Item" button only if invoice_type is not 1 -->
|
||||
<a class="btn" id="addItem">
|
||||
<h4><i class="fa fa-plus" aria-hidden="true"></i> Add More Item</h4>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@ -256,7 +261,8 @@
|
||||
<div class="form-row">
|
||||
<div class="form-group text-left col-md-12 ">
|
||||
<label for="terms">Notes</label>
|
||||
<textarea class="form-control" id="terms" name="terms"></textarea>
|
||||
<textarea class="form-control" id="terms" name="notes" value="<?= isset($invoice_details['notes']) ? $invoice_details['notes'] : '' ?>">
|
||||
</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -272,7 +278,7 @@
|
||||
<!-- Show the "Save as Approved" button only if the status is not "Approved" -->
|
||||
<button type="submit" class="btn btn-primary waves-effect mr-1" name="save_as_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') ? '1' : '2'; ?>">
|
||||
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : '' ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -1,10 +1,39 @@
|
||||
<html>
|
||||
<head>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="float-right">
|
||||
<a href="<?= base_url()."new_invoice/0"; ?>" class="btn btn-primary"><i class="fe-file-text"></i> Add New </a>
|
||||
</div><!-- end col-->
|
||||
<a href="#" id="addNewButton" class="btn btn-primary"><i class="fe-file-text"></i> Add New </a>
|
||||
<!-- HTML for the "Add New" button -->
|
||||
|
||||
<div id="standard-modal" >
|
||||
|
||||
<div id="invoiceTypeModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title" id="mySmallModalLabel">Select Invoice Type</h4>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<label>
|
||||
<input type="radio" name="invoiceType" value="subscription"> Subscription Invoice
|
||||
</label>
|
||||
<label>
|
||||
<input type="radio" name="invoiceType" value="book"> Book Invoice
|
||||
</label>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="confirmInvoiceType">Continue</button>
|
||||
</div>
|
||||
</div><!-- /.modal-content -->
|
||||
</div><!-- /.modal-dialog -->
|
||||
</div><!-- /.modal -->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||
@ -52,7 +81,13 @@
|
||||
<td><?= $row['customer_name']; ?></td>
|
||||
<td><?= $row['status']; ?></td>
|
||||
<td style align="center"><a href="<?= "approve_invoice/" . $row['invoice_id']; ?>" class="approve-button"><i class="ri-checkbox-circle-fill"></i></a></td>
|
||||
<td><a href="<?= "new_invoice/" . $row['invoice_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a></td>
|
||||
<td>
|
||||
<?php if ($row['invoice_type'] == 1): ?>
|
||||
<a href="<?= "new_subscription_invoice/" . $row['invoice_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
<?php elseif ($row['invoice_type'] == 2): ?>
|
||||
<a href="<?= "new_book_invoice/" . $row['invoice_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button"><i class="ri-file-download-line"></i></a></td>
|
||||
<td><a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button"><i class="ri-printer-line"></i></a></td>
|
||||
</tr>
|
||||
@ -71,5 +106,33 @@ function openPdfInNewTab(pdfUrl) {
|
||||
window.open(pdfUrl, '_blank');
|
||||
}
|
||||
</script>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#addNewButton").click(function() {
|
||||
// Show the pop-up modal
|
||||
$("#invoiceTypeModal").modal("show");
|
||||
});
|
||||
|
||||
$("#confirmInvoiceType").click(function() {
|
||||
// Get the selected invoice type
|
||||
var selectedType = $("input[name='invoiceType']:checked").val();
|
||||
|
||||
// Redirect the user to the appropriate form based on the selected type
|
||||
if (selectedType === "subscription") {
|
||||
// Redirect to the subscription invoice form
|
||||
window.location.href = "<?= base_url('new_subscription_invoice/0'); ?>"; // Update the URL as needed
|
||||
} else if (selectedType === "book") {
|
||||
// Redirect to the book invoice form
|
||||
window.location.href = "<?= base_url('new_book_invoice/0'); ?>"; // Update the URL as needed
|
||||
}
|
||||
});
|
||||
|
||||
// Close the modal when the close button is clicked
|
||||
$("#invoiceTypeModal .close").click(function() {
|
||||
$("#invoiceTypeModal").modal("hide");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ if (count($invoiceDateParts) === 3) {
|
||||
if (count($invoiceDateParts) === 3) {
|
||||
$formattedDueDate = $invoiceDateParts[2] . '/' . $invoiceDateParts[1] . '/' . $invoiceDateParts[0];
|
||||
} else {
|
||||
$formattedDueDate = 'Invalid Date'; // Handle invalid dates gracefully
|
||||
$formattedDueDate = ''; // Handle invalid dates gracefully
|
||||
}
|
||||
?>
|
||||
<th>Due Date : <?= $formattedDueDate ?></th>
|
||||
@ -196,7 +196,20 @@ if (count($invoiceDateParts) === 3) {
|
||||
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<?php if ($invoice_type === '1') : ?>
|
||||
<?php foreach ($invoiceItems as $item) : ?>
|
||||
|
||||
<th>From Subscription : <?= date('d/m/y', strtotime($item->from_subscription)) ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>To Subscription : <?= date('d/m/y', strtotime($item->to_subscription)) ?></th>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
@ -275,8 +288,18 @@ if (count($invoiceDateParts) === 3) {
|
||||
|
||||
</div>
|
||||
|
||||
<?php foreach ($data as $value) : ?>
|
||||
|
||||
<div class="terms">
|
||||
<p>Thank you!</p>
|
||||
<p>Thank you!</p><br><br>
|
||||
<?php if (!empty($value->notes)): ?>
|
||||
<p>Notes: <?= $value->notes ?></p><br><br>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($invoiceTerms as $row) : ?>
|
||||
|
||||
<p><?= $row->terms ?></p><br><br>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -6,8 +6,8 @@
|
||||
<!-- Add a "Print Addresses" button -->
|
||||
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#printAddressesModal">Print Addresses</button>
|
||||
|
||||
<a href="new_subscription" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add New </a>
|
||||
|
||||
<a href="<?= base_url()."new_subscription_invoice/0"; ?>" class="btn btn-primary"><i class="ri-shield-user-line"></i> Add New</a>
|
||||
|
||||
</div><!-- end col-->
|
||||
<br>
|
||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||
|
||||
@ -237,7 +237,8 @@
|
||||
<i class="ri-account-circle-line"></i>
|
||||
<span>My Account</span>
|
||||
</a>
|
||||
<a href="<?= base_url()."business_list"; ?>"class="dropdown-item notify-item">
|
||||
<a href="<?= base_url()."new_bussiness/".$bid; ?>"class="dropdown-item notify-item">
|
||||
|
||||
<i class="ri-briefcase-4-fill"></i>
|
||||
<span> Business Setting </span>
|
||||
</a>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user