<?php

include('includes/session2.php');

error_reporting(0);

include('includes/dbconnection.php');

require_once 'includes/session_term_helper.php';
$stResult = resolveCurrentSessionTerm($con);
$currentSessionName = $stResult['session_name'];
$currentTermName = $stResult['term_name'];

$cls = 'Incoming student';

$st = 'Incoming student';

$std = 'Incoming student';

$query = "SELECT * FROM fees WHERE class ='$cls' AND stream ='$st' AND student_type = '$std' ";

$result = mysqli_query($con, $query);





?>

<!DOCTYPE html>

<html>

<?php @include("includes/head.php"); ?>







<body class="hold-transition sidebar-mini layout-fixed">

  <div class="wrapper">

    <!-- Navbar -->

    <?php @include("includes/headerentrance.php"); ?>

    <!-- /.navbar -->



    <!-- Main Sidebar Container -->

    <?php @include("includes/entrancesidebar.php"); ?>



    <!-- Content Wrapper. Contains page content -->

    <div class="content-wrapper">

      <!-- Content Header (Page header) -->

      <section class="content-header premium-header">

        <div class="container-fluid">

          <div class="header-glass-card">

            <div class="row align-items-center">

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

                <div class="title-section">

                  <div class="icon-box bg-primary-gradient shadow-sm">

                    <i class="fas fa-credit-card"></i>

                  </div>

                  <div>

                    <h1 class="premium-title text-primary">

                      Payment Management

                      <span class="premium-subtitle text-secondary">Entrance Form</span>

                    </h1>

                    <div class="mt-1">
                      <?php if ($currentSessionName): ?>
                        <span class="badge badge-primary mr-1">
                          <i class="fas fa-calendar-alt"></i>
                          <?= htmlspecialchars($currentSessionName) ?>
                        </span>
                      <?php endif; ?>
                      <?php if ($currentTermName): ?>
                        <span class="badge badge-success">
                          <i class="fas fa-bookmark"></i>
                          <?= htmlspecialchars($currentTermName) ?>
                        </span>
                      <?php else: ?>
                        <span class="badge badge-warning">
                          <i class="fas fa-exclamation-triangle"></i> No active term
                        </span>
                      <?php endif; ?>
                    </div>

                  </div>

                </div>

              </div>

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

                <nav aria-label="breadcrumb">

                  <ol class="breadcrumb premium-breadcrumb">

                    <li class="breadcrumb-item"><a href="entrancedashboard.php" class="text-primary">Home</a></li>

                    <li class="breadcrumb-item active" aria-current="page">Entrance Form</li>

                  </ol>

                </nav>

              </div>

            </div>

          </div>

        </div>

      </section>





      <!-- Main content -->

      <section class="content">

        <div class="container-fluid">

          <div class="row">

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

              <!-- general form elements -->

              <div class="card card-primary">

                <div class="card-header">

                  <h5 class="card-title font-weight-bold">

                    <i class="fas fa-file"></i> Entrance Form Payment

                  </h5>

                </div>

                <!-- /.card-header -->

                <!-- form start -->

                <form role="form" method="" enctype="multipart/form-data">

                  <div class="card-body">

                    <span style="color: brown">

                      <h5>Select what you are paying for</h5>

                    </span>

                    <br>

                    <hr>

                    <br>

                    <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-4 gap-4 mb-10">

                      <?php

                      if (mysqli_num_rows($result) > 0) {



                        while ($row = mysqli_fetch_assoc($result)) {



                          $feeType = htmlspecialchars($row['name'], ENT_QUOTES, 'UTF-8');

                          $amount = (float) $row['amount'];

                          $class = htmlspecialchars($row['class'], ENT_QUOTES, 'UTF-8');

                          $feeId = (int) $row['id'];



                          /* -------------------------------

                             STYLE MAPPING (SECURE + CLEAN)

                          -------------------------------- */

                          if (stripos($feeType, 'BOARDING') !== false) {

                            $style = ["bg" => "bg-cyan-50", "text" => "text-cyan-600"];

                          } elseif (stripos($feeType, 'DAY') !== false) {

                            $style = ["bg" => "bg-orange-50", "text" => "text-orange-600"];

                          } elseif (stripos($feeType, 'FULL 2 TERM') !== false) {

                            $style = ["bg" => "bg-rose-50", "text" => "text-rose-600"];

                          } elseif (stripos($feeType, 'FULL SESSION') !== false) {

                            $style = ["bg" => "bg-blue-50", "text" => "text-blue-600"];

                          } else {

                            $style = ["bg" => "bg-emerald-50", "text" => "text-emerald-600"];

                          }

                          ?>

                          <div class="bento-card group">

                            <div class="flex justify-between items-start mb-4">

                              <div
                                class="w-10 h-10 <?php echo $style['bg']; ?> <?php echo $style['text']; ?> rounded-xl flex items-center justify-center transition-transform group-hover:scale-110">

                                <i class="fas fa-money-bill-wave"></i>

                              </div>



                              <a href="confirmpayen.php?fee_id=<?php echo $feeId; ?>&pay_amount=<?php echo $amount; ?>"
                                class="text-[12px] font-black text-slate-400 group-hover:text-slate-900 transition-colors tracking-tighter">

                                <i class="fas fa-arrow-right"></i> PAY HERE

                              </a>

                            </div>



                            <h5 class="text-[14px] font-bold text-slate-600 truncate">

                              <?php echo $class; ?>

                            </h5>



                            <p class="text-[11px] font-bold uppercase text-slate-500 truncate">

                              <?php echo $feeType; ?>

                            </p>



                            <p class="mt-2 text-[13px] font-extrabold <?php echo $style['text']; ?>">

                              ₦<?php echo number_format($amount, 2); ?>

                            </p>



                            <div class="mt-4 w-full h-1 bg-slate-200/50 rounded-full overflow-hidden">

                              <div
                                class="h-full <?php echo str_replace('text-', 'bg-', $style['text']); ?> opacity-40 w-full transform -translate-x-1/2 group-hover:translate-x-0 transition-transform duration-1000">
                              </div>

                            </div>

                          </div>

                          <?php

                        }

                      } else {

                        echo "<p class='text-red-500 col-span-full text-sm'>No entrance fee available at the moment.</p>";

                      }

                      ?>

                    </div>

                  </div>

                </form>

              </div>

            </div>

          </div>

        </div>

      </section>

    </div>



    <!-- ./wrapper -->

    <?php @include("includes/footer.php"); ?>



  </div>



  <!-- ./wrapper -->

  <?php @include("includes/foot.php"); ?>



</body>



</html>