<?php if (isset($component)) { $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54 = $attributes; } ?>
<?php $component = App\View\Components\AppLayout::resolve([] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('app-layout'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\App\View\Components\AppLayout::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
     <?php $__env->slot('header', null, []); ?> <?php echo e(__('Dashboard')); ?> <?php $__env->endSlot(); ?>

    <?php
        $chartLabelsJson    = json_encode($chartLabels);
        $chartSalesJson     = json_encode($chartSales);
        $chartPurchasesJson = json_encode($chartPurchases);
        $chartExpensesJson  = json_encode($chartExpenses);
        $hasFinancial = Auth::user()->canAny(['sales.view', 'purchases.view', 'expenses.view']);
        $hasPeople    = Auth::user()->canAny(['employees.view', 'customers.view', 'rosters.view']);
    ?>

    
    <div class="alert alert-light border mb-4 d-flex align-items-center gap-2 py-2">
        <i class="bi bi-person-circle fs-5 text-primary"></i>
        <span><?php echo e(__('Welcome back')); ?>, <strong><?php echo e(Auth::user()->name); ?></strong>
            &mdash; <?php echo e(now()->format('l, d M Y')); ?></span>
    </div>

    
    <?php if($hasFinancial): ?>
    <div class="row g-3 mb-4">
        
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.view')): ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card text-bg-primary h-100 border-0 shadow-sm">
                <div class="card-body py-3">
                    <div class="d-flex align-items-center gap-2 mb-1">
                        <i class="bi bi-cart3 fs-5"></i>
                        <small class="fw-semibold"><?php echo e(__("Today's Sales")); ?></small>
                    </div>
                    <h4 class="mb-0"><?php echo e(number_format($stats['sales'], 2)); ?></h4>
                </div>
            </div>
        </div>
        <?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('purchases.view')): ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card text-bg-success h-100 border-0 shadow-sm">
                <div class="card-body py-3">
                    <div class="d-flex align-items-center gap-2 mb-1">
                        <i class="bi bi-box-seam fs-5"></i>
                        <small class="fw-semibold"><?php echo e(__("Today's Purchases")); ?></small>
                    </div>
                    <h4 class="mb-0"><?php echo e(number_format($stats['purchases'], 2)); ?></h4>
                </div>
            </div>
        </div>
        <?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('expenses.view')): ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card text-bg-warning h-100 border-0 shadow-sm">
                <div class="card-body py-3">
                    <div class="d-flex align-items-center gap-2 mb-1">
                        <i class="bi bi-receipt fs-5"></i>
                        <small class="fw-semibold"><?php echo e(__("Today's Expenses")); ?></small>
                    </div>
                    <h4 class="mb-0"><?php echo e(number_format($stats['expenses'], 2)); ?></h4>
                </div>
            </div>
        </div>
        <?php endif; ?>
        
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.view')): ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card h-100 border-0 shadow-sm" style="background:#e8f5e9">
                <div class="card-body py-3">
                    <div class="d-flex align-items-center gap-2 mb-1 text-success">
                        <i class="bi bi-cart3 fs-5"></i>
                        <small class="fw-semibold"><?php echo e(__("Yesterday Sales")); ?></small>
                    </div>
                    <h4 class="mb-0 text-success"><?php echo e(number_format($stats['yesterday_sales'], 2)); ?></h4>
                </div>
            </div>
        </div>
        <?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('purchases.view')): ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card h-100 border-0 shadow-sm" style="background:#fce4ec">
                <div class="card-body py-3">
                    <div class="d-flex align-items-center gap-2 mb-1 text-danger">
                        <i class="bi bi-box-seam fs-5"></i>
                        <small class="fw-semibold"><?php echo e(__("Yesterday Purchases")); ?></small>
                    </div>
                    <h4 class="mb-0 text-danger"><?php echo e(number_format($stats['yesterday_purchases'], 2)); ?></h4>
                </div>
            </div>
        </div>
        <?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('expenses.view')): ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card h-100 border-0 shadow-sm" style="background:#fff3e0">
                <div class="card-body py-3">
                    <div class="d-flex align-items-center gap-2 mb-1" style="color:#e65100">
                        <i class="bi bi-receipt fs-5"></i>
                        <small class="fw-semibold"><?php echo e(__("Yesterday Expenses")); ?></small>
                    </div>
                    <h4 class="mb-0" style="color:#e65100"><?php echo e(number_format($stats['yesterday_expenses'], 2)); ?></h4>
                </div>
            </div>
        </div>
        <?php endif; ?>
    </div>
    <?php endif; ?>

    
    <?php if($hasFinancial): ?>
    <div class="row g-4 mb-4">
        
        <div class="col-12 col-xl-8">
            <div class="card shadow-sm border-0 h-100">
                <div class="card-header bg-white border-0 pt-3 pb-0">
                    <h6 class="fw-semibold mb-0"><i class="bi bi-graph-up me-2 text-primary"></i><?php echo e(__('Last 7 Days Overview')); ?></h6>
                </div>
                <div class="card-body">
                    <canvas id="weeklyChart" height="130"></canvas>
                </div>
            </div>
        </div>

        
        <div class="col-12 col-xl-4">
            <div class="card shadow-sm border-0 h-100">
                <div class="card-header bg-white border-0 pt-3 pb-0">
                    <h6 class="fw-semibold mb-0"><i class="bi bi-bar-chart-fill me-2 text-success"></i><?php echo e(__('Last 30 Days Totals')); ?></h6>
                </div>
                <div class="card-body d-flex align-items-center">
                    <canvas id="monthChart" height="200"></canvas>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>

    
    <?php if($hasFinancial || $hasPeople): ?>
    <div class="row g-4">
        
        <div class="col-12 col-xl-4">
            <div class="card shadow-sm border-0 h-100">
                <div class="card-header bg-white border-0 pt-3 pb-0">
                    <h6 class="fw-semibold mb-0"><i class="bi bi-clipboard-data me-2 text-secondary"></i><?php echo e(__('Summary')); ?></h6>
                </div>
                <div class="card-body p-0">
                    <ul class="list-group list-group-flush">
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('employees.view')): ?>
                        <li class="list-group-item d-flex justify-content-between align-items-center">
                            <span><i class="bi bi-people me-2 text-primary"></i><?php echo e(__('Employees')); ?></span>
                            <span class="badge rounded-pill bg-primary"><?php echo e($stats['employees']); ?></span>
                        </li>
                        <?php endif; ?>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('customers.view')): ?>
                        <li class="list-group-item d-flex justify-content-between align-items-center">
                            <span><i class="bi bi-person-check me-2 text-success"></i><?php echo e(__('Customers')); ?></span>
                            <span class="badge rounded-pill bg-success"><?php echo e($stats['customers']); ?></span>
                        </li>
                        <li class="list-group-item d-flex justify-content-between align-items-center">
                            <span><i class="bi bi-exclamation-circle me-2 text-danger"></i><?php echo e(__('Customers with Due')); ?></span>
                            <span class="badge rounded-pill bg-danger"><?php echo e($stats['due_customers']); ?></span>
                        </li>
                        <?php endif; ?>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('rosters.view')): ?>
                        <li class="list-group-item d-flex justify-content-between align-items-center">
                            <span><i class="bi bi-calendar3 me-2 text-info"></i><?php echo e(__("Today's Rosters")); ?></span>
                            <span class="badge rounded-pill bg-info"><?php echo e($stats['rosters']); ?></span>
                        </li>
                        <?php endif; ?>
                        <li class="list-group-item d-flex justify-content-between align-items-center">
                            <span><i class="bi bi-calendar-day me-2 text-secondary"></i><?php echo e(__('Today')); ?></span>
                            <span class="text-muted small"><?php echo e($today->toFormattedDateString()); ?></span>
                        </li>
                        <?php if($hasFinancial): ?>
                        <li class="list-group-item">
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.view')): ?>
                            <div class="d-flex justify-content-between align-items-center mb-1">
                                <small class="text-muted"><?php echo e(__('Month Sales')); ?></small>
                                <strong class="text-primary"><?php echo e(number_format($stats['month_sales'], 2)); ?></strong>
                            </div>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('purchases.view')): ?>
                            <div class="d-flex justify-content-between align-items-center mb-1">
                                <small class="text-muted"><?php echo e(__('Month Purchases')); ?></small>
                                <strong class="text-danger"><?php echo e(number_format($stats['month_purchases'], 2)); ?></strong>
                            </div>
                            <?php endif; ?>
                            <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('expenses.view')): ?>
                            <div class="d-flex justify-content-between align-items-center">
                                <small class="text-muted"><?php echo e(__('Month Expenses')); ?></small>
                                <strong class="text-warning"><?php echo e(number_format($stats['month_expenses'], 2)); ?></strong>
                            </div>
                            <?php endif; ?>
                        </li>
                        <?php endif; ?>
                    </ul>
                </div>
            </div>
        </div>

        
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.view')): ?>
        <div class="col-12 col-xl-8">
            <div class="card shadow-sm border-0 h-100">
                <div class="card-header bg-white border-0 pt-3 pb-0">
                    <h6 class="fw-semibold mb-0"><i class="bi bi-clock-history me-2 text-primary"></i><?php echo e(__('Latest 5 Sales')); ?></h6>
                </div>
                <div class="table-responsive">
                    <table class="table table-hover align-middle mb-0">
                        <thead class="table-light">
                            <tr>
                                <th><?php echo e(__('Date')); ?></th>
                                <th><?php echo e(__('Customer')); ?></th>
                                <th><?php echo e(__('Source')); ?></th>
                                <th class="text-end"><?php echo e(__('Amount')); ?></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php $__empty_1 = true; $__currentLoopData = $latestSales; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $sale): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                <tr>
                                    <td><?php echo e($sale->sale_date ?? $sale->created_at->format('Y-m-d')); ?></td>
                                    <td><?php echo e(optional($sale->customer)->name ?? __('Walk-in')); ?></td>
                                    <td><span class="badge bg-secondary"><?php echo e(str_replace('_', ' ', $sale->source ?? '')); ?></span></td>
                                    <td class="text-end fw-semibold"><?php echo e(number_format($sale->amount, 2)); ?></td>
                                </tr>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                <tr>
                                    <td colspan="4" class="text-center text-muted py-4"><?php echo e(__('No recent sales yet.')); ?></td>
                                </tr>
                            <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <?php endif; ?>
    </div>
    <?php endif; ?>

    
    <?php if(!$hasFinancial && !$hasPeople): ?>
    <div class="text-center py-5 text-muted">
        <i class="bi bi-shield-lock display-3 mb-3 d-block"></i>
        <h5><?php echo e(__('No dashboard data available for your role.')); ?></h5>
        <p class="mb-0"><?php echo e(__('Please contact an administrator if you believe this is a mistake.')); ?></p>
    </div>
    <?php endif; ?>

    
    <?php if($hasFinancial): ?>
    <script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.2/dist/chart.umd.min.js"></script>
    <script>
    (function () {
        const labels    = <?php echo $chartLabelsJson; ?>;
        const sales     = <?php echo $chartSalesJson; ?>;
        const purchases = <?php echo $chartPurchasesJson; ?>;
        const expenses  = <?php echo $chartExpensesJson; ?>;

        // Weekly Line Chart
        new Chart(document.getElementById('weeklyChart'), {
            type: 'line',
            data: {
                labels: labels,
                datasets: [
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.view')): ?>
                    {
                        label: '<?php echo e(__("Sales")); ?>',
                        data: sales,
                        borderColor: '#0d6efd',
                        backgroundColor: 'rgba(13,110,253,.1)',
                        tension: .4, fill: true, pointRadius: 4,
                    },
                    <?php endif; ?>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('purchases.view')): ?>
                    {
                        label: '<?php echo e(__("Purchases")); ?>',
                        data: purchases,
                        borderColor: '#dc3545',
                        backgroundColor: 'rgba(220,53,69,.08)',
                        tension: .4, fill: true, pointRadius: 4,
                    },
                    <?php endif; ?>
                    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('expenses.view')): ?>
                    {
                        label: '<?php echo e(__("Expenses")); ?>',
                        data: expenses,
                        borderColor: '#fd7e14',
                        backgroundColor: 'rgba(253,126,20,.08)',
                        tension: .4, fill: true, pointRadius: 4,
                    },
                    <?php endif; ?>
                ],
            },
            options: {
                responsive: true,
                interaction: { mode: 'index', intersect: false },
                plugins: { legend: { position: 'top' } },
                scales: { y: { beginAtZero: true } },
            },
        });

        // Monthly Bar Chart
        const barLabels = [];
        const barData   = [];
        const barColors = [];
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.view')): ?>
        barLabels.push('<?php echo e(__("Sales")); ?>'); barData.push(<?php echo e($stats['month_sales']); ?>); barColors.push('#0d6efd');
        <?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('purchases.view')): ?>
        barLabels.push('<?php echo e(__("Purchases")); ?>'); barData.push(<?php echo e($stats['month_purchases']); ?>); barColors.push('#dc3545');
        <?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('expenses.view')): ?>
        barLabels.push('<?php echo e(__("Expenses")); ?>'); barData.push(<?php echo e($stats['month_expenses']); ?>); barColors.push('#fd7e14');
        <?php endif; ?>

        new Chart(document.getElementById('monthChart'), {
            type: 'bar',
            data: {
                labels: barLabels,
                datasets: [{
                    label: '<?php echo e(__("Last 30 Days")); ?>',
                    data: barData,
                    backgroundColor: barColors,
                    borderRadius: 6,
                }],
            },
            options: {
                responsive: true,
                plugins: { legend: { display: false } },
                scales: { y: { beginAtZero: true } },
            },
        });
    })();
    </script>
    <?php endif; ?>
 <?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $attributes = $__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__attributesOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php if (isset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54)): ?>
<?php $component = $__componentOriginal9ac128a9029c0e4701924bd2d73d7f54; ?>
<?php unset($__componentOriginal9ac128a9029c0e4701924bd2d73d7f54); ?>
<?php endif; ?>
<?php /**PATH C:\Users\anwar\OneDrive\Desktop\Babu KSA\software\restaurant-management\resources\views/dashboard.blade.php ENDPATH**/ ?>