 <?php
session_start();
error_reporting(0);
@ini_set('display_errors', 0);
$id_user=$_SESSION['id'];
$branch=$_SESSION['branch_id'];
$business=$_SESSION['business_id'];
?>

 <!DOCTYPE html>
<html>

    <head>
           <?php include("../includes/header-links.php");
$permissions = mysqli_fetch_array(mysqli_query($con,"SELECT * FROM  
  permissions,users WHERE  permissions.role_id = users.role 
  AND users.id='$id_user' AND users.business_id ='$business' AND users.branch_id ='$branch'"));

if($permissions['view_permissions'] != 1){
?>
<script>window.location="../main/dashboard.php"</script>
<?php
}
?>

		<?php
		include("../includes/header-links.php");
		?>
    <link rel="stylesheet" href="../data-table-css/bootstrap-table.css">
    <link rel="stylesheet" href="../data-table-css/bootstrap-editable.css">
        
    </head>
    
    <body>
        <?php include '../includes/header.php'; ?>
        <div class="container-fluid">
		
            <div class="row-fluid">
                <?php include '../includes/sidebar.php'; ?>
                <!--/span-->
                <div class="span10" id="content">
					

                     <div class="row-fluid">
                        <!-- block -->
                        <div class="block">
						
                            <div class="navbar navbar-inner block-header">
                                <div class="muted pull-left">PERMISSIONS</div>
                            
                            <div class="muted pull-right" >&nbsp &nbsp &nbsp</div>
                               <!--  <div class="muted pull-right"><a href="../stock/stock.php"><button class="bt btn-primary">Add New Role</button> </a></div> -->
                                <div class="muted pull-right" >
                                         <a href="#myModal" data-toggle="modal" class="btn btn-primary"><i class="icon-plus icon-white"></i>&nbsp;Add New Role</a>
                                      </div>
                                </div>
                                <?php
include '../includes/connection.php';
// Create connection
// Create connection

$id=$_SESSION['id'];
$branch=$_SESSION['branch_id'];
$business=$_SESSION['business_id'];
$sql = "SELECT * FROM users where id='$id'";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        $businessid=$row['business_id'];
        $branch_id=$row['branch_id'];
        
    }
} else {
    echo "0 results";
}

//mysqli_close($conn)
?>
                                <!--Model begins here -->
                                      <div id="myModal" class="modal hide">
                                            <div class="modal-header" style="background: #08c; color: white; text-align: center;">
                                                <button data-dismiss="modal" class="close" type="button">&times;</button>
                                                <h3>Add New Role</h3>
                                            </div>
                                            <div class="modal-body">
                                                <form action="" method="POST">

                                                    <div class="form-group col-md-2">
                                                         <label class="control-label" for="select01">Select Branches</label>
                                                         <select  class="form-control" name="brancheses">
                                              <option disabled selected value="">Select Branch</option>
                                              <?php
include '../includes/connection.php';
// Create connection
// Create connection

$id=$_SESSION['id'];
$business=$_SESSION['business_id'];
$sql = "SELECT * FROM branches where branches.business_id='$business'";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
        ?>
<option value="<?php echo $row['branch_id']; ?>"><?php echo $row['branch_name']; ?></option>
        <?php
    }
} else {
    echo "0 results";
}

?>

</select>
                                                    </div>
                                
                                        

                                           
                                                
                        <label style=" font-size: 20px; "> New Role</label>
                        <input type="text" name="role" class="form-control"   style="width: 95%; height: 30px; font-size: 20px;">
                        
                        
                                                <div class="span12" >
                          <div class="span8">
                                          <button type="submit" name="submit" class="btn btn-primary">Save</button>
                                        </div>
                                        <div  class="span4">
                                          <a href="" class="btn btn-danger" data-dismiss="modal">Cancel</a>
                                        </div>  
                                      </div>
                                                </form>
                                            </div>
                                        </div>
                                        <!--Model Ends here -->
                            <div class="block-content collapse in">

							
                                <div class="span12">
                         
   
                                    <div class="datatable-dashv1-list custom-datatable-overright">
                                  <input type="hidden" id="text">
                                    <table  id="table" data-toggle="table" data-pagination="false" data-search="true" data-show-columns="true" data-show-pagination-switch="true" data-show-refresh="true" data-key-events="true" data-show-toggle="true" data-resizable="true" data-cookie="true"
                                        data-cookie-id-table="saveId" data-show-export="true" data-click-to-select="true" data-toolbar="#toolbar" data-export-options='{"fileName": "Testing_filename"}'>
                                        <thead>
                                          <tr>
                                            <th colspan="9"><h5 style="text-align: center;"> PERMISSIONS </h5></th>
                                          </tr>
                                          
                                          <?php
//SELECT FROM PERMISSIONS
  if ($_SESSION['branch_id']==0 && $_SESSION['business_id']!=0) {
                                                  $permission_roles = mysqli_query($con,"SELECT *,(SELECT branch_name FROM branches where branch_id=permissions.branch_id) as branch_name FROM permissions  WHERE business_id='$business' ");  
                                                     
                                                    }else{
             $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");  

                                                    }  

                                     
                                          ?>
                                            <tr>
                                                <th>PERMISSIONS</th>
                                                <?php
    while ( $fetch_roles = mysqli_fetch_array($permission_roles)) {
   
                                                ?>
                                                <th><?php echo$fetch_roles['role'];
                                                if ($_SESSION['branch_id']==0){ 
                                                    echo " ( ".$fetch_roles['branch_name']." )";
                                                }
                                                 ?>
                                                  
                                                </th>
                                                <?php
                                                     }
                                                ?>
                                                
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <td>View Stock</td>
                                                <?php
        if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }

       
    while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
        $view_stock = $fetch_stock['view_stock'];
          $role_id = $fetch_stock['role_id'];
        if( $view_stock == 1){
            ?>
  <td><input onchange="view_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_stock<?php echo $role_id; ?>" checked=""></td>
            <?php
        }else{
            ?>
  <td><input onchange="view_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_stock<?php echo $role_id; ?>">

  </td>

            <?php
        }
   
                                                ?>
                  <script type="text/javascript">
    function view_stock<?php echo $role_id; ?>(){
 
    var roleid ="<?php echo$role_id; ?>";

    var column="view_stock";
        if (document.getElementById('view_stock<?php echo $role_id; ?>').checked==true) {
            var state = 1;
        }else{
            var state = 0
        }
    document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
    var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       // Typical action to be performed when the document is ready:
       document.getElementById("text").innerHTML = xhttp.responseText;
    }else{
        document.getElementById('text').innerHTML="No responseText";
    }
};
xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
xhttp.send();
    }
</script>
                                                <?php
                                            }
                                                ?>
                                                
                                                
                                            </tr>



                                            <tr>
                                                <td>View Stock Buying Price</td>
                                                <?php

     if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
    while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
        $view_buyingprice = $fetch_stock['view_buyingprice'];
          $role_id = $fetch_stock['role_id'];
        if( $view_buyingprice == 1){
            ?>
  <td><input onchange="view_buyingprice<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_buyingprice<?php echo $role_id; ?>" checked=""></td>
            <?php
        }else{
            ?>
  <td><input onchange="view_buyingprice<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_buyingprice<?php echo $role_id; ?>">

  </td>

            <?php
        }
   
                                                ?>
                  <script type="text/javascript">
    function view_buyingprice<?php echo $role_id; ?>(){
 
    var roleid ="<?php echo$role_id; ?>";

    var column="view_buyingprice";
        if (document.getElementById('view_buyingprice<?php echo $role_id; ?>').checked==true) {
            var state = 1;
        }else{
            var state = 0
        }
    document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
    var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       // Typical action to be performed when the document is ready:
       document.getElementById("text").innerHTML = xhttp.responseText;
    }else{
        document.getElementById('text').innerHTML="No responseText";
    }
};
xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
xhttp.send();
    }
</script>
                                                <?php
                                            }
                                                ?>
                                                
                                                
                                            </tr>




<tr>
                                                <td>View Products</td>
                                                <?php

     if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
    while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
        $view_products = $fetch_stock['view_products'];
          $role_id = $fetch_stock['role_id'];
        if( $view_products == 1){
            ?>
  <td><input onchange="view_products<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_products<?php echo $role_id; ?>" checked=""></td>
            <?php
        }else{
            ?>
  <td><input onchange="view_products<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_products<?php echo $role_id; ?>">

  </td>

            <?php
        }
   
                                                ?>
                  <script type="text/javascript">
    function view_products<?php echo $role_id; ?>(){
 
    var roleid ="<?php echo$role_id; ?>";

    var column="view_products";
        if (document.getElementById('view_products<?php echo $role_id; ?>').checked==true) {
            var state = 1;
        }else{
            var state = 0
        }
    document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
    var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       // Typical action to be performed when the document is ready:
       document.getElementById("text").innerHTML = xhttp.responseText;
    }else{
        document.getElementById('text').innerHTML="No responseText";
    }
};
xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
xhttp.send();
    }
