CHANGE_ invoice preview , download , print (sales and jobcard)
This commit is contained in:
parent
7d1e8d9db1
commit
9f32a4933a
@ -81,6 +81,7 @@ $routes->get("new_sale/(:any)", "Sales::new_sale/$1");
|
||||
$routes->get("delete_sale/(:any)", "Sales::delete_sale/$1");
|
||||
$routes->post("delete_sales_product", "Sales::delete_sales_product");
|
||||
$routes->get("download_invoice/(:any)", "Sales::download_invoice/$1");
|
||||
$routes->get("preview_invoice/(:any)", "Sales::preview_invoice/$1");
|
||||
$routes->post("save_vehicle", "Sales::save_vehicle");
|
||||
$routes->post("getProducts", "Sales::getProducts");
|
||||
//end salle order//
|
||||
|
||||
@ -134,17 +134,20 @@ class Jobcard extends BaseController
|
||||
$totalAmount = ($amt_with_tax - (float)$discount) / (1 + ($totalTax/100));
|
||||
// Create single output array
|
||||
$labour_data[0] = [
|
||||
"product_name" => "Labour Cost",
|
||||
"qty" => 1,
|
||||
"name" => "Labour Cost",
|
||||
"qty" => "-",
|
||||
"per" => "-",
|
||||
"tax" => number_format($totalTax, 2),
|
||||
"custom_amount" => number_format($totalAmount, 2),
|
||||
"amount" => number_format($totalAmount, 2),
|
||||
"custom_tax" => number_format($totalTax, 2),
|
||||
"custom_total" => number_format($total, 2)
|
||||
];
|
||||
$data['job_card_products'] = array_merge($productdata, $labour_data);
|
||||
// echo json_encode($complaintdata);die;
|
||||
$html = view('invoice_pdf_template_jobcard', $data);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $html],200);
|
||||
|
||||
|
||||
|
||||
$html = view('invoice_pdf_template_jobcard', $data);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $html],200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed','code' => 500,'data' => $e],500);
|
||||
@ -195,10 +198,11 @@ class Jobcard extends BaseController
|
||||
$totalAmount = ($amt_with_tax - (float)$discount) / (1 + ($totalTax/100));
|
||||
// Create single output array
|
||||
$labour_data[0] = [
|
||||
"product_name" => "Labour Cost",
|
||||
"qty" => 1,
|
||||
"name" => "Labour Cost",
|
||||
"qty" => '-',
|
||||
"per" => '-',
|
||||
"tax" => number_format($totalTax, 2),
|
||||
"custom_amount" => number_format($totalAmount, 2),
|
||||
"amount" => number_format($totalAmount, 2),
|
||||
"custom_tax" => number_format($totalTax, 2),
|
||||
"custom_total" => number_format($total, 2)
|
||||
];
|
||||
@ -208,7 +212,7 @@ class Jobcard extends BaseController
|
||||
// Create an mPDF object
|
||||
$mpdf = new Mpdf([
|
||||
'mode' => '',
|
||||
'format' => 'A5',
|
||||
'format' => 'A4',
|
||||
'default_font_size' => 0,
|
||||
'default_font' => '',
|
||||
|
||||
|
||||
@ -12,9 +12,11 @@ use App\Models\VehicleModel;
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\BranchModel;
|
||||
use Mpdf\Mpdf;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
class Sales extends BaseController
|
||||
{
|
||||
public $session;
|
||||
use ResponseTrait;
|
||||
protected $BikemodelsModel;
|
||||
protected $BikemakeModel;
|
||||
public function __construct()
|
||||
@ -336,18 +338,18 @@ class Sales extends BaseController
|
||||
$BusinessModel = new BusinessModel();
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data = $model->getSalesPdf($sales_order_id);
|
||||
$bus_id = $this->session->get('logged_user_business_id');
|
||||
$branch = $BranchModel->where('branch_id', $data[0]->branch_id)->first();
|
||||
$business = $BusinessModel->where('business_id', $branch['business_id'])->first();
|
||||
$vehicle = $VehicleModel->where('vehicle_id',$data[0]->vehicle_id)->first();
|
||||
$bike_model = $BikemodelsModel->where('model_id',$vehicle['model'])->first();
|
||||
$bike_make = $BikemakeModel->where('make_id', $vehicle['make'])->first();
|
||||
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
|
||||
$data['sales'] = $model->getSalesPdf($sales_order_id);
|
||||
$data['branch'] = $BranchModel->where('branch_id', $data['sales'][0]->branch_id)->first();
|
||||
$data['vehicle'] = $VehicleModel->select('vehicle.reg_no,vehicle.colour,vehicle.email,vehicle.mobile_no,vehicle.year_of_manufacturing, make.make as make_name, model.model_name')
|
||||
->join('model', 'model.model_id = vehicle.model', 'left')
|
||||
->join('make', 'make.make_id = vehicle.make', 'left')
|
||||
->where('vehicle.vehicle_id', $data['sales'][0]->vehicle_id)
|
||||
->first();
|
||||
$data['items'] = $model->getSalesOrderProductsForPdf($sales_order_id);
|
||||
|
||||
$mpdf = new Mpdf([
|
||||
'mode' => '',
|
||||
'format' => 'A5',
|
||||
'format' => 'A4',
|
||||
'default_font_size' => 0,
|
||||
'default_font' => '',
|
||||
// 'margin_right' => 1,
|
||||
@ -361,35 +363,62 @@ class Sales extends BaseController
|
||||
$mpdf->autoLangToFont = true; $mpdf->autoScriptToLang = true;
|
||||
// Set PDF properties
|
||||
$mpdf->SetTitle('Invoice');
|
||||
$mpdf->SetAuthor($data[0]->branch_name);
|
||||
$mpdf->SetAuthor($data['sales'][0]->branch_name);
|
||||
$mpdf->SetCreator('');
|
||||
|
||||
// Generate the PDF content (HTML)
|
||||
if ($data[0]->status === 'Draft') {
|
||||
if ($data['sales'][0]->status === 'Draft') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Draft');
|
||||
$mpdf->showWatermarkText = true;
|
||||
}
|
||||
if ($data[0]->status === 'Cancelled') {
|
||||
if ($data['sales'][0]->status === 'Cancelled') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Cancelled');
|
||||
$mpdf->showWatermarkText = true;
|
||||
}
|
||||
if ($data[0]->status === 'Void') {
|
||||
if ($data['sales'][0]->status === 'Void') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Void');
|
||||
$mpdf->showWatermarkText = true;
|
||||
}
|
||||
|
||||
// return view('invoice_pdf_template', ['sales' => $data,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
|
||||
|
||||
// Generate the PDF content (HTML) with data
|
||||
$html = view('invoice_pdf_template', ['sales' => $data,'saleOrderCount' => $saleOrderCount,'items'=>$items,'branch'=>$branch, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
|
||||
$html = view('invoice_pdf_template', $data);
|
||||
// echo $html;die;
|
||||
// Load HTML into the mPDF instance
|
||||
$mpdf->WriteHTML($html);
|
||||
date_default_timezone_set('Asia/Kolkata');
|
||||
// Output the PDF to the browser for download
|
||||
$mpdf->Output($data[0]->order_number .'_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
$mpdf->Output($data['sales'][0]->order_number .'_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
}
|
||||
|
||||
|
||||
public function preview_invoice($sales_order_id)
|
||||
{
|
||||
|
||||
|
||||
// Fetch the invoice data based on $invoice_id
|
||||
$model = new SalesOrderModel();
|
||||
$saleOrderCount = count($model->where('status','Paid')->findAll());
|
||||
$VehicleModel = new VehicleModel();
|
||||
$BranchModel = new BranchModel();
|
||||
$BusinessModel = new BusinessModel();
|
||||
$BikemodelsModel = new BikemodelsModel();
|
||||
$BikemakeModel = new BikemakeModel();
|
||||
$data['sales'] = $model->getSalesPdf($sales_order_id);
|
||||
$data['branch'] = $BranchModel->where('branch_id', $data['sales'][0]->branch_id)->first();
|
||||
$data['vehicle'] = $VehicleModel->select('vehicle.reg_no,vehicle.colour,vehicle.email,vehicle.mobile_no,vehicle.year_of_manufacturing, make.make as make_name, model.model_name')
|
||||
->join('model', 'model.model_id = vehicle.model', 'left')
|
||||
->join('make', 'make.make_id = vehicle.make', 'left')
|
||||
->where('vehicle.vehicle_id', $data['sales'][0]->vehicle_id)
|
||||
->first();
|
||||
$data['items'] = $model->getSalesOrderProductsForPdf($sales_order_id);
|
||||
|
||||
|
||||
$html = view('invoice_pdf_template', $data);
|
||||
return $this->respond(['status' => 'success','code' => 200,'data' => $html],200);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ class SalesOrderModel extends Model
|
||||
|
||||
->join('branches as B','B.branch_id = sales_order.branch_id','left')
|
||||
->select('sales_order.*')
|
||||
->select('B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.contact_1 as company_mobile_no_1,B.contact_2 as company_mobile_no_2')
|
||||
->select('B.branch_name ,B.address as company_address,B.city as company_city,B.state as company_state,B.postal_code as company_postal_code,B.contact_1 as company_mobile_no_1,B.contact_2 as company_mobile_no_2,B.gstno as company_gstno')
|
||||
|
||||
->get()
|
||||
->getResult();
|
||||
|
||||
481
app/Views/invoice_pdf_template.php
Executable file → Normal file
481
app/Views/invoice_pdf_template.php
Executable file → Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
307
app/Views/invoice_pdf_template_old.php
Executable file
307
app/Views/invoice_pdf_template_old.php
Executable file
@ -0,0 +1,307 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<style>
|
||||
/* Add your CSS styles here to format the invoice for mPDF */
|
||||
body {font-family: 'Times New Roman', Times, sans-serif;font-size: 12px;}
|
||||
table.main-table {width: 100%;border-collapse: collapse;border: -0.5px solid black;}
|
||||
table.main-table th,table.main-table td {border: none;}
|
||||
table.business-details-table {width: 100%;border-collapse: collapse;}
|
||||
table.business-details-table td {padding: 8px;text-align: left;}
|
||||
.business-logo-container {text-align: center;}
|
||||
img.business-logo {max-width: 200px;}
|
||||
.business-name {font-size: 16px;font-weight: bold;margin-top: 10px;}
|
||||
table.invoice-info-table {width: 110%;}
|
||||
/* table.invoice-info-table th,table.invoice-info-table td {text-align: right;} */
|
||||
table.addresses-table {width: 100%;}
|
||||
table.addresses-table th {text-align: left;padding-left: 8px;}
|
||||
.billing-address {width: 50%;padding-left: 8px;}
|
||||
table.invoice-related-table {width: 100%;border-collapse: collapse;}
|
||||
table.invoice-related-table th,table.invoice-related-table td {border: none;padding: 8px;text-align: left;}
|
||||
table.invoice-related-table th {background-color: #DAC2AD;font-weight: bold;}
|
||||
table.invoice-related-table thead tr th{border: 0.5px solid black;}
|
||||
table.invoice-related-table thead tr{border: 0.5px solid black;}
|
||||
.business-stamp, .terms {text-align: center;margin-top: 20px;}
|
||||
.subtotal-table {width: 100%;margin-top: 20px;}
|
||||
.subtotal-table table {width: 100%;border-collapse: collapse;border: 1px solid black;}
|
||||
.subtotal-table th,.subtotal-table td {border: none;padding: 8px;text-align: right;}
|
||||
.subtotal-table th {background-color: #f2f2f2;font-weight: bold;}
|
||||
.subtotal-table td:last-child {font-weight: bold; }
|
||||
td.invoice-number {font-size: 18px;font-weight: bold; /* Make the text bold */}
|
||||
p {margin-top: 0;margin-bottom: 0rem;}
|
||||
.invoice-info-table {border-collapse: collapse;}
|
||||
.invoice-info-table td {border: 1px solid black;}
|
||||
.invoice-info-table tr:first-child td {border-top: none;}
|
||||
.invoice-info-table tr:first-child td {border-right: none;}
|
||||
.invoice-info-table tr td:nth-child(2) {border-left: none;}
|
||||
.invoice-info-table tr:first-child td {border-bottom: none;}
|
||||
.invoice-info-table tr:last-child td {border-bottom: none;}
|
||||
.invoice-info-table tr td:first-child {border-left: none;}
|
||||
.invoice-info-table tr td:last-child {border-right: none;}
|
||||
.term_condition {border-collapse: collapse;width: 100%;}
|
||||
.term_condition td {border: 0.5px solid black;padding: 8px;text-align: center;}
|
||||
</style>
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<h3 style="text-align:center;text-decoration: underline;">Tax Invoice</h3>
|
||||
<table class="main-table">
|
||||
<tr>
|
||||
<td>
|
||||
<table class="business-details-table">
|
||||
|
||||
<?php foreach ($sales as $value) : ?>
|
||||
<tr>
|
||||
<td class="business-logo-container"style="font-size: 16px;font-weight: bold;">
|
||||
<?= $business['business_name'] ?>
|
||||
<!-- <img src="https://vijayabharathambooks.com/wp-content/uploads/2021/09/vijaya-bharatham-logo-8pt.png" alt="Business Logo" class="business-logo"> -->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p style="margin-top: -15px;"><?= $value->company_address ?>,<br>
|
||||
<?= $value->company_city ?>,
|
||||
<?= $value->company_state ?>
|
||||
<?= $value->company_postal_code ?>.<br>
|
||||
|
||||
<!-- <?= $value->company_mobile_no_1 ?>, <?= $value->company_mobile_no_2 ?> -->
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<div style="margin-top: -20px;"><span>GSTIN: <?php echo $branch['gstno']?> </span><br>
|
||||
<span>State Name: <?php echo $branch['state']?> , Code: <?php echo $branch['state_code']?> </span><br>
|
||||
<span>Contact : <?php echo $branch['contact_1']?>, <?php echo $branch['contact_2']?></span><br>
|
||||
<span>Email : <?php echo $branch['email']?></span><br><br>
|
||||
<span ><b>Buyer (Bill To) </b> </span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table class="invoice-info-table" >
|
||||
<tbody >
|
||||
<tr><?php $currentYear = date('y');
|
||||
$nextYear = date('y', strtotime('+1 year'));
|
||||
$yearRange = $currentYear . '-' . $nextYear;
|
||||
|
||||
$businessName = trim($business['business_name']);
|
||||
$words = explode(' ', $businessName);
|
||||
$initials = '';
|
||||
foreach ($words as $word) {
|
||||
$word = preg_replace("/[^A-Za-z]/", '', $word);
|
||||
$initials .= strtoupper(substr($word, 0, 1));
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<td>Invoice No.</td><td><?= $initials ."/".$yearRange."/" . $saleOrderCount+1 ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Date</td><td><?= date('Y-m-d', strtotime($sales[0]->created_at)) ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bike Make & Model</td><td><?php echo $bike_make['make'], $bike_model['model_name']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Colour</td><td><?php echo $vehicle['colour']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Register Number</td><td><?php echo $vehicle['reg_no']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Contact Number</td><td><?php echo $vehicle['mobile_no']?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Sale Order No </td><td><?= $sales[0]->order_number ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Payment Mode</td><td><?= (isset($sales[0]->mode_of_payment) && strlen($sales[0]->mode_of_payment) > 0) ? $sales[0]->mode_of_payment : "Not Done" ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table class="addresses-table" style="margin-top: -10px;">
|
||||
<tr >
|
||||
<td class="billing-address">
|
||||
|
||||
<?php foreach ($sales as $value) : ?>
|
||||
<?= $value->client_name ?><br>
|
||||
<?= $value->billing_address != '' ? $value->billing_address." , <br>" : ''; ?>
|
||||
<?= $value->billing_city ?> <?= $value->billing_state." "?>
|
||||
<?php if ($value->billing_postal_code!=0): ?>
|
||||
<?= $value->billing_postal_code ?><br>
|
||||
<?php endif; ?>
|
||||
<?= $value->mobile_no." ." ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table><br><br>
|
||||
<table class="invoice-related-table">
|
||||
<thead>
|
||||
<tr >
|
||||
<th >S no</th>
|
||||
<th >Description Of Goods</th>
|
||||
<th>Rate</th>
|
||||
<th >Quantity</th>
|
||||
<th >Per</th>
|
||||
<th >Taxable Amount</th>
|
||||
<th >GST</th>
|
||||
<th >CGST Amount</th>
|
||||
<th >SGST Amount</th>
|
||||
<th >Total Tax</th>
|
||||
<th >Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php $serialNumber = 1; ?>
|
||||
<?php $total_taxable_amount = 0; $total_CGST = 0; $total_SGST = 0; foreach ($items as $item) :
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<?php $taxable_amount = $item->net_price * $item->qty;
|
||||
$total_taxable_amount += $taxable_amount;
|
||||
$cgst = ($taxable_amount * $item->tax / 100 ) /2;
|
||||
$sgst = ($taxable_amount * $item->tax / 100 ) /2;
|
||||
|
||||
$total_CGST += $cgst;
|
||||
$total_SGST += $sgst;
|
||||
?>
|
||||
<td style="border: 1px solid black;">
|
||||
<?= $serialNumber++; ?>
|
||||
</td>
|
||||
<td style="border: 0.5px solid black;"><?= $item->product_name ?></td>
|
||||
<td style="border: 0.5px solid black;"><?= $item->net_price; ?></td>
|
||||
<td style="border: 0.5px solid black;"><?= $item->qty ?></td>
|
||||
<td style="border: 0.5px solid black;">nos</td>
|
||||
<td style="border: 0.5px solid black;"><?= $taxable_amount ?></td>
|
||||
<td style="border: 0.5px solid black;"><?= $item->tax ?>%</td>
|
||||
<td style="border: 0.5px solid black;"><?= $cgst ?></td>
|
||||
<td style="border: 0.5px solid black;"><?= $sgst ?></td>
|
||||
<td style="border: 0.5px solid black;"><?= $cgst + $sgst ?></td>
|
||||
|
||||
<td style="border: 0.5px solid black;"><?= $item->amount ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td colspan="7" style="border-top: 0.5px solid black;border-left: 0.5px solid black;"></td>
|
||||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Subtotal</td>
|
||||
<td style="border: 0.5px solid black;"><?= $sales[0]->subtotal ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="border-left: 0.5px solid black;"></td>
|
||||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">CGST</td>
|
||||
<td style="border: 0.5px solid black;"><?= $sales[0]->tax / 2 ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="border-left: 0.5px solid black;"></td>
|
||||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">SGST</td>
|
||||
<td style="border: 0.5px solid black;"><?= $sales[0]->tax / 2 ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="border-left: 0.5px solid black;"></td>
|
||||
<td colspan="3" style="text-align:center;border: 0.5px solid black;">Total</td>
|
||||
<td style="border: 0.5px solid black;" id="total_amount"><?= $sales[0]->total ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="7" style="border: 0.5px solid black;border-right: none;text-align: center;">Amount Chargeable (in words):
|
||||
<?php
|
||||
$formatter = new NumberFormatter("en", NumberFormatter::SPELLOUT);
|
||||
$words = $formatter->format(round($sales[0]->subtotal + $sales[0]->tax));
|
||||
?>
|
||||
</td>
|
||||
<td colspan="4" style="border: 0.5px solid black; border-left: none;text-align: center;">
|
||||
<?php echo ucfirst($words); ?>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr><td></td></tr>
|
||||
<tr><td></td></tr>
|
||||
<tr>
|
||||
<td colspan="7" style="border: 0.5px solid black;"><p>Declaration: <br> We Declare that this invoice shows the actual price of the goods described and that all particulars are true and correct.<br><br>**This is computer generated bill and doesn’t require signature</p></td>
|
||||
<td colspan="4" style="border: 0.5px solid black;text-align: center;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
function numberToWords(number) {
|
||||
var words = {
|
||||
'0': 'zero', '1': 'one', '2': 'two', '3': 'three', '4': 'four',
|
||||
'5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine',
|
||||
'10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen',
|
||||
'14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen',
|
||||
'18': 'eighteen', '19': 'nineteen', '20': 'twenty', '30': 'thirty',
|
||||
'40': 'forty', '50': 'fifty', '60': 'sixty', '70': 'seventy',
|
||||
'80': 'eighty', '90': 'ninety'
|
||||
};
|
||||
|
||||
var units = ['', 'thousand', 'million', 'billion', 'trillion', 'quadrillion'];
|
||||
|
||||
// Function to convert a number less than 1000 to words
|
||||
function convertLessThan1000(num) {
|
||||
if (num === 0) {
|
||||
return '';
|
||||
} else if (num < 20) {
|
||||
return words[num] + ' ';
|
||||
} else if (num < 100) {
|
||||
return words[Math.floor(num / 10) * 10] + ' ' + convertLessThan1000(num % 10);
|
||||
} else {
|
||||
return words[Math.floor(num / 100)] + ' hundred ' + convertLessThan1000(num % 100);
|
||||
}
|
||||
}
|
||||
|
||||
// Function to convert a number to words
|
||||
function convert(num) {
|
||||
if (num === 0) {
|
||||
return 'zero';
|
||||
}
|
||||
|
||||
var result = '';
|
||||
var i = 0;
|
||||
|
||||
while (num > 0) {
|
||||
if (num % 1000 !== 0) {
|
||||
result = convertLessThan1000(num % 1000) + units[i] + ' ' + result;
|
||||
}
|
||||
num = Math.floor(num / 1000);
|
||||
i++;
|
||||
}
|
||||
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
// Convert the number to words
|
||||
return convert(number);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
// Calculate amount and update amount in words
|
||||
console.log($('#total_amount').html());
|
||||
// Call numberToWords function to get amount in words
|
||||
var amountInWords = numberToWords($('#total_amount').html());
|
||||
|
||||
// Update the span with the amount in words
|
||||
$('#amountInWords').html(amountInWords);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@ -635,7 +635,6 @@ $(document).ready(async function() {
|
||||
'</tr>';
|
||||
|
||||
$('#productItemTable tbody').append(newRow);
|
||||
// $(newRow).insertAfter(tr);
|
||||
initializeSelect2();
|
||||
}
|
||||
|
||||
@ -2112,7 +2111,7 @@ $closestTR.remove();
|
||||
});
|
||||
function initializeSelect2() {
|
||||
$('.SelExample').select2({
|
||||
width: '249px' // Adjust width as needed
|
||||
width: '249px'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -88,10 +88,10 @@
|
||||
|
||||
<?php if($admins) { ?>
|
||||
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" class="dropdown-item preview-invoice" href="#" title="Preview Invoice"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
|
||||
<a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Invoice</a>
|
||||
<!-- <a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Invoice</a> -->
|
||||
<?php } ?>
|
||||
<a href="#" data-job-card-id="<?= $value['job_card_id']; ?>" class="dropdown-item preview-jobcard" href="#" title="Preview Jobcard"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Jobcard</a>
|
||||
<a href="<?= base_url() ."download_jobcard/" . $value['job_card_id']; ?>" class="dropdown-item download-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Jobcard</a>
|
||||
<!-- <a href="<?= base_url() ."download_jobcard/" . $value['job_card_id']; ?>" class="dropdown-item download-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download Jobcard</a> -->
|
||||
|
||||
<?php if($value['status'] == 'Paid' && $admins && $value['is_rework'] == 0) { ?>
|
||||
<a href="<?= "new_jobcard/" . $value['job_card_id'] . "/re-work" ?>" class="dropdown-item edit-button"><i class="ri-registered-fill mr-2 text-muted font-18 vertical-middle"></i>Rework</a>
|
||||
@ -121,7 +121,8 @@
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewInvoiceModalLabel"></h5>
|
||||
|
||||
<a href="#" class="ri-download-2-fill ml-3 text-muted font-18" id="downloadInvoiceButton" title="Print Invoice"></a>
|
||||
<a href="#" class="ri-download-2-fill ml-3 text-muted font-18" id="downloadInvoiceButton" title="Download Invoice"></a>
|
||||
<a href="#" class="ri-printer-fill ml-3 text-muted font-18" id="printInvoiceButton" title="Print Invoice"></a>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
@ -137,7 +138,8 @@
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewJobcardModalLabel"></h5>
|
||||
<a href="#" class="ri-download-2-fill ml-3 text-muted font-18" id="downloadJobcardButton" title="Print Jobcard"></a>
|
||||
<a href="#" class="ri-download-2-fill ml-3 text-muted font-18" id="downloadJobcardButton" title="Download Jobcard"></a>
|
||||
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
@ -238,9 +240,10 @@
|
||||
success: function(response) {
|
||||
if (response.status == "success") {
|
||||
$('#PreviewInvoiceModal').modal('show');
|
||||
$('#PreviewInvoiceModalLabel').text('Preview Invoice Modal');
|
||||
$('#PreviewInvoiceModalLabel').text('Invoice Preview ');
|
||||
$('#PreviewInvoiceModal .modal-body').html(response.data);
|
||||
$('#downloadInvoiceButton').attr('href', '<?= base_url("download_jobcard_invoice/") ?>' + jobCardId);
|
||||
$('#printInvoiceButton').attr('data-id', jobCardId);
|
||||
}else{
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
@ -280,4 +283,77 @@
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '#printInvoiceButton', function() {
|
||||
var jobCardId = $(this).data('id');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'preview_jobcard_invoice/'+jobCardId,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.status == "success") {
|
||||
|
||||
var newWin = window.open("", "_blank", "width=600,height=400");
|
||||
newWin.document.write("<html><head><title>Print</title>");
|
||||
newWin.document.write(`
|
||||
<style>
|
||||
@media print {
|
||||
@page {
|
||||
size: A4; /* Set default print size to A4 */
|
||||
margin: 1cm; /* Set margin as per requirement */
|
||||
}
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
`);
|
||||
newWin.document.write("</head><body>");
|
||||
newWin.document.write(response.data);
|
||||
newWin.document.write("</body></html>");
|
||||
newWin.document.close();
|
||||
newWin.print();
|
||||
newWin.close();
|
||||
|
||||
|
||||
}else{
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document).on('click', '.print-jobcard', function() {
|
||||
var jobCardId = $(this).data('job-card-id');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'preview_jobcard/'+jobCardId,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.status == "success") {
|
||||
$('#PreviewJobcardModal').modal('show');
|
||||
$('#PreviewJobcardModalLabel').text('Preview Jobcard Modal');
|
||||
$('#PreviewJobcardModal .modal-body').html(response.data);
|
||||
$('#downloadJobcardButton').attr('href', '<?= base_url("download_jobcard/") ?>' + jobCardId);
|
||||
}else{
|
||||
$('#PreviewJobcardModal').modal('hide');
|
||||
$('#PreviewJobcardModalLabel').text('');
|
||||
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
$('#PreviewJobcardModal').modal('hide');
|
||||
$('#PreviewJobcardModalLabel').text('');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -99,6 +99,7 @@
|
||||
<a href="<?= "new_sale/" . $value['sales_order_id']; ?>" class="dropdown-item edit-button" onclick="datatableSalesOrder('sale_tr_<?php echo $index+1; ?>')"><i class="ri-pencil-line mr-2 text-muted font-18 vertical-middle"></i>Edit</a>
|
||||
<a href="<?= "delete_sale/" . $value['sales_order_id']; ?>" class="dropdown-item delete-button" onclick="datatableSalesOrder('sale_tr_<?php echo $index+1; ?>')"><i class="ri-delete-bin-line mr-2 text-muted font-18 vertical-middle"></i>Delete</a>
|
||||
<a href="<?= "download_invoice/" . $value['sales_order_id']; ?>" class="dropdown-item edit-button"><i class="ri-download-2-fill mr-2 text-muted font-18 vertical-middle"></i>Download</a>
|
||||
<a href="#" data-sales-order-id="<?= $value['sales_order_id']; ?>" class="dropdown-item preview-invoice" href="#" title="Preview Invoice"><i class="ri-book-read-line mr-2 text-muted font-18 vertical-middle"></i>Preview Invoice</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@ -116,7 +117,24 @@
|
||||
</div>
|
||||
<?php include('layout/footer.php'); ?>
|
||||
|
||||
<div class="modal fade" id="PreviewInvoiceModal" tabindex="-1" role="dialog" aria-labelledby="PreviewInvoiceModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg">
|
||||
<div class="modal-content" style="width: 794px; height: 1123px;">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="PreviewInvoiceModalLabel"></h5>
|
||||
|
||||
<a href="#" class="ri-download-2-fill ml-3 text-muted font-18" id="downloadInvoiceButton" title="Download Invoice"></a>
|
||||
<a href="#" class="ri-printer-fill ml-3 text-muted font-18" id="printInvoiceButton" title="Print Invoice"></a>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close" style="font-size: 27px; margin-bottom: 2px;">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body" style="font-family: Times New Roman, Times, sans-serif !important; font-size: 12px !important;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var datatable_sales_order ='';
|
||||
@ -185,4 +203,78 @@
|
||||
sessionStorage.setItem('hightlight_tr', value);
|
||||
|
||||
}
|
||||
|
||||
|
||||
$(document).on('click', '.preview-invoice', function() {
|
||||
var Id = $(this).data('sales-order-id');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'preview_invoice/'+Id,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.status == "success") {
|
||||
$('#PreviewInvoiceModal').modal('show');
|
||||
$('#PreviewInvoiceModalLabel').text('Invoice Preview ');
|
||||
$('#PreviewInvoiceModal .modal-body').html(response.data);
|
||||
$('#downloadInvoiceButton').attr('href', '<?= base_url("download_invoice/") ?>' + Id);
|
||||
$('#printInvoiceButton').attr('data-id', Id);
|
||||
}else{
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on('click', '#printInvoiceButton', function() {
|
||||
var Id = $(this).data('id');
|
||||
$.ajax({
|
||||
type: 'GET',
|
||||
url: 'preview_invoice/'+Id,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.status == "success") {
|
||||
|
||||
var newWin = window.open("", "_blank", "width=600,height=400");
|
||||
newWin.document.write("<html><head><title>Print</title>");
|
||||
newWin.document.write(`
|
||||
<style>
|
||||
@media print {
|
||||
@page {
|
||||
size: A4; /* Set default print size to A4 */
|
||||
margin: 1cm; /* Set margin as per requirement */
|
||||
}
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
`);
|
||||
newWin.document.write("</head><body>");
|
||||
newWin.document.write(response.data);
|
||||
newWin.document.write("</body></html>");
|
||||
newWin.document.close();
|
||||
newWin.print();
|
||||
newWin.close();
|
||||
|
||||
|
||||
}else{
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Handle error response here
|
||||
console.error(xhr.responseText);
|
||||
$('#PreviewInvoiceModal').modal('hide');
|
||||
$('#PreviewInvoiceModalLabel').text('');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
4
public/assets/css/bootstrap-corporate.css
vendored
4
public/assets/css/bootstrap-corporate.css
vendored
@ -4367,9 +4367,9 @@ a.close.disabled {
|
||||
|
||||
.modal-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 1rem 1rem;
|
||||
padding: 5px 5px;
|
||||
border-bottom: 1px solid #e5e8eb;
|
||||
border-top-left-radius: 0.2rem;
|
||||
border-top-right-radius: 0.2rem; }
|
||||
|
||||
BIN
public/assets/images/Group.png
Normal file
BIN
public/assets/images/Group.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
Loading…
Reference in New Issue
Block a user