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



$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($get_store_id!='')
{
$sql_store =DB_query("select id, StoreName from storetype where Store_Site='".$_REQUEST['site']."' and CompanyId='".$_SESSION['ACGCompanyId']."' and id in(".$main_store.",".$get_store_id.")",$db);
}
else
{
	$sql_store =DB_query("select id, StoreName from storetype where Store_Site='".$_REQUEST['site']."' and CompanyId='".$_SESSION['ACGCompanyId']."' and id in(".$main_store.")",$db);

}

?>


<?php 
	if(db_num_rows($sql_store)>0)
	{
		while($Storedetail=DB_fetch_array($sql_store))
		{?>
			<option value="<?php echo $Storedetail['id']; ?>"><?php echo $Storedetail['StoreName']; ?></option>
	<?php 
		}
   }
   else
   {
   	echo "<option value='0'>Select</option>";
   }
?>