
<?php $__env->startSection('title','Laporan Penjualan'); ?>

<?php $__env->startSection('content'); ?>

<div class="page-header d-flex align-items-start justify-content-between mb-4 flex-column flex-md-row gap-3">
    <div>
        <h1 class="page-header-title">Laporan Penjualan</h1>
        <p class="page-header-sub">Ringkasan pendapatan dan transaksi yang dapat difilter secara cepat.</p>
    </div>
    <a href="<?php echo e(route('laporan.pdf')); ?>" class="btn btn-primary">Cetak PDF</a>
</div>

<div class="card-dark mb-4 p-3">
    <form method="GET" action="<?php echo e(route('laporan.index')); ?>" class="d-flex flex-wrap gap-2 align-items-center">
        <input name="search" type="text" class="form-control-dark" placeholder="Cari nama pembeli, event, atau status" value="<?php echo e(request('search')); ?>" data-live-search="true" style="min-width:220px">
        <select name="status" class="form-control-dark" style="min-width:180px">
            <option value="">Semua Status</option>
            <option value="Pending" <?php echo e(request('status') == 'Pending' ? 'selected' : ''); ?>>Pending</option>
            <option value="Confirmed" <?php echo e(request('status') == 'Confirmed' ? 'selected' : ''); ?>>Confirmed</option>
            <option value="Rejected" <?php echo e(request('status') == 'Rejected' ? 'selected' : ''); ?>>Rejected</option>
        </select>
        <select name="date_filter" class="form-control-dark" style="min-width:180px">
            <option value="">Semua Tanggal</option>
            <option value="today" <?php echo e(request('date_filter') == 'today' ? 'selected' : ''); ?>>Hari Ini</option>
            <option value="this_week" <?php echo e(request('date_filter') == 'this_week' ? 'selected' : ''); ?>>Minggu Ini</option>
            <option value="this_month" <?php echo e(request('date_filter') == 'this_month' ? 'selected' : ''); ?>>Bulan Ini</option>
            <option value="custom" <?php echo e(request('date_filter') == 'custom' ? 'selected' : ''); ?>>Rentang Tanggal</option>
        </select>
        <?php if(request('date_filter') == 'custom'): ?>
            <input type="date" name="date_from" class="form-control-dark" value="<?php echo e(request('date_from')); ?>" style="min-width:170px">
            <input type="date" name="date_to" class="form-control-dark" value="<?php echo e(request('date_to')); ?>" style="min-width:170px">
        <?php endif; ?>
        <select name="perpage" class="form-control-dark" style="min-width:130px">
            <option value="10" <?php echo e(request('perpage', 10) == 10 ? 'selected' : ''); ?>>10</option>
            <option value="20" <?php echo e(request('perpage') == 20 ? 'selected' : ''); ?>>20</option>
            <option value="50" <?php echo e(request('perpage') == 50 ? 'selected' : ''); ?>>50</option>
        </select>
        <div class="ms-auto d-flex gap-2">
            <button class="btn-primary-glow">Filter</button>
            <a href="<?php echo e(route('laporan.index')); ?>" class="btn btn-outline-light">Reset</a>
        </div>
    </form>
</div>

<div class="row g-3 mb-4">
    <div class="col-md-4">
        <div class="stat-card indigo">
            <div class="stat-icon"><i class="bi bi-cash-stack"></i></div>
            <div class="stat-value">Rp<?php echo e(number_format($totalPendapatan ?? 0,0,',','.')); ?></div>
            <div class="stat-label">Total Pendapatan</div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="stat-card green">
            <div class="stat-icon"><i class="bi bi-ticket-perforated-fill"></i></div>
            <div class="stat-value"><?php echo e($totalTiket ?? 0); ?></div>
            <div class="stat-label">Tiket Terjual</div>
        </div>
    </div>
    <div class="col-md-4">
        <div class="stat-card purple">
            <div class="stat-icon"><i class="bi bi-bar-chart-fill"></i></div>
            <div class="stat-value"><?php echo e($transaksis->total()); ?></div>
            <div class="stat-label">Transaksi Ditemukan</div>
        </div>
    </div>
</div>

<div class="card-dark p-3">
    <div class="table-responsive">
        <table class="table table-dark-custom mb-0">
            <thead>
                <tr>
                    <th>Waktu</th>
                    <th>Pembeli</th>
                    <th>Event</th>
                    <th>Jumlah</th>
                    <th>Total</th>
                    <th>Status</th>
                </tr>
            </thead>
            <tbody>
                <?php $__empty_1 = true; $__currentLoopData = $transaksis; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $trx): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($trx->created_at->format('d M Y H:i')); ?></td>
                        <td><?php echo e($trx->nama_pembeli); ?></td>
                        <td><?php echo e($trx->tiket->event->nama_event ?? '-'); ?></td>
                        <td><?php echo e($trx->jumlah); ?></td>
                        <td>Rp<?php echo e(number_format($trx->total_harga,0,',','.')); ?></td>
                        <td><?php echo e($trx->status); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="6" class="text-center py-4">Belum ada transaksi untuk filter ini.</td>
                    </tr>
                <?php endif; ?>
            </tbody>
        </table>
    </div>

    <div class="mt-3 d-flex justify-content-center">
        <?php echo e($transaksis->appends(request()->except('page'))->links()); ?>

    </div>
</div>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH D:\tugas pa asur\konser-ticket\resources\views/laporan/index.blade.php ENDPATH**/ ?>