CHANGE_MECHANIC_JOB_INVOICE:ss
This commit is contained in:
parent
8e454e7849
commit
31c0581512
@ -84,7 +84,7 @@ $routes->post("add_jobs", "Jobcard::add_jobs");
|
||||
$routes->get("new_jobcard/(:any)", "Jobcard::new_jobcard/$1");
|
||||
$routes->get("delete_jobcard/(:any)", "Jobcard::delete_jobcard/$1");
|
||||
// $routes->post("delete_sales_product", "Jobcard::delete_sales_product");
|
||||
// $routes->get("download_invoice/(:any)", "Jobcard::download_invoice/$1");
|
||||
$routes->get("download_jobcard_invoice/(:any)", "Jobcard::download_jobcard_invoice/$1");
|
||||
// $routes->post("save_vehicle", "Jobcard::save_vehicle");
|
||||
$routes->post("getServices", "Jobcard::getServices");
|
||||
//End Job Card //
|
||||
|
||||
@ -70,9 +70,11 @@ class Business extends BaseController
|
||||
'business_name' => $this->request->getPost('businessname'),
|
||||
'email' => $this->request->getPost('email'),
|
||||
'address' => $this->request->getPost('address'),
|
||||
'gstno' => $this->request->getPost('gstno'),
|
||||
'mobile' => $this->request->getPost('mobile'),
|
||||
'city' => $this->request->getPost('city'),
|
||||
'state' => $this->request->getPost('state'),
|
||||
'code' => $this->request->getPost('code'),
|
||||
'postal_code' => $this->request->getPost('postalcode'),
|
||||
'country' => $this->request->getPost('country'),
|
||||
'isactive' => 1 // Assuming this is a default value or handled separately
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Models\BusinessModel;
|
||||
use App\Models\JobcardModel;
|
||||
use App\Models\JobcardComplaintModel;
|
||||
use App\Models\JobcardCustomComplaintModel;
|
||||
@ -19,17 +19,22 @@ use App\Models\SalesOrderProductModel;
|
||||
use App\Models\UsersModel;
|
||||
use App\Models\RoleModel;
|
||||
use Mpdf\Mpdf;
|
||||
|
||||
class Jobcard extends BaseController
|
||||
{
|
||||
public $session;
|
||||
public $BikemodelsModel;
|
||||
public $BikemakeModel;
|
||||
public $BusinessModel;
|
||||
public $JobcardModel;
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->session = session();
|
||||
$this->BikemodelsModel = new BikemodelsModel();
|
||||
$this->BikemakeModel = new BikemakeModel();
|
||||
$this->BusinessModel = new BusinessModel();
|
||||
$this->JobcardModel = new JobcardModel();
|
||||
|
||||
}
|
||||
|
||||
@ -46,6 +51,51 @@ class Jobcard extends BaseController
|
||||
return view('jobs_list',$data);
|
||||
}
|
||||
|
||||
public function download_jobcard_invoice($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->BusinessModel->where('business_id', $bus_id)->where('isactive', 1)->findAll();
|
||||
$data['job_card_products'] = $this->JobcardModel->get_jobcard_products_details($job_card_id);
|
||||
|
||||
// echo json_encode($data['job_card_products']);die;
|
||||
|
||||
|
||||
// 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('invoice_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('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
}
|
||||
|
||||
|
||||
public function new_jobcard($job_card_id)
|
||||
{
|
||||
@ -474,73 +524,6 @@ class Jobcard extends BaseController
|
||||
|
||||
return redirect()->to('job_card_index');
|
||||
}
|
||||
public function download_invoice($sales_order_id)
|
||||
{
|
||||
// echo "hello"; die;
|
||||
// Fetch the invoice data based on $invoice_id
|
||||
$model = new SalesOrderModel();
|
||||
$data = $model->getSalesPdf($sales_order_id);
|
||||
|
||||
$items = $model->getSalesOrderProductsForPdf($sales_order_id);
|
||||
|
||||
|
||||
|
||||
// print_r($items);die();
|
||||
|
||||
// print_r($invoiceItems);die();
|
||||
|
||||
// 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)
|
||||
if ($data[0]->status === 'Draft') {
|
||||
// Set the watermark text and options
|
||||
$mpdf->SetWatermarkText('Draft');
|
||||
$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
|
||||
$html = view('invoice_pdf_template', ['sales' => $data,'items'=>$items]);
|
||||
// echo $html;die;
|
||||
// Load HTML into the mPDF instance
|
||||
$mpdf->WriteHTML($html);
|
||||
|
||||
// Output the PDF to the browser for download
|
||||
$mpdf->Output('invoice_' . date('Y-m-d H-i-s') . '.pdf', 'D');
|
||||
}
|
||||
|
||||
|
||||
public function save_vehicle(){
|
||||
|
||||
@ -5,7 +5,7 @@ class BusinessModel extends Model
|
||||
{
|
||||
protected $table = 'business';
|
||||
protected $primaryKey = 'business_id';
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address','city','state','postal_code','country','isactive'];
|
||||
protected $allowedFields = ['business_id','business_unique_id','branch_unique_id','business_name','email','mobile','address', 'gstno','city','state', 'code','postal_code','country','isactive'];
|
||||
|
||||
public function getBusinessById($business_id) {
|
||||
return $this->db->table('business')->where('business_id', $business_id)->get()->getRowArray();
|
||||
|
||||
@ -56,5 +56,26 @@ class JobcardModel extends Model
|
||||
$this ->where('job_card.branch_id',$logged_user_branch_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function get_jobcard_vehicle_details($job_id)
|
||||
{
|
||||
$this->select('job_card.job_card_id, job_card.order_number, job_card.vehicle_id as jobcard_vehicle_id, vehicle.*, make.make as bike_company, model.model_name as bike_name');
|
||||
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id');
|
||||
$this->join('make', 'make.make_id = vehicle.make');
|
||||
$this->join('model', 'model.model_id = vehicle.model');
|
||||
$this->where('job_card.job_card_id', $job_id);
|
||||
$this->where('job_card.isactive', 1);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
public function get_jobcard_products_details($job_id)
|
||||
{
|
||||
$this->select('job_card_product.*, job_card_product.tax, products.product_name, products.per');
|
||||
$this->join('job_card_product', 'job_card_product.job_card_id = job_card.job_card_id');
|
||||
$this->join('products', 'products.product_id = job_card_product.product_id');
|
||||
$this->where('job_card_product.is_active', 1);
|
||||
$this->where('job_card_product.job_card_id', $job_id);
|
||||
return $this->findAll();
|
||||
}
|
||||
|
||||
}
|
||||
@ -41,6 +41,10 @@
|
||||
</div>
|
||||
<input type="hidden" id="business_id" name="business_id" value="<?= isset($business['business_id']) ? $business['business_id'] : '' ?>">
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">GST No</label>
|
||||
<input type="text" class="form-control" name="gstno" placeholder="GSTNO"value="<?= isset($business['gstno']) ? $business['gstno'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">City</label>
|
||||
<input type="text" class="form-control" name="city" placeholder="City"value="<?= isset($business['city']) ? $business['city'] : '' ?>" required>
|
||||
@ -49,6 +53,10 @@
|
||||
<label for="inputPassword4" class="col-form-label">State</label>
|
||||
<input type="text" class="form-control" name="state" placeholder="State"value="<?= isset($business['state']) ? $business['state'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">State Code</label>
|
||||
<input type="text" class="form-control" name="code" placeholder="Code"value="<?= isset($business['code']) ? $business['code'] : '' ?>" required>
|
||||
</div>
|
||||
<div class="form-group col-md-6">
|
||||
<label for="inputPassword4" class="col-form-label">Postal Code</label>
|
||||
<input type="text" class="form-control" name="postalcode" placeholder="Postal Code"value="<?= isset($business['postal_code']) ? $business['postal_code'] : '' ?>" required maxlength="6" minlength="6">
|
||||
|
||||
@ -143,148 +143,131 @@ p {
|
||||
<td>
|
||||
<table class="business-details-table">
|
||||
|
||||
<?php foreach ($sales as $value) : ?>
|
||||
<tr>
|
||||
<td class="business-logo-container"style="font-size: 16px;font-weight: bold;">
|
||||
THE MECHANIC
|
||||
<!-- <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><?= $value->company_address ?>,<br>
|
||||
<?= $value->company_city ?>,
|
||||
<?= $value->company_state ?>
|
||||
<?= $value->company_postal_code ?>.</p>
|
||||
|
||||
<p><?= $value->company_mobile_no ?></p>
|
||||
</td>
|
||||
<?php foreach ($company_address as $value) : ?>
|
||||
<td style="max-width: 50px;">
|
||||
<p><b>THE MECHANIC</b><br>
|
||||
<?= $value['address'] ?>,<br>
|
||||
<?= '<b>GSTNO: </b>'.$value['gstno'] ?><br>
|
||||
<?= '<b>State Name: </b>'.$value['state'].', code'.$value['code'] ?><br>
|
||||
<?= '<b>Contact: </b>'.$value['postal_code'] ?><br>
|
||||
<?= '<b>Email: </b>'.$value['email'] ?></p>
|
||||
<br>
|
||||
<b>Buyer (Bill To)</b><br>
|
||||
<p><?= $job_card[0]['billing_address'].', '.$job_card[0]['billing_city'].', '.$job_card[0]['billing_state'].', '.$job_card[0]['billing_country'].', '.$job_card[0]['billing_postal_code'] ?>,<br>
|
||||
<?= '<b>GSTNO: </b>' ?><br>
|
||||
<?= '<b>State Name: </b>'.$job_card[0]['billing_state'] ?><br>
|
||||
<?= '<b>Place of Supply: </b>'.$value['state'] ?></p>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</td>
|
||||
<td>
|
||||
<table class="invoice-info-table">
|
||||
<?php foreach ($sales as $value) : ?>
|
||||
<tr>
|
||||
<th><?php echo ($value->order_number) ? 'Order # ' . $value->order_number : 'Invoice # ' . $value->invoice_number; ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Date : <?= date('d-m-Y', strtotime($value->created_at)) ?></th>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
<table class="invoice-info-table" style="max-width: 250px;border: 1px solid black;">
|
||||
<tr>
|
||||
<td>Invoice No.</td>
|
||||
<td>1657</td>
|
||||
</tr>
|
||||
<tr style="border: 1px solid black;">
|
||||
<td>Bike Name</td>
|
||||
<td><?= $vehicle[0]['bike_company'].' '.$vehicle[0]['bike_name'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Color</td>
|
||||
<td><?= $vehicle[0]['colour'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Bie Number</td>
|
||||
<td><?= $vehicle[0]['reg_no'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Contact Number</td>
|
||||
<td><?= $vehicle[0]['mobile_no'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Job Card Number</td>
|
||||
<td><?= $vehicle[0]['order_number'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Dated</td>
|
||||
<td><?= (new DateTime($vehicle[0]['created_at']))->format('d/m/Y') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Delivery Date</td>
|
||||
<td>04/06/2024</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Mode of Payment</td>
|
||||
<td>Online</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="addresses-table">
|
||||
<tr >
|
||||
<th class="billing-address">Billing Address</th>
|
||||
|
||||
</tr>
|
||||
<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>
|
||||
<!-- <td class="shipping-address">
|
||||
|
||||
</td> -->
|
||||
</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 ($job_card_products as $item) : $totalamount = 0; ?>
|
||||
<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>
|
||||
<?= $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 style="border: 1px solid black;">
|
||||
<?= $serialNumber++; ?>
|
||||
</td>
|
||||
<td style="border-right: 0.5px solid black;"><?= $item['product_name'] ?></td>
|
||||
<td style="border-right: 0.5px solid black;"><?= $item['amount'] ?></td>
|
||||
<td style="border-right: 0.5px solid black;"><?= $item['qty'] ?></td>
|
||||
<td style="border-right: 0.5px solid black;">nos</td>
|
||||
<td style="border-right: 0.5px solid black;"><?= $item['tax'] ?>%</td>
|
||||
<td style="border-right: 0.5px solid black;"><?= ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
|
||||
<td style="border-right: 0.5px solid black;"><?= ($item['amount'] * ($item['tax'] / 2) / 100) ?></td>
|
||||
<td style="border: 0.5px solid black;"><?= ($item['amount'] * $item['tax'] / 100) ?></td>
|
||||
<td style="border-right: 0.5px solid black;"><?= ($item['amount'] + ($item['amount'] * $item['tax'] / 100) ) ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<tr>
|
||||
<td colspan="5" align="right">Subtotal : ₹<?= number_format($value->subtotal, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" align="right">Tax : ₹<?= number_format($value->tax, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
|
||||
|
||||
<!-- -->
|
||||
|
||||
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="5" align="right">Total : ₹<?= number_format($value->total, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
<?php if ($value->status === 'Approved'): ?>
|
||||
<tr>
|
||||
<td colspan="5" align="right">Paid : ₹<?= number_format($value->total_amount, 2, '.', ',') ?></td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<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;"><?= $job_card[0]['tax'] ?></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;"><?= $job_card[0]['tax'] ?></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;"><?= $job_card[0]['tax'] ?></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;"><?= $job_card[0]['total'] ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="10" style="border: 0.5px solid black;">Amount Chargeable (in words)</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="business-stamp">
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="terms">
|
||||
|
||||
|
||||
<p style=text-align:left><?= $value->terms_condition;?></p>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- ... (your existing HTML template) -->
|
||||
|
||||
<!-- Add this to the end of your HTML template -->
|
||||
|
||||
|
||||
<!-- <img src="https://cdn.pixabay.com/photo/2012/04/26/14/17/blue-42596_960_720.png" /> -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -79,7 +79,7 @@
|
||||
<td>
|
||||
<a href="<?= "new_jobcard/" . $value['job_card_id']; ?>" class="edit-button"><i class="ri-pencil-line"></i></a>
|
||||
|
||||
<a href="<?= "download_invoice/" . $value['job_card_id']; ?>" class="edit-button"><i class="ri-file-download-line"></i></a>
|
||||
<a href="<?= "download_jobcard_invoice/" . $value['job_card_id']; ?>" class="edit-button"><i class="ri-file-download-line"></i></a>
|
||||
|
||||
<a href="<?= "delete_jobcard/" . $value['job_card_id']; ?>" class="delete-button"><i class="ri-delete-bin-line"></i></a>
|
||||
</td>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user