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

// ================== Fetch Notifications ==================
// Pending counts for each section
$notifications = [
    'bar' => $conn->query("SELECT COUNT(*) as cnt FROM bar_requisitions WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'kitchen' => $conn->query("SELECT COUNT(*) as cnt FROM k_requisitions WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'restaurant' => $conn->query("SELECT COUNT(*) as cnt FROM r_requisitions WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'frontdesk' => $conn->query("SELECT COUNT(*) as cnt FROM front_desk_requisitions  WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'housekeeping' => $conn->query("SELECT COUNT(*) as cnt FROM hk_requisitions WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'maintenance' => $conn->query("SELECT COUNT(*) as cnt FROM maintenance_requests WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'finance' => $conn->query("SELECT COUNT(*) as cnt FROM petty_cash WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
];




// ================== Fetch Notifications ==================
// Pending counts for each section
$notificationss = [
    'bars' => $conn->query("SELECT COUNT(*) as cnt FROM  bar_purchase_requests  WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'kitchens' => $conn->query("SELECT COUNT(*) as cnt FROM purchase_requestsk WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'restaurants' => $conn->query("SELECT COUNT(*) as cnt FROM purchase_requests_restaurant  WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'frontdesks' => $conn->query("SELECT COUNT(*) as cnt FROM purchase_requests_front  WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
    'housekeepings' => $conn->query("SELECT COUNT(*) as cnt FROM purchase_requests WHERE status='Pending'")->fetch_assoc()['cnt'] ?? 0,
  
   
];
?>






<style>
/* ================== Button Cards ================== */
.btn-dashboard {
    display: inline-block;
    position: relative;
    padding: 18px 28px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 12px;
    margin: 10px 8px;
    transition: 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-dashboard:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* Notification badge */
.badge-notif {
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    font-size: 0.85rem;
    padding: 6px 10px;
    position: absolute;
    top: -10px;
    right: -10px;
    font-weight: bold;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    animation: bounce 1.2s infinite;
}

/* Bounce animation for notifications */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Center container */
.dashboard-center {
    text-align: center;
    margin-top: 40px;
}
</style>

<div class="container mt-4">
    <button class="btn btn-secondary mb-3" onclick="history.back()">
        <i class="fa fa-arrow-left"></i> Back
    </button>
    
    <div class="welcome-msg mb-4">
        <i class="fa fa-user-circle"></i> Welcome, <strong><?= htmlspecialchars($username) ?></strong>!
    </div>

    <div class="dashboard-center">
<h4>Inventory/Stores Requests</h4>
        <!-- Bar Requisitions -->
        <a href="approve_bar_requisitions.php" class="btn btn-primary btn-dashboard position-relative">
            <i class="fa fa-beer"></i> Bar
            <?php if($notifications['bar'] > 0): ?>
                <span class="badge-notif"><?= $notifications['bar'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Kitchen Requisitions -->
        <a href="kitchen_requisitions.php" class="btn btn-success btn-dashboard position-relative">
            <i class="fa fa-utensils"></i> Kitchen
            <?php if($notifications['kitchen'] > 0): ?>
                <span class="badge-notif"><?= $notifications['kitchen'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Restaurant -->
        <a href="restaurant_requisitions_approve.php" class="btn btn-warning btn-dashboard position-relative">
            <i class="fa fa-hamburger"></i> Restaurant
            <?php if($notifications['restaurant'] > 0): ?>
                <span class="badge-notif"><?= $notifications['restaurant'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Front Desk -->
        <a href="front_desk_requisitions_approval.php" class="btn btn-info btn-dashboard position-relative">
            <i class="fa fa-desktop"></i> Front Desk
            <?php if($notifications['frontdesk'] > 0): ?>
                <span class="badge-notif"><?= $notifications['frontdesk'] ?></span>
            <?php endif; ?>
        </a>

        <!-- House Keeping -->
        <a href="approve_hk_requisitions.php" class="btn btn-secondary btn-dashboard position-relative">
            <i class="fa fa-broom"></i> House Keeping
            <?php if($notifications['housekeeping'] > 0): ?>
                <span class="badge-notif"><?= $notifications['housekeeping'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Maintenance Requests -->
        <a href="maintenance_requests_approval.php" class="btn btn-danger btn-dashboard position-relative">
            <i class="fa fa-tools"></i> Maintenance
            <?php if($notifications['maintenance'] > 0): ?>
                <span class="badge-notif"><?= $notifications['maintenance'] ?></span>
            <?php endif; ?>
        </a>


    </div>



<!-- Purchase Requests  !-->

<style>
/* ================== Button Cards ================== */
.btn-dashboard {
    display: inline-block;
    position: relative;
    padding: 18px 28px;
    font-size: 1 rem;
    font-weight: bold;
    border-radius: 12px;
    margin: 10px 8px;
    transition: 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-dashboard:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* Notification badge */
.badge-notiff {
    background: #dc3545;
    color: #fff;
    border-radius: 50%;
    font-size: 1.85rem;
    padding: 1px 13px;
    position: absolute;
    top: -10px;
    right: -10px;
    font-weight: bold;
    border: 2px solid #000; /* Black border added */
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    animation: bounce 1.2s infinite;
}
/* Bounce animation for notifications */
@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Center container */
.dashboard-center {
    text-align: center;
    margin-top: 40px;
}
</style>
 <div class="dashboard-center">
<h4>Purchase Requests</h4>
        <!-- Bar Requisitions -->
        <a href="approve_bar_purchases.php" class="btn btn-primary btn-dashboard position-relative">
            <i class="fa fa-beer"></i> Bar
            <?php if($notificationss['bars'] > 0): ?>
                <span class="badge-notiff"><?= $notificationss['bars'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Kitchen Requisitions -->
        <a href="approve_kitchen_purchases.php" class="btn btn-success btn-dashboard position-relative">
            <i class="fa fa-utensils"></i> Kitchen
            <?php if($notificationss['kitchens'] > 0): ?>
                <span class="badge-notiff"><?= $notificationss['kitchens'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Restaurant -->
        <a href="approve_restaurant_purchases.php" class="btn btn-warning btn-dashboard position-relative">
            <i class="fa fa-hamburger"></i> Restaurant
            <?php if($notificationss['restaurants'] > 0): ?>
                <span class="badge-notiff"><?= $notificationss['restaurants'] ?></span>
            <?php endif; ?>
        </a>

        <!-- Front Desk -->
        <a href="approve_front_desk_purchases.php" class="btn btn-info btn-dashboard position-relative">
            <i class="fa fa-desktop"></i> Front Desk
            <?php if($notificationss['frontdesks'] > 0): ?>
                <span class="badge-notiff"><?= $notificationss['frontdesks'] ?></span>
            <?php endif; ?>
        </a>

        <!-- House Keeping -->
        <a href="approve_house_purchases.php" class="btn btn-secondary btn-dashboard position-relative">
            <i class="fa fa-broom"></i> House Keeping
            <?php if($notificationss['housekeepings'] > 0): ?>
                <span class="badge-notiff"><?= $notificationss['housekeepings'] ?></span>
            <?php endif; ?>
        </a>


    </div>




</div>

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