<?php

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

if ($_SESSION['role'] != 'admin')
{
    die("Access Denied");
}

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

<main class="container mt-4">

    <div class="row justify-content-center">

        <div class="col-lg-8">

            <div class="card shadow">

                <div class="card-header bg-success text-white">

                    <h5 class="mb-0">

                    <i class="fa-solid fa-plus"></i>

                    Add Equipment

                    </h5>

                </div>

                <div class="card-body">

                    <?php if(isset($_GET['success'])) { ?>

                    <div class="alert alert-success">

                    Equipment added successfully.

                    </div>

                    <?php } ?>

                    <?php if(isset($_GET['exists'])) { ?>

                    <div class="alert alert-warning">

                    Equipment already exists.

                    </div>

                    <?php } ?>

                    <form action="save_equipment.php" method="POST">

                        <div class="row">

                            <div class="col-md-8 mb-3">

                                <label class="form-label">

                                Equipment Name

                                </label>

                                <input
                                type="text"
                                name="equipment_name"
                                class="form-control"
                                placeholder="Example : Printer"
                                required>

                            </div>

                            <div class="col-md-4 mb-3">

                                <label class="form-label">

                                Display Order

                                </label>

                                <input
                                type="number"
                                name="display_order"
                                class="form-control"
                                value="1"
                                min="1"
                                required>

                            </div>

                        </div>

                        <div class="mb-3">

                            <label class="form-label">

                            Status

                            </label>

                            <select
                            name="status"
                            class="form-select">

                            <option value="Active" selected>

                            Active

                            </option>

                            <option value="Inactive">

                            Inactive

                            </option>

                            </select>

                        </div>

                        <hr>

                        <div class="d-flex justify-content-between">

                            <a
                            href="manage_equipment.php"
                            class="btn btn-secondary">

                            <i class="fa-solid fa-arrow-left"></i>

                            Back

                            </a>

                            <button
                            type="reset"
                            class="btn btn-warning">

                            <i class="fa-solid fa-eraser"></i>

                            Clear

                            </button>

                            <button
                            type="submit"
                            class="btn btn-success">

                            <i class="fa-solid fa-floppy-disk"></i>

                            Save Equipment

                            </button>

                        </div>

                    </form>

                </div>

            </div>

        </div>

    </div>

</main>

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