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

  {
 

    $rid=$_GET['rid'];

    $stringParts = explode("*", $rid);

    $uAl  = $stringParts[0];

    $r_id= $stringParts[1];

    $fval= $stringParts[2];

    //echo $fval;

    if ($fval==1){
 
      $cval=0;

    }

    else {

      $cval=1;

    }

    

  if ($uAl==2) {  ///  admin level
  
    mysqli_query($con,"update roll_master set l_second=$cval where r_id='$r_id' ")or die(mysqli_error());
echo "aa";
    }

  

  if ($uAl==3) {  ///  Manager

    mysqli_query($con,"update roll_master set l_third=$cval where r_id='$r_id' ")or die(mysqli_error());

    }



  if ($uAl==4) {  ///  Operator

    mysqli_query($con,"update roll_master set l_forth=$cval where r_id='$r_id' ")or die(mysqli_error());

    }



  if ($uAl==5) {  ///  Guest

    mysqli_query($con,"update roll_master set l_fifth=$cval where r_id='$r_id' ")or die(mysqli_error());

    }







    

  }



$x=0;

$first=' ';

$second=' ';

$third=' ';

$forth=' ';



?>




?>
<!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>OfficeSync|Home </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-lg-22 grid-margin stretch-card">
              <div class="card">
                <div class="card-body">
 <h4 >User - Roll Management</h4>


          <div class="row">
                    <div class="col-12">
                       <div>
                      <div class="table-responsive">
                        <table  class="table">
                          <thead>

                  <tr class="bg-primary text-white">

          <th>#</th>

                    <th>Roll Name</th>

                    <th>SysAdmin </th> 

          <th>Manager</th>  

          <th>Rep </th> 

          <th>Operator </th>

          <th>Guest </th>

                 

          

          

                  </tr>

                  </thead>

                  <tbody>

        <?php



        $query=mysqli_query($con,"SELECT * from roll_master order by r_id ")or die(mysqli_error()); 

    

                    while($row=mysqli_fetch_array($query)){   

    //for ($x = 0; $x <= 25; $x++) {   

        //if ($x==0) {  

            ?>      

        <tr>

          <td><?php echo $row['r_id'];?></td>

           <td><?php echo $row['r_name'];?></td>    

           <td><?php if ($row['l_first']>0) { ?> &#10004;<?php } else { ?> &#10006; <?php } ?></td> 

           <td><?php if ($row['l_second']>0) { ?> &#10004;<?php } else { ?> &#10006; <?php } ?><a href="user_roll_view.php?rid=<?php echo '2'; echo "*";echo $row['r_id']; echo "*";echo $row['l_second'];?>" > Change</a></td>          

           <td><?php if ($row['l_third']>0) { ?> &#10004;<?php } else { ?> &#10006; <?php } ?><a href="user_roll_view.php?rid=<?php echo '3'; echo "*";echo $row['r_id']; echo "*";echo $row['l_third'];?>" > Change</a></td>

           <td><?php if ($row['l_forth']>0) { ?> &#10004;<?php } else { ?> &#10006; <?php } ?><a href="user_roll_view.php?rid=<?php echo '4'; echo "*";echo $row['r_id']; echo "*";echo $row['l_forth'];?>" > Change</a></td>

           <td ><?php if ($row['l_fifth']>0) { ?> &#10004;<?php } else { ?> &#10006; <?php } ?><a href="user_roll_view.php?rid=<?php echo '5'; echo "*";echo $row['r_id']; echo "*";echo $row['l_fifth'];?>" > Change</a></td>                                

        </tr>

          

    <?php  } //}?>

                  </tbody>

                  <tfoot>

                <tr>

          <th></th>

                    <th></th>

                    <th> </th> 

          <th></th>   

          <th> </th> 

          <th> </th>

          <th> </th>

                  </tr>

                  </tfoot>

                </table>
        </div>
  
</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>
