FIX_A5 alignment

This commit is contained in:
VE10-Sanjeev 2024-09-20 10:29:16 +00:00
parent 66b17fe2c7
commit baa0d4a068
2 changed files with 45 additions and 52 deletions

View File

@ -857,41 +857,36 @@ class Invoice extends BaseController
$mpdf->Output($pdfFileName, 'D'); $mpdf->Output($pdfFileName, 'D');
} }
//new design
public function print_address_landscape($id) public function print_address_landscape($id)
{ {
$model = new InvoiceModel(); $model = new InvoiceModel();
$invoiceData = $model->getInvoiceData($id); $invoiceData = $model->getInvoiceData($id);
// print_r($invoiceData);die(); // print_r($invoiceData);die();
$config = [ $config = [
'mode' => 'utf-8', 'mode' => 'utf-8',
'format' => 'A5-L', // Change format to A5-L for landscape 'format' => 'A5-L', // A5 landscape format
'default_font_size' => 12, 'default_font_size' => 12,
'default_font' => 'Arial', 'default_font' => 'Arial',
'margin_left' => 0, 'margin_left' => 10,
'margin_right' => 0, 'margin_right' => 10,
'margin_top' => 5, 'margin_top' => 10,
'margin_bottom' => 5, 'margin_bottom' => 10,
'margin_header' => 0, 'orientation' => 'L', // Landscape orientation
'margin_footer' => 0,
'orientation' => 'L', // Change to landscape orientation
]; ];
// $mpdf = new \Mpdf\Mpdf($config);
$mpdf = new Mpdf($config); $mpdf = new Mpdf($config);
$mpdf->SetTitle('Customer Address'); $mpdf->SetTitle('Customer Address');
$mpdf->SetAuthor($invoiceData[0]->company_name); $mpdf->SetAuthor($invoiceData[0]->company_name);
$mpdf->SetCreator('');
// Generate the PDF content (HTML) with customer and address data // Generate the PDF content (HTML) with customer and address data
$html = view('address_pdf_landscape_template', ['invoiceData' => $invoiceData]); $html = view('address_pdf_landscape_template', ['invoiceData' => $invoiceData]);
// echo $html;die; // echo $html;die;
$mpdf->WriteHTML($html); $mpdf->WriteHTML($html);
$pdfFileName = 'customer_address_' . date('Y-m-d H-i-s') . '.pdf'; $pdfFileName = 'customer_address_' . date('Y-m-d_H-i-s') . '.pdf';
$mpdf->Output($pdfFileName, 'D'); $mpdf->Output($pdfFileName, 'D');
} }
public function general_inv_rp() public function general_inv_rp()
{ {
$model = new InvoiceModel(); $model = new InvoiceModel();

View File

@ -6,15 +6,15 @@
<title>Shipping Label Template</title> <title>Shipping Label Template</title>
<style> <style>
body { body {
font-family:Helvetica!important; font-family: Helvetica, Arial, sans-serif;
box-sizing: border-box; box-sizing: border-box;
font-size: 12px;
} }
.label-container { .label-container {
margin: 20px; margin: 30px;
padding: 20px; padding: 30px;
border: 2px solid #000; border: 2px solid #000;
width: 100%;
height: 100%;
position: relative; position: relative;
} }
.from-address, .to-address { .from-address, .to-address {
@ -35,46 +35,44 @@
float: right; float: right;
width: 60%; width: 60%;
clear: both; clear: both;
margin-top: 20px; /* Adjust for spacing in landscape */
} }
</style> </style>
</head> </head>
<body> <body>
<?php <?php foreach ($invoiceData as $value): ?>
foreach ($invoiceData as $value) : <div class="label-container">
?> <!-- From Address on the left -->
<div class="from-address">
<div class="label-container"> <strong>From :</strong><br>
<!-- From Address on the left --> <?= $value->company_name; ?><br>
<div class="from-address"> <?= $value->company_address . ","; ?><br>
<strong>From :</strong> <br> <?= $value->company_city; ?> - <?= $value->company_postal_code . ","; ?><br>
<?= $value->company_name; ?><br> <?= $value->company_state . "."; ?><br>
<?= $value->company_address. ","; ?><br> <?= $value->company_mobile_no; ?>
<?= $value->company_city; ?> - <?= $value->company_postal_code. ","; ?><br> </div>
<?= $value->company_state. "."; ?><br> <!-- Order Number on the right -->
<?= $value->company_mobile_no; ?> <div class="order-number">
</div> <b> Order : </b><?php echo $value->invoice_number; ?>
<!-- Order Number on the right --> </div>
<div class="order-number"> <!-- To Address -->
<b> Order : </b><?php echo $value->invoice_number; ?> <div class="to-address">
</div> <strong>To :</strong><br>
<!-- To Address in the center --> <?= $value->customer_name ?><br>
<div class="to-address"> <?php if($value->customer_ship_address && ($value->saddr_id !== null || $value->saddr_id !== '')){ ?>
<strong>To :</strong> <br> <?= $value->customer_ship_address ? $value->customer_ship_address . " , <br>" : "" ?>
<?= $value->customer_name ?><br> <?= $value->customer_ship_city ? $value->customer_ship_city . "&nbsp;" : "" ?>
<?php if($value->customer_ship_address && ($value->saddr_id !== null || $value->saddr_id !== '')){ ?> <?= $value->customer_ship_postal_code ? " - " . $value->customer_ship_postal_code . "<br>" : ""; ?>
<?= $value->customer_ship_address ? $value->customer_ship_address." , <br>" : "" ?> <?= $value->customer_ship_state ? $value->customer_ship_state . ". <br>" : "" ?>
<?= $value->customer_ship_city ? $value->customer_ship_city."&nbsp;" : "" ?> <?php }else if ($value->saddr_id === null || $value->saddr_id === '') {
<?= $value->customer_ship_postal_code ? " - " . $value->customer_ship_postal_code." <br>" : ""; ?>
<?= $value->customer_ship_state ? $value->customer_ship_state. ". <br>" : "" ?>
<?php }else if ($value->saddr_id === null || $value->saddr_id === '') {
echo $value->shipping_address ? $value->shipping_address.'<br>' : ''; echo $value->shipping_address ? $value->shipping_address.'<br>' : '';
} ?> } ?>
<?= $value->mobile_no ? "Mobile : ".$value->mobile_no." ." : "" ?> <?= $value->mobile_no ? "Mobile : " . $value->mobile_no . " ." : "" ?>
</div>
<div style="clear: both;"></div>
</div> </div>
<!-- Clear floats to maintain layout -->
<div style="clear: both;"></div>
</div>
<?php endforeach; ?> <?php endforeach; ?>
</body> </body>