I think you forgot to explain the problem? :)
Sep 17, 2022
6
Level 1
dompdf laravel
Hello All,
Im new here and would appreciate any help on the issue what I'm facing in dompdf laravel.
below code is from controller
public function mht_order_pdf(){
set_time_limit(300);
$order_unq_id[] = request()->session()->get('order_unq_id');
$val = $order_unq_id[0]['order_unq_id'];
$customers = Customer::all();
$linkeds = Linked::all();
$orders = Order::all();
$date = date('d-M-y');
$orderDtls = DB::select("SELECT
orders.customerName_input,
orders.order_unq_id,
orders.product_name_input,
orders.item_name_input,
orders.item_no_input,
orders.item_description_input,
orders.supplier_ref_no_input,
orders.supplier_barcode_input,
orders.item_cost_input,
items.item_unit_measure,
orders.item_quantity,
orders.itemTotal_input,
orders.subtotal_input,
orders.tax_input,
orders.total
FROM customers
JOIN linkeds ON customers.id = linkeds.customer_id
JOIN products ON linkeds.product_id = products.id
JOIN items ON linkeds.item_id = items.id
JOIN orders ON linkeds.id = orders.linked_id
WHERE orders.order_unq_id LIKE '$val';"
);
foreach($orderDtls as $order)
$customerName_input = $order->customerName_input;
$order_unq_id = $order->order_unq_id;
$subtotal_input = $order->subtotal_input;
$tax_input = $order->tax_input;
$total = $order->total;
$pdf = \PDF::loadView('mht_order_pdf', compact('customers', 'linkeds', 'orders', 'orderDtls', 'date',
'customerName_input', 'order_unq_id', 'subtotal_input', 'tax_input', 'total'));
$pdf->setPaper('A4', 'landscape');
return $pdf->stream('mht_order_pdf.pdf');
// return $pdf->download('mht_order_pdf.pdf');
}
below code is from blade.php
<style>
@page { margin: 1%; }
body { margin: 1%; }
.order_heading{
font-family: Arial, Helvetica, sans-serif;
}
.orderDtls{
position: absolute !important;
/* position: static !important; */
margin: 2% 5% 10% 76.1%;
width: 60%;
}
.orderSummary{
margin-top: 8%;
margin-bottom: 4%;
}
.date{
float: right;
margin-top: 8%;
font-size: 12px;
}
.navbar-brand{
font-size: 25px;
}
.details{
border: 1px solid #989898;
margin-top: -25px;
padding: 5px;
font-family: Arial, Helvetica, sans-serif;
font-size: 15px;
font-weight: normal;
width: 40%;
}
.details span{
color: red;
text-transform: uppercase;
float: right;
}
#orderTable{
/* position: absolute; */
margin-top: -2%;
font-family: Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 100%;
text-align: center;
padding-bottom: 5%;
}
#orderTable td, #orderTable th{
border: 1px solid #989898;
}
#orderTable th{
background: blue;
color: white;
font-size: 13px;
text-transform: uppercase
}
#orderTable td{
font-size: 13px;
}
header {
position: fixed;
left: 0px;
right: 0px;
height: 50px;
}
footer {
position: fixed;
bottom: 1%;
left: 0px;
right: 0px;
background-color: blue;
height: 3%;
color: white;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
width: 98%;
margin-left: 1%;
}
.contact_details{
font-size: 12px;
font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
margin-left: 1% !important;
margin-top: -4% !important;
}
.dtl{
margin-top: -1%;
}
</style>
</head>
<body>
<header>
<div class="d-block text-center" style="text-align: center; margin-top: -15px;">
<h1 style="text-align: center;" class="navbar-brand text-underline text-center"><u> ABC HOUSE </u></h1>
<p style="margin-top:-15px">Trading L.L.C.</p>
</div>
<div class="contact_details">
<p class="dtl">Tel.: 0123454455</p>
<p class="dtl">Mobile.: 0212121111</p>
<p class="dtl">Email: [email protected]</p>
</div>
<hr style="margin-top: -10px; width: 98%"><br><br>
</header>
<footer>
<div class="container my-auto">
<div class="copyright text-center" style="padding-top: 5px;">
<span>Copyright © <b> ABC House </b> <?php echo date("Y");?> </span>
</div>
</div>
</footer>
<div class="order_heading">
<p class="date"><u>Date: {{$date}}</u></p>
<h3 class="orderSummary">Order Summary: </h3>
<h5 class="details">Order ID: <span>{{$order_unq_id}}</span></h5>
<h5 class="details">Customer Name: <span>{{$customerName_input}}</span></h5>
</div><br>
<main class="page wrapper-page" style="page-break-after:auto;">
<table class="table caption-top" id="orderTable">
<thead>
<tr>
<th style="height: 4%;" scope="col">Product Name</th>
<th scope="col">Item Name</th>
<th scope="col">Item No.</th>
<th scope="col">Supplier Barcode</th>
<th scope="col">Units of Measure</th>
<th scope="col">Item Qty.</th>
<th scope="col">Item Cost</th>
<th scope="col">Item Total</th>
</tr>
</thead>
<tbody>
@foreach($orderDtls as $order)
<tr>
<td style="height: 3%;">{{$order->product_name_input}}</td>
<td>{{$order->item_name_input}}</td>
<td>{{$order->item_no_input}}</td>
<td>{{$order->supplier_barcode_input}}</td>
<td>{{$order->item_unit_measure}}</td>
<td>{{$order->item_quantity}}</td>
<td>{{$order->item_cost_input}}</td>
<td>{{$order->itemTotal_input}}</td>
</tr>
@endforeach
</tbody>
</table>
<div class="orderDtls" style="width: 52%;">
<h3>Order Details: </h3><br>
<h5 class="details">Subtotal: <span>{{$subtotal_input}}</span></h5>
<h5 class="details">VAT @5%: <span>{{$tax_input}}</span></h5>
<span><h5 style="background: blue; font-size: 18px; color:white; font-weight: bold;" class="details text-white">Grand Total: <span style="color: white; background: blue; float: right;">{{$total}}</span></h5></span>
</div><br><br>
</main>
Thank you in advance.
Please or to participate in this conversation.