</script>
                                                <?php
                                            }
                                                ?>
                                                
                                                
                                            </tr>





                                             <tr>
                                                    <td>Add Stock</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_stock = $fetch_stock['add_stock'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_stock == 1){
                    ?>
          <td><input onchange="add_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_stock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_stock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_stock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_stock";
            if (document.getElementById('add_stock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                <tr>
                                                    <td>Spoilt Stock</td>
                                                    <?php

                                    if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
                                    while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                                     $spoilt_stock = $fetch_stock['spoilt_stock'];
                                         $role_id = $fetch_stock['role_id'];
                                        if( $spoilt_stock == 1){
                                            ?>
                                        <td><input onchange="spoilt_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="spoilt_stock<?php echo $role_id; ?>" checked=""></td>
                                        <?php
                                    }else{
                                        ?>
                                <td><input onchange="spoilt_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="spoilt_stock<?php echo $role_id; ?>"></td>

                                    <?php
                                        }
           
                                                    ?>
                                                   <script type="text/javascript">
                                function spoilt_stock<?php echo $role_id; ?>(){
     
                                var roleid ="<?php echo$role_id; ?>";

                                var column="spoilt_stock";
                                    if (document.getElementById('spoilt_stock<?php echo $role_id; ?>').checked==true) {
                                var state = 1;
                                    }else{
                                        var state = 0
                                    }
                            document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
                            var xhttp = new XMLHttpRequest();
                                xhttp.onreadystatechange = function() {
                            if (this.readyState == 4 && this.status == 200) {
                                // Typical action to be performed when the document is ready:
                                document.getElementById("text").innerHTML = xhttp.responseText;
                             }else{
                            document.getElementById('text').innerHTML="No responseText";
                                }
                            };
                            xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
                            xhttp.send();
                             }
                            </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                </tr>



                                            <tr>
                                                    <td>New Product</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $new_product = $fetch_stock['new_product'];
                  $role_id = $fetch_stock['role_id'];
                if( $new_product == 1){
                    ?>
          <td><input onchange="new_product<?php echo $role_id; ?>(this.value)" type="checkbox" id="new_product<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="new_product<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="new_product<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function new_product<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="new_product";
            if (document.getElementById('new_product<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                             <tr>
                                                    <td>Reconcile Stock</td>
                                                    <?php

           if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_reconcile_stock = $fetch_stock['view_reconcile_stock'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_reconcile_stock == 1){
                    ?>
          <td><input onchange="view_reconcile_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_reconcile_stock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_reconcile_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_reconcile_stock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_reconcile_stock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_reconcile_stock";
            if (document.getElementById('view_reconcile_stock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                             



                                            <tr>
                                                    <td>Edit Stock</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_stock = $fetch_stock['edit_stock'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_stock == 1){
                    ?>
          <td><input onchange="edit_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_stock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_stock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_stock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_stock";
            if (document.getElementById('edit_stock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                               <tr>
                                                    <td>Add Product</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_product = $fetch_stock['add_product'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_product == 1){
                    ?>
          <td><input onchange="add_product<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_product<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_product<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_product<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_product<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_product";
            if (document.getElementById('add_product<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





                                               <tr>
                                                    <td>View Product Stock</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $product_stock = $fetch_stock['product_stock'];
                  $role_id = $fetch_stock['role_id'];
                if( $product_stock == 1){
                    ?>
          <td><input onchange="product_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="product_stock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="product_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="product_stock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function product_stock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="product_stock";
            if (document.getElementById('product_stock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




                                            <tr>
                                                    <td>View Product Categories</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_product_categories = $fetch_stock['view_product_categories'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_product_categories == 1){
                    ?>
          <td><input onchange="view_product_categories<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_product_categories<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_product_categories<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_product_categories<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_product_categories<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_product_categories";
            if (document.getElementById('view_product_categories<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                            <tr>
                                                    <td>Edit Product</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_product = $fetch_stock['edit_product'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_product == 1){
                    ?>
          <td><input onchange="edit_product<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_product<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_product<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_product<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_product<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_product";
            if (document.getElementById('edit_product<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




                                             <tr>
                                                    <td>Delete Product</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_product = $fetch_stock['delete_product'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_product == 1){
                    ?>
          <td><input onchange="delete_product<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_product<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_product<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_product<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_product<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_product";
            if (document.getElementById('delete_product<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                                    <td>Add Product Category</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_product_category = $fetch_stock['add_product_category'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_product_category == 1){
                    ?>
          <td><input onchange="add_product_category<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_product_category<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_product_category<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_product_category<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_product_category<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_product_category";
            if (document.getElementById('add_product_category<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                            <td>Edit Product Category</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_product_category = $fetch_stock['edit_product_category'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_product_category == 1){
                    ?>
          <td><input onchange="edit_product_category<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_product_category<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_product_category<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_product_category<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_product_category<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_product_category";
            if (document.getElementById('edit_product_category<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<td>Delete Product Category</td>
                                                    <?php

            if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_product_category = $fetch_stock['delete_product_category'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_product_category == 1){
                    ?>
          <td><input onchange="delete_product_category<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_product_category<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_product_category<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_product_category<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_product_category<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_product_category";
            if (document.getElementById('delete_product_category<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                            <td>View Sales</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_sales = $fetch_stock['view_sales'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_sales == 1){
                    ?>
          <td><input onchange="view_sales<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_sales<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_sales<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_sales<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_sales<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_sales";
            if (document.getElementById('view_sales<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                            <td>View Untaken Orders</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_untaken_orders = $fetch_stock['view_untaken_orders'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_untaken_orders == 1){
                    ?>
          <td><input onchange="view_untaken_orders<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_untaken_orders<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_untaken_orders<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_untaken_orders<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_untaken_orders<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_untaken_orders";
            if (document.getElementById('view_untaken_orders<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


                                            
                                            <td>View Customer Balance</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_customer_balance = $fetch_stock['view_customer_balance'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_customer_balance == 1){
                    ?>
          <td><input onchange="view_customer_balance<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_customer_balance<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_customer_balance<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_customer_balance<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_customer_balance<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_customer_balance";
            if (document.getElementById('view_customer_balance<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




                                            <td>View Pending Payments</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_pending_payments = $fetch_stock['view_pending_payments'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_pending_payments == 1){
                    ?>
          <td><input onchange="view_pending_payments<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_pending_payments<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_pending_payments<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_pending_payments<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_pending_payments<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_pending_payments";
            if (document.getElementById('view_pending_payments<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<td>Add order</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_order = $fetch_stock['add_order'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_order == 1){
                    ?>
          <td><input onchange="add_order<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_order<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_order<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_order<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_order<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_order";
            if (document.getElementById('add_order<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




                                           

                                           <td>Edit Order</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_order = $fetch_stock['edit_order'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_order == 1){
                    ?>
          <td><input onchange="edit_order<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_order<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_order<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_order<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_order<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_order";
            if (document.getElementById('edit_order<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Delete Order</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_order = $fetch_stock['delete_order'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_order == 1){
                    ?>
          <td><input onchange="delete_order<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_order<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_order<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_order<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_order<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_order";
            if (document.getElementById('delete_order<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>
                                           

<tr>
                                            <td>Process Order</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $process_order = $fetch_stock['process_order'];
                  $role_id = $fetch_stock['role_id'];
                if( $process_order == 1){
                    ?>
          <td><input onchange="process_order<?php echo $role_id; ?>(this.value)" type="checkbox" id="process_order<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="process_order<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="process_order<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function process_order<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="process_order";
            if (document.getElementById('process_order<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>View Purchase</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_purchase = $fetch_stock['view_purchase'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_purchase == 1){
                    ?>
          <td><input onchange="view_purchase<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_purchase<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_purchase<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_purchase<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_purchase<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_purchase";
            if (document.getElementById('view_purchase<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


 

                                           

<tr>
                                            <td>View Sales Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        } 
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_sales_report = $fetch_stock['view_sales_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_sales_report == 1){
                    ?>
          <td><input onchange="view_sales_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_sales_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_sales_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_sales_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_sales_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_sales_report";
            if (document.getElementById('view_sales_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


                                          

<tr>
                                            <td>Filter Sales Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_sales_report = $fetch_stock['filter_sales_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_sales_report == 1){
                    ?>
          <td><input onchange="filter_sales_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_sales_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_sales_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_sales_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_sales_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_sales_report";
            if (document.getElementById('filter_sales_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                                <td>Sales Report Branch</td>
                                                <?php

     if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
    while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
        $sales_report_branch = $fetch_stock['sales_report_branch'];
          $role_id = $fetch_stock['role_id'];
        if( $sales_report_branch == 1){
            ?>
  <td><input onchange="sales_report_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="sales_report_branch<?php echo $role_id; ?>" checked=""></td>
            <?php
        }else{
            ?>
  <td><input onchange="sales_report_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="sales_report_branch<?php echo $role_id; ?>">

  </td>

            <?php
        }
   
                                                ?>
                  <script type="text/javascript">
    function sales_report_branch<?php echo $role_id; ?>(){
 
    var roleid ="<?php echo$role_id; ?>";

    var column="sales_report_branch";
        if (document.getElementById('sales_report_branch<?php echo $role_id; ?>').checked==true) {
            var state = 1;
        }else{
            var state = 0
        }
    document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
    var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
    if (this.readyState == 4 && this.status == 200) {
       // Typical action to be performed when the document is ready:
       document.getElementById("text").innerHTML = xhttp.responseText;
    }else{
        document.getElementById('text').innerHTML="No responseText";
    }
};
xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
xhttp.send();
    }
</script>
                                                <?php
                                            }
                                                ?>
                                                
                                                
                                            </tr>







                                          

<tr>
                                            <td>Export Excel</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_excel = $fetch_stock['export_excel'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_excel == 1){
                    ?>
          <td><input onchange="export_excel<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_excel<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_excel<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_excel<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_excel<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_excel";
            if (document.getElementById('export_excel<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Print Sales Reciept</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $print_sales_reciept = $fetch_stock['print_sales_reciept'];
                  $role_id = $fetch_stock['role_id'];
                if( $print_sales_reciept == 1){
                    ?>
          <td><input onchange="print_sales_reciept<?php echo $role_id; ?>(this.value)" type="checkbox" id="print_sales_reciept<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="print_sales_reciept<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="print_sales_reciept<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function print_sales_reciept<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="print_sales_reciept";
            if (document.getElementById('print_sales_reciept<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Sales Return Button</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $sales_return_button = $fetch_stock['sales_return_button'];
                  $role_id = $fetch_stock['role_id'];
                if( $sales_return_button == 1){
                    ?>
          <td><input onchange="sales_return_button<?php echo $role_id; ?>(this.value)" type="checkbox" id="sales_return_button<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="sales_return_button<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="sales_return_button<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function sales_return_button<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="sales_return_button";
            if (document.getElementById('sales_return_button<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View sales report Total Sales</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_sales_report_total_sales = $fetch_stock['view_sales_report_total_sales'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_sales_report_total_sales == 1){
                    ?>
          <td><input onchange="view_sales_report_total_sales<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_sales_report_total_sales<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_sales_report_total_sales<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_sales_report_total_sales<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_sales_report_total_sales<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_sales_report_total_sales";
            if (document.getElementById('view_sales_report_total_sales<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Individual Product Sales</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_individual_product_sales = $fetch_stock['view_individual_product_sales'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_individual_product_sales == 1){
                    ?>
          <td><input onchange="view_individual_product_sales<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_individual_product_sales<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_individual_product_sales<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_individual_product_sales<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_individual_product_sales<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_individual_product_sales";
            if (document.getElementById('view_individual_product_sales<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Filter Individual Product Sales</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_individual_product_sales = $fetch_stock['filter_individual_product_sales'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_individual_product_sales == 1){
                    ?>
          <td><input onchange="filter_individual_product_sales<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_individual_product_sales<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_individual_product_sales<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_individual_product_sales<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_individual_product_sales<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_individual_product_sales";
            if (document.getElementById('filter_individual_product_sales<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>








<tr>
                                            <td>View Expenses</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_expenses = $fetch_stock['view_expenses'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_expenses == 1){
                    ?>
          <td><input onchange="view_expenses<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_expenses<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_expenses<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_expenses<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_expenses<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_expenses";
            if (document.getElementById('view_expenses<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Debtors Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_debtors_report = $fetch_stock['view_debtors_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_debtors_report == 1){
                    ?>
          <td><input onchange="view_debtors_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_debtors_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_debtors_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_debtors_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_debtors_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_debtors_report";
            if (document.getElementById('view_debtors_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>







<tr>
                                            <td>Add Expense</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_expense = $fetch_stock['add_expense'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_expense == 1){
                    ?>
          <td><input onchange="add_expense<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_expense<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_expense<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_expense<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_expense<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_expense";
            if (document.getElementById('add_expense<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Expense Categories</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_expense_categories = $fetch_stock['view_expense_categories'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_expense_categories == 1){
                    ?>
          <td><input onchange="view_expense_categories<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_expense_categories<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_expense_categories<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_expense_categories<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_expense_categories<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_expense_categories";
            if (document.getElementById('view_expense_categories<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Add Expense Categories</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_expense_categories = $fetch_stock['add_expense_categories'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_expense_categories == 1){
                    ?>
          <td><input onchange="add_expense_categories<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_expense_categories<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_expense_categories<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_expense_categories<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_expense_categories<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_expense_categories";
            if (document.getElementById('add_expense_categories<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Expenses Reports</td>
                                                    <?php

            if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_expense_Report = $fetch_stock['view_expense_Report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_expense_Report == 1){
                    ?>
          <td><input onchange="view_expense_Report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_expense_Report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_expense_Report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_expense_Report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_expense_Report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_expense_Report";
            if (document.getElementById('view_expense_Report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>
                                            <tr>
                                            <td>View Expenses Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_expense_branch = $fetch_stock['view_expense_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_expense_branch == 1){
                    ?>
          <td><input onchange="view_expense_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_expense_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_expense_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_expense_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_expense_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_expense_branch";
            if (document.getElementById('view_expense_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>







<tr>
                                            <td>Edit Expense Categories</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_expense_catgeories = $fetch_stock['edit_expense_catgeories'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_expense_catgeories == 1){
                    ?>
          <td><input onchange="edit_expense_catgeories<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_expense_catgeories<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_expense_catgeories<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_expense_catgeories<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_expense_catgeories<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_expense_catgeories";
            if (document.getElementById('edit_expense_catgeories<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Delete Expenses Categories</td>
                                                    <?php

            if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_expense_catgeories = $fetch_stock['delete_expense_catgeories'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_expense_catgeories == 1){
                    ?>
          <td><input onchange="delete_expense_catgeories<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_expense_catgeories<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_expense_catgeories<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_expense_catgeories<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_expense_catgeories<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_expense_catgeories";
            if (document.getElementById('delete_expense_catgeories<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Purchases Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_purchases_report = $fetch_stock['view_purchases_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_purchases_report == 1){
                    ?>
          <td><input onchange="view_purchases_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_purchases_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_purchases_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_purchases_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_purchases_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_purchases_report";
            if (document.getElementById('view_purchases_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>
<tr>
                                            <td>Filter Purchases Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_purchases_report = $fetch_stock['filter_purchases_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_purchases_report == 1){
                    ?>
          <td><input onchange="filter_purchases_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_purchases_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_purchases_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_purchases_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_purchases_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_purchases_report";
            if (document.getElementById('filter_purchases_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Purchases Return Button</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $purchases_return_button = $fetch_stock['purchases_return_button'];
                  $role_id = $fetch_stock['role_id'];
                if( $purchases_return_button == 1){
                    ?>
          <td><input onchange="purchases_return_button<?php echo $role_id; ?>(this.value)" type="checkbox" id="purchases_return_button<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="purchases_return_button<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="purchases_return_button<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function purchases_return_button<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="purchases_return_button";
            if (document.getElementById('purchases_return_button<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>New Purchases</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $new_purchases = $fetch_stock['new_purchases'];
                  $role_id = $fetch_stock['role_id'];
                if( $new_purchases == 1){
                    ?>
          <td><input onchange="new_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" id="new_purchases<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="new_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="new_purchases<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function new_purchases<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="new_purchases";
            if (document.getElementById('new_purchases<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>View Purchases Report Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $purchase_report_branch = $fetch_stock['purchase_report_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $purchase_report_branch == 1){
                    ?>
          <td><input onchange="purchase_report_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="purchase_report_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="purchase_report_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="purchase_report_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function purchase_report_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="purchase_report_branch";
            if (document.getElementById('purchase_report_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>









<tr>
                                            <td>View Individual Product Purchases</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_individaul_product_purchases = $fetch_stock['view_individaul_product_purchases'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_individaul_product_purchases == 1){
                    ?>
          <td><input onchange="view_individaul_product_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_individaul_product_purchases<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_individaul_product_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_individaul_product_purchases<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_individaul_product_purchases<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_individaul_product_purchases";
            if (document.getElementById('view_individaul_product_purchases<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Filter Individual Product Purchases</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_individual_product_purchases = $fetch_stock['filter_individual_product_purchases'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_individual_product_purchases == 1){
                    ?>
          <td><input onchange="filter_individual_product_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_individual_product_purchases<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_individual_product_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_individual_product_purchases<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_individual_product_purchases<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_individual_product_purchases";
            if (document.getElementById('filter_individual_product_purchases<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>New Individual Product Purchases</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $new_individual_product_purchases = $fetch_stock['new_individual_product_purchases'];
                  $role_id = $fetch_stock['role_id'];
                if( $new_individual_product_purchases == 1){
                    ?>
          <td><input onchange="new_individual_product_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" id="new_individual_product_purchases<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="new_individual_product_purchases<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="new_individual_product_purchases<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function new_individual_product_purchases<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="new_individual_product_purchases";
            if (document.getElementById('new_individual_product_purchases<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Creditors Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_creditors_report = $fetch_stock['view_creditors_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_creditors_report == 1){
                    ?>
          <td><input onchange="view_creditors_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_creditors_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_creditors_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_creditors_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_creditors_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_creditors_report";
            if (document.getElementById('view_creditors_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>










<tr>
                                            <td>Export Creditors Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_creditors_report = $fetch_stock['export_creditors_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_creditors_report == 1){
                    ?>
          <td><input onchange="export_creditors_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_creditors_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_creditors_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_creditors_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_creditors_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_creditors_report";
            if (document.getElementById('export_creditors_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>








<tr>
                                            <td>Creditors Pay Button</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $creditors_pay_button = $fetch_stock['creditors_pay_button'];
                  $role_id = $fetch_stock['role_id'];
                if( $creditors_pay_button == 1){
                    ?>
          <td><input onchange="creditors_pay_button<?php echo $role_id; ?>(this.value)" type="checkbox" id="creditors_pay_button<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="creditors_pay_button<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="creditors_pay_button<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function creditors_pay_button<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="creditors_pay_button";
            if (document.getElementById('creditors_pay_button<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>View Payment Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_payment_report = $fetch_stock['view_payment_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_payment_report == 1){
                    ?>
          <td><input onchange="view_payment_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_payment_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_payment_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_payment_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_payment_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_payment_report";
            if (document.getElementById('view_payment_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Filter Payment Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_payment_report = $fetch_stock['filter_payment_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_payment_report == 1){
                    ?>
          <td><input onchange="filter_payment_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_payment_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_payment_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_payment_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_payment_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_payment_report";
            if (document.getElementById('filter_payment_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Voucher</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_voucher = $fetch_stock['view_voucher'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_voucher == 1){
                    ?>
          <td><input onchange="view_voucher<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_voucher<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_voucher<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_voucher<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_voucher<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_voucher";
            if (document.getElementById('view_voucher<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Export Payment Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_payment_reports = $fetch_stock['export_payment_reports'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_payment_reports == 1){
                    ?>
          <td><input onchange="export_payment_reports<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_payment_reports<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_payment_reports<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_payment_reports<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_payment_reports<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_payment_reports";
            if (document.getElementById('export_payment_reports<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


                                                
                                    



<tr>
                                            <td>View Payment Logs Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_paymentlogs_branch = $fetch_stock['view_paymentlogs_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_paymentlogs_branch == 1){
                    ?>
          <td><input onchange="view_paymentlogs_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_paymentlogs_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_paymentlogs_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_paymentlogs_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_paymentlogs_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_paymentlogs_branch";
            if (document.getElementById('view_paymentlogs_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Transactions Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_transactions_report = $fetch_stock['view_transactions_report'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_transactions_report == 1){
                    ?>
          <td><input onchange="view_transactions_report<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_transactions_report<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_transactions_report<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_transactions_report<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_transactions_report<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_transactions_report";
            if (document.getElementById('view_transactions_report<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Filter Transactions Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_transactions_reports = $fetch_stock['filter_transactions_reports'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_transactions_reports == 1){
                    ?>
          <td><input onchange="filter_transactions_reports<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_transactions_reports<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_transactions_reports<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_transactions_reports<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_transactions_reports<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_transactions_reports";
            if (document.getElementById('filter_transactions_reports<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Export Transactions Report</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_transaction_reports = $fetch_stock['export_transaction_reports'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_transaction_reports == 1){
                    ?>
          <td><input onchange="export_transaction_reports<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_transaction_reports<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_transaction_reports<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_transaction_reports<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_transaction_reports<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_transaction_reports";
            if (document.getElementById('export_transaction_reports<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Transactions Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $transactions_branch = $fetch_stock['transactions_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $transactions_branch == 1){
                    ?>
          <td><input onchange="transactions_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="transactions_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="transactions_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="transactions_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function transactions_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="transactions_branch";
            if (document.getElementById('transactions_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Profit Analysis</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_profit_analysis = $fetch_stock['view_profit_analysis'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_profit_analysis == 1){
                    ?>
          <td><input onchange="view_profit_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_profit_analysis<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_profit_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_profit_analysis<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_profit_analysis<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_profit_analysis";
            if (document.getElementById('view_profit_analysis<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Profit Analysis By Graph</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $profit_analysis_by_graph = $fetch_stock['profit_analysis_by_graph'];
                  $role_id = $fetch_stock['role_id'];
                if( $profit_analysis_by_graph == 1){
                    ?>
          <td><input onchange="profit_analysis_by_graph<?php echo $role_id; ?>(this.value)" type="checkbox" id="profit_analysis_by_graph<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="profit_analysis_by_graph<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="profit_analysis_by_graph<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function profit_analysis_by_graph<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="profit_analysis_by_graph";
            if (document.getElementById('profit_analysis_by_graph<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Profit Analysis By Table</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $profit_analysis_by_table = $fetch_stock['profit_analysis_by_table'];
                  $role_id = $fetch_stock['role_id'];
                if( $profit_analysis_by_table == 1){
                    ?>
          <td><input onchange="profit_analysis_by_table<?php echo $role_id; ?>(this.value)" type="checkbox" id="profit_analysis_by_table<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="profit_analysis_by_table<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="profit_analysis_by_table<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function profit_analysis_by_table<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="profit_analysis_by_table";
            if (document.getElementById('profit_analysis_by_table<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Profit Analysis Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $profit_analysis_details = $fetch_stock['profit_analysis_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $profit_analysis_details == 1){
                    ?>
          <td><input onchange="profit_analysis_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="profit_analysis_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="profit_analysis_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="profit_analysis_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function profit_analysis_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="profit_analysis_details";
            if (document.getElementById('profit_analysis_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Filter Profit Analysis</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_profit_analysis = $fetch_stock['filter_profit_analysis'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_profit_analysis == 1){
                    ?>
          <td><input onchange="filter_profit_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_profit_analysis<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_profit_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_profit_analysis<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_profit_analysis<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_profit_analysis";
            if (document.getElementById('filter_profit_analysis<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Sales Analysis</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_sales_analysis = $fetch_stock['view_sales_analysis'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_sales_analysis == 1){
                    ?>
          <td><input onchange="view_sales_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_sales_analysis<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_sales_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_sales_analysis<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_sales_analysis<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_sales_analysis";
            if (document.getElementById('view_sales_analysis<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Sales Analysis By Graph</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_sales_analysis_by_Graph = $fetch_stock['view_sales_analysis_by_Graph'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_sales_analysis_by_Graph == 1){
                    ?>
          <td><input onchange="view_sales_analysis_by_Graph<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_sales_analysis_by_Graph<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_sales_analysis_by_Graph<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_sales_analysis_by_Graph<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_sales_analysis_by_Graph<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_sales_analysis_by_Graph";
            if (document.getElementById('view_sales_analysis_by_Graph<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Sales Analysis By Table</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $sales_by_table = $fetch_stock['sales_by_table'];
                  $role_id = $fetch_stock['role_id'];
                if( $sales_by_table == 1){
                    ?>
          <td><input onchange="sales_by_table<?php echo $role_id; ?>(this.value)" type="checkbox" id="sales_by_table<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="sales_by_table<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="sales_by_table<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function sales_by_table<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="sales_by_table";
            if (document.getElementById('sales_by_table<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Filter Sales Analysis</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_sales_analysis = $fetch_stock['filter_sales_analysis'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_sales_analysis == 1){
                    ?>
          <td><input onchange="filter_sales_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_sales_analysis<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_sales_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_sales_analysis<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_sales_analysis<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_sales_analysis";
            if (document.getElementById('filter_sales_analysis<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Sales Analysis Table Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $sales_analysis_details = $fetch_stock['sales_analysis_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $sales_analysis_details == 1){
                    ?>
          <td><input onchange="sales_analysis_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="sales_analysis_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="sales_analysis_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="sales_analysis_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function sales_analysis_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="sales_analysis_details";
            if (document.getElementById('sales_analysis_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Cash Analysis</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_cash_analysis = $fetch_stock['view_cash_analysis'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_cash_analysis == 1){
                    ?>
          <td><input onchange="view_cash_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_cash_analysis<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_cash_analysis<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_cash_analysis<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_cash_analysis<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_cash_analysis";
            if (document.getElementById('view_cash_analysis<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Cash Out</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $cash_out = $fetch_stock['cash_out'];
                  $role_id = $fetch_stock['role_id'];
                if( $cash_out == 1){
                    ?>
          <td><input onchange="cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" id="cash_out<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="cash_out<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function cash_out<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="cash_out";
            if (document.getElementById('cash_out<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>







<tr>
                                            <td>Filter Cash Out</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $filter_cash_out = $fetch_stock['filter_cash_out'];
                  $role_id = $fetch_stock['role_id'];
                if( $filter_cash_out == 1){
                    ?>
          <td><input onchange="filter_cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" id="filter_cash_out<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="filter_cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="filter_cash_out<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function filter_cash_out<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="filter_cash_out";
            if (document.getElementById('filter_cash_out<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>edit Cash Out</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_cash_out = $fetch_stock['edit_cash_out'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_cash_out == 1){
                    ?>
          <td><input onchange="edit_cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_cash_out<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_cash_out<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_cash_out<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_cash_out";
            if (document.getElementById('edit_cash_out<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Cash Out Export</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $cashout_export = $fetch_stock['cashout_export'];
                  $role_id = $fetch_stock['role_id'];
                if( $cashout_export == 1){
                    ?>
          <td><input onchange="cashout_export<?php echo $role_id; ?>(this.value)" type="checkbox" id="cashout_export<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="cashout_export<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="cashout_export<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function cashout_export<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="cashout_export";
            if (document.getElementById('cashout_export<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



       


<tr>
                                            <td>Add Cash Out</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_cash_out = $fetch_stock['add_cash_out'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_cash_out == 1){
                    ?>
          <td><input onchange="add_cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_cash_out<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_cash_out<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_cash_out<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_cash_out<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_cash_out";
            if (document.getElementById('add_cash_out<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



       


<tr>
                                            <td>Cash Out Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $cashout_branch = $fetch_stock['cashout_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $cashout_branch == 1){
                    ?>
          <td><input onchange="cashout_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="cashout_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="cashout_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="cashout_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function cashout_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="cashout_branch";
            if (document.getElementById('cashout_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Cash Out Action</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $cashout_action = $fetch_stock['cashout_action'];
                  $role_id = $fetch_stock['role_id'];
                if( $cashout_action == 1){
                    ?>
          <td><input onchange="cashout_action<?php echo $role_id; ?>(this.value)" type="checkbox" id="cashout_action<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="cashout_action<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="cashout_action<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function cashout_action<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="cashout_action";
            if (document.getElementById('cashout_action<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Cash At Hand Amount</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $cash_at_hand_amount = $fetch_stock['cash_at_hand_amount'];
                  $role_id = $fetch_stock['role_id'];
                if( $cash_at_hand_amount == 1){
                    ?>
          <td><input onchange="cash_at_hand_amount<?php echo $role_id; ?>(this.value)" type="checkbox" id="cash_at_hand_amount<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="cash_at_hand_amount<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="cash_at_hand_amount<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function cash_at_hand_amount<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="cash_at_hand_amount";
            if (document.getElementById('cash_at_hand_amount<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Cash At Hand</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $cash_at_hand = $fetch_stock['cash_at_hand'];
                  $role_id = $fetch_stock['role_id'];
                if( $cash_at_hand == 1){
                    ?>
          <td><input onchange="cash_at_hand<?php echo $role_id; ?>(this.value)" type="checkbox" id="cash_at_hand<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="cash_at_hand<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="cash_at_hand<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function cash_at_hand<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="cash_at_hand";
            if (document.getElementById('cash_at_hand<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Export Cash At Hand</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_cash_at_hand = $fetch_stock['export_cash_at_hand'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_cash_at_hand == 1){
                    ?>
          <td><input onchange="export_cash_at_hand<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_cash_at_hand<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_cash_at_hand<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_cash_at_hand<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_cash_at_hand<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_cash_at_hand";
            if (document.getElementById('export_cash_at_hand<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Short Expires</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_short_expiries = $fetch_stock['view_short_expiries'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_short_expiries == 1){
                    ?>
          <td><input onchange="view_short_expiries<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_short_expiries<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_short_expiries<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_short_expiries<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_short_expiries<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_short_expiries";
            if (document.getElementById('view_short_expiries<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Mark As Expired</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $mark_as_expired = $fetch_stock['mark_as_expired'];
                  $role_id = $fetch_stock['role_id'];
                if( $mark_as_expired == 1){
                    ?>
          <td><input onchange="mark_as_expired<?php echo $role_id; ?>(this.value)" type="checkbox" id="mark_as_expired<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="mark_as_expired<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="mark_as_expired<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function mark_as_expired<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="mark_as_expired";
            if (document.getElementById('mark_as_expired<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Edit Short Expires</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_short_expires = $fetch_stock['edit_short_expires'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_short_expires == 1){
                    ?>
          <td><input onchange="edit_short_expires<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_short_expires<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_short_expires<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_short_expires<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_short_expires<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_short_expires";
            if (document.getElementById('edit_short_expires<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Export Short Expires</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_short_expires = $fetch_stock['export_short_expires'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_short_expires == 1){
                    ?>
          <td><input onchange="export_short_expires<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_short_expires<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_short_expires<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_short_expires<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_short_expires<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_short_expires";
            if (document.getElementById('export_short_expires<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Logs</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_logs = $fetch_stock['view_logs'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_logs == 1){
                    ?>
          <td><input onchange="view_logs<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_logs<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_logs<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_logs<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_logs<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_logs";
            if (document.getElementById('view_logs<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Businesses</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_business = $fetch_stock['view_business'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_business == 1){
                    ?>
          <td><input onchange="view_business<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_business<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_business<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_business<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_business<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_business";
            if (document.getElementById('view_business<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Users</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_users = $fetch_stock['view_users'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_users == 1){
                    ?>
          <td><input onchange="view_users<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_users<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_users<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_users<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_users<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_users";
            if (document.getElementById('view_users<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Dashboard </td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_dashboard = $fetch_stock['view_dashboard'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_dashboard == 1){
                    ?>
          <td><input onchange="view_dashboard<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_dashboard<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_dashboard<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_dashboard<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_dashboard<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_dashboard";
            if (document.getElementById('view_dashboard<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Dashboard Header </td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_dashboard_creditors = $fetch_stock['view_dashboard_creditors'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_dashboard_creditors == 1){
                    ?>
          <td><input onchange="view_dashboard_creditors<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_dashboard_creditors<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_dashboard_creditors<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_dashboard_creditors<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_dashboard_creditors<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_dashboard_creditors";
            if (document.getElementById('view_dashboard_creditors<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Dashboard Business Summary </td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_dashboard_business_summary = $fetch_stock['view_dashboard_business_summary'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_dashboard_business_summary == 1){
                    ?>
          <td><input onchange="view_dashboard_business_summary<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_dashboard_business_summary<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_dashboard_business_summary<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_dashboard_business_summary<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_dashboard_business_summary<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_dashboard_business_summary";
            if (document.getElementById('view_dashboard_business_summary<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Dashboard New Orders</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dashboard_new_orders = $fetch_stock['dashboard_new_orders'];
                  $role_id = $fetch_stock['role_id'];
                if( $dashboard_new_orders == 1){
                    ?>
          <td><input onchange="dashboard_new_orders<?php echo $role_id; ?>(this.value)" type="checkbox" id="dashboard_new_orders<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dashboard_new_orders<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dashboard_new_orders<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dashboard_new_orders<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dashboard_new_orders";
            if (document.getElementById('dashboard_new_orders<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Dashboard Managment Stock</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dashboard_managment_stock = $fetch_stock['dashboard_managment_stock'];
                  $role_id = $fetch_stock['role_id'];
                if( $dashboard_managment_stock == 1){
                    ?>
          <td><input onchange="dashboard_managment_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="dashboard_managment_stock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dashboard_managment_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dashboard_managment_stock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dashboard_managment_stock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dashboard_managment_stock";
            if (document.getElementById('dashboard_managment_stock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Dashboard Manage Expenses</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_mahange_expense = $fetch_stock['dash_mahange_expense'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_mahange_expense == 1){
                    ?>
          <td><input onchange="dash_mahange_expense<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_mahange_expense<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_mahange_expense<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_mahange_expense<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_mahange_expense<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_mahange_expense";
            if (document.getElementById('dash_mahange_expense<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Most Demanaded Product Graph</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $most_demanded_prod_graph = $fetch_stock['most_demanded_prod_graph'];
                  $role_id = $fetch_stock['role_id'];
                if( $most_demanded_prod_graph == 1){
                    ?>
          <td><input onchange="most_demanded_prod_graph<?php echo $role_id; ?>(this.value)" type="checkbox" id="most_demanded_prod_graph<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="most_demanded_prod_graph<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="most_demanded_prod_graph<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function most_demanded_prod_graph<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="most_demanded_prod_graph";
            if (document.getElementById('most_demanded_prod_graph<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Sales Summary Graph</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $sales_summary_graph = $fetch_stock['sales_summary_graph'];
                  $role_id = $fetch_stock['role_id'];
                if( $sales_summary_graph == 1){
                    ?>
          <td><input onchange="sales_summary_graph<?php echo $role_id; ?>(this.value)" type="checkbox" id="sales_summary_graph<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="sales_summary_graph<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="sales_summary_graph<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function sales_summary_graph<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="sales_summary_graph";
            if (document.getElementById('sales_summary_graph<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Notifications</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_notification = $fetch_stock['view_notification'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_notification == 1){
                    ?>
          <td><input onchange="view_notification<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_notification<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_notification<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_notification<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_notification<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_notification";
            if (document.getElementById('view_notification<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Settings</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_settings = $fetch_stock['view_settings'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_settings == 1){
                    ?>
          <td><input onchange="view_settings<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_settings<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_settings<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_settings<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_settings<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_settings";
            if (document.getElementById('view_settings<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Settings_business</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_settings_business = $fetch_stock['nav_settings_business'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_settings_business == 1){
                    ?>
          <td><input onchange="nav_settings_business<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_settings_business<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_settings_business<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_settings_business<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_settings_business<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_settings_business";
            if (document.getElementById('nav_settings_business<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Settings Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_settings_branch = $fetch_stock['nav_settings_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_settings_branch == 1){
                    ?>
          <td><input onchange="nav_settings_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_settings_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_settings_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_settings_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_settings_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_settings_branch";
            if (document.getElementById('nav_settings_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Add New Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_add_new_branch = $fetch_stock['view_add_new_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_add_new_branch == 1){
                    ?>
          <td><input onchange="view_add_new_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_add_new_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_add_new_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_add_new_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_add_new_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_add_new_branch";
            if (document.getElementById('view_add_new_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Export Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_export_branches = $fetch_stock['view_export_branches'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_export_branches == 1){
                    ?>
          <td><input onchange="view_export_branches<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_export_branches<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_export_branches<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_export_branches<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_export_branches<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_export_branches";
            if (document.getElementById('view_export_branches<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Branch Action</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_branch_action = $fetch_stock['view_branch_action'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_branch_action == 1){
                    ?>
          <td><input onchange="view_branch_action<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_branch_action<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_branch_action<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_branch_action<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_branch_action<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_branch_action";
            if (document.getElementById('view_branch_action<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Branch Activate Button</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_branch_activate = $fetch_stock['view_branch_activate'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_branch_activate == 1){
                    ?>
          <td><input onchange="view_branch_activate<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_branch_activate<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_branch_activate<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_branch_activate<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_branch_activate<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_branch_activate";
            if (document.getElementById('view_branch_activate<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>







<tr>
                                            <td>View Advanced</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_advanced = $fetch_stock['view_advanced'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_advanced == 1){
                    ?>
          <td><input onchange="view_advanced<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_advanced<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_advanced<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_advanced<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_advanced<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_advanced";
            if (document.getElementById('view_advanced<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>View Accounts</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_accounts = $fetch_stock['view_accounts'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_accounts == 1){
                    ?>
          <td><input onchange="view_accounts<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_accounts<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_accounts<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_accounts<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_accounts<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_accounts";
            if (document.getElementById('view_accounts<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>View Users</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_users = $fetch_stock['nav_users'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_users == 1){
                    ?>
          <td><input onchange="nav_users<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_users<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_users<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_users<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_users<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_users";
            if (document.getElementById('nav_users<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Add Users</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_user = $fetch_stock['add_user'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_user == 1){
                    ?>
          <td><input onchange="add_user<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_user<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_user<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_user<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_user<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_user";
            if (document.getElementById('add_user<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Edit Users</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_user = $fetch_stock['edit_user'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_user == 1){
                    ?>
          <td><input onchange="edit_user<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_user<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_user<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_user<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_user<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_user";
            if (document.getElementById('edit_user<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Suspend Users</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $suspend_user = $fetch_stock['suspend_user'];
                  $role_id = $fetch_stock['role_id'];
                if( $suspend_user == 1){
                    ?>
          <td><input onchange="suspend_user<?php echo $role_id; ?>(this.value)" type="checkbox" id="suspend_user<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="suspend_user<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="suspend_user<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function suspend_user<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="suspend_user";
            if (document.getElementById('suspend_user<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Delete Users</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_user = $fetch_stock['delete_user'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_user == 1){
                    ?>
          <td><input onchange="delete_user<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_user<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_user<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_user<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_user<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_user";
            if (document.getElementById('delete_user<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>
                                                                                        </tr>

<tr>
                                            <td>Return User</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $Return_user = $fetch_stock['Return_user'];
                  $role_id = $fetch_stock['role_id'];
                if( $Return_user == 1){
                    ?>
          <td><input onchange="Return_user<?php echo $role_id; ?>(this.value)" type="checkbox" id="Return_user<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="Return_user<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="Return_user<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function Return_user<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="Return_user";
            if (document.getElementById('Return_user<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Users Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_users_branch = $fetch_stock['view_users_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_users_branch == 1){
                    ?>
          <td><input onchange="view_users_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_users_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_users_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_users_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_users_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_users_branch";
            if (document.getElementById('view_users_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Suppliers</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_suppliers = $fetch_stock['nav_suppliers'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_suppliers == 1){
                    ?>
          <td><input onchange="nav_suppliers<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_suppliers<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_suppliers<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_suppliers<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_suppliers<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_suppliers";
            if (document.getElementById('nav_suppliers<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Add Suppliers</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_supllier = $fetch_stock['add_supllier'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_supllier == 1){
                    ?>
          <td><input onchange="add_supllier<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_supllier<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_supllier<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_supllier<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_supllier<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_supllier";
            if (document.getElementById('add_supllier<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Edit Suppliers</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_supplier = $fetch_stock['edit_supplier'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_supplier == 1){
                    ?>
          <td><input onchange="edit_supplier<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_supplier<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_supplier<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_supplier<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_supplier<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_supplier";
            if (document.getElementById('edit_supplier<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Suspend Suppliers</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $suspend_supplier = $fetch_stock['suspend_supplier'];
                  $role_id = $fetch_stock['role_id'];
                if( $suspend_supplier == 1){
                    ?>
          <td><input onchange="suspend_supplier<?php echo $role_id; ?>(this.value)" type="checkbox" id="suspend_supplier<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="suspend_supplier<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="suspend_supplier<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function suspend_supplier<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="suspend_supplier";
            if (document.getElementById('suspend_supplier<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Edit Supplier</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_supplier = $fetch_stock['delete_supplier'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_supplier == 1){
                    ?>
          <td><input onchange="delete_supplier<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_supplier<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_supplier<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_supplier<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_supplier<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_supplier";
            if (document.getElementById('delete_supplier<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Supplier Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $supplier_branch = $fetch_stock['supplier_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $supplier_branch == 1){
                    ?>
          <td><input onchange="supplier_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="supplier_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="supplier_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="supplier_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function supplier_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="supplier_branch";
            if (document.getElementById('supplier_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Nav Products</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_products = $fetch_stock['nav_products'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_products == 1){
                    ?>
          <td><input onchange="nav_products<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_products<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_products<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_products<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_products<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_products";
            if (document.getElementById('nav_products<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Products Admin Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $products_admin_branch = $fetch_stock['products_admin_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $products_admin_branch == 1){
                    ?>
          <td><input onchange="products_admin_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="products_admin_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="products_admin_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="products_admin_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function products_admin_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="products_admin_branch";
            if (document.getElementById('products_admin_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Nav Units</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_units = $fetch_stock['nav_units'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_units == 1){
                    ?>
          <td><input onchange="nav_units<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_units<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_units<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_units<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_units<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_units";
            if (document.getElementById('nav_units<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Add Units</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_unit = $fetch_stock['add_unit'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_unit == 1){
                    ?>
          <td><input onchange="add_unit<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_unit<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_unit<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_unit<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_unit<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_unit";
            if (document.getElementById('add_unit<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Edit Units</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_unit = $fetch_stock['edit_unit'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_unit == 1){
                    ?>
          <td><input onchange="edit_unit<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_unit<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_unit<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_unit<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_unit<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_unit";
            if (document.getElementById('edit_unit<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Delete Units</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_unit = $fetch_stock['delete_unit'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_unit == 1){
                    ?>
          <td><input onchange="delete_unit<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_unit<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_unit<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_unit<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_unit<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_unit";
            if (document.getElementById('delete_unit<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td> Units Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $units_branch = $fetch_stock['units_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $units_branch == 1){
                    ?>
          <td><input onchange="units_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="units_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="units_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="units_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function units_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="units_branch";
            if (document.getElementById('units_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>View  Staff</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_staff = $fetch_stock['view_staff'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_staff == 1){
                    ?>
          <td><input onchange="view_staff<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_staff<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_staff<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_staff<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_staff<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_staff";
            if (document.getElementById('view_staff<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Set Staff Role</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $set_staff_role = $fetch_stock['set_staff_role'];
                  $role_id = $fetch_stock['role_id'];
                if( $set_staff_role == 1){
                    ?>
          <td><input onchange="set_staff_role<?php echo $role_id; ?>(this.value)" type="checkbox" id="set_staff_role<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="set_staff_role<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="set_staff_role<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function set_staff_role<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="set_staff_role";
            if (document.getElementById('set_staff_role<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>

<tr>
                                            <td>View Staff Branch</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $staff_branch = $fetch_stock['staff_branch'];
                  $role_id = $fetch_stock['role_id'];
                if( $staff_branch == 1){
                    ?>
          <td><input onchange="staff_branch<?php echo $role_id; ?>(this.value)" type="checkbox" id="staff_branch<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="staff_branch<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="staff_branch<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function staff_branch<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="staff_branch";
            if (document.getElementById('staff_branch<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Edit Staff</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_staff = $fetch_stock['edit_staff'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_staff == 1){
                    ?>
          <td><input onchange="edit_staff<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_staff<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_staff<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_staff<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_staff<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_staff";
            if (document.getElementById('edit_staff<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Delete Staff</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $delete_staff = $fetch_stock['delete_staff'];
                  $role_id = $fetch_stock['role_id'];
                if( $delete_staff == 1){
                    ?>
          <td><input onchange="delete_staff<?php echo $role_id; ?>(this.value)" type="checkbox" id="delete_staff<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="delete_staff<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="delete_staff<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function delete_staff<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="delete_staff";
            if (document.getElementById('delete_staff<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Suspend Staff</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $suspend_staff = $fetch_stock['suspend_staff'];
                  $role_id = $fetch_stock['role_id'];
                if( $suspend_staff == 1){
                    ?>
          <td><input onchange="suspend_staff<?php echo $role_id; ?>(this.value)" type="checkbox" id="suspend_staff<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="suspend_staff<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="suspend_staff<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function suspend_staff<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="suspend_staff";
            if (document.getElementById('suspend_staff<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Reciepts</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_reciepts = $fetch_stock['nav_reciepts'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_reciepts == 1){
                    ?>
          <td><input onchange="nav_reciepts<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_reciepts<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_reciepts<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_reciepts<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_reciepts<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_reciepts";
            if (document.getElementById('nav_reciepts<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Update Reciepts</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $update_reciepts = $fetch_stock['update_reciepts'];
                  $role_id = $fetch_stock['role_id'];
                if( $update_reciepts == 1){
                    ?>
          <td><input onchange="update_reciepts<?php echo $role_id; ?>(this.value)" type="checkbox" id="update_reciepts<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="update_reciepts<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="update_reciepts<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function update_reciepts<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="update_reciepts";
            if (document.getElementById('update_reciepts<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Advanced</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_advanced = $fetch_stock['nav_advanced'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_advanced == 1){
                    ?>
          <td><input onchange="nav_advanced<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_advanced<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_advanced<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_advanced<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_advanced<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_advanced";
            if (document.getElementById('nav_advanced<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Product Arrangment</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_product_arrangment = $fetch_stock['view_product_arrangment'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_product_arrangment == 1){
                    ?>
          <td><input onchange="view_product_arrangment<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_product_arrangment<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_product_arrangment<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_product_arrangment<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_product_arrangment<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_product_arrangment";
            if (document.getElementById('view_product_arrangment<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Other Settings</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $other_settings = $fetch_stock['other_settings'];
                  $role_id = $fetch_stock['role_id'];
                if( $other_settings == 1){
                    ?>
          <td><input onchange="other_settings<?php echo $role_id; ?>(this.value)" type="checkbox" id="other_settings<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="other_settings<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="other_settings<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function other_settings<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="other_settings";
            if (document.getElementById('other_settings<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>








<tr>
                                            <td>Update Product Arrangment</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $update_prod_arrangment = $fetch_stock['update_prod_arrangment'];
                  $role_id = $fetch_stock['role_id'];
                if( $update_prod_arrangment == 1){
                    ?>
          <td><input onchange="update_prod_arrangment<?php echo $role_id; ?>(this.value)" type="checkbox" id="update_prod_arrangment<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="update_prod_arrangment<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="update_prod_arrangment<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function update_prod_arrangment<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="update_prod_arrangment";
            if (document.getElementById('update_prod_arrangment<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Save Other Setttings</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $save_other_settings = $fetch_stock['save_other_settings'];
                  $role_id = $fetch_stock['role_id'];
                if( $save_other_settings == 1){
                    ?>
          <td><input onchange="save_other_settings<?php echo $role_id; ?>(this.value)" type="checkbox" id="save_other_settings<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="save_other_settings<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="save_other_settings<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function save_other_settings<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="save_other_settings";
            if (document.getElementById('save_other_settings<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Settings Store</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_settings_store = $fetch_stock['nav_settings_store'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_settings_store == 1){
                    ?>
          <td><input onchange="nav_settings_store<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_settings_store<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_settings_store<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_settings_store<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_settings_store<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_settings_store";
            if (document.getElementById('nav_settings_store<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Add to Store</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_add_to_store = $fetch_stock['nav_add_to_store'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_add_to_store == 1){
                    ?>
          <td><input onchange="nav_add_to_store<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_add_to_store<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_add_to_store<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_add_to_store<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_add_to_store<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_add_to_store";
            if (document.getElementById('nav_add_to_store<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Edit Store Quantity</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $edit_store_quantity = $fetch_stock['edit_store_quantity'];
                  $role_id = $fetch_stock['role_id'];
                if( $edit_store_quantity == 1){
                    ?>
          <td><input onchange="edit_store_quantity<?php echo $role_id; ?>(this.value)" type="checkbox" id="edit_store_quantity<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="edit_store_quantity<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="edit_store_quantity<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function edit_store_quantity<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="edit_store_quantity";
            if (document.getElementById('edit_store_quantity<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Store Logs</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $store_logs = $fetch_stock['store_logs'];
                  $role_id = $fetch_stock['role_id'];
                if( $store_logs == 1){
                    ?>
          <td><input onchange="store_logs<?php echo $role_id; ?>(this.value)" type="checkbox" id="store_logs<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="store_logs<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="store_logs<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function store_logs<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="store_logs";
            if (document.getElementById('store_logs<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


 <tr>
                                            <td>Settings Empties</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_settings_empties = $fetch_stock['nav_settings_empties'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_settings_empties == 1){
                    ?>
          <td><input onchange="nav_settings_empties<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_settings_empties<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_settings_empties<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_settings_empties<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_settings_empties<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_settings_empties";
            if (document.getElementById('nav_settings_empties<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


 <tr>
                                            <td>Empties Customer</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $empties_customer = $fetch_stock['empties_customer'];
                  $role_id = $fetch_stock['role_id'];
                if( $empties_customer == 1){
                    ?>
          <td><input onchange="empties_customer<?php echo $role_id; ?>(this.value)" type="checkbox" id="empties_customer<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="empties_customer<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="empties_customer<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function empties_customer<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="empties_customer";
            if (document.getElementById('empties_customer<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


 <tr>
                                            <td>Empties Categories</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $empties_categories = $fetch_stock['empties_categories'];
                  $role_id = $fetch_stock['role_id'];
                if( $empties_categories == 1){
                    ?>
          <td><input onchange="empties_categories<?php echo $role_id; ?>(this.value)" type="checkbox" id="empties_categories<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="empties_categories<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="empties_categories<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function empties_categories<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="empties_categories";
            if (document.getElementById('empties_categories<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



 <tr>
                                            <td>Add Taken Categories</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $add_taken_crates = $fetch_stock['add_taken_crates'];
                  $role_id = $fetch_stock['role_id'];
                if( $add_taken_crates == 1){
                    ?>
          <td><input onchange="add_taken_crates<?php echo $role_id; ?>(this.value)" type="checkbox" id="add_taken_crates<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="add_taken_crates<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="add_taken_crates<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function add_taken_crates<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="add_taken_crates";
            if (document.getElementById('add_taken_crates<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



 <tr>
                                            <td>Crates Export</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $export_crates = $fetch_stock['export_crates'];
                  $role_id = $fetch_stock['role_id'];
                if( $export_crates == 1){
                    ?>
          <td><input onchange="export_crates<?php echo $role_id; ?>(this.value)" type="checkbox" id="export_crates<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="export_crates<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="export_crates<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function export_crates<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="export_crates";
            if (document.getElementById('export_crates<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Settings Exchange Rate</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $nav_settings_exchange_rate = $fetch_stock['nav_settings_exchange_rate'];
                  $role_id = $fetch_stock['role_id'];
                if( $nav_settings_exchange_rate == 1){
                    ?>
          <td><input onchange="nav_settings_exchange_rate<?php echo $role_id; ?>(this.value)" type="checkbox" id="nav_settings_exchange_rate<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="nav_settings_exchange_rate<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="nav_settings_exchange_rate<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function nav_settings_exchange_rate<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="nav_settings_exchange_rate";
            if (document.getElementById('nav_settings_exchange_rate<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Daily Summary</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_daily_summary = $fetch_stock['view_daily_summary'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_daily_summary == 1){
                    ?>
          <td><input onchange="view_daily_summary<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_daily_summary<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_daily_summary<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_daily_summary<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_daily_summary<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_daily_summary";
            if (document.getElementById('view_daily_summary<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Total Sales</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $total_sales = $fetch_stock['total_sales'];
                  $role_id = $fetch_stock['role_id'];
                if( $total_sales == 1){
                    ?>
          <td><input onchange="total_sales<?php echo $role_id; ?>(this.value)" type="checkbox" id="total_sales<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="total_sales<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="total_sales<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function total_sales<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="total_sales";
            if (document.getElementById('total_sales<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Total Sales Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $total_sales_details = $fetch_stock['total_sales_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $total_sales_details == 1){
                    ?>
          <td><input onchange="total_sales_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="total_sales_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="total_sales_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="total_sales_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function total_sales_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="total_sales_details";
            if (document.getElementById('total_sales_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>

<tr>
                                            <td>Credit Sales</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $credit_sales = $fetch_stock['credit_sales'];
                  $role_id = $fetch_stock['role_id'];
                if( $credit_sales == 1){
                    ?>
          <td><input onchange="credit_sales<?php echo $role_id; ?>(this.value)" type="checkbox" id="credit_sales<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="credit_sales<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="credit_sales<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function credit_sales<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="credit_sales";
            if (document.getElementById('credit_sales<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>


<tr>
                                            <td>Dashboard Credit Sales Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $credit_sales_details = $fetch_stock['credit_sales_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $credit_sales_details == 1){
                    ?>
          <td><input onchange="credit_sales_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="credit_sales_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="credit_sales_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="credit_sales_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function credit_sales_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="credit_sales_details";
            if (document.getElementById('credit_sales_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Credit Paid</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $credits_paid = $fetch_stock['credits_paid'];
                  $role_id = $fetch_stock['role_id'];
                if( $credits_paid == 1){
                    ?>
          <td><input onchange="credits_paid<?php echo $role_id; ?>(this.value)" type="checkbox" id="credits_paid<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="credits_paid<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="credits_paid<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function credits_paid<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="credits_paid";
            if (document.getElementById('credits_paid<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>Dashboard Credit Paid Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $credits_paid_details = $fetch_stock['credits_paid_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $credits_paid_details == 1){
                    ?>
          <td><input onchange="credits_paid_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="credits_paid_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="credits_paid_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="credits_paid_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function credits_paid_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="credits_paid_details";
            if (document.getElementById('credits_paid_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Expenses</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $expenses = $fetch_stock['expenses'];
                  $role_id = $fetch_stock['role_id'];
                if( $expenses == 1){
                    ?>
          <td><input onchange="expenses<?php echo $role_id; ?>(this.value)" type="checkbox" id="expenses<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="expenses<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="expenses<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function expenses<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="expenses";
            if (document.getElementById('expenses<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Dash Expenses Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_expense_details = $fetch_stock['dash_expense_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_expense_details == 1){
                    ?>
          <td><input onchange="dash_expense_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_expense_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_expense_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_expense_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_expense_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_expense_details";
            if (document.getElementById('dash_expense_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Dashboard Cash At Hand</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_cash_at_hand = $fetch_stock['dash_cash_at_hand'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_cash_at_hand == 1){
                    ?>
          <td><input onchange="dash_cash_at_hand<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_cash_at_hand<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_cash_at_hand<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_cash_at_hand<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_cash_at_hand<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_cash_at_hand";
            if (document.getElementById('dash_cash_at_hand<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>Dashboard Cash At Hand Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_cash_at_hand_details = $fetch_stock['dash_cash_at_hand_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_cash_at_hand_details == 1){
                    ?>
          <td><input onchange="dash_cash_at_hand_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_cash_at_hand_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_cash_at_hand_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_cash_at_hand_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_cash_at_hand_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_cash_at_hand_details";
            if (document.getElementById('dash_cash_at_hand_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View General Summary</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_general_summary = $fetch_stock['view_general_summary'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_general_summary == 1){
                    ?>
          <td><input onchange="view_general_summary<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_general_summary<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_general_summary<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_general_summary<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_general_summary<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_general_summary";
            if (document.getElementById('view_general_summary<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Stock Value</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_stock_value = $fetch_stock['view_stock_value'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_stock_value == 1){
                    ?>
          <td><input onchange="view_stock_value<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_stock_value<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_stock_value<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_stock_value<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_stock_value<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_stock_value";
            if (document.getElementById('view_stock_value<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Stock Value Deatils</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_stock_value_details = $fetch_stock['view_stock_value_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_stock_value_details == 1){
                    ?>
          <td><input onchange="view_stock_value_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_stock_value_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_stock_value_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_stock_value_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_stock_value_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_stock_value_details";
            if (document.getElementById('view_stock_value_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>Stock Value Deatils</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $stock_value_details = $fetch_stock['stock_value_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $stock_value_details == 1){
                    ?>
          <td><input onchange="stock_value_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="stock_value_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="stock_value_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="stock_value_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function stock_value_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="stock_value_details";
            if (document.getElementById('stock_value_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>






<tr>
                                            <td>View Dashboard Creditors</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_creditors = $fetch_stock['dash_creditors'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_creditors == 1){
                    ?>
          <td><input onchange="dash_creditors<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_creditors<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_creditors<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_creditors<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_creditors<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_creditors";
            if (document.getElementById('dash_creditors<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>Creditors Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $creditors_details = $fetch_stock['creditors_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $creditors_details == 1){
                    ?>
          <td><input onchange="creditors_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="creditors_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="creditors_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="creditors_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function creditors_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="creditors_details";
            if (document.getElementById('creditors_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>




<tr>
                                            <td>View Dashboard Instock</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_instock = $fetch_stock['dash_instock'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_instock == 1){
                    ?>
          <td><input onchange="dash_instock<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_instock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_instock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_instock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_instock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_instock";
            if (document.getElementById('dash_instock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Dashboard Instock Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_instock_details = $fetch_stock['dash_instock_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_instock_details == 1){
                    ?>
          <td><input onchange="dash_instock_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_instock_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_instock_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_instock_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_instock_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_instock_details";
            if (document.getElementById('dash_instock_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>





<tr>
                                            <td>View Dashboard Out Of stock</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_out_of_stock = $fetch_stock['dash_out_of_stock'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_out_of_stock == 1){
                    ?>
          <td><input onchange="dash_out_of_stock<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_out_of_stock<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_out_of_stock<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_out_of_stock<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_out_of_stock<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_out_of_stock";
            if (document.getElementById('dash_out_of_stock<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



<tr>
                                            <td>View Dashboard Out Of stock Details</td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $dash_out_of_stock_details = $fetch_stock['dash_out_of_stock_details'];
                  $role_id = $fetch_stock['role_id'];
                if( $dash_out_of_stock_details == 1){
                    ?>
          <td><input onchange="dash_out_of_stock_details<?php echo $role_id; ?>(this.value)" type="checkbox" id="dash_out_of_stock_details<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="dash_out_of_stock_details<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="dash_out_of_stock_details<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function dash_out_of_stock_details<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="dash_out_of_stock_details";
            if (document.getElementById('dash_out_of_stock_details<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>

<tr>
                                            <td>View Permissions </td>
                                                    <?php

             if ($_SESSION['branch_id']==0){ 
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business'");
        }else{
          $permission_roles = mysqli_query($con,"SELECT * FROM permissions  WHERE business_id='$business' AND branch_id='$branch'");

        }  
            while ( $fetch_stock = mysqli_fetch_array($permission_roles)) {
                $view_permissions = $fetch_stock['view_permissions'];
                  $role_id = $fetch_stock['role_id'];
                if( $view_permissions == 1){
                    ?>
          <td><input onchange="view_permissions<?php echo $role_id; ?>(this.value)" type="checkbox" id="view_permissions<?php echo $role_id; ?>" checked=""></td>
                    <?php
                }else{
                    ?>
          <td><input onchange="view_permissions<?php echo $role_id; ?>(this.value)" type="checkbox" name="" id="view_permissions<?php echo $role_id; ?>"></td>

                    <?php
                }
           
                                                    ?>
                                                   <script type="text/javascript">
        function view_permissions<?php echo $role_id; ?>(){
     
        var roleid ="<?php echo$role_id; ?>";

        var column="view_permissions";
            if (document.getElementById('view_permissions<?php echo $role_id; ?>').checked==true) {
                var state = 1;
            }else{
                var state = 0
            }
        document.getElementById('text').innerHTML="ID ="+roleid+" column="+column+" status="+state;
        var xhttp = new XMLHttpRequest();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
           // Typical action to be performed when the document is ready:
           document.getElementById("text").innerHTML = xhttp.responseText;
        }else{
            document.getElementById('text').innerHTML="No responseText";
        }
    };
    xhttp.open("GET", "status_updater.php?id="+roleid+"&column="+column+"&status="+state, true);
    xhttp.send();
        }
    </script>
                                                    <?php
                                                }
                                                    ?>
                                                
                                                
                                            </tr>



                                        </tbody>
                                    </table>
                                  </div>
                                    
                                </div>
                            </div>
                        </div>
                        <!-- /block -->
                    </div>
                </div>
            </div>
            <hr>
            <?php include '../includes/footer.php'; ?>
        </div>
        <!--/.fluid-container-->

        <!--==========Footer js======-->
    <?php require_once("../includes/footerjs.php");?>
        <!--==========Footer js======-->
       
 


<script src="../data-table-js/bootstrap-table.js"></script>
    <script src="../data-table-js/tableExport.js"></script>
    <script src="../data-table-js/data-table-active.js"></script>
    <script src="../data-table-js/bootstrap-table-editable.js"></script>
    <script src="../data-table-js/bootstrap-editable.js"></script>
    <script src="../data-table-js/bootstrap-table-resizable.js"></script>
    <script src="../data-table-js/colResizable-1.5.source.js"></script>
    <script src="../data-table-js/bootstrap-table-export.js"></script>
    </body>

<?php


if(isset($_POST['submit'])){
    include '../includes/connection.php';
//$date=mysqli_real_escape_string($con,ucwords($_POST['date']));
//$reason=mysqli_real_escape_string($con,$_POST['role']);
$role=mysqli_real_escape_string($con,$_POST['role']);
$branches=mysqli_real_escape_string($con,$_POST['brancheses']);

//$pickedby=mysqli_real_escape_string($con,ucwords($_POST['pickedby']));

// $bad_symbols = array(",");
   
//     $amount=$_POST['amount'];
//     $amount= str_replace($bad_symbols, "", $amount);
$id_user=$_SESSION['id'];

$business=$_SESSION['business_id'];

// if($amount>$cash_at_hand){
//     echo"<script>alert('Failed!. The amount of $amount to be cashed out cannot be greater than the cash at hand of shs $cash_at_hand !!. Correct your inputs'),history.go(-1)</script>";
// }
// else{
$sql = mysqli_query($con,"INSERT INTO permissions (role,branch_id,business_id)
VALUES ('$role', '$branches','$business')");



if ($sql) {


    $id_user=$_SESSION['id'];
  $activity="Added a new role called".$role;
  $log_sql=mysqli_query($con,"INSERT INTO logs(user_id, activity,branch_id) VALUES 
('$id_user','$activity','$branches')");

  if ($log_sql) {
    ?>
<script>window.location="permissions.php"</script>
    <?php

  }
    

} else {
    echo "Error: " . $sql . "<br>" . mysqli_error($con);
}
 mysqli_close($con);
}
?>

</html>





