<?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>

@media(max-width: 992px){
    .insider{
        margin-top: -50px;
    }
    .card{
      height: 500px;
    }
    .negative{
      height: 500px;
    } 
    .card-header h5{
      font-size: 12px;
    }
}

.card{
    height: 600px;
}

</style>


<div id="notification-containers" class="notification-containers"></div>
<div class="insider">
  <div class="container">
    <div class="cat-pag">
      <div class="card mt-3">
        <div class="card-header">
            <h5>MY PROFILE</h5>
          </div>
          <div class="card-body" style="background: #F7F9FB;">
            <div class="student-card">
              <div class="student-header">
                <img src="student.jpg" alt="Student Photo">
                <h2>Jah Bless John</h2>
              </div>

              <!-- CASE 1: If teacher has NOT entered data yet -->
              <div class="info-box">
                No record entered yet. Please input attendance and activities.
              </div>

              <form>
                <div class="form-group">
                  <label>Attendance (Present / Times Opened)</label>
                  <input type="text" placeholder="e.g. 42/45">
                </div>

                <div class="form-group">
                  <label>Student Activities</label>
                  <textarea placeholder="e.g. Participated in debate, Class prefect, etc."></textarea>
                </div>

                <div class="form-group">
                  <label>Class Teacher's Comment</label>
                  <textarea placeholder="e.g. Hardworking and respectful student. Keep it up!"></textarea>
                </div>

                <button type="submit" class="btn">Save Record</button>
              </form>

              <!-- CASE 2: If teacher has already entered data -->
              <div class="entered-data">
                <p><strong>Attendance:</strong> 42/45</p>
                <p><strong>Activities:</strong> Debate club member, Football team</p>
                <p><strong>Comment:</strong> Hardworking and respectful student. Keep it up!</p>
                <button class="btn">Edit</button>
              </div>
            </div>
          </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 Styling -->
<style>
  .student-card {
      background: #fff;
      border-radius: 8px;
      padding: 20px;
      max-width: 600px;
      margin: 0 auto;
      box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .student-header {
      display: flex;
      align-items: center;
      margin-bottom: 15px;
    }

    .student-header img {
      width: 70px;
      height: 70px;
      border-radius: 50%;
      object-fit: cover;
      margin-right: 15px;
    }

    .student-header h2 {
      margin: 0;
      font-size: 20px;
      color: #333;
    }

    .form-group {
      margin-bottom: 15px;
    }

    .form-group label {
      font-weight: 600;
      display: block;
      margin-bottom: 5px;
      color: #444;
    }

    .form-group input, 
    .form-group textarea {
      width: 100%;
      padding: 10px;
      border: 1px solid #ddd;
      border-radius: 6px;
      font-size: 14px;
      background: #f9f9f9;
    }

    .form-group textarea {
      resize: vertical;
      min-height: 80px;
    }

    .btn {
      display: inline-block;
      padding: 10px 18px;
      background: #007bff;
      color: #fff;
      border-radius: 6px;
      text-decoration: none;
      font-size: 14px;
      border: none;
      cursor: pointer;
      transition: background 0.3s;
    }

    .btn:hover {
      background: #0056b3;
    }

    .info-box {
      background: #eef3fc;
      border-left: 4px solid #007bff;
      padding: 10px 15px;
      margin-bottom: 15px;
      color: #333;
      font-size: 14px;
      border-radius: 4px;
    }

    .entered-data {
      background: #f9f9f9;
      border: 1px solid #e1e1e1;
      padding: 15px;
      border-radius: 6px;
      margin-top: 10px;
    }

    .entered-data p {
      margin: 8px 0;
      font-size: 14px;
    }
</style>

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

