<?php 
$PageSecurity = 4;
include('includes/session.inc');
include('includes/DefineSuppTransClass.php');


//For hmis User
$sql_user_store="select hmis_storeid,StoreCode from www_users left join storetype on storetype.id=www_users.hmis_storeid where www_users.id='".$_SESSION['UserID']."'";
$result_user_store=DB_query($sql_user_store,$db);
$rs_user_store=DB_fetch_array($result_user_store);
$main_store=$rs_user_store[0];


$sql_other_store="select store_id,StoreCode from www_users_dtls left join storetype on storetype.id=www_users_dtls.store_id where user_id='".$_SESSION['UserID']."'";
$result_other_store=DB_query($sql_other_store,$db);
while($rs_other_store=DB_fetch_array($result_other_store))
{
  $store[]=$rs_other_store['store_id'];
}
if(!empty($store))
{
  $get_store_id=implode(",",$store);
}

if($_SESSION['UserType']!='SuperAdmin')
{
	if($get_store_id!='')
	{
	  $query = "select * from storetype where  id in(".$main_store.",".$get_store_id.")order by StoreCode ASC";
	 }
	 elseif ($main_store!='')
	  {
	  	$query = "select * from storetype where id in(".$main_store.") order by StoreCode ASC";
	  }
 }	   
  else
  {
  	$query = "select * from storetype order by StoreCode ASC";
  }
?>
             <option value="">Select Location</option>
			 <?php 
			 	$res = DB_query($query,$db) or die(DB_error());
				while($result = DB_fetch_array($res))
				{
				$p='';
				if($result['id'] == $_POST['store1'])
				{
					$p="selected";
				}
			?>
			<option value="<?php echo $result['id'];?><?php echo $p;?>"><?php echo $result['StoreName'];?></option>
			<?php
			}
			?>
		
 