<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Shop Dashboard Report</title>
    <style>
        body {
            font-family: 'DejaVu Sans', 'Arial', sans-serif;
            font-size: 10px;
            line-height: 1.4;
            color: #333;
            margin: 0;
            padding: 15mm;
        }

        .dashboard-container {
            max-width: 180mm;
            margin: 0 auto;
        }

        .dashboard-header {
            border-bottom: 2px solid #333;
            padding-bottom: 10px;
            margin-bottom: 20px;
            text-align: center;
        }

        .dashboard-header h1 {
            margin: 0;
            color: #333;
            font-size: 18px;
            font-weight: bold;
        }

        .dashboard-header p {
            margin: 3px 0;
            color: #666;
            font-size: 9px;
        }

        .filter-info {
            background-color: #f8f9fa;
            padding: 8px;
            border-radius: 4px;
            margin-bottom: 15px;
            font-size: 9px;
        }

        .metrics-grid {
            display: table;
            width: 100%;
            margin-bottom: 20px;
            border-collapse: separate;
            border-spacing: 8px 8px;
        }

        .metric-card {
            display: table-cell;
            background-color: #fff;
            border: 1px solid #dee2e6;
            border-radius: 6px;
            padding: 12px;
            width: 25%;
            vertical-align: top;
        }

        .metric-value {
            font-size: 16px;
            font-weight: bold;
            margin-bottom: 4px;
        }

        .metric-label {
            font-size: 8px;
            color: #6c757d;
            margin-bottom: 2px;
            text-transform: uppercase;
        }

        .metric-desc {
            font-size: 7px;
            color: #6c757d;
        }

        .text-primary { color: #007bff; }
        .text-success { color: #28a745; }
        .text-danger { color: #dc3545; }
        .text-warning { color: #ffc107; }
        .text-info { color: #17a2b8; }
        .text-secondary { color: #6c757d; }

        .transactions-section {
            margin-top: 20px;
        }

        .section-title {
            font-size: 14px;
            font-weight: bold;
            color: #333;
            margin-bottom: 10px;
            border-bottom: 1px solid #dee2e6;
            padding-bottom: 5px;
        }

        table {
            width: 100%;
            border-collapse: collapse;
            margin-bottom: 15px;
            font-size: 8px;
        }

        th, td {
            border: 1px solid #dee2e6;
            padding: 6px 8px;
            text-align: left;
        }

        th {
            background-color: #f8f9fa;
            font-weight: bold;
            font-size: 8px;
        }

        .badge {
            display: inline-block;
            padding: 2px 6px;
            font-size: 7px;
            font-weight: bold;
            border-radius: 3px;
            text-transform: uppercase;
        }

        .bg-primary { background-color: #007bff; color: white; }
        .bg-success { background-color: #28a745; color: white; }
        .bg-danger { background-color: #dc3545; color: white; }
        .bg-warning { background-color: #ffc107; color: black; }
        .bg-secondary { background-color: #6c757d; color: white; }

        .dashboard-footer {
            border-top: 1px solid #dee2e6;
            padding-top: 10px;
            margin-top: 20px;
            text-align: center;
            font-size: 8px;
            color: #6c757d;
        }
    </style>
</head>
<body>
    <div class="dashboard-container">
        <!-- Header -->
        <?php echo $__env->make('components.pdf.header', ['title' => 'Shop Dashboard Report', 'shop' => $selectedShop ?? null], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

        <!-- Filter Information -->
        <?php if($selectedShop || $startDate || $endDate): ?>
        <div class="filter-info">
            <strong>Applied Filters:</strong>
            <?php if($selectedShop): ?>
                Shop: <?php echo e($selectedShop->name); ?> |
            <?php endif; ?>
            <?php if($startDate && $endDate): ?>
                Period: <?php echo e($startDate->format('M d, Y')); ?> to <?php echo e($endDate->format('M d, Y')); ?>

            <?php elseif($startDate): ?>
                From: <?php echo e($startDate->format('M d, Y')); ?>

            <?php elseif($endDate): ?>
                Until: <?php echo e($endDate->format('M d, Y')); ?>

            <?php endif; ?>
        </div>
        <?php endif; ?>

        <!-- Key Metrics Grid -->
        <div class="metrics-grid">
            <div class="metric-card">
                <div class="metric-label">Total Sales</div>
                <div class="metric-value text-primary">Rs. <?php echo e(number_format($totalSalesAmount, 2)); ?></div>
                <div class="metric-desc"><?php echo e(number_format($totalSales)); ?> Invoices</div>
            </div>

            <div class="metric-card">
                <div class="metric-label">Collected Today</div>
                <div class="metric-value text-success">Rs. <?php echo e(number_format($totalEarnedToday, 2)); ?></div>
                <div class="metric-desc">Payments received</div>
            </div>

            <div class="metric-card">
                <div class="metric-label">Outstanding Payable</div>
                <div class="metric-value <?php echo e($totalOutstandingPayable > 0 ? 'text-danger' : 'text-success'); ?>">
                    Rs. <?php echo e(number_format(abs($totalOutstandingPayable), 2)); ?>

                </div>
                <div class="metric-desc"><?php echo e($totalOutstandingPayable > 0 ? 'Amount to pay' : 'Credit balance'); ?></div>
            </div>

            <div class="metric-card">
                <div class="metric-label">Return Invoices</div>
                <div class="metric-value text-warning"><?php echo e(number_format($totalReturnInvoices)); ?></div>
                <div class="metric-desc">Rs. <?php echo e(number_format($totalReturnAmount, 2)); ?></div>
            </div>
        </div>

        <!-- Secondary Metrics Grid -->
        <div class="metrics-grid">
            <div class="metric-card">
                <div class="metric-label">Total Revenue</div>
                <div class="metric-value text-info">Rs. <?php echo e(number_format($totalRevenue, 2)); ?></div>
                <div class="metric-desc">All receipts</div>
            </div>

            <div class="metric-card">
                <div class="metric-label">Total Expenses</div>
                <div class="metric-value text-danger">Rs. <?php echo e(number_format($totalExpenses, 2)); ?></div>
                <div class="metric-desc">All payments</div>
            </div>

            


        </div>

        <!-- Recent Transactions -->
        <div class="transactions-section">
            <div class="section-title">Recent Transactions</div>
            <table>
                <thead>
                    <tr>
                        <th>Date</th>
                        <th>Shop</th>
                        <th>Contact</th>
                        <th>Type</th>
                        <th>Reference</th>
                        <th>Amount</th>
                        <th>Transaction</th>
                    </tr>
                </thead>
                <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $recentTransactions; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $transaction): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                    <tr>
                        <td><?php echo e($transaction->local_db_created_at->format('M d, Y H:i')); ?></td>
                        <td><?php echo e($transaction->shop->name ?? 'N/A'); ?></td>
                        <td><?php echo e($transaction->contact->name ?? 'N/A'); ?></td>
                        <td>
                            <span class="badge bg-<?php echo e($transaction->reference_type === 'invoice' ? 'primary' : ($transaction->reference_type === 'goods_receipt' ? 'success' : ($transaction->reference_type === 'invoice_return' ? 'warning' : 'secondary'))); ?>">
                                <?php echo e($transaction->reference_type_label); ?>

                            </span>
                        </td>
                        <td><?php echo e($transaction->reference_code); ?></td>
                        <td style="color: <?php echo e(in_array($transaction->transaction_type, ['receipt', 'credit']) ? '#28a745' : '#dc3545'); ?>;">
                            Rs. <?php echo e(number_format($transaction->amount, 2)); ?>

                        </td>
                        <td>
                            <span class="badge bg-<?php echo e(in_array($transaction->transaction_type, ['receipt', 'credit']) ? 'success' : 'danger'); ?>">
                                <?php echo e($transaction->transaction_type_label); ?>

                            </span>
                        </td>
                    </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                    <tr>
                        <td colspan="7" style="text-align: center;">No transactions found</td>
                    </tr>
                    <?php endif; ?>
                </tbody>
            </table>
        </div>

        <!-- Footer -->
        <?php echo $__env->make('components.pdf.footer', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
    </div>
</body>
</html>
<?php /**PATH C:\laragon\www\habibcables-ERP\resources\views\pdf\dashboard.blade.php ENDPATH**/ ?>