<?php
session_start();
require_once __DIR__ . '/../../includes/auth.php';
require_once __DIR__ . '/../../classes/Database.php';


$database = new Database();
$conn = $database->getConnection();


$auth = new Auth($conn);
if (!isset($_SESSION['user_id'])) {
    header('Location: ../../login.php');
    exit();
}


if ($_SESSION['role'] != 'admin' && $_SESSION['role'] != 'warehouse') {
    header('Location: /IMS/unauthorized.php');
    exit;
}


?>

<?php include __DIR__ . '/../../includes/header.php'; ?>

<style>
    body { background: #f4f6f8; }
    .warehouse-choose-shell { max-width: 1200px; margin: 28px auto; padding: 0 15px; }
    .warehouse-choose-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 28px; flex-wrap: wrap; }
    .warehouse-choose-title { font-weight: 800; color: #172033; }
    .warehouse-choose-subtitle { color: #667085; }

    .option-card {
        height: 100%;
        border: 0;
        border-radius: 12px;
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.08);
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        display: flex;
        flex-direction: column;
    }
    .option-card:hover {
        transform: translateY(-4px);
        box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
    }
    .option-card .card-body {
        display: flex;
        flex-direction: column;
        flex: 1;
        padding: 28px 24px;
    }
    .option-icon {
        width: 60px;
        height: 60px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.6rem;
        margin-bottom: 18px;
    }
    .option-icon.simple { background: #e3f2fd; color: #1a73e8; }
    .option-icon.detailed { background: #eef2f7; color: #475467; }
    .option-icon.excel { background: #e6f4ea; color: #188038; }

    .option-card h3 { font-weight: 700; font-size: 1.15rem; color: #172033; }
    .option-card p { color: #667085; flex: 1; }
    .option-card .btn { margin-top: auto; }

    .warehouse-note {
        background: #fff;
        border-radius: 10px;
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
        padding: 14px 18px;
        color: #667085;
        margin-bottom: 24px;
    }
</style>

<div class="warehouse-choose-shell">
    <div class="warehouse-choose-topbar">
        <div>
            <h2 class="warehouse-choose-title mb-1"><i class="fas fa-warehouse"></i> Add Items to Warehouse Inventory</h2>
            <p class="warehouse-choose-subtitle mb-0">Choose the type of form to use for adding items to the warehouse.</p>
        </div>
        <?php if ($_SESSION['role'] == 'admin'): ?>
            <a href="../../admin.php" class="btn btn-outline-secondary">
                <i class="fas fa-arrow-left"></i> Back to Admin Dashboard
            </a>
        <?php else: ?>
            <a href="../dashboard/warehouse.php" class="btn btn-outline-secondary">
                <i class="fas fa-arrow-left"></i> Back to Warehouse Dashboard
            </a>
        <?php endif; ?>
    </div>

    <div class="warehouse-note">
        <i class="fas fa-circle-info me-1"></i>
        Items added to the warehouse inventory will be available for shipment to branches.
    </div>

    <div class="row g-4">
        <div class="col-md-6">
            <div class="card option-card">
                <div class="card-body">
                    <div class="option-icon detailed"><i class="fas fa-clipboard-list"></i></div>
                    <h3>Add Items</h3>
                    <p>Enter the batch details, then confirm each item's condition, serial number, model, and other specifics. Works equally well for a single quick item or a fully detailed batch.</p>
                    <a href="add_items.php" class="btn btn-primary">Add Items</a>
                </div>
            </div>
        </div>

        <div class="col-md-6">
            <div class="card option-card">
                <div class="card-body">
                    <div class="option-icon excel"><i class="fas fa-file-excel"></i></div>
                    <h3>Import from Excel</h3>
                    <p>Bulk import items from an Excel spreadsheet. Perfect for adding multiple items at once.</p>
                    <a href="import_excel.php" class="btn btn-success">Import from Excel</a>
                </div>
            </div>
        </div>
    </div>
</div>

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