CHANGE_jobcard_discount_calculation_and_jc_dwn_template:ss

This commit is contained in:
sriramv 2024-05-10 17:11:05 +05:30
parent cb5dda2769
commit 2c9289f309
7 changed files with 451 additions and 9 deletions

View File

@ -87,6 +87,7 @@ $routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
$routes->get("download_jobcard/(:any)", "Jobcard::download_jobcard/$1");
$routes->post("getServices", "Jobcard::getServices");
//End Job Card //

View File

@ -160,6 +160,55 @@ class Jobcard extends BaseController
}
public function download_jobcard($job_card_id)
{
$data['vehicle'] = $this->JobcardModel->get_jobcard_vehicle_details($job_card_id);
$bus_id = $this->session->get('logged_user_business_id');
$data['job_card'] = $this->JobcardModel->where('job_card_id',$job_card_id)->findAll();
$data['company_address'] = $this->BranchModel->where('branch_id', $this->session->get('logged_user_branch_id'))->where('business_id', $bus_id)->where('isactive', 1)->findAll();
$data['job_card_products'] = $this->JobcardModel->get_jobcard_products_details($job_card_id);
$data['service'] = $this->JobcardModel->get_jobcard_service($job_card_id);
$complaint = $this->JobcardModel->get_jobcard_complaint($job_card_id);
$customcomplaint = $this->JobcardModel->get_jobcard_custom_complaint($job_card_id);
$data['complaint'] = array_merge($complaint,$customcomplaint);
// Create an mPDF object
$mpdf = new Mpdf([
'mode' => '',
'format' => 'A5',
'default_font_size' => 0,
'default_font' => '',
// 'margin_right' => 1,
'margin_top' => 6,
'margin_bottom' => 6,
'margin_header' => 6,
'margin_footer' =>-30,
'orientation' => 'P',
]);
$mpdf->autoLangToFont = true;
$mpdf->autoScriptToLang = true;
// Set PDF properties
$mpdf->SetTitle('Invoice');
// $mpdf->SetAuthor($data[0]->branch_name);
$mpdf->SetCreator('');
// Generate the PDF content (HTML) with data
$html = view('jobcard_pdf_template', $data);
// echo $html;die;
// Load HTML into the mPDF instance
$mpdf->WriteHTML($html);
// Output the PDF to the browser for download
$mpdf->Output('JC_' . date('Y-m-d H-i-s') . '.pdf', 'D');
}
public function new_jobcard($job_card_id)
{

View File

@ -329,7 +329,8 @@ class Products extends BaseController
// Check if both make and model are provided
if (!empty($make) && !empty($model)) {
$data = [
'make' => $make
'make' => $make,
'business_id' => $this->session->get('logged_user_business_id'),
];
// Insert the make into the database
@ -339,6 +340,7 @@ class Products extends BaseController
$modelData = [
'model_name' => $model,
'make_id' => $make_id,
'business_id' => $this->session->get('logged_user_business_id'),
];
// Insert the model into the database

View File

@ -100,7 +100,7 @@ class JobcardModel extends Model
public function get_jobcard_custom_complaint($job_id)
{
$this->select('job_card.*, job_card_custom_complaint.*, job_card_custom_complaint.name as product_name, job_card_custom_complaint.labour_cost as labour_amount');
$this->select('job_card.*, job_card_custom_complaint.*, job_card_custom_complaint.complaint_name as product_name, job_card_custom_complaint.labour_cost as labour_amount');
$this->join('job_card_custom_complaint', 'job_card_custom_complaint.job_card_id = job_card.job_card_id');
$this->where('job_card.isactive', 1);
$this->where('job_card.job_card_id', $job_id);

View File

@ -3,6 +3,9 @@
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title"><?php echo $page_name?></h4>
<?php if(isset($jobs['job_card_id'])) { ?>
<a style="margin-left: 120px;position: absolute;" href="<?= base_url() ."download_jobcard/" . $jobs['job_card_id']; ?>" class="download-button" title="Download Jobcard"><i class="ri-download-2-fill" style="font-size: 20px;"></i></a>
<?php } ?>
<div class="page-title-right">
<a href="<?= base_url() . "sales_order_index"; ?>" class="btn btn-secondary waves-effect">Cancel</a>
<ol class="breadcrumb m-0">
@ -172,8 +175,17 @@
</div>
<div class="form-group">
<label for="grandtotal">Discount</label>
<input type="text" class="form-control" id="discount_amount" name="discount_amount" readonly value="<?= isset($sales['discount_amount']) ? $sales['discount_amount'] : '' ?>">
</div>
<div class="input-group">
<input type="text" class="form-control" id="dt_amount" name="discount" value="<?= isset($sales['dt_amount']) ? $sales['dt_amount'] : '' ?>">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="applyDiscountBtn">Apply</button>
<button class="btn btn-outline-secondary" type="button" id="refreshDiscountBtn">
<span class="fas fa-sync-alt"></span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
@ -423,7 +435,7 @@ $(document).ready(async function() {
'<td style="width:10%;"><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="1" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+data.tax+'" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="'+Math.round(total_tax_amt)+'" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + Math.round(total_wih_tax) + '" /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + Math.round(total_wih_tax) + '" /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
@ -665,6 +677,53 @@ $(window).on('load', function() {
updateCalculations();
});
function updateItemAmounts(discount) {
var amt = 0;
$('.lab_amt').each(function() {
amt = Number($(this).val());
if(discount > amt) {
discount = discount - amt;
$(this).val(0).change();
}
else {
amt = amt - discount;
$(this).val(amt).change();
return false;
}
});
}
var tableData;
var initial = 0;
// Update item amounts on change of discount
$('#applyDiscountBtn').on('click', function() {
if($('#dt_amount').val() != '' && $('#dt_amount').val() > 0 && $('#grandtotal').val() > 0) {
if(initial == 0) {
tableData = $('#productItemTable tbody').html();;
initial++;
}
var discount = parseFloat($('#dt_amount').val());
$('#refreshDiscountBtn').prop('disabled', false);
$('#dt_amount').prop('disabled', true);
$(this).prop('disabled', true);
updateItemAmounts(discount);
}
});
$('#refreshDiscountBtn').prop('disabled', true);
$('#refreshDiscountBtn').on('click', function() {
$('#productItemTable tbody').empty();
$('#productItemTable tbody').append(tableData);
$('#refreshDiscountBtn').prop('disabled', true);
$('#dt_amount').val(0);
$('#dt_amount').prop('disabled', false);
$('#applyDiscountBtn').prop('disabled', false);
});
$(document).on('keyup change', '#discout_amount', function() {
amount = $(this).val();
tax = $(this).closest('tr').find('.item-tax').val();
@ -1012,7 +1071,7 @@ $(window).on('load', function() {
'<td style="width:10%;"><input type="number" class="form-control item-quantity-'+cls+' item-quantity" min="0" name="quantity[]" value="'+1+'" /></td>' +
'<td style="width:8%;"><input type="text" class="form-control taxable-value item-tax" name="item-tax[]" value="'+tax+'" /></td>' +
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="'+total_tax_amt+'" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount" name="amount[]" value="' + total_wih_tax + '"/></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount lab_amt" name="amount[]" value="' + total_wih_tax + '"/></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';
@ -1330,7 +1389,7 @@ $(window).on('load', function() {
'<td style="width:10%;"><input type="number" class="form-control item-quantity" min="0" name="quantity[]" value="'+1+'" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control taxable-value item-tax item-tax_cc" name="item-tax[]" value="'+18+'" readonly /></td>' +
'<td style="width:8%;"><input type="text" class="form-control total-tax-amount" value="" readonly /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount item-amount_cc" name="amount1[]" value="" required /></td>' +
'<td style="width:12%;"><input type="text" class="form-control item-amount lab_amt item-amount_cc" name="amount1[]" value="" required /></td>' +
'<td hidden></td>' +
'<td hidden></td>' +
'</tr>';

View File

@ -0,0 +1,332 @@
<!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; /* Change this value to your desired font size */
}
/* Style for the main table with border */
table.main-table {
width: 100%;
border-collapse: collapse;
border: -0.5px solid black; /* Add a border around the entire invoice */
}
table.main-table th,
table.main-table td {
border: none; /* Remove borders from all cells inside the main table */
}
/* Style for the table containing business details */
table.business-details-table {
width: 100%;
border-collapse: collapse;
}
table.business-details-table td {
padding: 8px;
text-align: left;
}
/* Style for the business logo and title */
.business-logo-container {
text-align: center;
}
img.business-logo {
max-width: 200px; /* Adjust the size of the logo */
}
/* Style for the business name */
.business-name {
font-size: 16px;
font-weight: bold;
margin-top: 10px;
}
/* Style for the table containing invoice info */
table.invoice-info-table {
width: 100%;
border-collapse: collapse;
}
table.invoice-info-table th,
table.invoice-info-table td {
border: 1px solid;
text-align: left;
}
/* Style for the addresses table */
table.addresses-table {
width: 100%;
}
table.addresses-table th {
text-align: left;
padding-left: 8px;
}
/* Style for the billing and shipping addresses */
.billing-address {
width: 50%;
padding-left: 8px;
}
/* Style for the invoice-related table */
table.invoice-related-table {
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: left; /* Center-align text in cells */
max-width: 2px;
}
table.invoice-related-table th {
background-color: #DAC2AD;
font-weight: bold;
}
/* --------------------------------- */
table.invoice-related-table1 {
/* width: 100%; */
border-collapse: collapse;
}
table.invoice-related-table1 th,
table.invoice-related-table1 td {
border: none;
padding: 8px;
text-align: left;
max-width: 2px;
}
table.invoice-related-table1 th {
background-color: #DAC2AD;
font-weight: bold;
}
/* 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 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 {
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>
<table><tr>
<td style="padding:20px;"><b>DATE: </b><?= (new DateTime($vehicle[0]['created_at']))->format('d/m/Y') ?></td>
<td style="padding:20px;"><h3><b>JOB CARD</b></h3></td>
<td style="padding:20px;"><b>JOB NO: </b><?= $vehicle[0]['order_number'] ?></td>
</tr></table>
<hr style="margin-top: 10px; margin-bottom: 10px;">
<br>
<table class="list" style="width:100%">
<tr>
<td style="width: 33.33%; vertical-align: top;">
<table class="invoice-related-table1" style="width:95%;float:left;">
<tbody>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="2"><center>CUSTOMER INFO</center></th>
</tr>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">NAME</th>
<th style="border: 0.5px solid black;">MOBILE</th>
</tr>
<tr>
<td style="border: 1px solid black;"><?= $job_card[0]['client_name'] ?></td>
<td style="border: 0.5px solid black;"><?= $job_card[0]['client_mobile_no'] ?></td>
</tr>
</tbody>
</table>
</td>
<td style="width: 33.33%; vertical-align: top;">
<table class="invoice-related-table1" style="width:95%;margin:0 auto;">
<tbody>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="4"><center>VEHICLE INFO</center></th>
</tr>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">MAKE</th>
<th style="border: 0.5px solid black;">MODEL</th>
<th style="border: 0.5px solid black;">COLOR</th>
<th style="border: 0.5px solid black;">REG NO</th>
</tr>
<tr>
<td style="border: 1px solid black;"><?= $vehicle[0]['bike_company'] ?></td>
<td style="border: 0.5px solid black;"><?= $vehicle[0]['bike_name'] ?></td>
<td style="border: 0.5px solid black;"><?= $vehicle[0]['colour'] ?></td>
<td style="border: 0.5px solid black;"><?= $vehicle[0]['reg_no'] ?></td>
</tr>
</tbody>
</table>
</td>
<td style="width: 33.33%; vertical-align: top;">
<table class="invoice-related-table1" style="width:95%;float:right;">
<tbody>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="3"><center>DELIVERY INFO</center></th>
</tr>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">DATE</th>
<th style="border: 0.5px solid black;">FUEL QTY</th>
<th style="border: 0.5px solid black;">METER</th>
</tr>
<tr>
<td style="border: 1px solid black;">04/06/2024</td>
<td style="border: 0.5px solid black;">25%</td>
<td style="border: 0.5px solid black;">14556</td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<br>
<table class="list" style="width:100%; table-layout: fixed;">
<tr>
<td style="width: 50%; vertical-align: top;">
<table class="invoice-related-table1" style="width:95%; float:left;">
<tbody>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="2"><center>TYPE OF SERVICES</center></th>
</tr>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">Services List</th>
<th style="border: 0.5px solid black;">Action</th>
</tr>
<?php foreach ($service as $key => $item) : ?>
<tr>
<td style="border: 0.5px solid black;"><?= $item['product_name'] ?></td>
<td style="border: 0.5px solid black;"></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</td>
<td style="width: 50%; vertical-align: top;">
<table class="invoice-related-table1" style="width:95%; float:right;">
<thead>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="2"><center>OTHER WORKS</center></th>
</tr>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;">Complaint List</th>
<th style="border: 0.5px solid black;">Action</th>
</tr>
</thead>
<tbody>
<?php foreach ($complaint as $key => $item) : ?>
<tr>
<td style="border: 0.5px solid black;"><?= $item['product_name'] ?></td>
<td style="border: 0.5px solid black;"></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</td>
</tr>
</table>
<br>
<table class="invoice-related-table">
<tbody>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;" colspan="5"><center>PRODUCT DETAILS</center></th>
</tr>
<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;">Quantity</th>
<th style="border: 0.5px solid black;">Per</th>
<th style="border: 0.5px solid black;">Action</th>
</tr>
<?php foreach ($job_card_products as $key => $item) : ?>
<tr>
<td style="border: 1px solid black;"><?= $key+1; ?></td>
<td style="border: 0.5px solid black;"><?= $item['product_name'] ?></td>
<td style="border: 0.5px solid black;"><?= $item['qty'] ?></td>
<td style="border: 0.5px solid black;"><?= $item['per'] ?></td>
<td style="border: 0.5px solid black;"></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<table class="invoice-related-table">
<thead>
<tr style="border: 1px solid black;">
<th style="border: 0.5px solid black;"><center>DESCRIPTION</center></th>
</tr>
</thead>
<tbody>
<tr>
<td style="border: 0.5px solid black;">bike's right indicator is broken, and the tank is scratched.</td>
</tr>
</tbody>
</table>
</body>
</html>

View File

@ -76,10 +76,9 @@
<label for="model" class="col-form-label">Service</label>
<select class="form-control SelExample" id="serviceSelected" name="sub_service_id[]" multiple>
<option value="">Select a Service</option>
<option value="0" <?= isset($services['sub_service_id']) && in_array(0, json_decode($services['sub_service_id'])) ? 'selected' : '' ?>>None</option>
<?php foreach ($service as $value) : ?>
<?php if ((int)$value["isactive"] === 1) : ?>
<option value="<?= $value["service_id"] ?>" <?= isset($services['sub_service_id']) && !empty($services['sub_service_id']) && in_array($value['sub_service_id'], json_decode($services['sub_service_id'])) ? 'selected' : '' ?>>
<option value="<?= $value["service_id"] ?>" <?= isset($services['sub_service_id']) && is_array(json_decode($services['sub_service_id'])) && in_array($value['service_id'], json_decode($services['sub_service_id'])) ? 'selected' : '' ?>>
<?= $value["service_name"]; ?>
</option>
<?php endif; ?>