<?php
session_start();
if(!isset ($_SESSION['user_id'])){
    header("Location:../login.php?msg=Log in first");
    exit();
}else{
	include('../Server/connection.php');
	include('includes/session.php');
?>


<!DOCTYPE html>
<html lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <?php
	include 'title.php';
	?>
	
	<link type = "image/png" rel="icon" href="images/kreen.png" />

    <!-- Bootstrap -->
    <link href="../vendors/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Font Awesome -->
    <link href="../vendors/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <!-- NProgress -->
    <link href="../vendors/nprogress/nprogress.css" rel="stylesheet">
	
	 <!-- bootstrap-daterangepicker -->
    <link href="../vendors/bootstrap-daterangepicker/daterangepicker.css" rel="stylesheet">
    <!-- bootstrap-datetimepicker -->
    <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
	
	<!-- bootstrap-datetimepicker -->
    <link href="../vendors/bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.css" rel="stylesheet">
    
    <!-- Custom Theme Style -->
    <link href="../build/css/custom.min.css" rel="stylesheet">
	
	<style>
  .error {
    color: #F00;
}  

.cont80 { 
border:2px solid #ccc; width:100%; height: 300px; overflow-y: scroll; overflow-x: scroll;
}


/* The container */
.container12 {
  display: block;
  position: relative;
  padding-left: 35px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 12px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Hide the browser's default checkbox */
.container12 input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* Create a custom checkbox */
.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 25px;
  width: 25px;
  background-color: #eee;
}

/* On mouse-over, add a grey background color */
.container12:hover input ~ .checkmark {
  background-color: #ccc;
}

/* When the checkbox is checked, add a blue background */
.container12 input:checked ~ .checkmark {
  background-color: #2196F3;
}

/* Create the checkmark/indicator (hidden when not checked) */
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

/* Show the checkmark when checked */
.container12 input:checked ~ .checkmark:after {
  display: block;
}

/* Style the checkmark/indicator */
.container12 .checkmark:after {
  left: 9px;
  top: 5px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 3px 3px 0;
  -webkit-transform: rotate(45deg);
  -ms-transform: rotate(45deg);
  transform: rotate(45deg);
}


</style>

	
	
	
  </head>

  <body class="nav-md">
  
    <div class="container body">
	
    <?php
	//include 'header.php';
	?>
	
      <div class="main_container">
        <div class="col-md-3 left_col">
          <div class="left_col scroll-view">
		  
            <?php  
		include 'includes/role.php';
               ?>

            <div class="clearfix"></div>
            
			<?php
            include 'includes/profile.php';
			print '</br></br>';
			include 'includes/menu.php';
			?>

           

        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
		  
			
			
            <div class="clearfix"></div>

            <div class="row">
              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
				  
                    <a href="manage_users.php">  <h2><span class="glyphicon glyphicon-step-backward"></span> Back</h2></a>
					
					
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      
                     
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content" style="overflow: auto;">
				  
				  <?php
				$userId = $_GET['i'];
				$sql9 = "SELECT staff.firstname,staff.lastname,users.staff_id,users.role_id FROM users,staff WHERE staff.staff_id = users.staff_id and users.user_id='$userId'";
	$result9 = $conn->query($sql9);
	while($edge9=mysqli_fetch_array($result9)){
	   $userName = $edge9['firstname'].'&nbsp&nbsp'.$edge9['lastname'];
	   $role_id = $edge9['role_id'];
	   $staff_id = $edge9['staff_id'];
	         }
				?>
				  
				  <?php if (isset($_SESSION['success_message']) && !empty($_SESSION['success_message'])) { ?>
                        <div class="success-message" style="margin-bottom: 20px;font-size: 20px;color: green;"><?php echo $_SESSION['success_message']; ?></div>
                        <?php
                        unset($_SESSION['success_message']);
                    }
                    ?>	

                    <form action="php_action/addPermission_script.php"   method="post"  class="form-horizontal form-label-left">

                     <input type="hidden" name="role_id"  value="<?php echo $role_id; ?>" /> 
					 <input type="hidden" name="staff_id"  value="<?php echo $staff_id; ?>" />
                     <input type="hidden" name="user_id"  value="<?php echo $userId; ?>" /> 					 
					  
                      <span class="section">Add Permissions to &nbsp&nbsp<?php echo $userName;   ?>&nbsp&nbsp</span>
					  
					  
					
					  
                     <div class="item form-group">
                        <label for="password" class="control-label col-md-3">Permissions</label>
                        <div class="col-md-6 col-sm-6 col-xs-12">
						
						
                          
						  <div class="cont80">
			  
			  <?php
		$sql39 = "SELECT permissions.permission_id,permissions.permission_name,permissions.action,roles.role_name FROM permissions,roles where roles.role_id=permissions.role_id order by roles.role_id asc";	
        $result39 = $conn->query($sql39); 
		while ($row39 = mysqli_fetch_array($result39))
		{
			 $pname = $row39['permission_name'];
			 $paction = $row39['action'];
			 $roleName = $row39['role_name'];
			 $v = $pname.'&nbsp&nbsp'.$paction.'&nbsp&nbsp('.$roleName.')';
			  ?>
	<label class="container12">	  
	<input class="checkbox" type="checkbox"  id="myCheck" name="permission_id[]" value="<?php echo $row39['permission_id'] ?>" />&nbsp<?php echo $v; ?> <br/>
   <span class="checkmark"></span>
</label>
	   <?php
		}
	   ?>
	
	
              </div>
						  
						  
						</div>
                      </div>
				
					  <div class="ln_solid"></div>
                      <div class="form-group">
                        <div class="col-md-6 col-md-offset-3">
						  <button class="btn btn-success"><span class="glyphicon glyphicon-registration-save"> </span> Submit</button>
                        </div>
                      </div>
                    </form>
					
			
					
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->

		<?php
		include 'includes/footer.php';
		?>
		
        
      </div>
    </div>
	

    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <script src="../vendors/fastclick/lib/fastclick.js"></script>
    <!-- NProgress -->
    <script src="../vendors/nprogress/nprogress.js"></script>
	
    <!-- validator -->
    <!--<script src="../vendors/validator/validator.js"></script>-->
	
	<!-- bootstrap-daterangepicker -->
    <script src="../vendors/moment/min/moment.min.js"></script>
	
	<!-- bootstrap-datetimepicker -->    
    <script src="../vendors/bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min.js"></script>

    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	
	
	
  </body>
</html>



<?php
}
?>