<?php

$pageTitle = "My Profile";

require_once '../includes/auth.php';

require_login();

$user = current_user();

$userId = $user['id'] ?? null;

if (!$userId) {
    header("Location: ../login.php");
    exit;
}


/*
|--------------------------------------------------------------------------
| GET COMPLETE CORPS MEMBER PROFILE
|--------------------------------------------------------------------------
*/

$stmt = $db->prepare("
    SELECT
        cm.*,

        u.email AS account_email,
        u.phone AS account_phone,
        u.avatar AS account_avatar,
        u.status AS account_status,

        s.state_name,

        lg.lga_name,

        p.platoon_name,
        p.platoon_code,

        h.hostel_name,
        h.hostel_code

    FROM corps_members cm

    LEFT JOIN users u
        ON u.id = cm.user_id

    LEFT JOIN states s
        ON s.id = cm.state_id

    LEFT JOIN local_governments lg
        ON lg.id = cm.lga_id

    LEFT JOIN platoons p
        ON p.id = cm.platoon_id

    LEFT JOIN hostels h
        ON h.id = cm.hostel_id

    WHERE cm.user_id = ?

    LIMIT 1
");

$stmt->execute([$userId]);

$corpsMember = $stmt->fetch(PDO::FETCH_ASSOC);


require_once '../includes/header.php';
require_once '../includes/sidebar.php';

?>

<div class="overlay bg-black bg-opacity-50 w-100 h-100 position-fixed z-9 visibility-hidden opacity-0 duration-300">
</div>

<main class="dashboard-main">

    <?php require_once '../includes/topbar.php'; ?>

    <div class="dashboard-main-body">


        <!-- =========================================================
             BREADCRUMB
        ========================================================== -->

        <div class="breadcrumb d-flex flex-wrap align-items-center justify-content-between gap-3 mb-24">

            <div>

                <h6 class="fw-semibold mb-0">
                    <?= htmlspecialchars($pageTitle) ?>
                </h6>

                <p class="text-neutral-600 mt-4 mb-0">
                    <?= APP_SHORT_NAME ?> > My Profile
                </p>

            </div>

        </div>


        <!-- =========================================================
             FLASH MESSAGES
        ========================================================== -->

        <?php if (isset($_SESSION['success'])): ?>

        <div class="alert alert-success alert-dismissible fade show">

            <i class="ri-checkbox-circle-line me-1"></i>

            <?= htmlspecialchars($_SESSION['success']) ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert">
            </button>

        </div>

        <?php unset($_SESSION['success']); ?>

        <?php endif; ?>


        <?php if (isset($_SESSION['error'])): ?>

        <div class="alert alert-danger alert-dismissible fade show">

            <i class="ri-error-warning-line me-1"></i>

            <?= htmlspecialchars($_SESSION['error']) ?>

            <button type="button" class="btn-close" data-bs-dismiss="alert">
            </button>

        </div>

        <?php unset($_SESSION['error']); ?>

        <?php endif; ?>



        <?php if (!$corpsMember): ?>


        <!-- =====================================================
                 PROFILE NOT FOUND
            ====================================================== -->

        <div class="card">

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

                <iconify-icon icon="mdi:account-alert-outline" width="80" class="text-danger">
                </iconify-icon>

                <h5 class="mt-4">
                    Corps Member Profile Not Found
                </h5>

                <p class="text-secondary">

                    Your user account is not linked to a corps member
                    profile.

                </p>

            </div>

        </div>


        <?php else: ?>


        <!-- =====================================================
                 PROFILE HEADER
            ====================================================== -->

        <div class="card mb-24">

            <div class="card-body p-24">

                <div class="d-flex flex-wrap align-items-center gap-24">


                    <!-- PROFILE IMAGE -->

                    <div>

                        <?php

                            $profileImage = '../assets/images/thumbs/teacher-details-img.png';

                            if (!empty($corpsMember['passport'])) {

                                $profileImage =
                                    '../uploads/passports/' .
                                    $corpsMember['passport'];

                            } elseif (!empty($corpsMember['account_avatar'])) {

                                $profileImage =
                                    '../uploads/passports/' .
                                    $corpsMember['account_avatar'];

                            }

                            ?>

                        <div class="w-120-px h-120-px rounded-circle overflow-hidden border">

                            <img src="<?= htmlspecialchars($profileImage) ?>" alt="Profile Image"
                                class="w-100 h-100 object-fit-cover">

                        </div>

                    </div>



                    <!-- PROFILE BASIC DETAILS -->

                    <div class="flex-grow-1">

                        <h4 class="mb-4">

                            <?= htmlspecialchars(
                                    $corpsMember['firstname'] . ' ' .
                                    ($corpsMember['othername']
                                        ? $corpsMember['othername'] . ' '
                                        : '') .
                                    $corpsMember['lastname']
                                ) ?>

                        </h4>


                        <p class="text-secondary-light mb-4">

                            State Code:

                            <span class="fw-semibold text-primary-600">

                                <?= htmlspecialchars(
                                        $corpsMember['state_code']
                                    ) ?>

                            </span>

                        </p>


                        <p class="text-secondary-light mb-0">

                            Call-up Number:

                            <span class="fw-semibold">

                                <?= htmlspecialchars(
                                        $corpsMember['call_up_number']
                                        ?? 'Not Available'
                                    ) ?>

                            </span>

                        </p>

                    </div>



                    <!-- STATUS -->

                    <div>

                        <?php

                            $memberStatus =
                                $corpsMember['status'] ?? 'Registered';

                            $statusClass = 'bg-primary-100 text-primary-600';

                            if ($memberStatus === 'Serving') {

                                $statusClass =
                                    'bg-success-100 text-success-600';

                            } elseif (
                                $memberStatus === 'Suspended'
                            ) {

                                $statusClass =
                                    'bg-danger-100 text-danger-600';

                            } elseif (
                                $memberStatus === 'Completed'
                            ) {

                                $statusClass =
                                    'bg-info-100 text-info-600';

                            }

                            ?>

                        <span class="px-16 py-8 radius-8 fw-medium <?= $statusClass ?>">

                            <?= htmlspecialchars($memberStatus) ?>

                        </span>

                    </div>

                </div>

            </div>

        </div>



        <div class="row gy-4">


            <!-- =================================================
                PERSONAL INFORMATION
            ================================================== -->

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

                <div class="card h-100">

                    <div class="card-header border-bottom d-flex align-items-center justify-content-between">

                        <h6 class="mb-0">
                            Personal Information
                        </h6>

                        <button type="button" class="btn btn-sm btn-primary-600" data-bs-toggle="modal"
                            data-bs-target="#editPersonalInformationModal">

                            <i class="ri-edit-line me-1"></i>
                            Edit

                        </button>

                    </div>

                    <div class="card-body">

                        <div class="row gy-3">

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    First Name
                                </span>

                                <p class="fw-semibold mb-0">
                                    <?= htmlspecialchars($corpsMember['firstname']) ?>
                                </p>

                            </div>

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Last Name
                                </span>

                                <p class="fw-semibold mb-0">
                                    <?= htmlspecialchars($corpsMember['lastname']) ?>
                                </p>

                            </div>

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Other Name
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['othername'] ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Gender
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['gender'] ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Date of Birth
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= !empty($corpsMember['date_of_birth'])
                        ? date(
                            'd M Y',
                            strtotime($corpsMember['date_of_birth'])
                        )
                        : 'Not Available'
                    ?>

                                </p>

                            </div>

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Marital Status
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['marital_status'] ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>

                        </div>

                    </div>

                </div>

            </div>


            <!-- =================================================
                     NYSC INFORMATION
                ================================================== -->

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

                <div class="card h-100">

                    <div class="card-header border-bottom">

                        <h6 class="mb-0">
                            NYSC Information
                        </h6>

                    </div>


                    <div class="card-body">

                        <div class="row gy-3">


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    State Code
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['state_code']
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Call-up Number
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['call_up_number']
                                            ?? 'Not Available'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Batch
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['batch']
                                            ?? 'Not Available'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Stream
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['stream']
                                            ?? 'Not Available'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Service Year
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['year_of_service']
                                            ?? 'Not Available'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    LGA
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['lga_name']
                                            ?? 'Not Assigned'
                                        ) ?>

                                </p>

                            </div>


                        </div>

                    </div>

                </div>

            </div>



            <!-- =================================================
                CONTACT INFORMATION
            ================================================== -->

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

                <div class="card h-100">

                    <div class="card-header border-bottom d-flex align-items-center justify-content-between">

                        <h6 class="mb-0">
                            Contact Information
                        </h6>

                        <button type="button" class="btn btn-sm btn-primary-600" data-bs-toggle="modal"
                            data-bs-target="#editContactInformationModal">

                            <i class="ri-edit-line me-1"></i>
                            Edit

                        </button>

                    </div>


                    <div class="card-body">

                        <div class="row gy-3">

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Email
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['email']
                        ?? $corpsMember['account_email']
                        ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Phone
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['phone']
                        ?? $corpsMember['account_phone']
                        ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>


                            <div class="col-12">

                                <span class="text-secondary-light text-sm">
                                    Home Address
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= nl2br(
                        htmlspecialchars(
                            $corpsMember['home_address']
                            ?? 'Not Available'
                        )
                    ) ?>

                                </p>

                            </div>

                        </div>

                    </div>

                </div>

            </div>



            <!-- =================================================
                ACADEMIC INFORMATION
            ================================================== -->

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

                <div class="card h-100">

                    <div class="card-header border-bottom d-flex align-items-center justify-content-between">

                        <h6 class="mb-0">
                            Academic Information
                        </h6>

                        <button type="button" class="btn btn-sm btn-primary-600" data-bs-toggle="modal"
                            data-bs-target="#editAcademicInformationModal">

                            <i class="ri-edit-line me-1"></i>
                            Edit

                        </button>

                    </div>


                    <div class="card-body">

                        <div class="row gy-3">


                            <div class="col-12">

                                <span class="text-secondary-light text-sm">
                                    Institution
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['institution']
                        ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Course of Study
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['course_of_study']
                        ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Qualification
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['qualification']
                        ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Graduation Year
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                        $corpsMember['graduation_year']
                        ?? 'Not Available'
                    ) ?>

                                </p>

                            </div>


                        </div>

                    </div>

                </div>

            </div>



            <!-- =================================================
                NEXT OF KIN INFORMATION
            ================================================== -->

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

                <div class="card h-100">

                    <div class="card-header border-bottom d-flex align-items-center justify-content-between">

                        <h6 class="mb-0">
                            Next of Kin Information
                        </h6>

                        <button type="button" class="btn btn-sm btn-primary-600" data-bs-toggle="modal"
                            data-bs-target="#editNextOfKinModal">

                            <i class="ri-edit-line me-1"></i>
                            Edit

                        </button>

                    </div>

                    <div class="card-body">

                        <div class="row gy-3">

                            <!-- NEXT OF KIN NAME -->

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Full Name
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= !empty($corpsMember['next_of_kin'])
                        ? htmlspecialchars($corpsMember['next_of_kin'])
                        : 'Not Available'
                    ?>

                                </p>

                            </div>


                            <!-- NEXT OF KIN PHONE -->

                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Phone Number
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= !empty($corpsMember['next_of_kin_phone'])
                        ? htmlspecialchars($corpsMember['next_of_kin_phone'])
                        : 'Not Available'
                    ?>

                                </p>

                            </div>

                        </div>

                    </div>

                </div>

            </div>



            <!-- =================================================
                     ASSIGNMENT INFORMATION
                ================================================== -->

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

                <div class="card h-100">

                    <div class="card-header border-bottom">

                        <h6 class="mb-0">
                            Camp Assignment
                        </h6>

                    </div>


                    <div class="card-body">

                        <div class="row gy-3">


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Platoon
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['platoon_name']
                                            ?? 'Not Assigned'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Platoon Code
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['platoon_code']
                                            ?? 'Not Available'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Hostel
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['hostel_name']
                                            ?? 'Not Assigned'
                                        ) ?>

                                </p>

                            </div>


                            <div class="col-sm-6">

                                <span class="text-secondary-light text-sm">
                                    Hostel Code
                                </span>

                                <p class="fw-semibold mb-0">

                                    <?= htmlspecialchars(
                                            $corpsMember['hostel_code']
                                            ?? 'Not Available'
                                        ) ?>

                                </p>

                            </div>


                        </div>

                    </div>

                </div>

            </div>


        </div>


        <?php endif; ?>


    </div>

