1737192474a:1:{s:32:"dashboard/export-booking-pdf.htm";a:10:{s:8:"fileName";s:32:"dashboard/export-booking-pdf.htm";s:7:"content";s:4120:"title = "Export Booking List to PDF"
url = "/booking/export-pdf"
layout = ""
is_hidden = 0

[session]
security = "user"
allowedUserGroups[] = "admin"
allowedUserGroups[] = "supplier"
redirect = "dashboard/login"
==
<?php
  use Yuren\BaliTiket\Models\Bookings;
  use Yuren\BaliTiket\Models\Product;
  use Winter\Storm\Auth\AuthManager;
  use Auth;

  use bali_tiket\Dompdf\Dompdf;
  use bali_tiket\Dompdf\Options;

  function onStart()
  {
    $user = Auth::getUser();
    if ($user) {
      $this['vendor'] = $user->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 = '<html>
      <head>
        <title>Booking List</title>
        <style>
          table {
            width: 100%;
            border-collapse: collapse;
          }
          table, th, td {
            border: 1px solid black;
          }
          th, td {
            padding: 8px;
            text-align: left;
          }
        </style>
      </head>
      <body>
        <h1>Booking List</h1>
        <table>
          <thead>
            <tr>
              <th>No. Invoice</th>
              <th>Booking Date</th>
              <th>Name</th>
              <th>Arrival Date</th>
              <th>Ticket</th>
              <th>Amount</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>';

            foreach ($this['bookings'] as $booking) {
              $html .= '<tr>
                <td>' . $booking->no_invoice . '</td>
                <td>' . $booking->invoice_date . '</td>
                <td>' . $booking->firstname . '</td>
                <td>' . $booking->arrival_date . '</td>
                <td>' . $booking->productName($booking->product_id) . '</td>
                <td>IDR ' . $booking->priceFormat($booking->total_price) . '</td>
                <td>' . $booking->status_payment . '</td>
              </tr>';
            }

          $html .= '</tbody>
        </table>
      </body>
      </html>';

      // 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');
    }
  }
?>
==
<!-- Content (tidak digunakan, karena ini untuk PDF generation) -->
";s:5:"mtime";i:1727163213;s:6:"markup";s:67:"<!-- Content (tidak digunakan, karena ini untuk PDF generation) -->";s:4:"code";s:3811:"
  use Yuren\BaliTiket\Models\Bookings;
  use Yuren\BaliTiket\Models\Product;
  use Winter\Storm\Auth\AuthManager;
  use Auth;

  use bali_tiket\Dompdf\Dompdf;
  use bali_tiket\Dompdf\Options;

  function onStart()
  {
    $user = Auth::getUser();
    if ($user) {
      $this['vendor'] = $user->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 = '<html>
      <head>
        <title>Booking List</title>
        <style>
          table {
            width: 100%;
            border-collapse: collapse;
          }
          table, th, td {
            border: 1px solid black;
          }
          th, td {
            padding: 8px;
            text-align: left;
          }
        </style>
      </head>
      <body>
        <h1>Booking List</h1>
        <table>
          <thead>
            <tr>
              <th>No. Invoice</th>
              <th>Booking Date</th>
              <th>Name</th>
              <th>Arrival Date</th>
              <th>Ticket</th>
              <th>Amount</th>
              <th>Status</th>
            </tr>
          </thead>
          <tbody>';

            foreach ($this['bookings'] as $booking) {
              $html .= '<tr>
                <td>' . $booking->no_invoice . '</td>
                <td>' . $booking->invoice_date . '</td>
                <td>' . $booking->firstname . '</td>
                <td>' . $booking->arrival_date . '</td>
                <td>' . $booking->productName($booking->product_id) . '</td>
                <td>IDR ' . $booking->priceFormat($booking->total_price) . '</td>
                <td>' . $booking->status_payment . '</td>
              </tr>';
            }

          $html .= '</tbody>
        </table>
      </body>
      </html>';

      // 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');
    }
  }
";s:5:"title";s:26:"Export Booking List to PDF";s:3:"url";s:19:"/booking/export-pdf";s:6:"layout";s:0:"";s:9:"is_hidden";s:1:"0";s:7:"session";a:3:{s:8:"security";s:4:"user";s:17:"allowedUserGroups";a:2:{i:0;s:5:"admin";i:1;s:8:"supplier";}s:8:"redirect";s:15:"dashboard/login";}}}