<?php
include ('../ro_head.php'); 

 if($_SESSION['level'] != 1){

	header('Location: dashboard.php');

}

//include ('methodlist.php'); ?>
<!-- BEGIN PAGE LEVEL STYLES -->

<!-- END THEME STYLES -->
<link rel="shortcut icon" href="favicon.ico"/>
</head>

<script>
function validate() {
 // check if input is bigger than 3
 var value = document.getElementById('pass').value;
 
 if (value.length >4 && value.length <9 ) {
   
   return true; // keep form from submitting
 }
 
 else{
	
	alert("Password must be 5 to 8 characters.");
    return false;
 }
 
}

</script>

<!-- END HEAD -->
<!-- BEGIN CONTAINER -->
<div class="page-container">
<?php include_once("../ro_sidebar.php"); ?>
	
	<!-- BEGIN CONTENT -->
	<div class="page-content-wrapper">
		<div class="page-content">
		
			<!-- BEGIN PAGE CONTENT-->
			<div class="row">
				<div class="col-md-12">										
					
						<form name="addproduct" class="form-horizontal form-row-seperated" onsubmit="return validate();" action="user_crud.php" method="post">



						<div class="portlet">



							<div class="portlet-body">



								<div class="tabbable">



									<ul class="nav nav-tabs">



										<li class="active">



											<a href="#tab_general" data-toggle="tab">



											Edit User </a>



										</li>

									</ul>



									<div class="tab-content no-space">



										<div class="tab-pane active" id="tab_general">



											<div class="form-body">






					<div class="form-group">

					<?php    


								          $pid=mysqli_real_escape_string($con,$_REQUEST['pid']);
								          
								          mysql_query ("set character_set_results='utf8'");

								          $rs = @mysqli_query($con,"select * from adminusers where u_id='$pid'");
								          
								          $prow=mysqli_fetch_array($rs);	
								          							          

								    ?>   
								
                            <div class="form-group">

								<label class="col-md-2 control-label">
									Name: <span class="required">* </span>
								</label>

								<div class="col-md-4">
									<input type="text" class="form-control" name="user[name]" placeholder="" value='<?php echo $prow["name"]; ?>' required>
								</div>

							</div>


                        </div>

                        <div class="form-group">


							<div class="form-group">



								<label class="col-md-2 control-label">
									Email: <span class="required">* </span>
								</label>



								<div class="col-md-4">
									<input type="email" class="form-control" name="user[u_email]" placeholder="" value='<?php echo $prow["u_email"]; ?>' required>
								</div>

							</div>
							
						</div>
                         	
						<div class="form-group">


							<div class="form-group">



								<label class="col-md-2 control-label">
									User Name: <span class="required">* </span>
								</label>



								<div class="col-md-4">
									<input type="text" class="form-control" name="user[u_name]" placeholder="" value='<?php echo $prow["u_name"]; ?>'  required >
								</div>

							</div>
							
						</div>
					
						
						<?php //if($prow["u_type"]!=1){ ?>

						<div class="form-group">

							<div class="form-group">

								<label class="col-md-2 control-label">
									Status: <span class="required">* </span>
								</label>

								<div class="col-md-4">								

									<select name="user[u_status]" class="form-control">
 									<?php
 										if($prow["u_status"]==1){
 											?>
 											<option value="1">Active</option>
 											<option value="0">inactive</option>
 											<?php
 										}else{
 											?>
 											<option value="0">inactive</option>
 											<option value="1">Active</option>
 											<?php
 										}
 									?>
 								</select>

								</div>

							</div>
							
						</div>
						
                        <div class="form-group">
							<div class="form-group">
								<label class="col-md-2 control-label">
										Delivery Center: <span class="required">* </span>
								</label>

								<div class="col-md-3">
									<select name="user[delcenter]" class="form-control" required>
									  	<option value=""> - Select -</option>
								
								<?php    
		                            $delrs = mysqli_query($con,"select * from deli_location_table where status=1 order by deliloc_name ASC");
                            		while($delrow=mysqli_fetch_array($delrs)){ 
                                
                                 	  	echo "<option value=".$delrow["deliloc_id"];
                                 	  	if($delrow["deliloc_id"]==$prow["delcenter"]) echo " selected";
                                 	  	echo"> ".$delrow["deliloc_name"]." </option>";
									  	
									} 
								?>	
									</select>	
                                
								</div>

							</div>
							
						</div> 
						<div class="form-group">

							<div class="form-group">

								<label class="col-md-2 control-label">
									Restrictions: <span class="required">* </span>
								</label>



								<div class="col-md-4">
																										

									<?php 

									
									$string = $prow["restrictions"];

									$array = explode(',', $string);
									
									for ($row = 0; $row < count($rules); $row++) {

										 //if(in_array($rules[$row],$array)) echo "OK";
									  
										?>											

											
											<label class="">										
											<input type="checkbox" name="rule[]" value="<?php echo $rules[$row];?>" class="icheck" <?php if(in_array($rules[$row],$array)) echo "checked";?> style="position: absolute; ">
											 <div style="position: relative; padding-left:25px;"> <?php echo $rules[$row]; ?> </div>
											</label><br/>
											
										
									 
									<?php
									}
									?>
									
								</div>

							</div>
							
						</div>
						             
						<?php //} ?>


								                 <div class="form-group">
								                	<label class="col-sm-2 control-label" ></label>
								                	<input type='hidden' name='actionid' value='update'>
								                	<input type='hidden' name='id' value='<?php echo $prow['u_id'];?>'>
								                  <div class="col-sm-10"><button class="btn green"><i class="fa fa-check"></i> Update</button></div>
								                </div>






											</div>



										</div>





									</div>



								</div>



							</div>



						</div>



					</form>
					
					
				</div>
			</div>
			<!-- END PAGE CONTENT-->
		</div>
	</div>
	<!-- END CONTENT -->
</div>
<!-- END CONTAINER -->
<!-- BEGIN FOOTER -->
<?php include_once("../ro_footer.php"); ?>
<!-- END FOOTER -->
<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
<!-- BEGIN CORE PLUGINS -->
<!--[if lt IE 9]>
<script src="../assets/global/plugins/respond.min.js"></script>
<script src="../assets/global/plugins/excanvas.min.js"></script> 
<![endif]-->
<?php include_once("../ro_js.php"); ?>

<!-- END PAGE LEVEL SCRIPTS -->
<script>
        jQuery(document).ready(function() {    
           Metronic.init(); // init metronic core components
Layout.init(); // init current layout
QuickSidebar.init(); // init quick sidebar
Demo.init(); // init demo features
          
        });
    </script>
<!-- END JAVASCRIPTS -->
</body>
<!-- END BODY -->
</html>