<script language="javascript" type="text/javascript" src="userroll/userrole.js"></script>
<?php 
		$roll_name=''; 
		$active_status ='';
		if($_GET['userroll_id'] !='')
		{
			  $sql = "SELECT * FROM userroll where userroll_id=".$_GET['userroll_id'];
			  $pdo_statement = $pdo_conn->prepare($sql);
			  $pdo_statement->execute();
			  $updateresult = $pdo_statement->fetchAll();
			  $roll_name=$updateresult[0]['roll_name'];			  
		}  
?> 
<?php 
if($_GET[userroll_id]!='')
{

?>

<div class="content-wrapper">
	<div class="page-title">
		<div><h1>Update User Permission</h1></div>
		<div>
            <ul class="breadcrumb side">
                <li class="active"><a href="index1.php?fopen=userroll/list">List</a></li>
                <li>Update</li>
            </ul>
        </div>
    </div>

<?php
}
else
{
?>

<div class="content-wrapper">
	<div class="page-title">
		<div><h1>Add New User Permission </h1></div>
		<div>
            <ul class="breadcrumb side">
                <li class="active"><a href="index1.php?fopen=userroll/list">List</a></li>
                <li>Create</li>
            </ul>
        </div>
    </div>
<?php
}
?>


<div class="row">
        <div class="col-md-12">
            <div class="card">
                <div class="card-body">
   
        <form class="was-validated"  name="userroll" autocomplete="off">
        <div class="row">
         <div class="col-md-6 ">
              <div class="form-group">
				   <h5>User Type</h5>
				   <div class="controls">
                       
                        <input type="text" name="roll_name" id="roll_name" class="form-control" value ="<?php echo $roll_name;?>" required>
                        <div id="roll_name_error"></div>
                        
					</div>
			  </div>
            </div>
        	<div class="clearfix"></div>
            <div class="col-md-12">
            	<?php 
				include('formlist.php'); 
				?>
            </div>
            
            </div>
             
          <a href="index1.php?fopen=userroll/list" class="float-left btn btn-primary">Cancel</a>
          <?php if($updateresult==''){?>
		  <button type="button" class="float-right btn btn-success" onClick="userrole_cu('','Add')">Save</button>
          <?php }else{?>
          <button type="button" class="float-right btn btn-success" onclick="userrole_cu('<?php echo $updateresult[0]['userroll_id'];?>','Update')">Update</button>
          <?php }?>
	
          </form>
          
          
      </div>
      </div>
      </div>
      </div>
      
        <!-- /.box-body -->
        <div id="userrole_list"></div>
        <div id="distinct_error" style="color:red"></div>
        
      </div>
      


			</div>
			 
		
	</div>

    
    
    
<?php
function checkstatus($rollid, $formid){
	global $pdo_conn;
	$status = '0';	$data = '';
	$sql = "SELECT * FROM userformrights  WHERE delete_status != 1 AND roll_id = '".$rollid."' AND form_id = '".$formid."' ";
	$prepare = $pdo_conn->prepare($sql);
	$exc = $prepare->execute();
		if($exc == TRUE){
			$list = $prepare->fetchAll();
			$status = $list[0]['status'];
			if($status == '1'){
				$data = 'checked';
			}
		}
	return $data;
}

?>
