<?php
include 'includes/auth.php';
include 'db.php';
include 'includes/header.php';
$username = $_SESSION['username'] ?? 'Guest';

// ================== Fetch Notifications ==================
// Pending Bar Requisitions
$pending_bar_reqs = $conn->query("
    SELECT COUNT(*) as cnt 
    FROM bar_requisitions
    WHERE status='Pending'
")->fetch_assoc()['cnt'] ?? 0;




// Pending Bar Requisitions
$pending_hk_reqs = $conn->query("
    SELECT COUNT(*) as cntt 
    FROM hk_requisitions 
    WHERE status='Pending'
")->fetch_assoc()['cntt'] ?? 0;
?>

<style>
.kitchen-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
    background: #fdfdfd;
    transition: 0.2s;
}
.kitchen-card:hover { box-shadow: 0px 3px 8px rgba(0,0,0,0.2); }
.kitchen-title { font-weight: bold; font-size: 1.1rem; }
.kitchen-subtitle { font-size: 0.9rem; color: #555; }
.kitchen-actions { margin-top: 10px; }

/* Notification badge */
.badge-notif {
    background: red;
    color: #fff;
    border-radius: 50%;
    font-size: 0.7rem;
    padding: 3px 6px;
    position: relative;
    top: -10px;
    left: -5px;
}
</style>

<div class="container mt-4">

    <div class="welcome-msg">
        <i class="fa fa-user-circle"></i> Welcome, 
        <strong><?= htmlspecialchars($_SESSION['username'] ?? 'Guest') ?></strong>!
    </div>

    <button class="btn btn-secondary mb-3" onclick="history.back()">
        <i class="fa fa-arrow-left"></i> Back
    </button>

    <h4 class="mb-3"><i class="fa fa-chart-bar text-primary"></i> Reports Dashboard</h4>
    <hr>

    <div class="row g-3">

        <?php
        function reportCard($link, $icon, $title, $color='bg-primary', $badge=null){
            echo '
            <div class="col-md-3">
                <a href="'.$link.'" class="text-decoration-none">
                    <div class="card shadow-sm text-center report-card">
                        <div class="card-body">
                            <div class="icon-box '.$color.' mx-auto mb-2">
                                <i class="fa '.$icon.'"></i>
                            </div>
                            <h6 class="mb-1">'.$title.'</h6>';
                            
                            if($badge){
                                echo '<span class="badge bg-danger">'.$badge.'</span>';
                            }

            echo        '</div>
                    </div>
                </a>
            </div>';
        }

        // REPORT BUTTONS
        reportCard('rooms_report.php','fa-bed','Rooms Report','bg-info');
        reportCard('checkouts_report.php','fa-sign-out-alt','Checkouts Report','bg-success');
        reportCard('restaurant_orders_report.php','fa-file-alt','Restaurant Orders Report','bg-warning');
        reportCard('invoices_report.php','fa-file-invoice','Invoices Report','bg-primary');
        reportCard('payments_report.php','fa-money-bill','Payments Report','bg-success');
        reportCard('sales_report.php','fa-shopping-cart','Sales Report','bg-dark');
        reportCard('sales_plus_payments_report.php','fa-coins','Sales + Payments','bg-secondary');
        reportCard('sales_against_invoices.php','fa-exchange-alt','Sales vs Invoices','bg-warning');
          

        reportCard('conference_report.php','fa-handshake','Conferences Report','bg-info');
        reportCard('reservations_report.php','fa-calendar-check','Reservations Report','bg-success');

           reportCard('report_inventory.php','fa-exchange-alt','Inventory','bg-warning');
          
 reportCard('analytics_report.php','fa-file-invoice','Accomodation Analytics','bg-primary');
 reportCard('bar_analytics.php','fa-file-invoice','Bar Analytics','bg-primary');
  reportCard('restaurant_analytics.php','fa-file-invoice','Restaurant Analytics','bg-primary');
  reportCard('reque_analytics.php','fa-file-invoice','Requisition Analytics','bg-primary');

  reportCard('individual_reports.php','fa-coins','Sales Audit','bg-success');

  reportCard('kitchen_production_report.php','fa-exchange-alt','Kitchen Production','bg-warning');
 reportCard('perishables_report.php','fa-file-invoice','Perishables Report','bg-primary');



   reportCard('levy_report.php','fa-coins','Tourism Levy','bg-success');
 reportCard('vat_report.php','fa-file-invoice','VAT Report','bg-warning');
   reportCard('discount_report.php','fa-money-bill','Discounts','bg-dark');


    
        ?>

    </div>

</div>

<?php include 'includes/footer.php'; ?>
