feat: switch to dompdf for receipt generation
This commit is contained in:
@@ -278,11 +278,49 @@ class PagesController extends Controller
|
||||
GROUP BY winning_bids.winning_bidder_num
|
||||
");
|
||||
|
||||
return Pdf::view('receiptpdf', [
|
||||
use Dompdf\Dompdf;
|
||||
|
||||
// ...
|
||||
|
||||
public function downloadReceiptPdf(Request $request)
|
||||
{
|
||||
$checkoutid = $request->checkout_id;
|
||||
$checkout_final_results = Checkout::where('checkout_id', '=', $checkoutid)->first();
|
||||
if (!$checkout_final_results) {
|
||||
return redirect('/mywinnings')->with('error', 'Checkout record not found.');
|
||||
}
|
||||
|
||||
$bidder_num = $checkout_final_results->bidder_num;
|
||||
$checkout_list_results = DB::select("SELECT
|
||||
*, items.item_assigned_num, items.item_desc
|
||||
FROM winning_bids
|
||||
INNER JOIN items AS items ON winning_bids.winning_item_num=items.iditems
|
||||
WHERE winning_bidder_num = $bidder_num
|
||||
");
|
||||
$checkout_info_results = DB::select("SELECT
|
||||
winning_bids.*,
|
||||
bidders.*,
|
||||
sum(winning_cost) AS total_cost
|
||||
FROM winning_bids
|
||||
INNER JOIN bidders AS bidders ON winning_bids.winning_bidder_num=bidders.idbidders
|
||||
WHERE winning_bidder_num = $bidder_num
|
||||
GROUP BY winning_bids.winning_bidder_num
|
||||
");
|
||||
|
||||
$dompdf = new Dompdf();
|
||||
$dompdf->setOptions(['isHtml5ParserEnabled' => true, 'isRemoteEnabled' => true]);
|
||||
|
||||
$html = view('receiptpdf', [
|
||||
'checkout_final_results' => $checkout_final_results,
|
||||
'checkout_list_results' => $checkout_list_results,
|
||||
'checkout_info_results' => $checkout_info_results
|
||||
])->name('receipt-'.$checkoutid.'.pdf');
|
||||
])->render();
|
||||
|
||||
$dompdf->loadHtml($html);
|
||||
$dompdf->setPaper('letter', 'portrait');
|
||||
$dompdf->render();
|
||||
|
||||
return $dompdf->stream('receipt-'.$checkoutid.'.pdf');
|
||||
}
|
||||
|
||||
public function reprintReceipt(Request $reprint_receipt_req)
|
||||
|
||||
Reference in New Issue
Block a user