</main>

<!-- =========================================================
     EDIT PERSONAL INFORMATION MODAL
========================================================== -->

<div class="modal fade" id="editPersonalInformationModal" tabindex="-1"
    aria-labelledby="editPersonalInformationModalLabel" aria-hidden="true">

    <div class="modal-dialog modal-lg modal-dialog-centered">

        <div class="modal-content radius-16 bg-base">

            <div class="modal-header py-16 px-24 border-bottom">

                <h5 class="modal-title" id="editPersonalInformationModalLabel">

                    Edit Personal Information

                </h5>

                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
                </button>

            </div>


            <form action="../actions/update-personal-information.php" method="POST">

                <div class="modal-body p-24">

                    <div class="row gy-3">


                        <!-- FIRST NAME -->

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                First Name
                                <span class="text-danger">*</span>
                            </label>

                            <input type="text" name="firstname" class="form-control"
                                value="<?= htmlspecialchars($corpsMember['firstname']) ?>" required>

                        </div>


                        <!-- LAST NAME -->

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Last Name
                                <span class="text-danger">*</span>
                            </label>

                            <input type="text" name="lastname" class="form-control"
                                value="<?= htmlspecialchars($corpsMember['lastname']) ?>" required>

                        </div>


                        <!-- OTHER NAME -->

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Other Name
                            </label>

                            <input type="text" name="othername" class="form-control"
                                value="<?= htmlspecialchars($corpsMember['othername'] ?? '') ?>">

                        </div>


                        <!-- GENDER -->

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Gender
                            </label>

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

                                <option value="">
                                    Select Gender
                                </option>

                                <option value="Male" <?= ($corpsMember['gender'] ?? '') === 'Male'
                                        ? 'selected'
                                        : '' ?>>

                                    Male

                                </option>

                                <option value="Female" <?= ($corpsMember['gender'] ?? '') === 'Female'
                                        ? 'selected'
                                        : '' ?>>

                                    Female

                                </option>

                            </select>

                        </div>


                        <!-- DATE OF BIRTH -->

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Date of Birth
                            </label>

                            <input type="date" name="date_of_birth" class="form-control"
                                value="<?= htmlspecialchars($corpsMember['date_of_birth'] ?? '') ?>">

                        </div>


                        <!-- MARITAL STATUS -->

                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Marital Status
                            </label>

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

                                <?php

                                $maritalStatuses = [
                                    'Single',
                                    'Married',
                                    'Divorced',
                                    'Widowed'
                                ];

                                foreach ($maritalStatuses as $status):

                                ?>

                                <option value="<?= $status ?>" <?= ($corpsMember['marital_status'] ?? '') === $status
                                            ? 'selected'
                                            : '' ?>>

                                    <?= $status ?>

                                </option>

                                <?php endforeach; ?>

                            </select>

                        </div>


                    </div>

                </div>


                <div class="modal-footer">

                    <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">

                        Cancel

                    </button>

                    <button type="submit" class="btn btn-primary-600">

                        <i class="ri-save-line me-1"></i>

                        Save Changes

                    </button>

                </div>

            </form>

        </div>

    </div>

