<?php 
require 'header.php';

?>
        <div class="container-fluid" width="1800px">
          <div class="card shadow mb-4">
            <?php if(isset($_SESSION['response'])) { ?>
                <div class="alert alert-<?= $_SESSION['res_type']; ?> 
                alert-dismissible text-center">
                <button class="close" type="button" data-dismiss="alert">
                &times;
                </button>
                <b class="text-center"><?=  $_SESSION['response']; ?></b>                
                </div>
              <?php  } unset($_SESSION['response']);?>
            <div class="card-header py-2">
              <h6 class="m-0 font-weight-bold text-primary">LIST OF REGION</h6>
            </div>
            <div class="card-body">
              <div class="table-responsive">
                <table class="table table-bordered text-center" id="dataTable"  cellspacing="0">
                  <thead>
                    <tr>
                      <th>COUNTRY ID</th>
                       <th>REGION CODE</th>
                      <th>REGION NAME</th>
                      
                      <th>OPERATION</th>
                    </tr>
                  </thead>
                  <tfoot>
                    <tr>
                      <th>COUNTRY ID</th>
                      <th>REGION CODE</th>
                      <th>REGION NAME</th>
                      
                      <th>OPERATION</th>
                    </tr>
                  </tfoot>
                  <?php 
                    
                    $query="SELECT * FROM `tbl_region`";
                    $stmt=$Connection->prepare($query);
                    $stmt->execute();
                    $result=$stmt->get_result();
                  ?>
                  <tbody>
                    <?php while($row=$result->FETCH_ARRAY()) {?>
                    <tr>

                      <td><?= $row['c_id']; ?></td>
                      <td><?= $row['r_code']; ?></td>
                      <td><?= $row['r_name']; ?></td>
                      
                      <td>
                        <a href="update_region.php?edit=<?=$row['r_id'];?>"><span class="fa fas fa-edit fa-2x"  data-toggle="tooltip"
                        data-placement="top" title="edit data"></span></a>
                        &nbsp;
                        <a href="addRegion.php?delete=<?=$row['r_id']; ?>" 
                          onClick="return confirm('Do you want to delete?');"><span class="fa fas fa-trash fa-2x" data-toggle="tooltip" title="delete data"></span></a>
                      </td>
                    </tr>
                  <?php } ?>
                  </tbody>
                </table>
              </div>
            </div>
          </div>
        </div>

        <!-- /.container-fluid -->
        <script>
          $(document).ready(function(){
            $('[data-toggle="tooltip"]').tooltip();   
          });
        </script>

      </div>
      <!-- End of Main Content -->

      <!-- Footer -->
      <footer class="sticky-footer bg-white">
        <div class="container my-auto">
          <div class="copyright text-center my-auto">
            <span>Copyright &copy; SoftArena 2020</span>
          </div>
        </div>
      </footer>

      <!-- End of Footer -->
  <!-- End of Page Wrapper -->

  <!-- Scroll to Top Button-->
  <a class="scroll-to-top rounded" href="#page-top">
    <i class="fas fa-angle-up"></i>
  </a>

  <!-- Logout Modal-->
  <div class="modal fade" id="logoutModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="exampleModalLabel">Ready to Leave?</h5>
          <button class="close" type="button" data-dismiss="modal" aria-label="Close">
            <span aria-hidden="true">×</span>
          </button>
        </div>
        <div class="modal-body">Select "Logout" below if you are ready to end your current session.</div>
        <div class="modal-footer">
          <button class="btn btn-secondary" type="button" data-dismiss="modal">Cancel</button>
          <a class="btn btn-primary" href="logout.html">Logout</a>
        </div>
      </div>
    </div>
  </div>

  <!-- Bootstrap core JavaScript-->
  <script src="vendor/jquery/jquery.min.js"></script>
  <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>

  <!-- Core plugin JavaScript-->
  <script src="vendor/jquery-easing/jquery.easing.min.js"></script>

  <!-- Custom scripts for all pages-->
  <script src="js/sb-admin-2.min.js"></script>

  <!-- Page level plugins -->
  <script src="vendor/datatables/jquery.dataTables.min.js"></script>
  <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script>

  <!-- Page level custom scripts -->
  <script src="js/demo/datatables-demo.js"></script>

</body>

</html>
