 <?php 
include("../connection.php");
include("../user.php");
$cur_date=date('Y-m-d H:i:s');
$user=$_SESSION['user'];
$ho_access=$_SESSION['ha'];
$name=$_REQUEST['user_id'];
$role_code=$_REQUEST['role_code'];
$role_access=mysqli_query($con,"SELECT * FROM `role_master` where code='$role_code' ");
$get_role=mysqli_fetch_array($role_access);
$got_code=$get_role['ho_admin_access'];
// echo "select m.branch_id,r.branch_name from branch_mapping m join branch_master r on r.id=m.branch_id  where m.user_id='$name' and m.to_date is null";
?>
<?php
if($got_code=="no")
{
	?>
 <div class="col col-md-3"><label for="select" class="form-control-label">Center</label></div>
   <div class="col-12 col-md-9">
       <select name="branch_name" id="branch_name" class="form-control" style="padding:5px;text-transform:uppercase;"  required>
		<?php 
		$que=mysqli_fetch_array(mysqli_query($con,"select m.branch_id,r.branch_name from branch_mapping m join branch_master r on r.id=m.branch_id  where m.user_id='$name' and m.to_date is null"));
			//echo "select m.branch_id,r.branch_name from branch_mapping m join branch_master r on r.id=m.branch_id  where m.user_id='$name' and m.to_date is null";
		?> 
		<?php
		if($que)
		{
		$br=$que['branch_name'];
		?>
		<option value="<?php echo $que['branch_id'];?>"><?php echo $que['branch_name'];?></option>
		<?php
		//$sql=mysqli_query($con,"select * from branch_master where status='0' and branch_name<>'$br'");
		$sql=mysqli_query($con,"select * from location_master where status='0' and branch_name<>'$br'");
		while($query=mysqli_fetch_array($sql))
		{
		?>
		<option value="<?php echo $query['id'];?>"><?php echo $query['location'];?></option>
		<?php
		}	
		?>	
		<?php }
		else { ?>
		<option disabled selected>SELECT</option>
		<?php
			//$sql=mysqli_query($con,"select * from branch_master where status='0'");
				$sql=mysqli_query($con,"select * from location_master where status='0'");
		while($query=mysqli_fetch_array($sql))
		{
		?>
		<option value="<?php echo $query['id'];?>"><?php echo $query['location'];?></option>
		<?php
		}	
		?>	
		<?php }
		?>
		
		</select> 
   </div>
   <br/>
   <br/>
   <div class="col col-md-3"><label for="select" class="form-control-label">Division</label></div>
   <div class="col-12 col-md-9">
       <select name="divison_name" id="divison_name" class="form-control" style="padding:5px;text-transform:uppercase;"  required>
		<?php 
			$que=mysqli_fetch_array(mysqli_query($con,"select m.id,r.branch_name from branch_mapping m join branch_master r on r.id=m.branch_id  where m.user_id='$name' and m.to_date is null")); 
		if($que)
		{
		 $br=$que['branch_name'];
		?>
		<option value="<?php echo $que['id'];?>"><?php echo $que['branch_name'];?></option>
		<?php
				$sql=mysqli_query($con,"select * from branch_master where status='0' and branch_name<>'$br'");
		while($query=mysqli_fetch_array($sql))
		{
		?>
		<option value="<?php echo $query['id'];?>"><?php echo $query['branch_name'];?></option>
		<?php
		}	
		?>	
		<?php }
		else { ?>
		<option disabled selected>SELECT</option>
		<?php
				$sql1=mysqli_query($con,"select * from branch_master where status='0'");
		while($query1=mysqli_fetch_array($sql1))
		{
		?>
		<option value="<?php echo $query1['id'];?>"><?php echo $query1['branch_name'];?></option>
		<?php
		}	
		?>	
		<?php }
		?>
		
		</select> 
   </div>
<?php } ?>