</div>

<!-- =========================================================
     EDIT CONTACT INFORMATION MODAL
========================================================== -->

<div class="modal fade" id="editContactInformationModal" tabindex="-1" aria-hidden="true">

    <div class="modal-dialog modal-lg modal-dialog-centered">

        <div class="modal-content radius-16 bg-base">

            <div class="modal-header">

                <h5 class="modal-title">
                    Edit Contact Information
                </h5>

                <button type="button" class="btn-close" data-bs-dismiss="modal">
                </button>

            </div>


            <form action="../actions/update-contact-information.php" method="POST">

                <div class="modal-body p-24">

                    <div class="row gy-3">


                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Email Address
                            </label>

                            <input type="email" name="email" class="form-control" value="<?= htmlspecialchars(
                                    $corpsMember['email']
                                    ?? $corpsMember['account_email']
                                    ?? ''
                                ) ?>" required>

                        </div>


                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Phone Number
                            </label>

                            <input type="text" name="phone" class="form-control" value="<?= htmlspecialchars(
                                    $corpsMember['phone']
                                    ?? $corpsMember['account_phone']
                                    ?? ''
                                ) ?>" required>

                        </div>


                        <div class="col-12">

                            <label class="form-label fw-semibold">
                                Home Address
                            </label>

                            <textarea name="home_address" class="form-control" rows="4"><?= htmlspecialchars(
                                    $corpsMember['home_address'] ?? ''
                                ) ?></textarea>

                        </div>

                    </div>

                </div>


                <div class="modal-footer">

                    <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">

                        Cancel

                    </button>

                    <button type="submit" class="btn btn-primary-600">

                        <i class="ri-save-line me-1"></i>

                        Save Changes

                    </button>

                </div>

            </form>

        </div>

    </div>

