<?php
session_start();

if (!isset($_SESSION['admin_logged_in']) || $_SESSION['admin_logged_in'] !== true) {
    header('Location: index.php');
    exit;
}

// Optional: access admin ID like this
$admin_id = $_SESSION['admin_id'];
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CRA - Clinical Research Analysis
    </title>

    <link rel="preconnect" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700;800&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="assets/css/bootstrap.css">

    <link rel="stylesheet" href="assets/vendors/iconly/bold.css">

    <link rel="stylesheet" href="assets/vendors/perfect-scrollbar/perfect-scrollbar.css">
    <link rel="stylesheet" href="assets/vendors/bootstrap-icons/bootstrap-icons.css">
    <link rel="stylesheet" href="assets/css/app.css">
    <link rel="shortcut icon" href="assets/images/favicon.svg" type="image/x-icon">
</head>

<body>
    <div id="app">
        <div id="sidebar" class="active">
            <div class="sidebar-wrapper active">
                <div class="sidebar-header">
                    <div class="d-flex justify-content-between">
                        <div class="logo">
                              <a href="dashboard.php"><img src="img/logo.png" alt="Logo" style="width: 150px; height:50px" srcset=""></a>
                        </div>
                        <div class="toggler">
                            <a href="#" class="sidebar-hide d-xl-none d-block"><i class="bi bi-x bi-middle"></i></a>
                        </div>
                    </div>
                </div>
               <div class="sidebar-menu">
                    <ul class="menu">
                      
                        <li class="sidebar-item  ">
                            <a href="dashboard.php" class='sidebar-link'>
                                <i class="bi bi-grid-fill"></i>
                                <span>Dashboard</span>
                            </a>
                        </li>
                         <li class="sidebar-item active ">
                            <a href="add_clinic.php" class='sidebar-link'>
                                <i class="bi bi-cloud-arrow-up-fill"></i>
                                <span>Add Clinics</span>
                            </a>
                        </li>

                        <li class="sidebar-item ">
                            <a href="all_clinics.php" class='sidebar-link'>
                                <i class="bi bi-stack"></i>
                                <span>Clinics</span>
                            </a>
                        
                        </li>


                       <li class="sidebar-item  ">
                            <a href="basic_information.php" class='sidebar-link'>
                                <i class="bi bi-collection-fill"></i>
                                <span>Basic Information</span>
                            </a>
                           
                        </li>

                        <li class="sidebar-item ">
                            <a href="principal_investigator.php" class='sidebar-link'>
                                <i class="bi bi-grid-1x2-fill"></i>
                                <span>Principal Investigator</span>
                            </a>
                        </li>
                        <li class="sidebar-item  ">
                            <a href="study_design.php" class='sidebar-link'>
                                <i class="bi bi-hexagon-fill"></i>
                                <span>Study Design</span>
                            </a>
                        </li>

                        <li class="sidebar-item  ">
                            <a href="site_facility.php" class='sidebar-link'>
                                <i class="bi bi-file-earmark-medical-fill"></i>
                                <span>Site & Facility</span>
                            </a>
                        </li>

                        <li class="sidebar-item  ">
                            <a href="investigational_products.php" class='sidebar-link'>
                                <i class="bi bi-pen-fill"></i>
                                <span>Investigational Product</span>
                            </a>
                        </li>

                        <li class="sidebar-item  ">
                            <a href="requirement_datacollection.php" class='sidebar-link'>
                                <i class="bi bi-grid-1x2-fill"></i>
                                <span>Recruitment & Data<br> Collection</span>
                            </a>
                        </li>
                        
                        <li class="sidebar-item  ">
                            <a href="logout.php" class='sidebar-link'>
                                <i class="bi bi-x-octagon-fill"></i>
                                <span>Log Out</span>
                            </a>
                           
                        </li>

                    </ul>
                </div>
                <button class="sidebar-toggler btn x"><i data-feather="x"></i></button>
            </div>
        </div>
        <div id="main">
            <header class="mb-3">
                <a href="#" class="burger-btn d-block d-xl-none">
                    <i class="bi bi-justify fs-3"></i>
                </a>
            </header>

           <div class="container-fluid pt-4 px-4">
                <div class="row justify-content-center">
                    <div class="col-12">
                        <div class="bg-light rounded p-4 mb-4">
                            <h4 class="mb-4"><i class="fa fa-hospital me-2 text-primary"></i>Add Clinic</h4>
                           <form action="save_clinic.php" method="post" onsubmit="return validateForm();">
                             <div class="mb-3">
                            <label for="clinic_name" class="form-label"><i class="fa fa-building me-2"></i>Clinic Name</label>
                            <input type="text" class="form-control" id="clinic_name" name="clinic_name" required>
                        </div>
                        <div class="mb-3">
                            <label for="email" class="form-label"><i class="fa fa-envelope me-2"></i>Email</label>
                            <input type="email" class="form-control" id="email" name="email" required>
                        </div>
                        <div class="mb-3">
                            <label for="phone" class="form-label"><i class="fa fa-phone me-2"></i>Phone</label>
                            <input type="text" class="form-control" id="phone" name="phone" required pattern="\d{10}" title="Enter 10 digit phone number">
                        </div>
                        <div class="mb-3">
                            <label for="location" class="form-label"><i class="fa fa-map-marker-alt me-2"></i>Location</label>
                            <input type="text" class="form-control" id="location" name="location" required>
                        </div>
                        <div class="mb-3">
                            <label for="designation" class="form-label"><i class="fa fa-user-tag me-2"></i>Designation</label>
                            <textarea class="form-control" id="designation" name="designation" rows="2" required></textarea>
                        </div>
                        <div class="mb-3">
                            <label for="specification" class="form-label"><i class="fa fa-vials me-2"></i>Specification (Type of Testing)</label>
                            <textarea class="form-control" id="specification" name="specification" rows="2" required></textarea>
                        </div>
                        <div class="mb-3">
                            <label for="password" class="form-label"><i class="fa fa-lock me-2"></i>Password</label>
                            <input type="password" class="form-control" id="password" name="password" required minlength="6">
                        </div>
                        <div class="mb-3">
                            <label for="confirm_password" class="form-label"><i class="fa fa-lock me-2"></i>Confirm Password</label>
                            <input type="password" class="form-control" id="confirm_password" name="confirm_password" required>
                        </div>
                        <button type="submit" class="btn btn-primary w-100"><i class="fa fa-plus me-2"></i>Add Clinic</button>
                    </form>


                        </div>
                    </div>
                </div>
            </div>

            <footer>
                <div class="footer clearfix mb-0 text-muted">
                    <div class="float-start">
                        <p>2025 &copy; Phaseon Clinical Research</p>
                    </div>
                    <div class="float-end">
                        <p>Design by PoojaInfotech</p>
                    </div>
                </div>
            </footer>
        </div>
    </div>
    <script>
    function validateForm() {
        const password = document.getElementById('password').value.trim();
        const confirmPassword = document.getElementById('confirm_password').value.trim();

        if (password !== confirmPassword) {
            alert("Passwords do not match.");
            return false;
        }

        return true;
    }
</script>
        
    <script src="assets/vendors/perfect-scrollbar/perfect-scrollbar.min.js"></script>
    <script src="assets/js/bootstrap.bundle.min.js"></script>

    <script src="assets/vendors/apexcharts/apexcharts.js"></script>
    <script src="assets/js/pages/dashboard.js"></script>

    <script src="assets/js/main.js"></script>
</body>

</html>