<?php 
if(!isset($_SESSION)) { 
  session_start(); 
  include('../includes/dbcon.php');
}
if(empty($_SESSION['rm_id'])):
header('Location:../index.php');
endif;




?>
<!DOCTYPE html>
<html lang="en">


<head>
  <!-- Required meta tags -->
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>SalesHub | Customer Management </title>
  <!-- plugins:css -->
  <?php include('../includes/commonheader.php');?>

</head>
<body>
 <?php include('../includes/header.php');?>
 <?php include('../includes/leftsidebar.php');?>
           <!-- partial -->
 <div class="main-panel">        
        <div class="content-wrapper">      
             
         <div class="col-12 grid-margin">
             
         <div class="card">
      

       
       

                <div class="card-body">
        <div style="display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 1rem; margin: 0;">
  <h5 style="margin: 0;">Customer List</h5>
  <button type="button" onclick="document.location='admin_customer.php'" class="btn btn-success" style="padding: 0.3rem 0.5rem; font-size: 14px;">
    <i class="fas fa-arrow-left"></i> Add New Customer
  </button>
</div>

<div class="table-responsive">
                    <table id="order-listing" class="table">
                       <thead>
  <tr class="bg-primary text-white">
   
    <th width="8%">#</th>
    <th width="10%"> Name</th>
    <th width="10%">Address</th>
    <th width="10%">Telephone</th>
    <th width="8%">Email</th> 
    <th width="5%">City</th> 
    <th width="5%">sup Code</th> 
   
    <th width="10%">Vat Number</th> 
    <th width="10%">Actions</th>   

   
    </tr>
  </thead>
<tbody>
<?php
$rcount=0;

//echo$tt;

$sql="SELECT * from customer_master"  ;

$query=mysqli_query($con,$sql)or die(mysqli_error()); 

              while($row=mysqli_fetch_array($query)){   $rcount=$rcount+1;
                $cus_name=$row['cus_name']; 
                 $address=$row['add1']; 
                $telephone=$row['telephone']; 
                $email=$row['email'];
                $city=$row['city'];
                $notes=$row['notes'];
                $cus_id=$row['cus_id'];
                $vat_number=$row['vat_number'];
                $vat_required=$row['vat_required'];
                $sup_code=$row['sup_code'];
                
               
              ?>   

               <tr>       
            <td> <?php echo $rcount;   ?></td>
            <td> <?php echo $cus_name;   ?></td>
             <td> <?php echo $address;   ?></td>
            <td> <?php echo $telephone;   ?></td>
            <td><?php echo $email; ?></td>
           <td> <?php echo $city;   ?></td>
            <td><?php echo $sup_code; ?></td>
          
            <td><?php echo $vat_number; ?></td>
            
           
<td>
       <a href="#addvoucher<?php echo $row['cus_id'];?>" data-target="#addvoucher<?php echo $row['cus_id'];?>"data-toggle="modal"     </div> <i class="fas fa-edit "></i>  </i> </a> </td>
              

</td>

 <!----------------------Model ------------------------------->
     <div id="addvoucher<?php echo $row['cus_id'];?>" class="modal fade in" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
          <div class="modal-dialog" style="width:80%; aria-hidden="true>
          <div class="modal-content" style="height:auto">        
          <div class="modal-body">
   <h4>Edit Customer </h4>
             <form class="form-horizontal" method="post" action="admin_customer_edit.php" enctype='multipart/form-data'>
      <div class="form-group">
            <label for="exampleInputPassword1">Customer Name</label>
            <input type="text" class="form-control" id="cusname_edit" name="cusname_edit" value="<?php echo $cus_name; ?>">
            <input type="hidden" class="form-control" id="cusid_edit" name="cusid_edit" value="<?php echo $row['cus_id'];?>">

                </div>  
 <div class="form-group">
                     <label for="exampleInputPassword1">Address</label>
                <input type="text" class="form-control" id="cusadd_edit" name="cusadd_edit" value="<?php echo $address; ?>">
      

                </div>  



               <div class="form-group">
              <label for="exampleInputEmail1">Telephone </label>
          <input type="text" class="form-control" id="tel_edit" name="tel_edit" value="<?php echo $telephone; ?>">   
               </div>


                  <div class="form-group">
             

                   
<div class="form-group">
                  <label for="exampleInputPassword1">Email</label>
                   <input type="text" class="form-control" id="email_edit" name="email_edit" value="<?php echo $email; ?>">  
          
</div>
                </div>  


                <div class="form-group">
                     <label for="exampleInputPassword1">City</label>
                <input type="text" class="form-control" id="city_edit" name="city_edit" value="<?php echo $city; ?>">    
                </div> 

               




                     <div class="form-group">
                    <label for="exampleInputPassword1">Note</label>
                <input type="text" class="form-control" id="note_edit" name="note_edit" value="<?php echo $notes; ?>">    
                </div>


                     <div class="form-group">
                    <label for="exampleInputPassword1">Sup Code</label>
                <input type="text" class="form-control" id="sup_edit" name="sup_edit" value="<?php echo $sup_code; ?>">    
                </div>


                   <div class="modal-footer">
                   <button type="submit" class="btn btn-primary">Save changes</button>
                   <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                   </div>                   
          </form>

   


          </div>
        </div>
      </div>
    </div>
<!--------------- End of Model ------------------------------------>



                    
            

         
             </tr>
                
                    <?php }  ?>
                    </tbody>
                    </table>
                  </div>
 </div> </div> </div>

        </div>  <!----- <div class="content-wrapper">------>
  </div>

 </div><!-----End of main panel--~~~~~~~~~~~~~~~~~~~~~~~--------------->
 </div><!-----Dont Delete this DIV--~~~~~~~~~~~~~~~~~~~~~~~--------------->
  <!-- container-scroller -->
<?php include('../includes/footer.php');?>
<?php include('../includes/commonjs.php');?>
 
</body>


</html>

<script>
    $( document ).ready(function() {
         // alert("Please Select Order Type");

    });



</script>

 <!-- End custom js for this page-->
  <script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

    //Initialize Select2 Elements
    $('.select2bs4').select2({
      theme: 'bootstrap4'
    })
  })

</script>