</div>

<!-- =========================================================
     EDIT ACADEMIC INFORMATION MODAL
========================================================== -->

<div class="modal fade" id="editAcademicInformationModal" tabindex="-1" aria-hidden="true">

    <div class="modal-dialog modal-lg modal-dialog-centered">

        <div class="modal-content radius-16 bg-base">

            <div class="modal-header">

                <h5 class="modal-title">
                    Edit Academic Information
                </h5>

                <button type="button" class="btn-close" data-bs-dismiss="modal">
                </button>

            </div>


            <form action="../actions/update-academic-information.php" method="POST">

                <div class="modal-body p-24">

                    <div class="row gy-3">


                        <div class="col-12">

                            <label class="form-label fw-semibold">
                                Institution
                            </label>

                            <input type="text" name="institution" class="form-control" value="<?= htmlspecialchars(
                                    $corpsMember['institution'] ?? ''
                                ) ?>">

                        </div>


                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Course of Study
                            </label>

                            <input type="text" name="course_of_study" class="form-control" value="<?= htmlspecialchars(
                                    $corpsMember['course_of_study'] ?? ''
                                ) ?>">

                        </div>


                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Qualification
                            </label>

                            <input type="text" name="qualification" class="form-control" value="<?= htmlspecialchars(
                                    $corpsMember['qualification'] ?? ''
                                ) ?>">

                        </div>


                        <div class="col-md-6">

                            <label class="form-label fw-semibold">
                                Graduation Year
                            </label>

                            <input type="number" name="graduation_year" class="form-control" min="1950"
                                max="<?= date('Y') ?>" value="<?= htmlspecialchars(
                                    $corpsMember['graduation_year'] ?? ''
                                ) ?>">

                        </div>


                    </div>

                </div>


                <div class="modal-footer">

                    <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">

                        Cancel

                    </button>

                    <button type="submit" class="btn btn-primary-600">

                        <i class="ri-save-line me-1"></i>

                        Save Changes

                    </button>

                </div>

            </form>

        </div>

    </div>

