<?php
    include '../connection.php';
    session_start();
    $user=$_SESSION['user'];
    if (!isset($user)) {
        header('location:../officer-login.php');
        die();
    }
    $current_date = date("Y-m-d")

?>
<!doctype html>
<html lang="en">
  <head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>जिला लोक शिकायत केंद्र</title>
    <!-- Bootstrap CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Material+Icons" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="css/table-style.css">
    <style type="text/css">
     
    </style>
  </head>
  <body>
    <section id="allocator-topbar">
      <div>
        <img src="topbar.jpg">
      </div>
    </section>
    <section id="allocator-header">
      <div class="container">
        <div class="row">
          <div class="col-md-8 col-lg-8 col-sm-12 col-12">
            <div class="user-desk">
              <h5><?php echo $user; ?></h5>
              <h6>Allocator (L-2)</h6>
              <span class="fa fa-sign-out"></span><a href="logout.php">Sign-Out</a>
            </div>
          </div>
          <div class="col-md-1 col-lg-1 col-sm-3 col-3">
            <div class="header-content">
              <a href="index.php"><button type="button" class="btn btn-danger">Today</button></a>
            </div>
          </div>
          <div class="col-md-1 col-lg-1 col-sm-3 col-3">
            <div class="header-content">
              <a href="all-grievance.php"><button type="button" class="btn btn-primary">All</button></a>
            </div>
          </div>
          <div class="col-md-1 col-lg-1 col-sm-3 col-3">
            <div class="header-content">
              <a href="panding-grievance.php"><button type="button" class="btn btn-primary">Panding</button></a>
            </div>
          </div>
          <div class="col-md-1 col-lg-1 col-sm-3 col-3">
            <div class="header-content">
              <a href="close-grievance.php"><button type="button" class="btn btn-primary">Close</button></a>
            </div>
          </div>
          
        </div>
      </div>
    </section>
    <section id="grievance-data">
      <div class="container-fluid">
        <h3 class="text-center text-danger mt-5 mb-3">Grievance Registration Data:</h3>
        <table class="table table-striped table-bordered" id="myTable">
          <thead class="thead-dark" id="tabel_head">
            <tr>
              <th scope="col">S.No</th>
              <th scope="col">Grievance Id</th>
              <th scope="col">First Name</th>
              <th scope="col">Middle Name</th>
              <th scope="col">Last Name</th>
              <th scope="col">Mobile Number</th>
              <th scope="col">Grievance Date</th>
            </tr>
          </thead>
          <tbody>
            <?php
              $num=1;
              $date=date("Y-m-d");
              $grievance="SELECT * FROM grievence_from WHERE reg_date='$date'";
              $query=mysqli_query($con,$grievance);
              while ($row=mysqli_fetch_assoc($query)) {
            ?>
              <tr>
                <th scope="row"><?php echo $num; ?></th>
                <td><a href="forword-grievance.php?gr_id=<?php echo $row['id']; ?>"><?php echo $row['grievance_id']; ?></a></td>
                <td><?php echo $row['first_name']; ?></td>
                <td><?php echo $row['middle_name']; ?></td>
                <td><?php echo $row['last_name']; ?></td>
                <td><?php echo $row['mobile']; ?></td>
                <td><?php echo $row['reg_date']; ?></td>
              </tr>
            <?php
                $num++;
              }

            ?>
          </tbody>
        </table>
      </div>
    </section>


    <!-- Option 1: Bootstrap Bundle with Popper -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>

    <!-- Option 2: Separate Popper and Bootstrap JS -->
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.10.2/dist/umd/popper.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js"></script>
     <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js" ></script>
     <!------Data Table------->
     <script type="text/javascript" src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>

    <script type="text/javascript" src="js/script.js"></script>
    <script type="text/javascript">
      $(document).ready( function () {
        $('#myTable').DataTable();
    } );
    </script>
  </body>
  </html>