<!doctype html>
<?php 
include("../connection.php");
include("../user.php");
$role_code1=$_REQUEST['user_id'];
?>
<html class="no-js" lang=""> 
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><?php echo TITLE;?></title>
    <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="apple-touch-icon" href="../images/bluebase.png">
    <link rel="shortcut icon" href="../images/bluebase.png">
<style>
input[type=text] 
{
	text-transform:uppercase;
}
</style>  
</head>
<body>
<div class="col-lg-8">
<div class="card">
	<div class="card-header">
	<strong style="float:left;">Edit Role</strong>
	<a href="role_master.php"><button class="btn btn-primary" style="width:50px;float:right;"onclick=""><i class="fa fa-backward"></i></button></a>	
	</div>
<div class="card-body card-block">
		<form action="role_update.php" method="post" enctype="multipart/form-data" class="form-horizontal">
				<div class="row form-group">
					<?php 
						$role=mysqli_fetch_array(mysqli_query($con,"select * from role_master where code='$role_code1'"));
						$r_name=$role['role_name'];
					?>
					<div class="col col-md-3"><label for="text-input" class=" form-control-label">Role name</label><span style="color:red;">*</span></div>
					<div class="col-12 col-md-9"><input type="text" id="role_name" value="<?php echo $r_name;?>" name="role_name" placeholder="Enter role name" class="form-control" autocomplete="off" required></div>

					<input type="hidden" id="id" name="id" value="<?php echo $role['id'];?>">
					<input type="hidden" name="user_id" value="<?php echo $role_code1; ?>">

				</div>
				<div class="row form-group">
						<div class="col col-md-3"><label class=" form-control-label" style="color:red;">H/O-Access</label></div>
						<div class="col col-md-9">
							<div class="form-check">
								<div class="radio-inline">
									<label class="filled">
										<input type="radio" name="ho_admin" id="ho_admin" value="yes" <?= $role['ho_admin_access'] == 'yes' ? 'checked' : ''; ?> />YES</label>
									<label class="filled">
										<input type="radio" name="ho_admin" id="ho_admin" value="no" <?= $role['ho_admin_access'] == 'no' ? 'checked' : ''; ?>/>NO</label>
								</div>
							</div>
						</div>
					</div>
				 <?php
			 $menu=mysqli_query($con,"select id,menu_code from menu_master order by id");
			  $r=1;
			while($menu_code=mysqli_fetch_array($menu)) 
			{
				
				?><b style="padding: 5px 0px;color:blue;"><?php echo $menu_code['menu_code']; ?></b><br>
				<?php
				 $men=$menu_code['id']; 
				 
				  $submenu=mysqli_query($con,"select m.menu_name,s.submenu_code,r.view_only,r.submenu_id from role_detail r right join menu_master m on r.menu_id=m.id right join submenu_master s on r.submenu_id=s.id where r.code='$role_code1' and r.menu_id='$men' order by r.id  ");
				  
				  //echo "select m.menu_name,s.submenu_code,r.view_only,,r.approvalr.submenu_id from role_detail r join menu_master m on r.menu_id=m.id join submenu_master s on r.submenu_id=s.id where r.code='$role_code1' and r.menu_id='$men' order by r.id  ";
				 
				  while($sub_menu_code=mysqli_fetch_array($submenu)) { 
					  $ck=$sub_menu_code['view_only'];
//$app=$sub_menu_code['approval'];
					  $sid=$sub_menu_code['submenu_id'];
					  $s=1;
				?>
				<div style="width:100%;float:left;padding: 5px 0px;">
				<input class="checkbox" style="width:2%;float:left;" type="checkbox" name="checkbox<?php echo $r;?>"name="checkbox<?php echo $r;?> onclick="enablebox(this.id)"">
				<div style="width:30%;float:left;">&emsp;<?php echo $sub_menu_code['submenu_code']; ?></div>
					 <input type="hidden"  id="menu" name="menu[]" class="form-control"  value="<?php echo $men.":".$sid;?>" >
				 <input type="hidden"  id="submenu" name="submenu[]" class="form-control"  value="<?php echo $sid;?>" >
				<?php
				if ($ck=="View")
				{
					?>
					<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" checked value="View"  />&emsp;VIEW</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" value="Edit"  />&emsp;EDIT</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>"  value="All"   />&emsp;ALL</div>
				</div>
					<?php
				}
				elseif ($ck=="Edit")
				{
					?>
					<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" value="View"  />&emsp;VIEW</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" checked value="Edit"  />&emsp;EDIT</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>"  value="All"   />&emsp;ALL</div>
				</div>
					<?php
				}
				elseif ($ck=="All")
				{
					?>
					<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" value="View"/>&emsp;VIEW</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" value="Edit"  />&emsp;EDIT</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" checked value="All"   />&emsp;ALL</div>
				</div>
					<?php
				}
				elseif ($ck=="")
				{
					?>
					<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" value="View"  />&emsp;VIEW</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>" value="Edit"  />&emsp;EDIT</div>
				<div style="width:10%;float:left;"><input type="radio" name="new<?php echo $r ; ?>" id="new<?php echo $r.$s++ ; ?>"  value="All"   />&emsp;ALL</div>
				</div>
					<?php
				}
				  $r++;
				  }
			}
			 
			 ?>
	<div style="">
		<button type="submit" name="submit" class="btn btn-success" ><i class="fa fa-dot-circle-o"></i> update</button>
	</div>       
	</form>
</div>
</div>
<div class="clearfix"></div>
    <footer class="site-footer">     
    </footer>
</div><!-- /#right-panel -->

<!-- Right Panel -->

<!-- Scripts -->



</body>
</html>
<?php
			require ("checkbox.js");
	?> 
