Tracker issue
This commit is contained in:
parent
f73bf2013f
commit
6a57d1a640
@ -114,12 +114,17 @@ $routes->get('invoice_number_format/(:any)', 'Event::invoice_number_format/$1');
|
|||||||
$routes->post("insert_invoice_number_format", "Event::insert_invoice_number_format");
|
$routes->post("insert_invoice_number_format", "Event::insert_invoice_number_format");
|
||||||
#invoices
|
#invoices
|
||||||
$routes->get("invoice_list/", "Invoice::index");
|
$routes->get("invoice_list/", "Invoice::index");
|
||||||
|
$routes->get("offline_invoice/", "Invoice::offline_invoice");
|
||||||
$routes->get("new_book_invoice/(:any)", "Invoice::new_book_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->get("new_subscription_invoice/(:any)", "Invoice::new_subscription_invoice/$1");
|
||||||
// $routes->get("download_invoice_pdf/(:num)",'Invoice::download_invoice_pdf/$1');
|
// $routes->get("download_invoice_pdf/(:num)",'Invoice::download_invoice_pdf/$1');
|
||||||
$routes->get("download_invoice_pdf/(:any)", 'Invoice::download_invoice_pdf/$1');
|
$routes->get("download_invoice_pdf/(:any)", 'Invoice::download_invoice_pdf/$1');
|
||||||
|
|
||||||
|
|
||||||
|
$routes->post("saveBook", "Invoice::saveBook");
|
||||||
|
$routes->post("updateInvoiceStatus", "Invoice::updateInvoiceStatus");
|
||||||
|
$routes->post("updateInvoiceCancelStatus", "Invoice::updateInvoiceCancelStatus");
|
||||||
|
|
||||||
|
|
||||||
$routes->post("get_customer_billing_details", "Invoice::get_customer_billing_details");
|
$routes->post("get_customer_billing_details", "Invoice::get_customer_billing_details");
|
||||||
$routes->post("get_customer_membership_details", "Invoice::get_customer_membership_details");
|
$routes->post("get_customer_membership_details", "Invoice::get_customer_membership_details");
|
||||||
@ -128,6 +133,9 @@ $routes->post("save_invoice/", "Invoice::save_invoice/");
|
|||||||
$routes->get("delete_invoice/(:any)", "Invoice::delete_invoice/$1");
|
$routes->get("delete_invoice/(:any)", "Invoice::delete_invoice/$1");
|
||||||
$routes->add('approve_invoice/(:num)', 'Invoice::approve_invoice/$1');
|
$routes->add('approve_invoice/(:num)', 'Invoice::approve_invoice/$1');
|
||||||
$routes->get('generate_invoice_pdf/(:num)', 'Invoice::generate_invoice_pdf/$1');
|
$routes->get('generate_invoice_pdf/(:num)', 'Invoice::generate_invoice_pdf/$1');
|
||||||
|
$routes->get('generate_invoice_pdf_preview/(:any)', 'Invoice::generate_invoice_pdf_preview/$1');
|
||||||
|
|
||||||
|
|
||||||
$routes->get('print_address/(:num)', 'Invoice::print_address/$1');
|
$routes->get('print_address/(:num)', 'Invoice::print_address/$1');
|
||||||
|
|
||||||
$routes->match(['get','post'],'/general_inv_rp','Invoice::general_inv_rp');
|
$routes->match(['get','post'],'/general_inv_rp','Invoice::general_inv_rp');
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace App\Controllers;
|
|||||||
use App\Models\EventModel;
|
use App\Models\EventModel;
|
||||||
use App\Models\CustomerModel;
|
use App\Models\CustomerModel;
|
||||||
use App\Models\InvoiceModel;
|
use App\Models\InvoiceModel;
|
||||||
|
use App\Models\BooksModel;
|
||||||
use App\Helpers\NotificationHelper;
|
use App\Helpers\NotificationHelper;
|
||||||
|
|
||||||
use Mpdf\Mpdf;
|
use Mpdf\Mpdf;
|
||||||
@ -28,7 +29,7 @@ class Invoice extends BaseController
|
|||||||
}
|
}
|
||||||
|
|
||||||
$model = new InvoiceModel();
|
$model = new InvoiceModel();
|
||||||
$data['page_name'] = 'Invoice Details';
|
$data['page_name'] = 'Online Invoice Details';
|
||||||
$data['invoice'] = $model->getJoinedData($where);
|
$data['invoice'] = $model->getJoinedData($where);
|
||||||
$this->logger->info("Invoice: Listing Count ." . count($data['invoice']));
|
$this->logger->info("Invoice: Listing Count ." . count($data['invoice']));
|
||||||
$this->render_page('invoice_list', $data);
|
$this->render_page('invoice_list', $data);
|
||||||
@ -36,6 +37,30 @@ class Invoice extends BaseController
|
|||||||
return redirect()->to('login');
|
return redirect()->to('login');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function offline_invoice()
|
||||||
|
{
|
||||||
|
helper('session');
|
||||||
|
if (is_session_active()) {
|
||||||
|
$session_role = get_user_role();
|
||||||
|
$session_bid = get_business_id();
|
||||||
|
|
||||||
|
if (!empty($session_role) && $session_role !== "sadmin") {
|
||||||
|
$this->logger->info("Invoice: Listing In Admin BID = " . $session_bid);
|
||||||
|
$where = ['I.business_id' => (int)$session_bid, 'I.isactive' => 1,'I.invoice_type'=>1];
|
||||||
|
} else {
|
||||||
|
$this->logger->info("Invoice: Listing In the Super-Admin ");
|
||||||
|
$where = ['I.business_id != ' => NULL, 'I.isactive != ' => NULL,'I.invoice_type'=>1];
|
||||||
|
}
|
||||||
|
|
||||||
|
$model = new InvoiceModel();
|
||||||
|
$data['page_name'] = 'Offline Invoice Details';
|
||||||
|
$data['invoice'] = $model->getJoinedData($where);
|
||||||
|
$this->logger->info("Invoice: Listing Count ." . count($data['invoice']));
|
||||||
|
$this->render_page('offline_invoice_list', $data);
|
||||||
|
} else {
|
||||||
|
return redirect()->to('login');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
## To Load Invoice ADD/EDIT page...
|
## To Load Invoice ADD/EDIT page...
|
||||||
public function new_book_invoice($id = '0')
|
public function new_book_invoice($id = '0')
|
||||||
@ -339,7 +364,7 @@ class Invoice extends BaseController
|
|||||||
} else {
|
} else {
|
||||||
// For other invoice types, redirect to the invoice list.
|
// For other invoice types, redirect to the invoice list.
|
||||||
$this->logger->info(session()->getFlashdata());
|
$this->logger->info(session()->getFlashdata());
|
||||||
return redirect()->route('invoice_list'); // Adjust the route name as needed.
|
return redirect()->route('offline_invoice'); // Adjust the route name as needed.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +492,7 @@ class Invoice extends BaseController
|
|||||||
$this->logger->error("Invoice: Err Occur = " . $e->getMessage());
|
$this->logger->error("Invoice: Err Occur = " . $e->getMessage());
|
||||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
return redirect()->route('invoice_list');
|
return redirect()->route('offline_invoice');
|
||||||
}
|
}
|
||||||
|
|
||||||
## To Approve Invoice details based on invoice ID
|
## To Approve Invoice details based on invoice ID
|
||||||
@ -501,7 +526,7 @@ class Invoice extends BaseController
|
|||||||
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
session()->setFlashdata('error', 'Message: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
// Redirect back to the invoice list
|
// Redirect back to the invoice list
|
||||||
return redirect()->route('invoice_list');
|
return redirect()->route('offline_invoice');
|
||||||
}
|
}
|
||||||
public function subscription_inactive(){
|
public function subscription_inactive(){
|
||||||
$model = new InvoiceModel();
|
$model = new InvoiceModel();
|
||||||
@ -702,16 +727,53 @@ $encodedUrl = urlencode($url);
|
|||||||
$mpdf->SetWatermarkText('Draft');
|
$mpdf->SetWatermarkText('Draft');
|
||||||
$mpdf->showWatermarkText = true;
|
$mpdf->showWatermarkText = true;
|
||||||
}
|
}
|
||||||
|
if ($data[0]->status === 'Cancelled') {
|
||||||
|
// Set the watermark text and options
|
||||||
|
$mpdf->SetWatermarkText('Cancelled');
|
||||||
|
$mpdf->showWatermarkText = true;
|
||||||
|
}
|
||||||
|
if ($data[0]->status === 'Void') {
|
||||||
|
// Set the watermark text and options
|
||||||
|
$mpdf->SetWatermarkText('Void');
|
||||||
|
$mpdf->showWatermarkText = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Generate the PDF content (HTML) with data
|
// Generate the PDF content (HTML) with data
|
||||||
$html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems,'invoice_type' => $invoice_type,'invoiceTerms'=>$data]);
|
$html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems,'invoice_type' => $invoice_type,'invoiceTerms'=>$data]);
|
||||||
|
// echo $html;die;
|
||||||
// Load HTML into the mPDF instance
|
// Load HTML into the mPDF instance
|
||||||
$mpdf->WriteHTML($html);
|
$mpdf->WriteHTML($html);
|
||||||
|
|
||||||
// Output the PDF to the browser for download
|
// Output the PDF to the browser for download
|
||||||
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||||
}
|
}
|
||||||
|
public function generate_invoice_pdf_preview($id)
|
||||||
|
{
|
||||||
|
// Load required model
|
||||||
|
$model = new InvoiceModel();
|
||||||
|
$data = $model->getInvoiceData($id);
|
||||||
|
|
||||||
|
$invoiceItems = $model->getInvoiceItems($id,'groupby');
|
||||||
|
|
||||||
|
foreach($invoiceItems as $index => $singleItem)
|
||||||
|
{
|
||||||
|
$productImgs= $model->getProductImgs($singleItem->product);
|
||||||
|
$invoiceItems[$index]->imgs = $productImgs;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoice_type = $data[0]->invoice_type;
|
||||||
|
|
||||||
|
// Get status data
|
||||||
|
$status = $data[0]->status;
|
||||||
|
|
||||||
|
// Load view with data
|
||||||
|
$html = view('invoice_pdf_template', ['data' => $data, 'invoiceItems' => $invoiceItems, 'invoice_type' => $invoice_type, 'invoiceTerms' => $data, 'status' => $status]);
|
||||||
|
|
||||||
|
// Return HTML content
|
||||||
|
echo $html;
|
||||||
|
}
|
||||||
|
|
||||||
// public function generate_invoice_pdf($id)
|
// public function generate_invoice_pdf($id)
|
||||||
// {
|
// {
|
||||||
// // Fetch the invoice data based on $invoice_id
|
// // Fetch the invoice data based on $invoice_id
|
||||||
@ -1096,6 +1158,99 @@ private function getInvoiceIdByMd5($md5Hash)
|
|||||||
|
|
||||||
return $result ? $result->invoice_id : null;
|
return $result ? $result->invoice_id : null;
|
||||||
}
|
}
|
||||||
|
public function saveBook() {
|
||||||
|
// Retrieve book details from POST data
|
||||||
|
$bookName = $this->request->getPost('bookName');
|
||||||
|
$publication_date = $this->request->getPost('publication_date');
|
||||||
|
$publication_code = $this->request->getPost('publishers_code');
|
||||||
|
$isbn_code = $this->request->getPost('isbn_code');
|
||||||
|
$bookPrice = $this->request->getPost('bookPrice');
|
||||||
|
$publisher_name = $this->request->getPost('publisher');
|
||||||
|
|
||||||
|
// Load the model
|
||||||
|
$model = new BooksModel();
|
||||||
|
|
||||||
|
// Call the model function to save the book
|
||||||
|
$bookId = $model->saveBook($bookName, $bookPrice, $isbn_code, $publication_date, $publication_code, $publisher_name);
|
||||||
|
|
||||||
|
// Return a response (e.g., JSON response)
|
||||||
|
$response = array();
|
||||||
|
if ($bookId) {
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'Book saved successfully.';
|
||||||
|
$response['book_id'] = $bookId; // Include the book ID in the response
|
||||||
|
$response['title'] = $bookName;
|
||||||
|
// $response['tax'] = $bookId;
|
||||||
|
$response['price'] = $bookPrice;
|
||||||
|
} else {
|
||||||
|
$response['success'] = false;
|
||||||
|
$response['message'] = 'Failed to save book.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send JSON response
|
||||||
|
return $this->response->setJSON($response);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Your controller method to handle updating status and reason
|
||||||
|
public function updateInvoiceStatus()
|
||||||
|
{
|
||||||
|
// Retrieve data from the request
|
||||||
|
$invoiceId = $this->request->getPost('invoice_id');
|
||||||
|
$voidReason = $this->request->getPost('void_reason');
|
||||||
|
|
||||||
|
// Perform any validation if needed
|
||||||
|
|
||||||
|
// Update the invoice status and void reason in the database
|
||||||
|
$model = new InvoiceModel(); // Assuming you have a model named InvoiceModel
|
||||||
|
$updated = $model->updateInvoiceStatus($invoiceId, $voidReason);
|
||||||
|
|
||||||
|
// Prepare the response
|
||||||
|
$response = [];
|
||||||
|
if ($updated) {
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'Invoice status updated successfully.';
|
||||||
|
} else {
|
||||||
|
$response['success'] = false;
|
||||||
|
$response['message'] = 'Failed to update invoice status.';
|
||||||
|
}
|
||||||
|
if ($updated) {
|
||||||
|
|
||||||
|
}
|
||||||
|
// Return the response as JSON
|
||||||
|
return $this->response->setJSON($response);
|
||||||
|
}
|
||||||
|
public function updateInvoiceCancelStatus()
|
||||||
|
{
|
||||||
|
// Retrieve data from the request
|
||||||
|
$invoiceIds = $this->request->getPost('invoice_id');
|
||||||
|
$cancelReason = $this->request->getPost('cancel_reason');
|
||||||
|
|
||||||
|
// Perform any validation if needed
|
||||||
|
|
||||||
|
// Update the invoice status and cancel reason in the database
|
||||||
|
$model = new InvoiceModel(); // Assuming you have a model named InvoiceModel
|
||||||
|
$updated = $model->updateInvoiceCancelStatus($invoiceIds, $cancelReason);
|
||||||
|
|
||||||
|
// Prepare the response
|
||||||
|
$response = [];
|
||||||
|
if ($updated) {
|
||||||
|
$response['success'] = true;
|
||||||
|
$response['message'] = 'Invoice status updated successfully.';
|
||||||
|
// Redirect to the invoice_list page upon successful cancellation
|
||||||
|
// return redirect()->to('invoice_list');
|
||||||
|
} else {
|
||||||
|
$response['success'] = false;
|
||||||
|
$response['message'] = 'Failed to update invoice status.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return the response as JSON
|
||||||
|
return $this->response->setJSON($response);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -147,5 +147,31 @@ public function getData($table, $where = null,$whereIn = null)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public function saveBook($bookName, $bookPrice,$isbn_code,$publication_date,$publication_code,$publisher_name) {
|
||||||
|
// Prepare data to insert into the database
|
||||||
|
$data = array(
|
||||||
|
'title' => $bookName,
|
||||||
|
'price' => $bookPrice,
|
||||||
|
'isbn_code'=>$isbn_code,
|
||||||
|
'publication_date'=>$publication_date,
|
||||||
|
'publishers_code'=>$publication_code,
|
||||||
|
'publisher'=>$publisher_name
|
||||||
|
// Add other columns as needed
|
||||||
|
);
|
||||||
|
|
||||||
|
// Use Query Builder to insert data into the 'books' table
|
||||||
|
$this->db->table('books')->insert($data);
|
||||||
|
|
||||||
|
// Return the ID of the inserted record
|
||||||
|
return $this->db->insertID();
|
||||||
|
}
|
||||||
|
public function getAllActiveBooks() {
|
||||||
|
// Fetch active books from the database
|
||||||
|
$query = $this->db->table('books')
|
||||||
|
->where('isactive', 1)
|
||||||
|
->get(); // No need to pass 'books' again here
|
||||||
|
return $query->getResult(); // Use getResult() instead of result()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,13 +206,11 @@ public function getSubscriptionInvoiceDetail($where)
|
|||||||
->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_id=invoice.customer_id and A.address_type=1','left')
|
|
||||||
->join('states', 'states.state_short_name = A.state AND A.country = "IN"', '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 as customer_mobile')
|
||||||
->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,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('concat(A.address_1," ", A.address_2) as customer_bill_address,A.postal_code as customer_bill_postal_code ,A.city as customer_bill_city, countries.country_name as customer_bill_country')
|
// ->select(' customer_bill_country')
|
||||||
->get()
|
->get()
|
||||||
->getResult();
|
->getResult();
|
||||||
|
|
||||||
@ -506,6 +504,48 @@ public function itemwise_report_data_with_publish_code($f_date = null, $t_date =
|
|||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
public function updateInvoiceStatus($invoiceId, $voidReason)
|
||||||
|
{
|
||||||
|
// Assuming 'invoices' is the name of your table
|
||||||
|
$builder = $this->db->table('invoice');
|
||||||
|
|
||||||
|
// Define the data to be updated
|
||||||
|
$data = [
|
||||||
|
'status' => 'Void', // Set the status to 'Void'
|
||||||
|
'reason' => $voidReason, // Set the void reason
|
||||||
|
// You can add more fields to update here if needed
|
||||||
|
];
|
||||||
|
|
||||||
|
// Set the where condition to identify the invoice by its ID
|
||||||
|
$builder->where('invoice_id', $invoiceId);
|
||||||
|
|
||||||
|
// Perform the update and check if successful
|
||||||
|
$updated = $builder->update($data);
|
||||||
|
|
||||||
|
return $updated;
|
||||||
|
}
|
||||||
|
public function updateInvoiceCancelStatus($invoiceIds, $cancelReason)
|
||||||
|
{
|
||||||
|
// Assuming 'invoices' is the name of your table
|
||||||
|
$builder = $this->db->table('invoice');
|
||||||
|
|
||||||
|
// Define the data to be updated
|
||||||
|
$data = [
|
||||||
|
'status' => 'Cancelled', // Set the status to 'Canceled'
|
||||||
|
'reason' => $cancelReason, // Set the cancel reason
|
||||||
|
// You can add more fields to update here if needed
|
||||||
|
];
|
||||||
|
|
||||||
|
// Set the where condition to identify the invoices by their IDs
|
||||||
|
$builder->where('invoice_id', $invoiceIds);
|
||||||
|
|
||||||
|
// Perform the update and check if successful
|
||||||
|
$updated = $builder->update($data);
|
||||||
|
|
||||||
|
return $updated;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -51,10 +51,8 @@
|
|||||||
<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>
|
<?= $value->shipping_address ?><br>
|
||||||
<?= $value->customer_bill_city ?> <?= $value->customer_bill_state ? $value->customer_bill_state : "" ?>
|
|
||||||
<?= $value->customer_bill_postal_code ? " - ".$value->customer_bill_postal_code :""; ?>
|
|
||||||
<?= $value->customer_bill_country." ." ?>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
|
|||||||
@ -84,16 +84,15 @@
|
|||||||
<input type="text" class="form-control" id="invoiceNumber" name="invoice_number" value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
|
<input type="text" class="form-control" id="invoiceNumber" name="invoice_number" value="<?= isset($invoice_details['invoice_number']) ? $invoice_details['invoice_number'] : '' ?>">
|
||||||
<input type="hidden" id="hiddenNextId" name="next_id" placeholder="hidden for next id" />
|
<input type="hidden" id="hiddenNextId" name="next_id" placeholder="hidden for next id" />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group col-md-6">
|
|
||||||
<label for="orderNumber">Order Number</label>
|
|
||||||
<input type="text" class="form-control" id="orderNumber" name="order_number" value="<?= isset($invoice_details['order_number']) ? $invoice_details['order_number'] : '' ?>">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="invoiceDate">Invoice Date<span class="text-danger"> *</span></label>
|
<label for="invoiceDate">Invoice Date<span class="text-danger"> *</span></label>
|
||||||
<input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required>
|
<input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : date('Y-m-d') ?>" max="<?= date('Y-m-d'); ?>" required>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- <div class="form-group col-md-4">
|
||||||
|
<label for="invoiceDate">Invoice Date<span class="text-danger"> *</span></label>
|
||||||
|
<input type="date" class="form-control" id="invoiceDate" name="invoice_date" value="<?= isset($invoice_details['invoice_date']) ? $invoice_details['invoice_date'] : '' ?>" max="<?= date('Y-m-d'); ?>" required>
|
||||||
|
</div> -->
|
||||||
<?php if ($invoice_type === '2') : ?>
|
<?php if ($invoice_type === '2') : ?>
|
||||||
<div class="form-group col-md-4">
|
<div class="form-group col-md-4">
|
||||||
<label for="fromsubcription">From Subscription<span class="text-danger"> *</span></label>
|
<label for="fromsubcription">From Subscription<span class="text-danger"> *</span></label>
|
||||||
@ -105,10 +104,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-row">
|
<div class="form-row" id="itemTableContainer">
|
||||||
<div class="form-group col-md-12">
|
<div class="form-group col-md-12">
|
||||||
<h4>Item Details</h4>
|
<h4>Item Details</h4>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<table class="table table-bordered" id="itemTable">
|
<table class="table table-bordered" id="itemTable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@ -127,8 +127,9 @@
|
|||||||
<?php if (!empty($invoice_item_details)) {
|
<?php if (!empty($invoice_item_details)) {
|
||||||
foreach ($invoice_item_details as $inx => $ii_details) : ?>
|
foreach ($invoice_item_details as $inx => $ii_details) : ?>
|
||||||
<tr>
|
<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;">
|
<td><select class="form-control book-select" id="<?= "book" . $inx; ?>bookSelect" name="item_details[]" onchange="displayBookTag(this,<?= $inx; ?>)" required data-toggle="select2" style="width: 249px !important;">
|
||||||
<option value="">Select a <?= $flag_name; ?></option>
|
<option value="">Select a <?= $flag_name; ?></option>
|
||||||
|
<option value="add_new_book">+ Add New Book</option>
|
||||||
<?php foreach ($books as $book) : ?>
|
<?php foreach ($books as $book) : ?>
|
||||||
<?php $disabled = ((int)$book->isactive == 0) ? 'disabled' : ''; ?>
|
<?php $disabled = ((int)$book->isactive == 0) ? 'disabled' : ''; ?>
|
||||||
<option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?> <?= $disabled; ?>>
|
<option value="<?= $book->book_id ?>" <?php if (isset($ii_details['product']) && ($ii_details['product'] === $book->book_id)) echo "selected"; ?> <?= $disabled; ?>>
|
||||||
@ -168,6 +169,7 @@
|
|||||||
<td style="width:30% !important;">
|
<td style="width:30% !important;">
|
||||||
<select class="form-control book-select" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required data-toggle="select2" style="width: 249px !important;">
|
<select class="form-control book-select" id="book0" name="item_details[]" onchange="displayBookTag(this,0)" required data-toggle="select2" style="width: 249px !important;">
|
||||||
<option value="">Select a <?= $flag_name ?></option>
|
<option value="">Select a <?= $flag_name ?></option>
|
||||||
|
<option value="add_new_book">+ Add New Book</option>
|
||||||
<?php
|
<?php
|
||||||
foreach ($books as $book) :
|
foreach ($books as $book) :
|
||||||
if ((int)$book->isactive === 1) : ?>
|
if ((int)$book->isactive === 1) : ?>
|
||||||
@ -366,14 +368,19 @@
|
|||||||
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : 'Draft' ?>">
|
<input type="hidden" id="status" name="status" value="<?= isset($invoice_details['status']) ? $invoice_details['status'] : 'Draft' ?>">
|
||||||
<input type="hidden" id="hiddenInvoiceId" name="invoice_id" placeholder="hidden for invoice id" value="<?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>" />
|
<input type="hidden" id="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">
|
<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') : ?>
|
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
||||||
<!-- Show the "Save as Draft" button only if the status is not "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="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 endif; ?>
|
||||||
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
<?php if (!isset($invoice_details['status']) || $invoice_details['status'] !== 'Approved') : ?>
|
||||||
<!-- Show the "Save as Approved" button only if the status is not "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>
|
<button type="button" class="btn btn-primary waves-effect mr-1" name="saveas" value="Approved" id="saveApprovedButton">Save as Approved</button>
|
||||||
<?php endif; ?>
|
<?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'; ?>">
|
<input type="hidden" name="invoice_type" value="<?php echo ($page_name === 'Add Subscription Invoice Details' || $page_name === 'Edit Subscription Invoice Details') ? '2' : '1'; ?>">
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -381,11 +388,113 @@
|
|||||||
</div>
|
</div>
|
||||||
</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..."></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="submitVoidReason">Submit</button>
|
||||||
|
</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</label>
|
||||||
|
<input type="text" class="form-control" id="bookName" name="bookName" required>
|
||||||
|
</div>
|
||||||
|
<div class="form-group col-md-6">
|
||||||
|
<label for="bookPrice">Price</label>
|
||||||
|
<input type="number" class="form-control" id="bookPrice" name="bookPrice" required>
|
||||||
|
</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<span class="text-danger"> *</span></label>
|
||||||
|
<input type="text" class="form-control" id="isbn_code" name="isbn_code" placeholder="ISBN Code" required />
|
||||||
|
<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<span class="text-danger"> *</span></label>
|
||||||
|
<input type="text" class="form-control" id="publisher" name="publisher" placeholder="Publisher Name" value="<?= isset($details['publisher']) ? $details['publisher'] : '' ?>" required />
|
||||||
|
<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</label>
|
||||||
|
<input type="text" class="form-control" id="publishers_code" name="publishers_code" placeholder="Publisher Code" />
|
||||||
|
</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>
|
||||||
|
var bookData=<?php echo json_encode($books); ?>;
|
||||||
|
|
||||||
document.getElementById("addItem").addEventListener("click", function() {
|
document.getElementById("addItem").addEventListener("click", function() {
|
||||||
var bookArray = <?php echo json_encode($books); ?>;
|
var bookArray = bookData;
|
||||||
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
var table = document.getElementById("itemTable").getElementsByTagName("tbody")[0];
|
||||||
var counter = table.rows.length;
|
var counter = table.rows.length;
|
||||||
var newRow = table.insertRow(table.rows.length);
|
var newRow = table.insertRow(table.rows.length);
|
||||||
@ -401,6 +510,7 @@
|
|||||||
|
|
||||||
cell1.innerHTML = `<select class="form-control book-select" id="book${counter}" name="item_details[]" onchange="displayBookTag(this, ${counter})" data-toggle="select2" required>
|
cell1.innerHTML = `<select class="form-control book-select" id="book${counter}" name="item_details[]" onchange="displayBookTag(this, ${counter})" data-toggle="select2" required>
|
||||||
<option value=""><?= "Select a ".$flag_name ?></option>
|
<option value=""><?= "Select a ".$flag_name ?></option>
|
||||||
|
<option value="add_new_book">+ Add New Book</option>
|
||||||
<?php foreach ($books as $book) : if ((int)$book->isactive === 1) : ?>
|
<?php foreach ($books as $book) : if ((int)$book->isactive === 1) : ?>
|
||||||
<option value="<?= $book->book_id ?>"><?= $book->title ?></option>
|
<option value="<?= $book->book_id ?>"><?= $book->title ?></option>
|
||||||
<?php endif; endforeach; ?>
|
<?php endif; endforeach; ?>
|
||||||
@ -415,6 +525,7 @@
|
|||||||
cell7.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
|
cell7.innerHTML = '<select class="form-control item-discount-type" style=""width:12%;" id="item_discount_type' + counter + '" name="discount_type[]" oninput="calculateInvoice(this,' + counter + ')"><option value="₹">₹</option><option value="%">%</option></select>';
|
||||||
cell8.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
|
cell8.innerHTML = '<input type="hidden" class="form-control" id="hiddenInvoiceChildId' + counter + '" placeholder="hidden for invoice child/item id" name="invoice_child_id[]" value=""><center><i class="fa fa-trash remove-item "></center>';
|
||||||
$(newRow.querySelector('.book-select')).select2();
|
$(newRow.querySelector('.book-select')).select2();
|
||||||
|
localStorage.setItem('add_book_index', counter);
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -422,16 +533,35 @@
|
|||||||
function displayBookTag(inputElement, counter) {
|
function displayBookTag(inputElement, counter) {
|
||||||
var row = inputElement.parentElement.parentElement;
|
var row = inputElement.parentElement.parentElement;
|
||||||
var bookId = inputElement.value;
|
var bookId = inputElement.value;
|
||||||
var bookArray = <?php echo json_encode($books); ?>;
|
|
||||||
|
|
||||||
const selectedBook = bookArray.find(book => book.book_id == bookId);
|
// Check if the selected option is "add_new_book"
|
||||||
|
if (bookId === "add_new_book") {
|
||||||
|
// Open the modal dialog for adding a new book
|
||||||
|
$('#addBookModal').modal('show');
|
||||||
|
// Reset the select back to its default value
|
||||||
|
$(inputElement).val('');
|
||||||
|
} else {
|
||||||
|
// Get the selected book details
|
||||||
|
var selectedBook = bookData.find(book => book.book_id == bookId);
|
||||||
|
|
||||||
|
if (selectedBook) {
|
||||||
|
// Update the fields in the current row with book details
|
||||||
row.querySelector('#quantity' + counter).value = 1;
|
row.querySelector('#quantity' + counter).value = 1;
|
||||||
row.querySelector('#rate' + counter).value = selectedBook.price;
|
row.querySelector('#rate' + counter).value = selectedBook.price;
|
||||||
row.querySelector('#rate' + counter).readOnly = true;
|
row.querySelector('#rate' + counter).readOnly = true;
|
||||||
row.querySelector("#tax" + counter).value = selectedBook.tax ? selectedBook.tax : 0;
|
row.querySelector("#tax" + counter).value = selectedBook.tax ? selectedBook.tax : 0;
|
||||||
row.querySelector("#tax" + counter).readOnly = true;
|
row.querySelector("#tax" + counter).readOnly = true;
|
||||||
calculateInvoice(inputElement, counter);
|
calculateInvoice(inputElement, counter);
|
||||||
|
} else {
|
||||||
|
console.log(bookData);
|
||||||
|
// Handle case where selectedBook is undefined
|
||||||
|
console.log("Book ID:", bookId); // Check the extracted book ID
|
||||||
|
console.log("Book Array:", bookData);
|
||||||
|
console.error("Selected book not found!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function calculateInvoice(inputElement, counter) {
|
function calculateInvoice(inputElement, counter) {
|
||||||
var row = inputElement.parentElement.parentElement;
|
var row = inputElement.parentElement.parentElement;
|
||||||
@ -1097,3 +1227,196 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
// JavaScript code to handle form submission and AJAX request
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#addBookForm').submit(function(e) {
|
||||||
|
e.preventDefault(); // Prevent default form submission
|
||||||
|
|
||||||
|
// Serialize form data
|
||||||
|
var formData = $(this).serialize();
|
||||||
|
|
||||||
|
// Send AJAX request to save the book
|
||||||
|
$.ajax({
|
||||||
|
url: '<?php echo base_url("saveBook"); ?>', // URL to your controller function
|
||||||
|
type: 'POST',
|
||||||
|
data: formData,
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
console.log("Response:", response); // Log the response object
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
// Book saved successfully
|
||||||
|
alert(response.message);
|
||||||
|
$('#addBookModal').modal('hide');
|
||||||
|
$('#addBookForm')[0].reset();
|
||||||
|
// Append the new book to the bookData array
|
||||||
|
var newBook = {
|
||||||
|
book_id: response.book_id,
|
||||||
|
title: response.title,
|
||||||
|
price: response.price,
|
||||||
|
tax: response.tax
|
||||||
|
// Add other properties as needed
|
||||||
|
};
|
||||||
|
bookData.push(newBook);
|
||||||
|
|
||||||
|
console.log("Updated bookData:", bookData); // Log the updated bookData array
|
||||||
|
|
||||||
|
// Retrieve the index from localStorage
|
||||||
|
var addBookIndex = localStorage.getItem('add_book_index');
|
||||||
|
|
||||||
|
// Reload only the dropdown at the specified index
|
||||||
|
var dropdown = $('#itemTable tbody tr:eq(' + addBookIndex + ')').find('.book-select');
|
||||||
|
dropdown.empty(); // Clear existing options
|
||||||
|
// Add default and new book options
|
||||||
|
dropdown.append('<option value="">Select a <?= $flag_name ?></option><option value="add_new_book">+ Add New Book</option>');
|
||||||
|
bookData.forEach(function(book) {
|
||||||
|
dropdown.append('<option value="' + book.book_id + '">' + book.title + '</option>');
|
||||||
|
});
|
||||||
|
dropdown.select2(); // Reinitialize select2
|
||||||
|
|
||||||
|
// Select the newly added book in the dropdown
|
||||||
|
dropdown.val(response.book_id).trigger('change');
|
||||||
|
} else {
|
||||||
|
// Failed to save book
|
||||||
|
alert(response.message);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
// JavaScript code to handle voiding invoice and submitting reason
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Handle clicking on the "Void" button
|
||||||
|
$('#voidButton').click(function() {
|
||||||
|
var invoiceId = <?= isset($invoice_details['invoice_id']) ? $invoice_details['invoice_id'] : '' ?>; // Get the invoice_id
|
||||||
|
$('#voidReasonModal').modal('show');
|
||||||
|
$('#voidReasonModal').find('#voidReason').data('invoiceId', invoiceId); // Set the invoice_id in the modal
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle submitting void reason
|
||||||
|
$('#submitVoidReason').click(function() {
|
||||||
|
var voidReason = $('#voidReason').val();
|
||||||
|
var invoiceId = $('#voidReason').data('invoiceId'); // Get the invoice_id from the modal
|
||||||
|
|
||||||
|
// Perform AJAX request to update status and reason
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '<?php echo base_url("updateInvoiceStatus"); ?>', // Adjust the URL to match your controller route
|
||||||
|
data: {
|
||||||
|
invoice_id: invoiceId,
|
||||||
|
void_reason: voidReason
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
window.location.href = "<?php echo base_url('offline_invoice'); ?>";
|
||||||
|
// Handle success response
|
||||||
|
// For example, close modal and show success message
|
||||||
|
$('#voidReasonModal').modal('hide');
|
||||||
|
// alert('Invoice voided successfully!');
|
||||||
|
// You may want to refresh the page or update the UI accordingly
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Handle error response
|
||||||
|
console.error(error);
|
||||||
|
alert('Error occurred while voiding invoice.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
// JavaScript code to handle voiding invoice and submitting reason
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Handle clicking on the "Cancel" button
|
||||||
|
$('#cancelButton').click(function() {
|
||||||
|
var invoiceIds = <?= isset($invoice_details['invoice_id']) ? json_encode($invoice_details['invoice_id']) : '' ?>; // Get the invoice_id(s)
|
||||||
|
$('#cancelReasonModal').modal('show');
|
||||||
|
$('#cancelReasonModal').find('#cancelReason').data('invoiceIds', invoiceIds); // Set the invoice_id(s) in the modal
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle submitting cancel reason
|
||||||
|
$('#submitCancelReason').click(function() {
|
||||||
|
var cancelReason = $('#cancelReason').val();
|
||||||
|
var invoiceIds = $('#cancelReason').data('invoiceIds'); // Get the invoice_id(s) from the modal
|
||||||
|
|
||||||
|
// Perform AJAX request to update status and reason
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
url: '<?php echo base_url("updateInvoiceCancelStatus"); ?>', // Adjust the URL to match your controller route
|
||||||
|
data: {
|
||||||
|
invoice_id: invoiceIds,
|
||||||
|
cancel_reason: cancelReason
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
// Redirect to the invoice_list page upon successful cancellation
|
||||||
|
window.location.href = "<?php echo base_url('offline_invoice'); ?>";
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
// Handle error response
|
||||||
|
console.error(error);
|
||||||
|
alert('Error occurred while canceling invoice.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
var status = "<?php echo isset($invoice_details['status']) ? $invoice_details['status'] : ''; ?>";
|
||||||
|
|
||||||
|
// Function to hide all buttons
|
||||||
|
function hideAllButtons() {
|
||||||
|
$('#cancelButton, #saveDraftButton, #voidButton, #saveApprovedButton').hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function to show buttons based on status
|
||||||
|
function showButtonsBasedOnStatus(status) {
|
||||||
|
hideAllButtons(); // Hide all buttons first
|
||||||
|
|
||||||
|
if (status === '') {
|
||||||
|
// Case 1: When status is empty, show Draft and Approved buttons
|
||||||
|
$('#saveDraftButton, #saveApprovedButton').show();
|
||||||
|
} else if (status === 'Draft') {
|
||||||
|
// Case 2: When status is Draft, show Void, Draft, and Approved buttons
|
||||||
|
$('#voidButton, #saveDraftButton, #saveApprovedButton').show();
|
||||||
|
} else if (status === 'Approved') {
|
||||||
|
// Case 3: When status is Approved, show Cancel button only
|
||||||
|
$('#cancelButton').show();
|
||||||
|
} else if (status === 'Cancelled' || status === 'Void') {
|
||||||
|
// Case 4 and 5: When status is Cancelled or Void, hide all buttons
|
||||||
|
hideAllButtons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initial call to show buttons based on the initial status
|
||||||
|
showButtonsBasedOnStatus(status);
|
||||||
|
|
||||||
|
// Handling button clicks can be done similarly as in the previous example
|
||||||
|
// Handle click on the "Cancel" button
|
||||||
|
$('#cancelButton').click(function() {
|
||||||
|
console.log('Cancel button clicked');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle click on the "Save as Draft" button
|
||||||
|
$('#saveDraftButton').click(function() {
|
||||||
|
console.log('Save as Draft button clicked');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle click on the "Void" button
|
||||||
|
$('#voidButton').click(function() {
|
||||||
|
console.log('Void button clicked');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Handle click on the "Save as Approved" button
|
||||||
|
$('#saveApprovedButton').click(function() {
|
||||||
|
console.log('Save as Approved button clicked');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@ -1,35 +1,36 @@
|
|||||||
|
<style>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
/* CSS for modal content */
|
||||||
|
#pdfPreviewModal .modal-dialog {
|
||||||
|
max-width: 210mm; /* A5 width */
|
||||||
|
width: auto;
|
||||||
|
margin: 1.75rem auto;
|
||||||
|
}
|
||||||
|
#pdfPreviewModal .modal-body {
|
||||||
|
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.table-responsive{
|
||||||
|
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#printPdfButton .ri-printer-line {
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
|
.modal-lg, .modal-xl {
|
||||||
|
max-width: 678px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
<a href="<?= base_url() . "new_book_invoice/0"; ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Invoice </a>
|
|
||||||
</div>
|
|
||||||
<!-- 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>
|
||||||
<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>
|
|
||||||
</div>
|
|
||||||
</div> -->
|
|
||||||
<br>
|
<br>
|
||||||
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||||
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||||
@ -55,7 +56,7 @@
|
|||||||
<thead class="thead-light">
|
<thead class="thead-light">
|
||||||
<tr>
|
<tr>
|
||||||
<th hidden></th>
|
<th hidden></th>
|
||||||
<th>Invoice Number</th>
|
<th>Order Number</th>
|
||||||
<th>Invoice Date</th>
|
<th>Invoice Date</th>
|
||||||
<th>Customer Name</th>
|
<th>Customer Name</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
@ -65,29 +66,29 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($invoice as $row) :
|
<?php foreach ($invoice as $row) :
|
||||||
if ($row['invoice_type'] == 1) : // Check if it's a subscription invoice
|
if (!empty($row['order_number']) && $row['invoice_type'] == 1) :
|
||||||
$invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
|
$invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td hidden><?= $row['invoice_id']; ?></td>
|
<td hidden><?= $row['invoice_id']; ?></td>
|
||||||
<td><?= $row['invoice_number']; ?></td>
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['order_number']; ?></td>
|
||||||
<td><?= $invoice_date; ?></td>
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $invoice_date; ?></td>
|
||||||
<td><?= $row['customer_name']; ?></td>
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['customer_name']; ?></td>
|
||||||
<td><?= $row['status']; ?></td>
|
<td class="preview-pdf" id="status-column" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['status']; ?></td>
|
||||||
<td><?= "₹ ".$row['total_amount']; ?></td>
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= "₹ " . $row['total_amount']; ?></td>
|
||||||
<td>
|
<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> -->
|
|
||||||
<?php if ($row['invoice_type'] == 2) : ?>
|
<?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 Subscription"></i></a>
|
<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>
|
||||||
<?php elseif ($row['invoice_type'] == 1) : ?>
|
<?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>
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>
|
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>
|
||||||
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>
|
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endif; endforeach; ?>
|
<?php endif;
|
||||||
|
endforeach; ?>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@ -95,11 +96,55 @@
|
|||||||
</div> <!-- end card -->
|
</div> <!-- end card -->
|
||||||
</div><!-- end col-->
|
</div><!-- end col-->
|
||||||
</div><!-- end row-->
|
</div><!-- end row-->
|
||||||
<script>
|
|
||||||
function openPdfInNewTab(pdfUrl) {
|
<!-- Modal for selecting invoice type -->
|
||||||
window.open(pdfUrl, '_blank');
|
<div id="invoiceTypeModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||||
}
|
<div class="modal-dialog modal-sm">
|
||||||
</script>
|
<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" class="btn btn-primary">Continue</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal fade" id="pdfPreviewModal" tabindex="-1" role="dialog" aria-labelledby="pdfPreviewModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="pdfPreviewModalLabel"></h5>
|
||||||
|
<!-- Placeholder for status -->
|
||||||
|
<a href="#" class="" id="downloadPdfButton" title="Invoice PDF" style="font-size: large;"><i class="ri-file-download-line"></i> </a>
|
||||||
|
<a href="#" class="ri-printer-line" id="printPdfButton" title="Print Invoice" style="font-size: large; margin-left: 8px;"></a>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
|
||||||
|
<span id="statusText"></span>
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="modal-body">
|
||||||
|
|
||||||
|
<!-- PDF content will be loaded here -->
|
||||||
|
</div>
|
||||||
|
<!-- <div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$("#addNewButton").click(function() {
|
$("#addNewButton").click(function() {
|
||||||
@ -137,3 +182,70 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '.preview-pdf', function() {
|
||||||
|
var invoiceId = $(this).data('invoice-id');
|
||||||
|
|
||||||
|
// Send AJAX request to controller
|
||||||
|
$.ajax({
|
||||||
|
url: '<?= base_url('generate_invoice_pdf_preview/') ?>' + invoiceId,
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'html',
|
||||||
|
success: function(response) {
|
||||||
|
// Display the PDF content in a modal or an iframe
|
||||||
|
$('#pdfPreviewModal .modal-body').html(response);
|
||||||
|
$('#downloadPdfButton').attr('href', '<?= base_url("generate_invoice_pdf/") ?>' + invoiceId);
|
||||||
|
|
||||||
|
// Get the status text
|
||||||
|
var status = $('.preview-pdf[data-invoice-id="' + invoiceId + '"]').closest('tr').find('#status-column').text().trim();
|
||||||
|
|
||||||
|
// Update the status in the modal header
|
||||||
|
$('#statusText').text('' + status);
|
||||||
|
|
||||||
|
// Hide the "Edit" button if the status is approved
|
||||||
|
if (status.toLowerCase() === 'approved') {
|
||||||
|
$('#editInvoiceButton').hide();
|
||||||
|
} else {
|
||||||
|
$('#editInvoiceButton').show();
|
||||||
|
$('#editInvoiceButton').attr('href', '<?= base_url("new_book_invoice/") ?>' + invoiceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#pdfPreviewModal').modal('show');
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(error);
|
||||||
|
alert('Failed to load PDF preview.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
// JavaScript click event handler for printing PDF
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(document).on('click', '#printPdfButton', function() {
|
||||||
|
// Get the modal body content
|
||||||
|
var printableContent = $('#pdfPreviewModal .modal-body').html();
|
||||||
|
|
||||||
|
// Modify the font size of the content
|
||||||
|
var modifiedContent = '<html><head><title>Print Preview</title><style>body { font-size: 8px; }</style></head><body>' + printableContent + '</body></html>';
|
||||||
|
|
||||||
|
// Create a new window for printing
|
||||||
|
var printWindow = window.open('', '_blank');
|
||||||
|
|
||||||
|
// Write the modified content to the new window
|
||||||
|
printWindow.document.open();
|
||||||
|
printWindow.document.write(modifiedContent);
|
||||||
|
printWindow.document.close();
|
||||||
|
|
||||||
|
// Wait for content to load before printing
|
||||||
|
printWindow.onload = function() {
|
||||||
|
printWindow.focus(); // Focus the new window
|
||||||
|
printWindow.print(); // Print the content
|
||||||
|
printWindow.close(); // Close the window after printing
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
table.main-table {
|
table.main-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
border: 1px solid black; /* Add a border around the entire invoice */
|
border: -0.5px solid black; /* Add a border around the entire invoice */
|
||||||
}
|
}
|
||||||
|
|
||||||
table.main-table th,
|
table.main-table th,
|
||||||
@ -128,6 +128,10 @@ td.invoice-number {
|
|||||||
font-size: 18px; /* Increase font size to your desired value */
|
font-size: 18px; /* Increase font size to your desired value */
|
||||||
/* Highlight background color */
|
/* Highlight background color */
|
||||||
font-weight: bold; /* Make the text bold */
|
font-weight: bold; /* Make the text bold */
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
@ -148,7 +152,7 @@ td.invoice-number {
|
|||||||
<p><?= $value->company_address ?>,<br>
|
<p><?= $value->company_address ?>,<br>
|
||||||
<?= $value->company_city ?>,
|
<?= $value->company_city ?>,
|
||||||
<?= $value->company_state ?>
|
<?= $value->company_state ?>
|
||||||
<?= $value->company_postal_code ? " - ".$value->company_postal_code:"" ?>.</p><br>
|
<?= $value->company_postal_code ? " - ".$value->company_postal_code:"" ?>.</p>
|
||||||
<p><?= $value->company_email ?></p>
|
<p><?= $value->company_email ?></p>
|
||||||
<p><?= $value->company_mobile_no ?></p>
|
<p><?= $value->company_mobile_no ?></p>
|
||||||
</td>
|
</td>
|
||||||
@ -160,14 +164,12 @@ td.invoice-number {
|
|||||||
<table class="invoice-info-table">
|
<table class="invoice-info-table">
|
||||||
<?php foreach ($data as $value) : ?>
|
<?php foreach ($data as $value) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Invoice # <?= $value->invoice_number ?></th>
|
<th><?php echo ($value->order_number) ? 'Order # ' . $value->order_number : 'Invoice # ' . $value->invoice_number; ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Invoice Date : <?= $value->formatted_invoice_date ?></th>
|
<th>Invoice Date : <?= $value->formatted_invoice_date ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<th>Order Number : <?= $value->order_number ? $value->order_number : "-" ?></th>
|
|
||||||
</tr>
|
|
||||||
<?php if ($value->due_date) : ?>
|
<?php if ($value->due_date) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Due Date : <?= $value->formatted_due_date ?></th>
|
<th>Due Date : <?= $value->formatted_due_date ?></th>
|
||||||
@ -290,10 +292,10 @@ td.invoice-number {
|
|||||||
<!-- ... (your existing HTML template) -->
|
<!-- ... (your existing HTML template) -->
|
||||||
|
|
||||||
<!-- Add this to the end of your HTML template -->
|
<!-- Add this to the end of your HTML template -->
|
||||||
<div class="footer">
|
|
||||||
|
|
||||||
<!-- <img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png" /> -->
|
<!-- <img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png" /> -->
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
278
app/Views/offline_invoice_list.php
Normal file
278
app/Views/offline_invoice_list.php
Normal file
@ -0,0 +1,278 @@
|
|||||||
|
<style>
|
||||||
|
<style>
|
||||||
|
/* CSS for modal content */
|
||||||
|
#pdfPreviewModal .modal-dialog {
|
||||||
|
max-width: 210mm; /* A5 width */
|
||||||
|
width: auto;
|
||||||
|
margin: 1.75rem auto;
|
||||||
|
}
|
||||||
|
#pdfPreviewModal .modal-body {
|
||||||
|
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
.table-responsive{
|
||||||
|
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#printPdfButton .ri-printer-line {
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
|
.modal-lg, .modal-xl {
|
||||||
|
max-width: 678px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<!-- /* CSS for modal content */
|
||||||
|
#pdfPreviewModal .modal-body {
|
||||||
|
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
font-size:12px;
|
||||||
|
}
|
||||||
|
.table-responsive{
|
||||||
|
font-family: 'Apple System', 'BlinkMacSystemFont', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
||||||
|
font-size:12px;
|
||||||
|
}
|
||||||
|
#printPdfButton .ri-printer-line {
|
||||||
|
font-size: 8px;
|
||||||
|
}
|
||||||
|
</style> -->
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="float-right">
|
||||||
|
<a href="<?= base_url() . "new_book_invoice/0"; ?>" class="btn btn-primary"><i class="ri-currency-line"></i> Add Invoice </a>
|
||||||
|
</div>
|
||||||
|
<!-- 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>
|
||||||
|
</div>
|
||||||
|
</div> -->
|
||||||
|
<br>
|
||||||
|
<h4 class="header-title mb-3"><?= $page_name; ?></h4>
|
||||||
|
<?php if (session()->getFlashdata('success') || session()->getFlashdata('error')) : ?>
|
||||||
|
<?php if (session()->getFlashdata('success')) : ?>
|
||||||
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
||||||
|
<?= session('success') ?>
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (session()->getFlashdata('error')) : ?>
|
||||||
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
||||||
|
<?= session('error') ?>
|
||||||
|
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="scroll-horizontal-datatable_wrapper" class="table w-100 nowrap">
|
||||||
|
<thead class="thead-light">
|
||||||
|
<tr>
|
||||||
|
<th hidden></th>
|
||||||
|
<th>Invoice Number</th>
|
||||||
|
<th>Invoice Date</th>
|
||||||
|
<th>Customer Name</th>
|
||||||
|
<th>Status</th>
|
||||||
|
<th>Total</th>
|
||||||
|
<th align="center">Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php foreach ($invoice as $row) :
|
||||||
|
if ($row['invoice_type'] == 1) : // Check if it's a subscription invoice
|
||||||
|
$invoice_date = date('d/m/Y', strtotime($row['invoice_date']));
|
||||||
|
?>
|
||||||
|
<?php if (empty($row['order_number'])) : // Check if order_number is empty ?>
|
||||||
|
<tr>
|
||||||
|
<td hidden><?= $row['invoice_id']; ?></td>
|
||||||
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['invoice_number']; ?></td>
|
||||||
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $invoice_date; ?></td>
|
||||||
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['customer_name']; ?></td>
|
||||||
|
<td class="preview-pdf" id="status-column" data-invoice-id="<?= $row['invoice_id']; ?>"><?= $row['status']; ?></td>
|
||||||
|
<td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>"><?= "₹ ".$row['total_amount']; ?></td>
|
||||||
|
<!-- Add a class to each td -->
|
||||||
|
<!-- <td class="preview-pdf" data-invoice-id="<?= $row['invoice_id']; ?>">Preview</td> -->
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<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> -->
|
||||||
|
<?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 Subscription"></i></a>
|
||||||
|
<?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>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<a href="<?= base_url("generate_invoice_pdf/{$row['invoice_id']}") ?>" class="download-pdf-button" title="Download the Invoice"><i class="ri-file-download-line"></i></a>
|
||||||
|
<a href="<?= base_url("print_address/{$row['invoice_id']}") ?>" class="print-address-button" title="Print Address"><i class="ri-printer-line"></i></a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endif; endforeach; ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div> <!-- end card body-->
|
||||||
|
</div> <!-- end card -->
|
||||||
|
</div><!-- end col-->
|
||||||
|
</div><!-- end row-->
|
||||||
|
<!-- PDF Preview Modal -->
|
||||||
|
<!-- PDF Preview Modal -->
|
||||||
|
<div class="modal fade" id="pdfPreviewModal" tabindex="-1" role="dialog" aria-labelledby="pdfPreviewModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<a href="#" class="" id="downloadPdfButton" title="Invoice PDF" style="font-size: large;"><i class="ri-file-download-line"></i> </a>
|
||||||
|
<a href="#" class="" id="editInvoiceButton" title="Edit Invoice"style="font-size: large;margin-left: 8px;"><i class="ri-pencil-line"></i> </a>
|
||||||
|
<a href="#" class="ri-printer-line" id="printPdfButton" title="Print Invoice"style="font-size: large;margin-left: 8px;"></a>
|
||||||
|
<h5 class="modal-title" id="pdfPreviewModalLabel"></h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"style="font-size: 27px;
|
||||||
|
margin-bottom: 2px;">
|
||||||
|
<span id="statusText"></span>
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<!-- PDF content will be loaded here -->
|
||||||
|
</div>
|
||||||
|
<!-- <div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
||||||
|
|
||||||
|
</div> -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
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>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#scroll-horizontal-datatable_wrapper').DataTable({
|
||||||
|
"order": [
|
||||||
|
[0, "desc"]
|
||||||
|
] // 4 is the column index of "created_on" in your table
|
||||||
|
// Other DataTables configuration options
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
|
||||||
|
$(document).on('click', '.preview-pdf', function() {
|
||||||
|
var invoiceId = $(this).data('invoice-id');
|
||||||
|
|
||||||
|
// Send AJAX request to controller
|
||||||
|
$.ajax({
|
||||||
|
url: '<?= base_url('generate_invoice_pdf_preview/') ?>' + invoiceId,
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'html',
|
||||||
|
success: function(response) {
|
||||||
|
// Display the PDF content in a modal or an iframe
|
||||||
|
$('#pdfPreviewModal .modal-body').html(response);
|
||||||
|
$('#downloadPdfButton').attr('href', '<?= base_url("generate_invoice_pdf/") ?>' + invoiceId);
|
||||||
|
|
||||||
|
// Get the status text
|
||||||
|
var status = $('.preview-pdf[data-invoice-id="' + invoiceId + '"]').closest('tr').find('#status-column').text().trim();
|
||||||
|
|
||||||
|
// Update the status in the modal header
|
||||||
|
$('#statusText').text('' + status);
|
||||||
|
|
||||||
|
// Hide the "Edit" button if the status is approved
|
||||||
|
if (status.toLowerCase() === 'approved') {
|
||||||
|
$('#editInvoiceButton').hide();
|
||||||
|
} else {
|
||||||
|
$('#editInvoiceButton').show();
|
||||||
|
$('#editInvoiceButton').attr('href', '<?= base_url("new_book_invoice/") ?>' + invoiceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('#pdfPreviewModal').modal('show');
|
||||||
|
},
|
||||||
|
error: function(xhr, status, error) {
|
||||||
|
console.error(error);
|
||||||
|
alert('Failed to load PDF preview.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script>
|
||||||
|
// JavaScript click event handler for printing PDF
|
||||||
|
$(document).ready(function() {
|
||||||
|
$(document).on('click', '#printPdfButton', function() {
|
||||||
|
// Get the modal body content
|
||||||
|
var printableContent = $('#pdfPreviewModal .modal-body').html();
|
||||||
|
|
||||||
|
// Modify the font size of the content
|
||||||
|
var modifiedContent = '<html><head><title>Print Preview</title><style>body { font-size: 8px; }</style></head><body>' + printableContent + '</body></html>';
|
||||||
|
|
||||||
|
// Create a new window for printing
|
||||||
|
var printWindow = window.open('', '_blank');
|
||||||
|
|
||||||
|
// Write the modified content to the new window
|
||||||
|
printWindow.document.open();
|
||||||
|
printWindow.document.write(modifiedContent);
|
||||||
|
printWindow.document.close();
|
||||||
|
|
||||||
|
// Wait for content to load before printing
|
||||||
|
printWindow.onload = function() {
|
||||||
|
printWindow.focus(); // Focus the new window
|
||||||
|
printWindow.print(); // Print the content
|
||||||
|
printWindow.close(); // Close the window after printing
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
@ -53,11 +53,11 @@
|
|||||||
<div class="logo-box">
|
<div class="logo-box">
|
||||||
<a href="dashboard" class="logo logo-dark text-center">
|
<a href="dashboard" class="logo logo-dark text-center">
|
||||||
<span class="logo-sm">
|
<span class="logo-sm">
|
||||||
<img src="<?= $company_logo_small; ?>" alt="<?= $company_short_name; ?>" height="24">
|
<img src="http://localhost/vb_book/public/uploads/vbp_1.jpg" alt="VP" height="24">
|
||||||
<!-- <span class="logo-lg-text-light">Minton</span> -->
|
<!-- <span class="logo-lg-text-light">Minton</span> -->
|
||||||
</span>
|
</span>
|
||||||
<span class="logo-lg">
|
<span class="logo-lg">
|
||||||
<img src="<?= $company_logo_large; ?>" alt="<?= $company_name; ?>" height="50">
|
<img src="https://vbp.venbait.in/vb_book/public/uploads/Vijayabharatham_withname_1.png" alt="Vijayabharatham Prasuram" height="50">
|
||||||
<!-- <img src="<?= base_url()."public/uploads/default.png" ?>" alt="<?= $company_name; ?>" height="20"> -->
|
<!-- <img src="<?= base_url()."public/uploads/default.png" ?>" alt="<?= $company_name; ?>" height="20"> -->
|
||||||
<!-- <span class="logo-lg-text-light">M</span> -->
|
<!-- <span class="logo-lg-text-light">M</span> -->
|
||||||
</span>
|
</span>
|
||||||
@ -65,11 +65,11 @@
|
|||||||
|
|
||||||
<a href="dashboard" class="logo logo-light text-center">
|
<a href="dashboard" class="logo logo-light text-center">
|
||||||
<span class="logo-sm">
|
<span class="logo-sm">
|
||||||
<img src="<?= $company_logo_small; ?>" alt="<?= $company_short_name; ?>" height="24">
|
<img src="http://localhost/vb_book/public/uploads/vbp_1.jpg" alt="VP" height="24">
|
||||||
</span>
|
</span>
|
||||||
<span class="logo-lg">
|
<span class="logo-lg">
|
||||||
<!-- <img src="<?= base_url()."public/uploads/default.png" ?>" alt="<?= $company_name; ?>" height="24"> -->
|
<!-- <img src="<?= base_url()."public/uploads/default.png" ?>" alt="<?= $company_name; ?>" height="24"> -->
|
||||||
<img src="<?= $company_logo_large; ?>" alt="<?= $company_name; ?>" height="50">
|
<img src="https://vbp.venbait.in/vb_book/public/uploads/Vijayabharatham_withname_1.png" alt="Vijayabharatham Prasuram" height="50">
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@ -133,11 +133,33 @@
|
|||||||
</li>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($loggedin_person_role !== 'sadmin') : ?>
|
<?php if ($loggedin_person_role !== 'sadmin') : ?>
|
||||||
<li>
|
<!-- <li>
|
||||||
<a href="<?= base_url()."invoice_list"; ?>">
|
<a href="<?= base_url()."invoice_list"; ?>">
|
||||||
<i class="fe-file-text"></i>
|
<i class="fe-file-text"></i>
|
||||||
<span> Sales </span>
|
<span> Sales </span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
</li> -->
|
||||||
|
<li>
|
||||||
|
<a href="#reportLayouts" data-toggle="collapse">
|
||||||
|
<i class="ri-file-chart-fill"></i>
|
||||||
|
<span> Sales </span>
|
||||||
|
<span class="menu-arrow"></span>
|
||||||
|
</a>
|
||||||
|
<div class="collapse" id="reportLayouts">
|
||||||
|
<ul class="nav-second-level">
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url()."invoice_list"; ?>">Online Sales</a>
|
||||||
|
</li>
|
||||||
|
<!-- <li>
|
||||||
|
<a href="<?= base_url()."mem_inv_rp"; ?>">Membership Invoice Report</a>
|
||||||
|
</li> -->
|
||||||
|
<li>
|
||||||
|
<a href="<?= base_url()."offline_invoice"; ?>">Offline Sales</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ($loggedin_person_role !== 'sadmin') : ?>
|
<?php if ($loggedin_person_role !== 'sadmin') : ?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user