1737192474a:1:{s:22:"officer/guest-list.htm";a:9:{s:8:"fileName";s:22:"officer/guest-list.htm";s:7:"content";s:14723:"title = "Guest List"
url = "/officer/guest-list"
layout = "BaliTiket2"

[session]
security = "user"
allowedUserGroups[] = "officer"
redirect = "bali-tiket/login"
==
<?php
	use Yuren\BaliTiket\Models\Bookings;
	use Yuren\BaliTiket\Models\Vendor;
    use Yuren\BaliTiket\Models\Guestlist;

	use Winter\Storm\Auth\AuthManager;
	use Auth;
    use Carbon\Carbon;

	function onStart()
    {
        date_default_timezone_set('Asia/Singapore');
        $dateNow = date('Y-m-d'); // Formatkan tanggal sekarang
        $this['dateNow'] = $dateNow;
        $yesterday = date('Y-m-d', strtotime('-1 day'));
        $this['yesterday'] = date('Y-m-d', strtotime('-1 day'));

        $user = Auth::getUser();
        if ($user) {
            $this['user'] = $user;

            // Ambil vendor berdasarkan user
            $this['vendors'] = Vendor::where('id', $user->vendor)->first();

            // Ambil semua booking dengan status pembayaran "paid"
            $this['booking'] = Bookings::where('status_payment', 'paid')->get();

            // Ambil nilai filter tanggal dari input (jika ada)
            $date_filter = Input::get('date_filter');
            $date_from = Input::get('from');
            $date_to = Input::get('to');
            $view_by = Input::get('view_by');

            // Jika tidak ada filter yang diberikan, isi date_filter dengan hari ini
            if (!$date_filter && !$date_from && !$date_to) {
                $date_filter = $dateNow;
            }

            // Simpan nilai filter untuk digunakan di view
            $this['date_filter'] = $date_filter;
            $this['from'] = $date_from;
            $this['to'] = $date_to;
            $this['view_by'] = $view_by;

            // Default: Tampilkan data berdasarkan filter yang diberikan atau hari ini
            $query = Guestlist::orderBy('datetime', 'desc');
            $queryBooking = Bookings::where('status_payment', 'paid')->orderBy('no_invoice', 'desc');
            $queryguestCount = Bookings::where('status_payment', 'paid');
            $queryguestCheckinCount = Guestlist::orderBy('no_invoice', 'asc');

            if ($date_filter) {
                if ($date_filter == 'today'){
                    $query->whereRaw('DATE(datetime) = ?', [$dateNow]);
                    $queryBooking->whereRaw('DATE(arrival_date) = ?', [$dateNow]);
                    $queryguestCount->whereRaw('DATE(arrival_date) = ?', [$dateNow]);
                    $queryguestCheckinCount->whereRaw('DATE(datetime) = ?', [$dateNow]);
                    $this['date_choice'] = date('d, F Y');
                } elseif ($date_filter == 'yesterday'){
                    $query->whereRaw('DATE(datetime) = ?', [$yesterday]);
                    $queryBooking->whereRaw('DATE(arrival_date) = ?', [$yesterday]);
                    $queryguestCount->whereRaw('DATE(arrival_date) = ?', [$yesterday]);
                    $queryguestCheckinCount->whereRaw('DATE(datetime) = ?', [$yesterday]);
                    $this['date_choice'] = date('d, F Y', strtotime('-1 day'));
                } elseif ($date_filter == 'date-range'){
                    if ($date_from) {
                        $query->whereRaw('DATE(datetime) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $queryBooking->whereRaw('DATE(arrival_date) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $queryguestCount->whereRaw('DATE(arrival_date) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $queryguestCheckinCount->whereRaw('DATE(datetime) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $this['date_choice'] = date('d, F Y', strtotime($date_from)) . ' - ' . date('d, F Y', strtotime($date_to));
                    }
                }
            }

            // Eksekusi query
            $this['guests'] = $query->get();
            $this['bookings'] = $queryBooking->get();
            $this['guestCount'] = $queryguestCount->sum('person');
            $this['guestCheckinCount'] = $queryguestCheckinCount->count();

        }
    }
?>
==

<div class="container py-md-4 py-3">
    <div class="row g-0">
        <div class="col-md-12 row g-0">
            <div class="col-md-12 row g-0 mb-4">
                <div class="col-md-3 col-6 pe-2 pe-md-3">
                    <div class="card rounded-0 w-100 shadow">
                        <div class="card-body">
                            <p class="fw-bold mb-1"><small>Number of Guests</small></p>
                            <p class="mb-1 fs-2 fw-semibold text-primary">{{guestCount}} Guests</p>
                            <p class="fw-bold mb-0"><small>{{ date_choice }}</small></p>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-6 pe-md-3 ps-md-0 ps-2">
                    <div class="card rounded-0 w-100 shadow">
                        <div class="card-body">
                            <p class="fw-bold mb-1"><small>Number of Check-in</small></p>
                            <p class="mb-1 fs-2 fw-semibold text-success">{{guestCheckinCount}} Guests</p>
                            <p class="fw-bold mb-0"><small>{{ date_choice }}</small></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-12 mb-4 pe-md-3 pe-0">
                <div class="card rounded-0 shadow">
                    <div class="card-body">
                        <form method="get" action="{{url('officer/guest-list')}}" class="row g-0">
                            <div class="col-md-3 col-6 p-2 order-md-1 order-1">
                                <label for="">Filter Date</label>
                                <select class="form-select rounded-0 mt-1" name="date_filter" id="">
                                    <option value="today" selected>Today</option>
                                    <option value="yesterday">Yesterday</option>
                                    <option value="date-range">Date Range</option>
                                </select>
                            </div>
                            <div class="container-date-from col-md-3 col-6 p-2 order-md-2 order-3">
                                <label for="">From</label>
                                <input class="form-control rounded-0 mt-1 flatpickr flatpickr-input date-from w-100"
                                    type="text" placeholder="From" name="from">
                            </div>
                            <div class="container-date-to col-md-3 col-6 p-2 order-md-3 order-4">
                                <label for="">To</label>
                                <input class="form-control rounded-0 mt-1 flatpickr flatpickr-input date-to w-100"
                                    type="text" placeholder="To" name="to">
                            </div>
                            <div class="col-md-3 col-6 p-2 order-md-4 order-2">
                                <label for="">View By</label>
                                <select class="form-select rounded-0 mt-1" id="" name="view_by">
                                    <option value="guest-list" selected>Guest List</option>
                                    <option value="booking-list">Booking List</option>
                                    <option value="list-ticket">List Ticket</option>
                                </select>
                            </div>
                            <div class="col-12 p-2 order-md-5 order-5">
                                <button type="submit" class="btn btn-primary rounded-0 px-4">Submit</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="tab-content" id="myTabContent">
                    <div class="tab-pane fade {{ (view_by == 'guest-list') ? 'show active' : '' }}" id="tab-guest-list" role="tabpanel"
                        aria-labelledby="tab-guest-list" tabindex="0">
                        <div class="table-responsive">
                            <table class="table table-bordered border-dark">
                                <thead style="background: #a1e8f5;">
                                    <tr>
                                        <th class="text-center" scope="col">No</th>
                                        <th scope="col">Booking ID</th>
                                        <th scope="col">Name</th>
                                        <th scope="col">Ticket</th>
                                        <th scope="col">Date Time</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% set no = 1 %}
                                    {% for guest in guests %}
                                    <tr>
                                        <th class="text-center">{{ no }}</th>
                                        <td>{{ guest.no_invoice }}</td>
                                        <td>{{ guest.name }}</td>
                                        <td>{{ guest.ticketName(guest.ticket_id) }}</td>
                                        <td>{{ guest.datetime|date('Y-m-d H:i') }}</td>
                                    </tr>
                                    {% set no = no + 1 %}
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade {{ (view_by == 'booking-list') ? 'show active' : '' }}" id="tab-guest-list" role="tabpanel" aria-labelledby="tab-guest-list"
                        tabindex="0">
                        <div class="table-responsive">
                            <table class="table table-bordered border-dark">
                                <thead style="background: #a1e8f5;">
                                    <tr>
                                        <th class="text-center" scope="col">No</th>
                                        <th scope="col">Booking ID</th>
                                        <th scope="col">Name</th>
                                        <th scope="col">Ticket</th>
                                        <th scope="col">Person</th>
                                        <th scope="col">Person Check-in</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% set no = 1 %}
                                    {% for booking in bookings %}
                                    <tr>
                                        <th class="text-center">{{ no }}</th>
                                        <td>{{ booking.no_invoice }}</td>
                                        <td>{{ booking.firstname }}</td>
                                        <td>{{ booking.ticketName(booking.ticket_id) }}</td>
                                        <td>{{ booking.person }}</td>
                                        <td>{{ booking.personCheckin(booking.no_invoice) }}</td>
                                    </tr>
                                    {% set no = no + 1 %}
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade {{ (view_by == 'list-ticket') ? 'show active' : '' }}" id="tab-guest-list" role="tabpanel" aria-labelledby="tab-guest-list"
                        tabindex="0">
                        <div class="table-responsive">
                            <table class="table table-bordered border-dark">
                                <thead style="background: #a1e8f5;">
                                    <tr>
                                        <th class="text-center" scope="col">No</th>
                                        <th scope="col">Booking ID</th>
                                        <th scope="col">Name</th>
                                        <th scope="col">Ticket</th>
                                        <th scope="col">Date Time</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% set no = 1 %}
                                    {% for guest in guests %}
                                    <tr>
                                        <th class="text-center">{{ no }}</th>
                                        <td>{{ guest.no_invoice }}</td>
                                        <td>{{ guest.name }}</td>
                                        <td>{{ guest.ticketName(guest.ticket_id) }}</td>
                                        <td>{{ guest.datetime|date('Y-m-d H:i') }}</td>
                                    </tr>
                                    {% set no = no + 1 %}
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{% put scripts %}
<script type="text/javascript">
    $(".date-from").flatpickr({
        maxDate: "today",
        dateFormat: "Y-m-d",
    });
    $(".date-to").flatpickr({
        maxDate: "today",
        dateFormat: "Y-m-d",
    });

    $(document).ready(function () {
        // Set initial state berdasarkan pilihan yang sudah ada
        toggleDateRangeFields();

        // Ketika ada perubahan pada pilihan Filter Date
        $('select[name="date_filter"]').on('change', function () {
            toggleDateRangeFields();
        });

        function toggleDateRangeFields() {
            const dateFilter = $('select[name="date_filter"]').val();

            if (dateFilter === 'date-range') {
                $('.container-date-from, .container-date-to').removeClass('d-none').addClass('d-block');
            } else {
                $('.container-date-from, .container-date-to').removeClass('d-block').addClass('d-none');
            }
        }
    });

</script>
{% endput %}";s:5:"mtime";i:1735872481;s:6:"markup";s:10563:"<div class="container py-md-4 py-3">
    <div class="row g-0">
        <div class="col-md-12 row g-0">
            <div class="col-md-12 row g-0 mb-4">
                <div class="col-md-3 col-6 pe-2 pe-md-3">
                    <div class="card rounded-0 w-100 shadow">
                        <div class="card-body">
                            <p class="fw-bold mb-1"><small>Number of Guests</small></p>
                            <p class="mb-1 fs-2 fw-semibold text-primary">{{guestCount}} Guests</p>
                            <p class="fw-bold mb-0"><small>{{ date_choice }}</small></p>
                        </div>
                    </div>
                </div>
                <div class="col-md-3 col-6 pe-md-3 ps-md-0 ps-2">
                    <div class="card rounded-0 w-100 shadow">
                        <div class="card-body">
                            <p class="fw-bold mb-1"><small>Number of Check-in</small></p>
                            <p class="mb-1 fs-2 fw-semibold text-success">{{guestCheckinCount}} Guests</p>
                            <p class="fw-bold mb-0"><small>{{ date_choice }}</small></p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-md-6 col-12 mb-4 pe-md-3 pe-0">
                <div class="card rounded-0 shadow">
                    <div class="card-body">
                        <form method="get" action="{{url('officer/guest-list')}}" class="row g-0">
                            <div class="col-md-3 col-6 p-2 order-md-1 order-1">
                                <label for="">Filter Date</label>
                                <select class="form-select rounded-0 mt-1" name="date_filter" id="">
                                    <option value="today" selected>Today</option>
                                    <option value="yesterday">Yesterday</option>
                                    <option value="date-range">Date Range</option>
                                </select>
                            </div>
                            <div class="container-date-from col-md-3 col-6 p-2 order-md-2 order-3">
                                <label for="">From</label>
                                <input class="form-control rounded-0 mt-1 flatpickr flatpickr-input date-from w-100"
                                    type="text" placeholder="From" name="from">
                            </div>
                            <div class="container-date-to col-md-3 col-6 p-2 order-md-3 order-4">
                                <label for="">To</label>
                                <input class="form-control rounded-0 mt-1 flatpickr flatpickr-input date-to w-100"
                                    type="text" placeholder="To" name="to">
                            </div>
                            <div class="col-md-3 col-6 p-2 order-md-4 order-2">
                                <label for="">View By</label>
                                <select class="form-select rounded-0 mt-1" id="" name="view_by">
                                    <option value="guest-list" selected>Guest List</option>
                                    <option value="booking-list">Booking List</option>
                                    <option value="list-ticket">List Ticket</option>
                                </select>
                            </div>
                            <div class="col-12 p-2 order-md-5 order-5">
                                <button type="submit" class="btn btn-primary rounded-0 px-4">Submit</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="col-md-12">
                <div class="tab-content" id="myTabContent">
                    <div class="tab-pane fade {{ (view_by == 'guest-list') ? 'show active' : '' }}" id="tab-guest-list" role="tabpanel"
                        aria-labelledby="tab-guest-list" tabindex="0">
                        <div class="table-responsive">
                            <table class="table table-bordered border-dark">
                                <thead style="background: #a1e8f5;">
                                    <tr>
                                        <th class="text-center" scope="col">No</th>
                                        <th scope="col">Booking ID</th>
                                        <th scope="col">Name</th>
                                        <th scope="col">Ticket</th>
                                        <th scope="col">Date Time</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% set no = 1 %}
                                    {% for guest in guests %}
                                    <tr>
                                        <th class="text-center">{{ no }}</th>
                                        <td>{{ guest.no_invoice }}</td>
                                        <td>{{ guest.name }}</td>
                                        <td>{{ guest.ticketName(guest.ticket_id) }}</td>
                                        <td>{{ guest.datetime|date('Y-m-d H:i') }}</td>
                                    </tr>
                                    {% set no = no + 1 %}
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade {{ (view_by == 'booking-list') ? 'show active' : '' }}" id="tab-guest-list" role="tabpanel" aria-labelledby="tab-guest-list"
                        tabindex="0">
                        <div class="table-responsive">
                            <table class="table table-bordered border-dark">
                                <thead style="background: #a1e8f5;">
                                    <tr>
                                        <th class="text-center" scope="col">No</th>
                                        <th scope="col">Booking ID</th>
                                        <th scope="col">Name</th>
                                        <th scope="col">Ticket</th>
                                        <th scope="col">Person</th>
                                        <th scope="col">Person Check-in</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% set no = 1 %}
                                    {% for booking in bookings %}
                                    <tr>
                                        <th class="text-center">{{ no }}</th>
                                        <td>{{ booking.no_invoice }}</td>
                                        <td>{{ booking.firstname }}</td>
                                        <td>{{ booking.ticketName(booking.ticket_id) }}</td>
                                        <td>{{ booking.person }}</td>
                                        <td>{{ booking.personCheckin(booking.no_invoice) }}</td>
                                    </tr>
                                    {% set no = no + 1 %}
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade {{ (view_by == 'list-ticket') ? 'show active' : '' }}" id="tab-guest-list" role="tabpanel" aria-labelledby="tab-guest-list"
                        tabindex="0">
                        <div class="table-responsive">
                            <table class="table table-bordered border-dark">
                                <thead style="background: #a1e8f5;">
                                    <tr>
                                        <th class="text-center" scope="col">No</th>
                                        <th scope="col">Booking ID</th>
                                        <th scope="col">Name</th>
                                        <th scope="col">Ticket</th>
                                        <th scope="col">Date Time</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% set no = 1 %}
                                    {% for guest in guests %}
                                    <tr>
                                        <th class="text-center">{{ no }}</th>
                                        <td>{{ guest.no_invoice }}</td>
                                        <td>{{ guest.name }}</td>
                                        <td>{{ guest.ticketName(guest.ticket_id) }}</td>
                                        <td>{{ guest.datetime|date('Y-m-d H:i') }}</td>
                                    </tr>
                                    {% set no = no + 1 %}
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

