<?
session_start();
include('includes/config.php');
include('defs.php');

if(strlen($_SESSION['aid'])==0)
  { header('location:index.php');
}

$usr=$_SESSION['uname'];



//$query=mysqli_query($link,"select sum(ledgers.Debit-ledgers.Credit) as bal, acc_heads.A_Id, acc_heads.Id, acc_heads.Name, acc_heads.C_Person, acc_heads.Contact_No, acc_heads.City from ledgers, acc_heads where ledgers.A_Id=acc_heads.A_Id and acc_heads.M_Head='Customer' group by acc_heads.A_Id order by acc_heads.A_Id");



?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  <title>GLAKB  | Customer Details</title>

  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- Theme style -->
  <link rel="stylesheet" href="../dist/css/adminlte.min.css">
  <!--Function Email Availabilty---->

</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
  <!-- Navbar -->
<?php include_once("includes/navbar.php");?>
  <!-- /.navbar -->

  <!-- Main Sidebar Container -->
 <?php include_once("includes/sidebar.php");?>

 
  <div class="content-wrapper">
    <?
if($_GET['action']=='delete'){
$lid=$_GET['tid'];
//$profilepic=$_GET['profilepic'];
//$ppicpath="teacherspic"."/".$profilepic;
$query=mysqli_query($link,"delete from acc_heads where A_Id = '$lid'");
$query1=mysqli_query($link,"delete from ledgers where A_Id = '$lid'");

if($query){
//unlink($ppicpath);
echo "<script>alert('Customer details deleted successfully.');</script>";
echo "<script type='text/javascript'> document.location = 'editview.php'; </script>";
}
}

  ?>
<!DOCTYPE html>
<style>

#customers {
  font-family: Times-Roman;
  border-collapse: collapse;
  width: 100%;
}

#customers td, #customers th {
  border: 1px solid #4444;
  padding: 4px;
}

#customers tr:nth-child(even){background-color:gainsboro ;}


#customers th {
  padding-top: 8px;
  padding-bottom: 8px;
  text-align: center;
  background-color:dodgerblue;
  color: white;
}
</style>   
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">



  
  <!-- Google Font: Source Sans Pro -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
  <!-- DataTables -->
  <link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
  <link rel="stylesheet" href="../plugins/datatables-buttons/css/buttons.bootstrap4.min.css">
  <!-- Theme style -->
  <link rel="stylesheSet" href="../dist/css/adminlte.css">
</head>


              <div class="card-body">
                <table align="center" id="customers">
     
<tr>
    <th colspan="8"><font size="5">EDIT  / DELETE CUSTOMER DETAILS</th>

  </tr>

                <table id="example1" class="table table-bordered table-striped">
                    <br>
                  <thead>
                  <tr>
                    <th>#</th>
                    <th>Customer Code</th>
                    <th>Customer Head</th>
                    <th>Warehouse</th>
                    <th>Contact Person</th>
                      <th>Contact No.</th>
                    <th>City / Town</th>
                      <th>Province</th>
                    <th>Edit</th>                
                    <th>Delete</th>
                  </tr>
                  </thead>
                  <tbody>
<?php $query=mysqli_query($link,"select * from acc_heads where M_Head='Customer' order by Name");


$cnt=1;
while($result=mysqli_fetch_array($query)){
?>


                  <tr>
                    <td><?php echo $cnt;?></td>
                 
                   <td><?php echo $result['A_Id']?></td>
                   <td><?php echo $result['Name']?></td>
                     <td><?php echo $result['Warehouse']?></td>
                    <td><?php echo $result['C_Person']?></td>
                     <td><?php echo $result['Contact_No']?></td>
                   <td><?php echo $result['City']?></td>
                     <td><?php echo $result['Province']?></td>
                  
                   <td align="center">
<a href="edit_cust.php?tid=<?php echo $result['Id'];?>" title="Edit Cusomer Details"> <i class="fa fa-edit" aria-hidden="true" align=center></i> </a>


</td>
  <td align="center">
      <a href="editview.php?action=delete&&tid=<?php echo $result['A_Id']; ?>" style="color:red;" title="Delete Accounts Head" onclick="return confirm('Do you really want to delete this record?');"><i class="fa fa-trash" aria-hidden="true"></i> </a>
 </td>
                  </tr>
         <?php $cnt++;} ?>
             
                  </tbody>
                  
                </table>
              </div>
              <!-- /.card-body -->
            </div>
            <!-- /.card -->
          </div>
          <!-- /.col -->
        </div>
        <!-- /.row -->
      </div>
      <!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
<?php include_once('footer.php');?>

  <!-- Control Sidebar -->
  <aside class="control-sidebar control-sidebar-dark">
    <!-- Control sidebar content goes here -->
  </aside>
  <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->

<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- DataTables  & Plugins -->
<script src="../plugins/datatables/jquery.dataTables.min.js"></script>
<script src="../plugins/datatables-bs4/js/dataTables.bootstrap4.min.js"></script>
<script src="../plugins/datatables-responsive/js/dataTables.responsive.min.js"></script>
<script src="../plugins/datatables-responsive/js/responsive.bootstrap4.min.js"></script>
<script src="../plugins/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.bootstrap4.min.js"></script>
<script src="../plugins/jszip/jszip.min.js"></script>
<script src="../plugins/pdfmake/pdfmake.min.js"></script>
<script src="../plugins/pdfmake/vfs_fonts.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.print.min.js"></script>
<script src="../plugins/datatables-buttons/js/buttons.colVis.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- Page specific script -->
<script>
  $(function () {
    $("#example1").DataTable({
      "responsive": true, "lengthChange": false, "autoWidth": false,
     
    }).buttons().container().appendTo('#example1_wrapper .col-md-6:eq(0)');
    $('#example2').DataTable({
      "paging": true,
      "lengthChange": false,
      "searching": false,
      "ordering": true,
      "info": true,
      "autoWidth": false,
      "responsive": true,
    });
  });
</script>
</body>
</html>
<?php  ?>