<!DOCTYPE html>
<html>
<head>
    <title>Laporan Penjualan Teh Tarik 99</title>
    <style>
        body { font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 11px; color: #333; line-height: 1.4; }
        .header { margin-bottom: 20px; border-bottom: 3px solid #448b39; padding-bottom: 10px; }
        .brand { font-size: 24px; font-weight: bold; color: #448b39; text-transform: uppercase; margin: 0; }
        .subtitle { font-size: 12px; color: #666; margin: 5px 0 0 0; }
        
        .info-section { width: 100%; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 8px; }
        .info-cell { font-size: 10px; color: #555; }
        
        .filter-status { background: #f8f9fa; border: 1px solid #e9ecef; padding: 10px; border-radius: 6px; margin-bottom: 15px; }
        .filter-title { font-weight: bold; color: #495057; font-size: 10px; margin-bottom: 5px; text-transform: uppercase; }
        .filter-item { display: inline-block; margin-right: 15px; font-size: 10px; }

        .stats-grid { width: 100%; margin-bottom: 20px; border-collapse: separate; border-spacing: 10px 0; }
        .stat-card { background: #fff; border: 1px solid #dee2e6; border-radius: 8px; padding: 12px; text-align: center; }
        .stat-label { font-size: 9px; color: #6c757d; font-weight: bold; text-transform: uppercase; margin-bottom: 4px; }
        .stat-val { font-size: 16px; font-weight: bold; color: #212529; }

        table.data-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
        table.data-table th { background-color: #448b39; color: white; padding: 8px; font-weight: bold; font-size: 10px; text-transform: uppercase; border: 1px solid #448b39; }
        table.data-table td { padding: 8px; border: 1px solid #e9ecef; font-size: 10px; }
        .text-right { text-align: right; }
        .text-center { text-align: center; }
        .fw-bold { font-weight: bold; }
        .footer { margin-top: 40px; text-align: center; font-size: 9px; color: #adb5bd; border-top: 1px solid #eee; padding-top: 10px; }
    </style>
</head>
<body>

    <div class="header">
        <h1 class="brand">TEH TARIK 99</h1>
        <p class="subtitle">Laporan Penjualan Kasir (Per <?php echo e(request('tab') == 'barang' ? 'Barang' : 'Pendapatan'); ?>)</p>
    </div>

    <table class="info-section">
        <tr>
            <td class="info-cell"><strong>Dicetak oleh:</strong> <?php echo e(auth()->user()->name); ?> (Kasir)</td>
            <td class="info-cell text-right"><strong>Tanggal Cetak:</strong> <?php echo e(now()->translatedFormat('d F Y, H:i')); ?> WIB</td>
        </tr>
    </table>

    <div class="filter-status">
        <div class="filter-title">Filter yang Diterapkan:</div>
        <div class="filter-item"><strong>Mulai:</strong> <?php echo e(request('tgl_mulai') ?: '-'); ?></div>
        <div class="filter-item"><strong>Selesai:</strong> <?php echo e(request('tgl_selesai') ?: '-'); ?></div>
        <?php if(request('tab') == 'barang'): ?>
            <div class="filter-item"><strong>Produk:</strong> <?php echo e(request('produk_id') ?: 'Semua Produk'); ?></div>
        <?php else: ?>
            <div class="filter-item"><strong>Pembayaran:</strong> <?php echo e(request('pembayaran') ?: 'Semua Pembayaran'); ?></div>
        <?php endif; ?>
        <?php if(request('search')): ?>
            <div class="filter-item"><strong>Pencarian:</strong> "<?php echo e(request('search')); ?>"</div>
        <?php endif; ?>
    </div>

    <!-- STATS -->
    <table class="stats-grid">
        <tr>
            <?php if(request('tab') == 'barang'): ?>
                <td width="33.3%">
                    <div class="stat-card">
                        <div class="stat-label">TOTAL TERJUAL</div>
                        <div class="stat-val"><?php echo e($totalTerjual); ?> Item</div>
                    </div>
                </td>
                <td width="33.3%">
                    <div class="stat-card">
                        <div class="stat-label">PRODUK TERLARIS</div>
                        <div class="stat-val" style="font-size: 13px;"><?php echo e($namaProdukTerlaris); ?> (<?php echo e($produkTerlaris); ?> Item)</div>
                    </div>
                </td>
                <td width="33.3%">
                    <div class="stat-card">
                        <div class="stat-label">TOTAL PENDAPATAN</div>
                        <div class="stat-val">Rp <?php echo e(number_format($totalPendapatan, 0, ',', '.')); ?></div>
                    </div>
                </td>
            <?php else: ?>
                <td width="33.3%">
                    <div class="stat-card">
                        <div class="stat-label">TOTAL PENDAPATAN</div>
                        <div class="stat-val">Rp <?php echo e(number_format($totalPendapatan, 0, ',', '.')); ?></div>
                    </div>
                </td>
                <td width="33.3%">
                    <div class="stat-card">
                        <div class="stat-label">TOTAL TRANSAKSI</div>
                        <div class="stat-val"><?php echo e($totalTransaksi); ?></div>
                    </div>
                </td>
                <td width="33.3%">
                    <div class="stat-card">
                        <div class="stat-label">RATA-RATA PER TRANSAKSI</div>
                        <div class="stat-val">Rp <?php echo e(number_format($rataRata, 0, ',', '.')); ?></div>
                    </div>
                </td>
            <?php endif; ?>
        </tr>
    </table>

    <h3 style="font-size: 12px; margin-top: 20px; color: #495057;">Tabel Rincian Data</h3>
    <table class="data-table">
        <thead>
            <tr>
                <th width="5%" class="text-center">NO</th>
                <th width="20%">TANGGAL & WAKTU</th>
                <?php if(request('tab') == 'barang'): ?>
                    <th width="35%">NAMA PRODUK</th>
                    <th width="10%" class="text-center">JUMLAH ITEM</th>
                    <th width="15%" class="text-right">HARGA SATUAN</th>
                    <th width="15%" class="text-right">TOTAL PENDAPATAN</th>
                <?php else: ?>
                    <th width="20%">NO. TRANSAKSI</th>
                    <th width="15%" class="text-center">JUMLAH ITEM</th>
                    <th width="20%">METODE PEMBAYARAN</th>
                    <th width="20%" class="text-right">TOTAL BAYAR</th>
                <?php endif; ?>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $data; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $index => $item): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr>
                <td class="text-center"><?php echo e($index + 1); ?></td>
                <td><?php echo e(($item->transaksi ? $item->transaksi->created_at : $item->created_at)->format('d M Y, H:i')); ?></td>
                
                <?php if(request('tab') == 'barang'): ?>
                    <td><?php echo e($item->nama_produk); ?></td>
                    <td class="text-center"><?php echo e($item->qty); ?></td>
                    <td class="text-right">Rp <?php echo e(number_format($item->harga_satuan, 0, ',', '.')); ?></td>
                <?php else: ?>
                    <td>TRX-<?php echo e(str_pad($item->transaksi_id, 5, '0', STR_PAD_LEFT)); ?></td>
                    <td class="text-center"><?php echo e($item->qty); ?></td>
                    <td><?php echo e($item->transaksi->metode_pembayaran ?? 'Tunai'); ?></td>
                <?php endif; ?>
                
                <td class="text-right fw-bold" style="color: #2e7d32;">Rp <?php echo e(number_format($item->qty * $item->harga_satuan, 0, ',', '.')); ?></td>
            </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr>
                <td colspan="<?php echo e(request('tab') == 'barang' ? 5 : 4); ?>" class="text-center">Data tidak ditemukan.</td>
            </tr>
            <?php endif; ?>
        </tbody>
    </table>

    <div class="footer">
        <p>Laporan ini dihasilkan secara otomatis oleh Sistem Kasir Teh Tarik 99.</p>
    </div>

</body>
</html><?php /**PATH C:\xampp\htdocs\tehtarik\resources\views/kasir/laporan_pdf.blade.php ENDPATH**/ ?>