{% put scripts %}
<script type="text/javascript">
    $(".date-from").flatpickr({
        maxDate: "today",
        dateFormat: "Y-m-d",
    });
    $(".date-to").flatpickr({
        maxDate: "today",
        dateFormat: "Y-m-d",
    });

    $(document).ready(function () {
        // Set initial state berdasarkan pilihan yang sudah ada
        toggleDateRangeFields();

        // Ketika ada perubahan pada pilihan Filter Date
        $('select[name="date_filter"]').on('change', function () {
            toggleDateRangeFields();
        });

        function toggleDateRangeFields() {
            const dateFilter = $('select[name="date_filter"]').val();

            if (dateFilter === 'date-range') {
                $('.container-date-from, .container-date-to').removeClass('d-none').addClass('d-block');
            } else {
                $('.container-date-from, .container-date-to').removeClass('d-block').addClass('d-none');
            }
        }
    });

</script>
{% endput %}";s:4:"code";s:3970:"
	use Yuren\BaliTiket\Models\Bookings;
	use Yuren\BaliTiket\Models\Vendor;
    use Yuren\BaliTiket\Models\Guestlist;

	use Winter\Storm\Auth\AuthManager;
	use Auth;
    use Carbon\Carbon;

	function onStart()
    {
        date_default_timezone_set('Asia/Singapore');
        $dateNow = date('Y-m-d'); // Formatkan tanggal sekarang
        $this['dateNow'] = $dateNow;
        $yesterday = date('Y-m-d', strtotime('-1 day'));
        $this['yesterday'] = date('Y-m-d', strtotime('-1 day'));

        $user = Auth::getUser();
        if ($user) {
            $this['user'] = $user;

            // Ambil vendor berdasarkan user
            $this['vendors'] = Vendor::where('id', $user->vendor)->first();

            // Ambil semua booking dengan status pembayaran "paid"
            $this['booking'] = Bookings::where('status_payment', 'paid')->get();

            // Ambil nilai filter tanggal dari input (jika ada)
            $date_filter = Input::get('date_filter');
            $date_from = Input::get('from');
            $date_to = Input::get('to');
            $view_by = Input::get('view_by');

            // Jika tidak ada filter yang diberikan, isi date_filter dengan hari ini
            if (!$date_filter && !$date_from && !$date_to) {
                $date_filter = $dateNow;
            }

            // Simpan nilai filter untuk digunakan di view
            $this['date_filter'] = $date_filter;
            $this['from'] = $date_from;
            $this['to'] = $date_to;
            $this['view_by'] = $view_by;

            // Default: Tampilkan data berdasarkan filter yang diberikan atau hari ini
            $query = Guestlist::orderBy('datetime', 'desc');
            $queryBooking = Bookings::where('status_payment', 'paid')->orderBy('no_invoice', 'desc');
            $queryguestCount = Bookings::where('status_payment', 'paid');
            $queryguestCheckinCount = Guestlist::orderBy('no_invoice', 'asc');

            if ($date_filter) {
                if ($date_filter == 'today'){
                    $query->whereRaw('DATE(datetime) = ?', [$dateNow]);
                    $queryBooking->whereRaw('DATE(arrival_date) = ?', [$dateNow]);
                    $queryguestCount->whereRaw('DATE(arrival_date) = ?', [$dateNow]);
                    $queryguestCheckinCount->whereRaw('DATE(datetime) = ?', [$dateNow]);
                    $this['date_choice'] = date('d, F Y');
                } elseif ($date_filter == 'yesterday'){
                    $query->whereRaw('DATE(datetime) = ?', [$yesterday]);
                    $queryBooking->whereRaw('DATE(arrival_date) = ?', [$yesterday]);
                    $queryguestCount->whereRaw('DATE(arrival_date) = ?', [$yesterday]);
                    $queryguestCheckinCount->whereRaw('DATE(datetime) = ?', [$yesterday]);
                    $this['date_choice'] = date('d, F Y', strtotime('-1 day'));
                } elseif ($date_filter == 'date-range'){
                    if ($date_from) {
                        $query->whereRaw('DATE(datetime) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $queryBooking->whereRaw('DATE(arrival_date) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $queryguestCount->whereRaw('DATE(arrival_date) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $queryguestCheckinCount->whereRaw('DATE(datetime) BETWEEN ? AND ?', [$date_from, $date_to]);
                        $this['date_choice'] = date('d, F Y', strtotime($date_from)) . ' - ' . date('d, F Y', strtotime($date_to));
                    }
                }
            }

            // Eksekusi query
            $this['guests'] = $query->get();
            $this['bookings'] = $queryBooking->get();
            $this['guestCount'] = $queryguestCount->sum('person');
            $this['guestCheckinCount'] = $queryguestCheckinCount->count();

        }
    }
";s:5:"title";s:10:"Guest List";s:3:"url";s:19:"/officer/guest-list";s:6:"layout";s:10:"BaliTiket2";s:7:"session";a:3:{s:8:"security";s:4:"user";s:17:"allowedUserGroups";a:1:{i:0;s:7:"officer";}s:8:"redirect";s:16:"bali-tiket/login";}}}