<?php

require_once __DIR__ . '/../includes/auth.php';
require_once __DIR__ . '/../config/app.php';

if (($_SESSION['role'] ?? '') !== 'admin') {
    header('Location: ' . BASE_URL . 'dashboard.php');
    exit();
}

include '../includes/header.php';
include '../includes/navbar.php';
?>

<main class="container py-4">

    <div class="d-flex flex-column flex-md-row
                justify-content-between align-items-md-center mb-4">

        <div>
            <h3 class="fw-bold text-primary mb-1">
                <i class="fa-solid fa-gears me-2"></i>
                System Management
            </h3>

            <p class="text-muted mb-0">
                Manage the inventory system master data and reports.
            </p>
        </div>

    </div>

    <div class="row g-4">

        <!-- Schools -->
        <div class="col-12 col-sm-6 col-lg-4">

            <div class="card shadow-sm h-100">

                <div class="card-body text-center">

                    <div class="display-5 text-primary mb-3">
                        <i class="fa-solid fa-school"></i>
                    </div>

                    <h5 class="fw-bold">
                        School Management
                    </h5>

                    <p class="text-muted">
                        View, search, upload and manage school master data.
                    </p>

                    <a
                        href="<?= BASE_URL ?>admin/manage_schools.php"
                        class="btn btn-primary w-100">

                        <i class="fa-solid fa-arrow-right me-1"></i>
                        Manage Schools

                    </a>

                </div>

            </div>

        </div>

        <!-- Users -->
        <div class="col-12 col-sm-6 col-lg-4">

            <div class="card shadow-sm h-100">

                <div class="card-body text-center">

                    <div class="display-5 text-success mb-3">
                        <i class="fa-solid fa-users"></i>
                    </div>

                    <h5 class="fw-bold">
                        User Management
                    </h5>

                    <p class="text-muted">
                        Add, edit and manage administrators, directors and users.
                    </p>

                    <a
                        href="<?= BASE_URL ?>admin/users.php"
                        class="btn btn-success w-100">

                        <i class="fa-solid fa-arrow-right me-1"></i>
                        Manage Users

                    </a>

                </div>

            </div>

        </div>

        <!-- Units -->
        <div class="col-12 col-sm-6 col-lg-4">

            <div class="card shadow-sm h-100">

                <div class="card-body text-center">

                    <div class="display-5 text-warning mb-3">
                        <i class="fa-solid fa-building"></i>
                    </div>

                    <h5 class="fw-bold">
                        Unit Management
                    </h5>

                    <p class="text-muted">
                        Manage Computer Lab, Office and other inventory locations.
                    </p>

                    <a
                        href="<?= BASE_URL ?>admin/units.php"
                        class="btn btn-warning w-100">

                        <i class="fa-solid fa-arrow-right me-1"></i>
                        Manage Units

                    </a>

                </div>

            </div>

        </div>

        <!-- Equipment -->
        <div class="col-12 col-sm-6 col-lg-4">

            <div class="card shadow-sm h-100">

                <div class="card-body text-center">

                    <div class="display-5 text-danger mb-3">
                        <i class="fa-solid fa-computer"></i>
                    </div>

                    <h5 class="fw-bold">
                        Equipment Management
                    </h5>

                    <p class="text-muted">
                        Manage equipment and assign equipment to inventory units.
                    </p>

                    <a
                        href="<?= BASE_URL ?>admin/equipment.php"
                        class="btn btn-danger w-100">

                        <i class="fa-solid fa-arrow-right me-1"></i>
                        Manage Equipment

                    </a>

                </div>

            </div>

        </div>

        <div class="col-md-6 col-lg-4 mb-4">

            <div class="card shadow-sm h-100 text-center">

                <div class="card-body d-flex flex-column">

                    <div class="mb-3">

                        <i
                            class="fa-solid fa-file-excel
                                fa-4x text-success"
                        ></i>

                    </div>

                    <h4 class="card-title">
                        School Data Import
                    </h4>

                    <p class="text-muted flex-grow-1">

                        Upload and update school master data
                        using an Excel file.

                    </p>

                    <a
                        href="<?= BASE_URL ?>admin/upload_school_data.php"
                        class="btn btn-success"
                    >
                        <i class="fa-solid fa-file-import me-1"></i>
                        Upload School Data
                    </a>

                </div>

            </div>

        </div>

    </div>

</main>

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