CHANGE_SALE_INVOICE_PDF : AADHAVAN

This commit is contained in:
aadhavan valli 2024-05-02 17:07:01 +05:30
parent 0ffaae5057
commit 94ad1626da
4 changed files with 256 additions and 129 deletions

View File

@ -9,6 +9,8 @@ use App\Models\ClientModel;
use App\Models\BikemodelsModel;
use App\Models\BikemakeModel;
use App\Models\VehicleModel;
use App\Models\BusinessModel;
use App\Models\BranchModel;
use Mpdf\Mpdf;
class Sales extends BaseController
{
@ -291,9 +293,24 @@ public function delete_sales_product()
if(!$this->session->has('logged_user')) { return redirect()->to(base_url()); }
// Fetch the invoice data based on $invoice_id
$model = new SalesOrderModel();
$VehicleModel = new VehicleModel();
$BranchModel = new BranchModel();
$BusinessModel = new BusinessModel();
$BikemodelsModel = new BikemodelsModel();
$BikemakeModel = new BikemakeModel();
$data = $model->getSalesPdf($sales_order_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();
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
$bike_model = $BikemodelsModel->where('model_id',$vehicle['model'])->first();
$bike_make = $BikemakeModel->where('make_id', $vehicle['make'])->first();
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
@ -338,9 +355,9 @@ public function delete_sales_product()
$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,'items'=>$items]);
$html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items, 'business' => $business , 'vehicle' => $vehicle,'bike_model'=>$bike_model,'bike_make'=>$bike_make]);
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);

View File

