<?php include("conn.php");
$page=' User Role';?>
<!DOCTYPE html>
<html lang="en">
<?php include("common/head.php")?>
<?php

if ($user_role=='none') {
    echo"<script>alert('You are not allow to access this page, contact your admintrator'); window.location.href='login'</script>";
}
?>
<style>
    .table-role{
        overflow: scroll;
    }
</style>
<body>
<?php include("common/menu.php")?>
<!---side nav bar end-->
<?php include("common/tittle.php")?>
            <!--Nav menu end-->

            <!--Main body Start-->
            <div id="accordions" class="col-sm-12 mt-2">
           
              
                   <hr class="bg-success">
   
                   <div style="overflow: scroll; height:100vh;" id="collapseOne" class="table-role collapse show " data-parent="#accordions">
                    <h5 class="text-center">User Roles</h5>
                    <table id="example_table" class="table-customer table-striped table-hover  w-100 table-bordered">
                        <thead>
                        <tr>
                        <th>id</th>
        <th>Image</th>
        <th>Name</th>
        <th>Role</th>
        <th>Place order</th>
        <th>Prepare order(B)</th>
        <th>Prepare order(R)</th>
        <th>M_users</th>
        <th>m_menu_bar</th>
        <th>m_menu_rest</th>
        <th>Analystic</th>
        <th>Settings</th>
        <th>Customer</th>
        <th>Orders</th>
        <th>User Role</th>
        <th>Inventory</th>
        <th>View Cash</th>
        <th>Status</th>
        <th>Action</th>
                        </tr>
                        </thead>
                        <tbody>
                        <?php

      
$sql = "SELECT * FROM `users` ";
$result = $conn->query($sql);
$i=1;
while($row = $result->fetch_assoc()) { 
$sql2 = "SELECT * FROM `user_role` WHERE userid='".$row['id']."'";
$result2=$conn->query($sql2);
$row1=$result2->fetch_assoc();
$data=$row['id'];
$status=$row['status'];
$place_order=$row1['dashboard'];
$prepare_order_b=$row1['prepare_order_b'];
$prepare_order_r=$row1['prepare_order_r'];
$m_user=$row1['m_user'];
$m_menu_bar=$row1['m_menu_bar'];
$m_menu_rest=$row1['m_menu_rest'];
$analytics=$row1['analytics'];
$settings=$row1['settings'];
$customer=$row1['customer'];
$order=$row1['order'];
$user_role=$row1['user_role'];
$inventory=$row1['inventory'];
$view_cash=$row1['view_amount'];



$links="user_status.php?id=".urlencode(base64_encode($data)); 
$link="user_role_ajax.php?id=".urlencode(base64_encode($data)); 

if ($place_order==='1') {
    $place_order_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
   }
   else{
       $place_order_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
   }
   if ($prepare_order_b=='1') {
       $prepare_order_b_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $prepare_order_b_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($prepare_order_r=='1') {
       $prepare_order_r_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
        $prepare_order_r_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($m_user=='1') {
       $m_user_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $m_user_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($m_menu_bar=='1') {
       $m_menu_bar_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $m_menu_bar_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
   
      if ($m_menu_rest=='1') {
       $m_menu_rest_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $m_menu_rest_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($analytics=='1') {
       $analytics_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $analytics_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($settings=='1') {
       $settings_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $settings_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($customer=='1') {
       $customer_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $customer_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($order=='1') {
       $order_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $order_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   

   
      if ($user_role=='1') {
       $user_role_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $user_role_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }
   
      if ($inventory=='1') {
       $inventory_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
      }
      else{
          $inventory_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
      }

      if ($view_cash=='1') {
        $view_cash_fa=' <i class="fa fa-check text-success" aria-hidden="true"></i>' ; 
       }
       else{
           $view_cash_fa='<i class="fa fa-ban text-danger" aria-hidden="true"></i>';
       }










          
                            $text='';

                            if ($status==='1') {
                              $text='Active';
                              $read='btn-success';
                              $de='deactivate';
                              $sta=0;
                            }
                                                       else {
                              $text='Inactive';
                              $read='btn-danger';
                             $de='activate';
                             $sta=1;
                            }

                        ?>
                        <tr>
                            <td><?php echo $data ?></td>
                            <td><img style="width: 60px;" src="user_image/<?php echo $row['image'] ?>" alt=""></td>
                            <td><?php echo $row['fname']." ". $row['sname']?></td>
                            <td><?php echo $row['role'] ?></td>
                            <td><?php echo $place_order_fa?></td>
                            <td><?php echo $prepare_order_b_fa?></td>
                            <td><?php echo $prepare_order_r_fa?></td>
                            <td><?php echo $m_user_fa?></td>
                            <td><?php echo $m_menu_bar_fa?></td>
                            <td><?php echo $m_menu_rest_fa?></td>
                            <td><?php echo $analytics_fa?></td>
                            <td><?php echo $settings_fa?></td>
                            <td><?php echo $customer_fa?></td>
                            <td><?php echo $order_fa?></td>
                            <td><?php echo $user_role_fa?></td>
                            <td><?php echo $inventory_fa?></td>
                            <td><?php echo $view_cash_fa?></td>
                            <td>
                           

                         
                        
                        </td>
                            <td>
                                   <input  type="button" name="view" value="Edit" id="<?php echo $row["id"]; ?>" class="btn  btn-primary btn-sm view_datase" />
                        
                           

                                
                        </tr>
                        <?php } ?>
                        <thead>
                        <th>id</th>
        <th>Image</th>
        <th>Name</th>
        <th>Role</th>
        <th>Place order</th>
        <th>Prepare order(B)</th>
        <th>Prepare order(R)</th>
        <th>M_users</th>
        <th>m_menu_bar</th>
        <th>m_menu_rest</th>
        <th>Analystic</th>
        <th>Settings</th>
        <th>Customer</th>
        <th>Orders</th>
        <th>User Role</th>
        <th>Inventory</th>
        <th>View Cash</th>
        <th>Status</th>
        <th>Action</th>
                    </tbody>
                    </table>
    
    
    
                        
                        
               
    

                </div>

           

      <!-- Small modal -->
<div id="dataModalse"  class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-sm">
    <div id="employee_detailse" class="modal-content text-dark">
     
    
    
    </div>
  </div>
</div>
       

   
    
    <!--  isotope plugin cdn  -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/3.0.6/isotope.pkgd.min.js" integrity="sha256-CBrpuqrMhXwcLLUd5tvQ4euBHCdh7wGlDfNz8vbu/iI=" crossorigin="anonymous"></script>
    <script src="js/script.js"></script>
     <!-- jQuery js-->
 
     <!-- Bootstrap js -->
     <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
     <!-- jQuery Datatable js -->
     <script src="https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min.js"></script>
     <!-- Bootstrap Datatable js -->    
     <script src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min.js"></script>
     <script>
       $(document).ready( function () {
           $('#example_table').DataTable();
       } );

</script>

<script>
         $(document).ready(function(){  
      $('.view_datase').click(function(){  
           var employee_idse = $(this).attr("id");  
           $.ajax({  
                url:"user_role_ajax.php",  
                method:"post",  
                data:{employee_idse:employee_idse},  
                success:function(data){  
                     $('#employee_detailse').html(data);  
                     $('#dataModalse').modal("show");  
                }  
           });  
      });  
 });  
     </script>
</body>

</html>