title = "Export Booking List to PDF" url = "/booking/export-pdf" layout = "" is_hidden = 0 [session] security = "user" allowedUserGroups[] = "admin" allowedUserGroups[] = "supplier" redirect = "dashboard/login" == vendor; $name = input('name'); $type = input('type'); $from = input('from'); $to = input('to'); $no_invoice = input('no_invoice'); $status = input('status'); $product = input('product'); $this['name'] = $name; $this['type'] = $type; $this['from'] = $from; $this['to'] = $to; $this['no_invoice'] = $no_invoice; $this['status'] = $status; $this['product'] = $product; $query = Bookings::where('vendor_id', $user->vendor); if ($name != null) { $query->where('name', 'like', '%' . $name . '%'); } if ($type != null) { if ($type == 'Booking Date'){ if ($from != null) { $query->where('invoice_date', '>=', $from); } if ($to != null) { $query->where('invoice_date', '<=', $to); } } elseif ($type == 'Arrival Date'){ if ($from != null) { $query->where('arrival_date', '>=', $from); } if ($to != null) { $query->where('arrival_date', '<=', $to); } } } if ($no_invoice != null) { $query->where('no_invoice', 'like', '%' . $no_invoice . '%'); } if ($status != null) { $query->where('status_payment', $status); } if ($product != null) { $query->where('product_id', $product); } // Get bookings $this['bookings'] = $query->orderBy('invoice_date', 'desc')->get(); $this['products'] = Product::orderBy('id', 'desc')->where('vendor_id', $user->vendor)->get(); // Generate PDF $html = ' Booking List

Booking List

'; foreach ($this['bookings'] as $booking) { $html .= ''; } $html .= '
No. Invoice Booking Date Name Arrival Date Ticket Amount Status
' . $booking->no_invoice . ' ' . $booking->invoice_date . ' ' . $booking->firstname . ' ' . $booking->arrival_date . ' ' . $booking->productName($booking->product_id) . ' IDR ' . $booking->priceFormat($booking->total_price) . ' ' . $booking->status_payment . '
'; // Inisialisasi Dompdf dan load HTML $dompdf = new Dompdf(); $dompdf->loadHtml($html); // (Optional) Setup ukuran dan orientasi kertas $dompdf->setPaper('A4', 'landscape'); // Render HTML sebagai PDF $dompdf->render(); // Kirim PDF sebagai response download return $dompdf->stream('bookings.pdf'); } } ?> ==