@ -79,65 +79,105 @@
/* Style for the invoice-related table */
table.invoice-related-table {
width: 100%;
border-collapse: collapse;
}
width: 100%;
border-collapse: collapse;
}
table.invoice-related-table th,
table.invoice-related-table td {
border: none; /* Remove borders from all cells in the invoice items table */
padding: 8px;
text-align: center; /* Center-align text in cells */
}
table.invoice-related-table th,
table.invoice-related-table td {
border: none;
padding: 8px;
text-align: left;
}
table.invoice-related-table th {
background-color: #f2f2f2;
font-weight: bold;
}
table.invoice-related-table th {
background-color: #DAC2AD;
font-weight: bold;
}
/* Style for the business stamp and terms */
.business-stamp, .terms {
text-align: center;
/* Style for the business stamp and terms */
.business-stamp, .terms {
text-align: center;
margin-top: 20px;
}
.subtotal-table {
width: 100%;
margin-top: 20px;
}
.subtotal-table {
width: 100%;
margin-top: 20px;
}
.subtotal-table table {
width: 100%;
border-collapse: collapse;
border: 1px solid black; /* Add a border around the subtotal table */
}
.subtotal-table table {
width: 100%;
border-collapse: collapse;
border: 1px solid black; /* Add a border around the subtotal table */
}
.subtotal-table th,
.subtotal-table td {
border: none; /* Remove borders from cells inside the subtotal table */
padding: 8px;
text-align: right;
}
.subtotal-table th,
.subtotal-table td {
border: none; /* Remove borders from cells inside the subtotal table */
padding: 8px;
text-align: right;
}
.subtotal-table th {
background-color: #f2f2f2;
font-weight: bold;
}
.subtotal-table td:last-child {
font-weight: bold; /* Make the last column (total values) bold */
}
td.invoice-number {
font-size: 18px; /* Increase font size to your desired value */
/* Highlight background color */
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;
width: 100px;
}
.invoice-info-table tr:first-child td {
border-top: 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;
}
.subtotal-table th {
background-color: #f2f2f2;
font-weight: bold;
}
.subtotal-table td:last-child {
font-weight: bold; /* Make the last column (total values) bold */
}
td.invoice-number {
font-size: 18px; /* Increase font size to your desired value */
/* Highlight background color */
font-weight: bold; /* Make the text bold */
}
p {
margin-top: 0;
margin-bottom: 0rem;
}
</style>
</head>
<body>
<h3 style="text-align:center;text-decoration: underline;">Tax Invoice</h3>
<table class="main-table">
<tr>
<td>
@ -162,30 +202,67 @@ p {
</td>
</tr>
<?php endforeach; ?>
<tr>
<td><span>GSTIN: <?php echo $business['gstno']?> </span><br>
<span>State Name: <?php echo $business['state']?> , Code: <?php echo $business['code']?> </span><br>
<span>Contact : <?php echo $business['mobile']?></span><br>
<span>Email : <?php echo $business['email']?></span><br><br>
<span style="font-size: 15px;font-weight: bold;">Buyer (Bill To) </span>
</td>
</table>
</td>
<td>
<table class="invoice-info-table">
<?php foreach ($sales as $value) : ?>
<table class="invoice-info-table" >
<tbody >
<tr>
<th><?php echo ($value->order_number) ? 'Order # ' . $value->order_number : 'Invoice # ' . $value->invoice_number; ?></th>
<td>Invoice No.</td>
<td>1</td>
</tr>
<tr>
<th>Date : <?= date('d-m-Y', strtotime($value->created_at)) ?></th>
<td>Dated</td>
<td>2</td>
</tr>
<?php endforeach; ?>
<tr>
<td>Bike Name</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>Bike 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>Job Card No. </td>
<td>5</td>
</tr>
<tr>
<td>Dated</td>
<td>5</td>
</tr>
<tr>
<td>Delivery Date</td>
<td>5</td>
</tr>
<tr>
<td>Mode Of Payment</td>
<td>5</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<table class="addresses-table">
<tr >
<th class="billing-address">Billing Address</th>
</tr>
<tr >
<td class="billing-address">
@ -206,75 +283,89 @@ p {
</tr>
</table>
<br> <br>
<table class="invoice-related-table">
<thead>
<thead>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">S no</th>
<th style="border: 0.5px solid black;">Description Of Goods</th>
<th style="border: 0.5px solid black;">Taxable Value</th>
<th style="border: 0.5px solid black;">Quantity</th>
<th style="border: 0.5px solid black;">Per</th>
<th style="border: 0.5px solid black;">GST</th>
<th style="border: 0.5px solid black;">CGST Amount</th>
<th style="border: 0.5px solid black;">SGST Amount</th>
<th style="border: 0.5px solid black;">Total Tax</th>
<th style="border: 0.5px solid black;">Total</th>
</tr>
</thead>
<tbody>
<?php $serialNumber = 1; ?>
<?php foreach ($items as $item) : ?>
<tr>
<th>S.no</th>
<th>Item Name</th>
<th>MRP</th>
<th>Qty</th>
<th>Total</th>
</tr>
</thead>
<tbody>
<?php $serialNumber = 1; ?>
<?php foreach ($items as $item) : ?>
<tr>
<td>
<?php $taxPercentage = $item->tax / 100;
$taxAmount = $item->amount * $taxPercentage;
$amountWithoutTax = $item->amount - $taxAmount;
$value_tax = number_format($taxAmount, 2, '.', ',');?>
<td style="border: 1px solid black;">
<?= $serialNumber++; ?>
</td>
<td><?= $item->product_name ?></td>
<td><?= number_format($item->net_price, 2, '.', ',') ?></td>
<td><?= $item->qty ?></td>
<td><?= number_format($item->amount, 2, '.', ',') ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<table class="subtotal-table">
<?php foreach ($sales as $value) : ?>
</td>
<td style="border-right: 0.5px solid black;"><?= $item->product_name ?></td>
<td style="border-right: 0.5px solid black;"> <?php echo number_format($amountWithoutTax, 2, '.', ','); ?></td>
<td style="border-right: 0.5px solid black;"><?= $item->qty ?></td>
<td style="border-right: 0.5px solid black;"></td>
<td style="border-right: 0.5px solid black;"><?= $item->tax ?>%</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border-right: 0.5px solid black;"><?php echo $value_tax /2;?>
</td>
<td style="border: 0.5px solid black;"><?php echo $value_tax;?></td>
<td style="border-right: 0.5px solid black;"><?= $item->amount ?></td>
</tr>
<?php endforeach; ?>
<tr>
<td colspan="5" align="right">Subtotal : &nbsp;&nbsp;<?= number_format($value->subtotal, 2, '.', ',') ?></td>
</tr>
<tr>
<td colspan="5" align="right">Tax : &nbsp;&nbsp;<?= number_format($value->tax, 2, '.', ',') ?></td>
</tr>
<td colspan="6" 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;">Total Taxable Value</td>
<td style="border: 0.5px solid black;"></td>
</tr>
<tr>
<td colspan="6" 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;"></td>
</tr>
<tr>
<td colspan="6" 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;"></td>
</tr>
<tr>
<td colspan="6" 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;"></td>
</tr>
<tr>
<td colspan="10" style="border: 0.5px solid black;">Amount Chargeable (in words)</td>
</tr>
<!-- -->
<tr>
<td colspan="5" align="right">Total : &nbsp;&nbsp;<?= number_format($value->total, 2, '.', ',') ?></td>
</tr>
<?php if ($value->status === 'Approved'): ?>
<tr>
<td colspan="5" align="right">Paid : &nbsp;&nbsp;<?= number_format($value->total_amount, 2, '.', ',') ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<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 doesnt require signature</p></td>
<td colspan="3" style="border: 0.5px solid black;"><p>for THE MECHANIC</p><br><br><br> Authorised Signatory</td>
</tr>
</tbody>
</table>
<div class="business-stamp">
</div>
<div class="terms">
<p style=text-align:left><?= $value->terms_condition;?></p>
</div>
<div class="terms">
<!-- <p style=text-align:left><?= $value->terms_condition;?></p> -->
</div>
<!-- ... (your existing HTML template) -->

View File

@ -617,7 +617,6 @@
var product = products.find(function(item) {
return item.product_id == productId;
});
console.log("22222222222");
console.log(product);
var cgst = parseFloat(product.cgst);
var sgst = parseFloat(product.sgst);
@ -644,7 +643,6 @@
var product = complaint.find(function(item) {
return item.complaint_id == productId;
});
console.log("3333333");
console.log(product);
var cgst = parseFloat(product.cgst);
var igst = parseFloat(product.sgst);
@ -657,7 +655,6 @@
}
const service_child_products = async (data,tr) => {
console.log();
console.log(JSON.parse(data.product_id));
JSON.parse(data.product_id).forEach(async(element,index) => {
if(element == 0) return;
@ -774,8 +771,13 @@
// Event listener for "Add More Item" button
$(document).on('click', '#addProduct', function() {
if($(this).parent().parent().parent().attr('class') == 'complaint_class'){
var product_tr_class_name_set = 'complaint_product_'+$(this).closest('tr').data('select2Id');
}else{
var product_tr_class_name_set = 'custom_complaint_product_'+$(this).parent().parent().parent().attr('class').match(/\d+/)[0];
}
var newRow = '<tr class="complaint_product_'+$(this).closest('tr').data('select2Id')+'"><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
var newRow = '<tr class="'+product_tr_class_name_set+'"><td hidden style="width:10%;"><input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td style="padding-left: 40px !important;"><i class="fa fa-caret-right" style="font-size: 20px;margin-top: 8px;position: absolute;margin-left: -18px;" aria-hidden="true"></i><select class="form-control book-select SelExample product" name="item_details[]" required data-toggle="select2" style="width: 249px !important;"><option value="">Select a Product</option>';
for (var i = 0; i < productarray.length; i++)
{
@ -866,7 +868,7 @@
$('#addCustomComplaint').click(function() {
complaint = <?php echo json_encode($complaint) ?>;
// console.log(productarray);
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" rows="5"></textarea></td>' +
var newRow = '<tr class="custom_complaint_class"><td hidden style="width:10%;"> <input type="number" class="form-control labour-cost" name="labour_cost[]"></td><td><textarea class="form-control custom-comp" id="custom_complaint_detail" data-toggle="select2" rows="5"></textarea></td>' +
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" value="1" name="quantity[]" readonly/></td>' +
'<td style="width:10%;"><input type="text" class="form-control item-rate" name="unit-price[]" /></td>' +
'<td style="width:8%;"><input type="text" class="form-control item-tax" name="item-tax[]" /></td>' +
@ -886,15 +888,32 @@
$('#productItemTable tbody').append(newRow);
initializeSelect2();
initializeSelect2();
// Function to increment class name
function incrementClassName(className) {
var classNumber = parseInt(className.match(/\d+/)[0]);
return className.replace(/\d+/, classNumber + 1);
}
// Initial class name
var initialClassName = 'custom_complaint_class';
var currentClassName;
// Loop to check for existence of subsequent classes
for (var i = 2000; i <= 2100; i++) {
currentClassName = initialClassName + '_' + i;
if ($('.' + currentClassName).length === 0) {
// If the class doesn't exist, increment the last found class
$('.' + initialClassName).removeClass(initialClassName).addClass(currentClassName);
break;
}
}
});
// Event listener for removing item
$(document).on('click', '.remove-item', function() {
console.log( );
var main_tr_to_remove = $(this).closest('tr').data('select2Id');
$(this).closest('tr').remove();
@ -905,8 +924,8 @@
}else if($(this).closest('tr').attr('class') == 'service_class'){
$('.service_product_'+main_tr_to_remove).remove();
}else if($(this).closest('tr').attr('class') == 'custom_complaint_class'){
$('.service_product_'+main_tr_to_remove).remove();
}else if($(this).closest('tr').attr('class').indexOf('custom_complaint_class') !== -1){
$('.custom_complaint_product_'+$(this).closest('tr').attr('class').match(/\d+/)[0]).remove();
}

View File

@ -52,7 +52,7 @@
</div>
<!-- Start Bike Manufacturer Create Pop-UP -->
<!-- Start Biake Mnufacturer Create Pop-UP -->
<div id="manufacturer_login-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">