<?php

session_name('mini_admin_session');

session_start();

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'];

if (strlen($_SESSION['sid'] == 0)) {

  header('location:logoutmini.php');

}





$admin = $_SESSION['sid'];



$sql = "SELECT * FROM tblusers WHERE id = ?";

$stmt = $dbh->prepare($sql);

$stmt->execute([$admin]);



if ($stmt->rowCount() > 0) {

  $fecthemail = $stmt->fetch(PDO::FETCH_ASSOC);

  $request = $fecthemail['id'];

}

?>

<!DOCTYPE html>

<html>

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

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

  <div class="wrapper">

    <!-- Navbar -->

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

    <!-- /.navbar -->



    <!-- Main Sidebar Container -->

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



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

    <div class="content-wrapper">

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

      <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-wallet"></i>

                  </div>

                  <div>

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

                      Payment Management

                      <span class="premium-subtitle text-secondary">Manage Approved Request</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="dashboard1.php" class="text-primary">Home</a></li>

                    <li class="breadcrumb-item active" aria-current="page">Approved Request</li>

                  </ol>

                </nav>

              </div>

            </div>

          </div>

        </div>

      </section>



      <!-- Main content -->

      <section class="content">

        <div class="container-fluid">

          <div class="row">

            <div class="col-12">

              <div class="card card-primary">

                <div class="card-header">

                  <h3 class="card-title font-weight-bold"><i class="fas fa-check-circle"></i> Approved Payment Request
                  </h3>

                  <div class="card-tools">

                    <a href="pay_tuition1.php"><button type="button" class="btn btn-xs btn-primary"><span
                          style="color: #fff;"><i class="fas fa-plus"></i> Request Payment Approval</span>

                      </button> </a>

                  </div>

                </div>

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





                <div class="card-body mt-2 ">

                  <table id="example1" class="table table-bordered table-hover">

                    <thead>

                      <tr>

                        <th>#</th>

                        <th>Admission No.</th>

                        <th>Fullname</th>

                        <th>Class </th>

                        <th>Payment Purpose</th>

                        <th>Amount</th>

                        <th>Payment Method</th>

                        <th>Bank Account</th>

                        <th>Sender Name</th>

                        <th>Payment Date</th>

                        <th>Info</th>

                      </tr>

                    </thead>

                    <tbody>

                      <?php $query = mysqli_query($con, "select * from message where status = 1 AND request ='$request' ORDER BY date DESC");

                      $cnt = 1;

                      while ($row = mysqli_fetch_array($query)) {

                        ?>

                        <tr>

                          <td><?php echo htmlentities($cnt); ?></td>

                          <td><?php echo htmlentities($row['regno']); ?></td>

                          <td><?php echo htmlentities($row['fullname']); ?></td>

                          <td><?php echo htmlentities($row['class']); ?></td>

                          <td><?php echo htmlentities($row['purpose']); ?></td>

                          <td><?php echo htmlentities($row['amount']); ?></td>

                          <td><?php echo htmlentities($row['method']); ?></td>

                          <td><?php echo htmlentities($row['Bank_account']); ?></td>

                          <td><?php echo htmlentities($row['Sender']); ?></td>

                          <td><?php echo htmlentities($row['dop']); ?></td>

                          <td><?php echo htmlentities($row['Addinfo']); ?></td>

                        </tr>

                        <?php $cnt = $cnt + 1;

                      } ?>

                    </tbody>

                  </table>

                </div>

                <!-- /.card-body -->

              </div>

              <!-- /.card -->

            </div>

            <!-- /.col -->

          </div>

          <!-- /.row -->

        </div>

        <!-- /.container-fluid -->

      </section>

      <!-- /.content -->

    </div>

    <!-- /.content-wrapper -->

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



    <!-- Control Sidebar -->

    <aside class="control-sidebar control-sidebar-dark">

      <!-- Control sidebar content goes here -->

    </aside>

    <!-- /.control-sidebar -->

  </div>



  <!-- ./wrapper -->

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

</body>

</html>