<?php
session_start();

// Check if the user is logged in
if (!isset($_SESSION['admin_id']) && !isset($_SESSION['sub_user_id'])) {
    // If not logged in, redirect to login page
    header("Location: login.html");
    exit();
}

// The rest of your page code goes here
?>

  <!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8">
    <title>Registration Form</title>
    <link rel="stylesheet" href="../Css/dash.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
    <!-- Boxicons CDN Link -->
    <link href='https://unpkg.com/boxicons@2.0.7/css/boxicons.min.css' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
     <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
      <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
     <style>
        .input-group {
            margin-bottom: 15px;
        }
        .input-group i {
            margin-right: 10px;
        }
        label {
            display: block;
            margin-bottom: 5px;
        }
        button {
            margin-top: 20px;
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
        }
    </style>
   </head>
<body>
  <div class="sidebar">
    <div class="logo-details">
      <i class='bx bx-desktop'></i>
      <span class="logo_name">Mips</span>
    </div>
      <ul class="nav-links">
        <li>
          <a href="dashboard.php">
            <i class='bx bx-grid-alt' ></i>
            <span class="links_name">Dashboard</span>
          </a>
        </li>
        <li>
          <a href="index.php" class="active">
            <i class='bx bx-box' ></i>
            <span class="links_name">Register</span>
          </a>
        </li>
        <li>
          <a href="users.php">
            <i class='bx bx-list-ul' ></i>
            <span class="links_name">Participants</span>
          </a>
        </li>
         <li>
                <a href="attendance_scanner.php">
                    <i class='bx bxs-user-detail'></i>
                    <span class="links_name">Attendance</span>
                </a>
            </li>
            <li>
                <a href="meals_deduction.php">
                    <i class='fa-solid fa-bowl-food'></i>
                    <span class="links_name">Meals</span>
                </a>
            </li>
            <li>
                <a href="promotion_scanner.php">
                    <i class='bx bx-list-ul'></i>
                    <span class="links_name">Promotions</span>
                </a>
            </li>
        <li>
          <a href="sub_user.php">
            <i class="fas fa-user"></i>
            <span class="links_name">Create User</span>
          </a>
        </li>
        <li>
          <a href="Disubuser.php">
            <i class="fas fa-user-check"></i>
            <span class="links_name">Sub User</span>
          </a>
        </li>
           
        <li class="log_out">
          <a href="logout.php">
            <i class='bx bx-log-out'></i>
            <span class="links_name">Log out</span>
          </a>
        </li>
      </ul>
  </div>
  <section class="home-section">
    <nav>
      <div class="sidebar-button">
        <i class='bx bx-menu sidebarBtn'></i>
        <span class="dashboard">Register</span>
      </div>
</nav>
 <div class="home-content">
    <div class="container">
        
         <form class="meal-card-form" action="reg.php" method="POST">
    <h2>Registration Form</h2>

    <div class="input-group">
        <i class="fas fa-user-friends"></i>
        <select id="participant_type" name="participant_type" required>
            <option value="" disabled selected>Select Participant Type</option>
            <option value="Deligates">Deligates</option>
            <option value="Staff">Staff</option>
            <option value="Sponsor">Sponsor</option>
            <option value="Speaker">Speaker</option>
            <option value="Service Provider">Service Provider</option>
            <option value="Media">Media</option>
        </select>
    </div>

    <div class="input-group">
        <i class="fas fa-user"></i>
        <input type="text" id="fullname" name="fullname" placeholder="Full Name" required>
    </div>
    <div class="input-group">
        <i class="fas fa-envelope"></i>
        <input type="email" id="email" name="email" placeholder="Email" required>
    </div>
    <div class="input-group">
        <i class="fas fa-phone"></i>
        <input type="tel" id="phone" name="phone" placeholder="Phone Number" required>
    </div>

    <label><i class="fas fa-money-check-alt"></i> Payment Status:</label>
    <div class="input-group">
        <input type="radio" id="paid" name="payment_status" value="Paid" required>
        <label for="paid">Paid</label>
    </div>
    <div class="input-group">
        <input type="radio" id="not_paid" name="payment_status" value="Not Paid" required>
        <label for="not_paid">Not Paid</label>
    </div>

    <div id="commitment_options" class="input-group" style="display: none;">
        <input type="radio" id="approved" name="commitment_status" value="Approved">
        <label for="approved">Approved</label>
    </div>

    <div class="input-group">
        <i class="fas fa-hotel"></i>
        <select id="hotel" name="hotel" required>
            <option value="" disabled selected>Select Hotel</option>
            <option value="Ekhaya">Ekhaya</option>
            <option value="Club Makokola">Club Makokola</option>
            <option value="Nkopola">Nkopola</option>
            <option value="Sunbird">Sun n Sand</option>
            <option value="Participation_only">Participation Only</option>
            <option value="Meals Only">Meals Only</option>
        </select>
    </div>
    <div class="input-group">
        <i class="fas fa-university"></i>
        <input type="text" id="institution" name="institution" placeholder="Institution" required>
    </div>
    <div class="input-group">
        <i class="fas fa-user-friends"></i>
        <select id="membership_type" name="membership_type" required>
            <option value="" disabled selected>Select Membership Category</option>
            <option value="Full Member">Full Member</option>
            <option value="Affiliate">Affiliate</option>
            <option value="Student">Student</option>
            <option value="Corporate">Corporate</option>
            <option value="Foreign">Foreign</option>
            <option value="Non-Member">Non-Member</option>
        </select>
    </div>

    <div class="input-group" style="display: flex; align-items: center; margin-bottom: 15px;">
    <i class="fas fa-utensils" style="font-size: 18px; color: #555; margin-right: 10px;"></i>
    <input type="number" id="meals_allocated" name="meals_allocated" placeholder="Meals (Number of Days)" required 
    style="padding: 10px; border: 1px solid #ccc; border-radius: 5px; flex: 1; font-size: 16px;" 
    min="0" max="6" oninput="validateMeals()">
</div>


    <button type="submit"><i class="fas fa-paper-plane"></i> Register</button>
</form>

    </div>
</div>

 </section>
 <script>
document.getElementById('not_paid').addEventListener('change', function() {
    document.getElementById('commitment_options').style.display = 'block';
});

document.getElementById('paid').addEventListener('change', function() {
    document.getElementById('commitment_options').style.display = 'none';
});

function validateMeals() {
        const mealsInput = document.getElementById('meals_allocated');
        if (mealsInput.value > 6) {
            mealsInput.value = 6;
        }
        if (mealsInput.value < 0) {
            mealsInput.value = 0;
        }
    }
 
let sidebar = document.querySelector(".sidebar");
let sidebarBtn = document.querySelector(".sidebarBtn");
sidebarBtn.onclick = function() {
  sidebar.classList.toggle("active");
  if(sidebar.classList.contains("active")){
  sidebarBtn.classList.replace("bx-menu" ,"bx-menu-alt-right");
}else
  sidebarBtn.classList.replace("bx-menu-alt-right", "bx-menu");
}
 </script>

</body>
</html>

