<?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');

} 

if(isset($_GET['del']))

{

  mysqli_query($con,"delete from students where id = '".$_GET['id']."'");

  $_SESSION['delmsg']="student deleted !!";

}

?>

<!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 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">Disapproved Payments</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">Disapproved Payments</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">

                  <h5 class="card-title font-weight-bold"><i class="fas fa-ban"></i> Disapproved Payment Request</h5>

                  <div class="card-tools">

                    <a href="approve1.php"><button type="button" class="btn btn-sm btn-primary"  ><span style="color: #fff;"><i class="ion ion-person-add" ></i> Confirm Payment</span>

                    </button> </a>                  

                  </div>

                </div>

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

                <div id="editData" class="modal fade">

                  <div class="modal-dialog modal-xl">

                    <div class="modal-content">

                      <div class="modal-header">

                        <h5 class="modal-title">Student details</h5>

                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                          <span aria-hidden="true">&times;</span>

                        </button>

                      </div>

                      <div class="modal-body" id="info_update">
<!-- loaded via AJAX -->
</div>

                      <div class="modal-footer ">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

                      </div>

                      <!-- /.modal-content -->

                    </div>

                    <!-- /.modal-dialog -->

                  </div>

                  <!-- /.modal -->

                </div>

                <!--   end modal -->

               

                <div id="editData2" class="modal fade">

                  <div class="modal-dialog ">

                    <div class="modal-content">

                      <div class="modal-header">

                        <h5 class="modal-title">Student Details</h5>

                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">

                          <span aria-hidden="true">&times;</span>

                        </button>

                      </div>

                      <div class="modal-body" id="info_update2">
<!-- loaded via AJAX -->
</div>

                      <div class="modal-footer ">

                        <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>

                      </div>

                      <!-- /.modal-content -->

                    </div>

                    <!-- /.modal-dialog -->

                  </div>

                  <!-- /.modal -->

                </div>

                <!--   end modal -->



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

                      </tr> 

                    </thead> 

                    <tbody>

                      <?php $query=mysqli_query($con,"select * from message where status = 2 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>

                        </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"); ?>

  <script type="text/javascript">

    $(document).ready(function(){

      $(document).on('click','.edit_data',function(){

        var edit_id=$(this).attr('id');

        $.ajax({

          url:"edit_student.php",

          type:"post",

          data:{edit_id:edit_id},

          success:function(data){

            $("#info_update").html(data);

            $("#editData").data('ajax-src', 'edit_student.php').modal('show');
            $("#editData").find('form:not([action])').attr('data-ajax-action', 'edit_student.php');

          }

        });

      });

    });

  </script>

  <script type="text/javascript">

    $(document).ready(function(){

      $(document).on('click','.edit_data2',function(){

        var edit_id2=$(this).attr('id');

        $.ajax({

          url:"view_student_info.php",

          type:"post",

          data:{edit_id2:edit_id2},

          success:function(data){

            $("#info_update2").html(data);

            $("#editData2").data('ajax-src', 'view_student_info.php').modal('show');
            $("#editData2").find('form:not([action])').attr('data-ajax-action', 'view_student_info.php');

          }

        });

      });

    });

  </script>

</body>

</html>

