<?php session_start();?>
<?php include'includes/header.php'; ?>
<?php include'includes/sidebar.php';?>
<?php include'includes/functions.php';?>
<?php include'includes/navbar.php'; ?>

<!-- Handle Add Slider -->
<style>

header {
      background: #2c3e50;
      color: white;
      padding: 15px 20px;
      font-size: 20px;
    }
    .container {
      padding: 20px;
    }
    .card {
      background: white;
      padding: 20px;
      margin-bottom: 20px;
      border-radius: 6px;
      box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    h2 {
      margin-bottom: 15px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin-bottom: 15px;
    }
    table th, table td {
      border: 1px solid #ddd;
      padding: 10px;
      text-align: left;
    }
    table th {
      background: #f1f1f1;
    }
    .btn {
      display: inline-block;
      padding: 8px 15px;
      margin: 5px;
      border-radius: 4px;
      cursor: pointer;
      text-decoration: none;
      font-size: 14px;
    }
    .btn-review {
      background: #3498db;
      color: white;
    }
    .btn-approve {
      background: #2ecc71;
      color: white;
    }
    .btn-reject {
      background: #e74c3c;
      color: white;
    }
    .modal {
      display: none;
      position: fixed;
      z-index: 999;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: rgba(0,0,0,0.5);
      justify-content: center;
      align-items: center;
    }
    .modal-content {
      background: white;
      padding: 20px;
      border-radius: 6px;
      width: 70%;
      max-height: 90vh;
      overflow-y: auto;
    }
    .modal-header {
      font-weight: bold;
      margin-bottom: 10px;
    }
    .close {
      float: right;
      cursor: pointer;
      color: #555;
    }
    textarea {
      width: 100%;
      padding: 8px;
      margin-top: 10px;
      border-radius: 4px;
      border: 1px solid #ccc;
      resize: vertical;
    }

</style>


<div id="notification-containers" class="notification-containers"></div>
<div class="insider">
  <div class="container">
    <div class="cat-pag">
      <div class="card mt-3">
        <header>
          Vice Principal Dashboard - Result Approval
        </header>

        <div class="container">

          <!-- Pending Classes -->
          <div class="card">
            <h2>Classes Pending Approval</h2>
            <table>
              <tr>
                <th>Class</th>
                <th>Term</th>
                <th>Session</th>
                <th>Submitted By</th>
                <th>Action</th>
              </tr>
              <tr>
                <td>JSS1B</td>
                <td>2nd Term</td>
                <td>2024/2025</td>
                <td>Mr. Okoro</td>
                <td><button class="btn btn-review" onclick="openModal()">Review</button></td>
              </tr>
              <tr>
                <td>JSS2A</td>
                <td>2nd Term</td>
                <td>2024/2025</td>
                <td>Mrs. James</td>
                <td><button class="btn btn-review" onclick="openModal()">Review</button></td>
              </tr>
            </table>
          </div>

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

<?php
if (isset($_POST['upd-pass'])) {
    
    $password = $_POST['password'];
    $confirm = $_POST['confirm'];
    
    if ($password != $confirm) {
        $_SESSION['message'] = 'Password does not match';
        $_SESSION['type'] = 'error';
    }else{
        $valPass = password_hash($password, PASSWORD_DEFAULT);
        $updater = "UPDATE staff SET password = ? WHERE staffId = ?";
        $insertpdo = $pdo->prepare($updater);
        if ($insertpdo->execute([$valPass, $staffId])) {
            $_SESSION['message'] = 'Password Updated Successfully.';
            $_SESSION['type'] = 'success';
        }else{
            $_SESSION['message'] = 'Something went wrong.';
            $_SESSION['type'] = 'error';

        }
        
    }

}
if (isset($_POST['upd-save-btn'])) {
  $title = $_POST['title'];
  $names = $_POST['names'];
  $email = $_POST['email'];
  $mobile = $_POST['mobile'];

  $updan = "UPDATE staff SET title = ?, fullname = ?, email = ?, phone_number = ?
          WHERE staffId = ?";
  $updStmt = $pdo->prepare($updan);
  $updStmt->execute([$title, $names, $email, $mobile, $staffId]);

  $_SESSION['message'] = 'Updated Successfully';
  $_SESSION['type'] = 'success';
}
?>


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



<!-- Modal -->
<div id="reviewModal" class="modal">
  <div class="modal-content">
    <span class="close" onclick="closeModal()">&times;</span>
    
    <div class="modal-header">Class: JSS1B | Submitted by: Mr. Okoro</div>
    
    <table>
      <tr>
        <th>Student</th>
        <th>Subjects Completed</th>
        <th>Attendance</th>
        <th>Teacher Remark</th>
        <th>Action</th>
      </tr>
      <tr>
        <td>John Peter</td>
        <td>12/12</td>
        <td>40/45</td>
        <td>Very Attentive</td>
        <td><button class="btn btn-review">View Full</button></td>
      </tr>
      <tr>
        <td>Mary Thomas</td>
        <td>12/12</td>
        <td>38/45</td>
        <td>Needs Improvement</td>
        <td><button class="btn btn-review">View Full</button></td>
      </tr>
    </table>

    <h3>VP Comment</h3>
    <textarea rows="4" placeholder="Write your general comment for the class..."></textarea>

    <br>
    <button class="btn btn-approve">Approve Entire Class</button>
    <button class="btn btn-reject">Send Back for Corrections</button>
  </div>
</div>

<script>
  function openModal() {
    document.getElementById("reviewModal").style.display = "flex";
  }
  function closeModal() {
    document.getElementById("reviewModal").style.display = "none";
  }
</script>

<?php include'includes/notification-alert-js.php';?>