</div>

<!-- =========================================================
     EDIT NEXT OF KIN INFORMATION MODAL
========================================================== -->

<div class="modal fade" id="editNextOfKinModal" tabindex="-1" aria-labelledby="editNextOfKinModalLabel"
    aria-hidden="true">

    <div class="modal-dialog modal-lg modal-dialog-centered">

        <div class="modal-content radius-16 bg-base">


            <!-- MODAL HEADER -->

            <div class="modal-header py-16 px-24 border-bottom">

                <h5 class="modal-title" id="editNextOfKinModalLabel">

                    Edit Next of Kin Information

                </h5>

                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close">
                </button>

            </div>


            <!-- FORM -->

            <form action="../actions/update-next-of-kin.php" method="POST">

                <div class="modal-body p-24">

                    <div class="row gy-3">


                        <!-- NEXT OF KIN FULL NAME -->

                        <div class="col-md-6">

                            <label for="next_of_kin" class="form-label fw-semibold">

                                Full Name
                                <span class="text-danger">*</span>

                            </label>

                            <input type="text" id="next_of_kin" name="next_of_kin" class="form-control"
                                placeholder="Enter next of kin full name" value="<?= htmlspecialchars(
                                    $corpsMember['next_of_kin'] ?? ''
                                ) ?>" required>

                        </div>


                        <!-- NEXT OF KIN PHONE -->

                        <div class="col-md-6">

                            <label for="next_of_kin_phone" class="form-label fw-semibold">

                                Phone Number
                                <span class="text-danger">*</span>

                            </label>

                            <input type="text" id="next_of_kin_phone" name="next_of_kin_phone" class="form-control"
                                placeholder="Enter next of kin phone number" value="<?= htmlspecialchars(
                                    $corpsMember['next_of_kin_phone'] ?? ''
                                ) ?>" required>

                        </div>


                    </div>

                </div>


                <!-- MODAL FOOTER -->

                <div class="modal-footer">

                    <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal">

                        Cancel

                    </button>


                    <button type="submit" class="btn btn-primary-600">

                        <i class="ri-save-line me-1"></i>

                        Save Changes

                    </button>

                </div>

            </form>

        </div>

    </div>

</div>


<?php

require_once '../includes/footer.php';

?>