<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Laporan Keuangan</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            font-size: 12px;
            margin: 20px;
        }
        .header {
            text-align: center;
            margin-bottom: 30px;
        }
        .header h1 {
            color: #333;
            margin-bottom: 5px;
        }
        .header p {
            color: #666;
            margin: 0;
        }
        .summary {
            margin-bottom: 20px;
        }
        .summary-box {
            display: inline-block;
            width: 23%;
            margin-right: 1%;
            padding: 10px;
            border: 1px solid #ddd;
            text-align: center;
        }
        .summary-box h3 {
            margin: 5px 0;
            color: #333;
        }
        .summary-box p {
            margin: 0;
            color: #666;
            font-size: 11px;
        }
        table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: left;
        }
        th {
            background-color: #f2f2f2;
            font-weight: bold;
        }
        .text-center {
            text-align: center;
        }
        .text-right {
            text-align: right;
        }
        .footer {
            margin-top: 30px;
            text-align: center;
            color: #666;
            font-size: 10px;
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>LAPORAN KEUANGAN</h1>
        <p>Periode: <?php echo e($startDate ?? 'Semua'); ?> - <?php echo e($endDate ?? 'Semua'); ?></p>
        <p>Dibuat: <?php echo e(date('d-m-Y H:i:s')); ?></p>
    </div>

    <?php if($includeSummary): ?>
    <div class="summary">
        <div class="summary-box">
            <h3><?php echo e(function_exists('formatRupiah') ? formatRupiah($totalIncome) : 'Rp ' . number_format($totalIncome, 0, ',', '.')); ?></h3>
            <p>Total Pendapatan</p>
        </div>
        <div class="summary-box">
            <h3><?php echo e($completedBookings); ?></h3>
            <p>Booking Selesai</p>
        </div>
        <div class="summary-box">
            <h3><?php echo e($payments->count()); ?></h3>
            <p>Total Transaksi</p>
        </div>
        <div class="summary-box">
            <h3><?php echo e(function_exists('formatRupiah') ? formatRupiah($avgTransaction) : 'Rp ' . number_format($avgTransaction, 0, ',', '.')); ?></h3>
            <p>Rata-rata Transaksi</p>
        </div>
    </div>
    <?php endif; ?>

    <?php if($includeTransactions): ?>
    <table>
        <thead>
            <tr>
                <th>Tanggal</th>
                <th>Kode Booking</th>
                <th>Customer</th>
                <th>Lapangan</th>
                <th>Jam</th>
                <th class="text-right">Total</th>
                <th>Status</th>
                <th>Payment</th>
            </tr>
        </thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $payments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td><?php echo e($payment->created_at->format('d-m-Y')); ?></td>
                    <td>BK<?php echo e(str_pad($payment->booking_id, 3, '0', STR_PAD_LEFT)); ?></td>
                    <td><?php echo e($payment->booking->user->name ?? 'Unknown'); ?></td>
                    <td><?php echo e($payment->booking->lapangan->nama ?? 'Unknown'); ?></td>
                    <td><?php echo e($payment->booking->jam_mulai->format('H:i')); ?>-<?php echo e($payment->booking->jam_selesai->format('H:i')); ?></td>
                    <td class="text-right"><?php echo e(function_exists('formatRupiah') ? formatRupiah($payment->jumlah) : 'Rp ' . number_format($payment->jumlah, 0, ',', '.')); ?></td>
                    <td><?php echo e(ucfirst($payment->booking->status)); ?></td>
                    <td><?php echo e(ucfirst($payment->status)); ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr>
                    <td colspan="8" class="text-center">Tidak ada data transaksi</td>
                </tr>
            <?php endif; ?>
        </tbody>
    </table>
    <?php endif; ?>

    <?php if($includeSummary && $byLapangan->count() > 0): ?>
    <h3>Pendapatan per Lapangan</h3>
    <table>
        <thead>
            <tr>
                <th>Lapangan</th>
                <th class="text-right">Total Pendapatan</th>
                <th class="text-right">Jumlah Transaksi</th>
            </tr>
        </thead>
        <tbody>
            <?php $__currentLoopData = $byLapangan; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $lapanganName => $total): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <?php
                    $lapanganPayments = $payments->filter(function($p) use ($lapanganName) {
                        return ($p->booking->lapangan->nama ?? 'Unknown') === $lapanganName;
                    });
                ?>
                <tr>
                    <td><?php echo e($lapanganName); ?></td>
                    <td class="text-right"><?php echo e(function_exists('formatRupiah') ? formatRupiah($total) : 'Rp ' . number_format($total, 0, ',', '.')); ?></td>
                    <td class="text-right"><?php echo e($lapanganPayments->count()); ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </tbody>
    </table>
    <?php endif; ?>

    <div class="footer">
        <p>Laporan ini dibuat secara otomatis oleh sistem Manfutsal</p>
    </div>
</body>
</html><?php /**PATH C:\Users\User\Documents\Projek Kelas 12\Manfutsal\resources\views/exports/keuangan_pdf.blade.php ENDPATH**/ ?>