<?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);
}


$data1='';

if($get_store_id!='')
{
$sql_store =DB_query("select id, StoreName from storetype where Store_Site='".$_REQUEST['branchcode']."' and CompanyId='".$_SESSION['ACGCompanyId']."' and id in(".$main_store.",".$get_store_id.") order by StoreCode ASC",$db);
}
else
{
	$sql_store =DB_query("select id, StoreName from storetype where Store_Site='".$_REQUEST['branchcode']."' and CompanyId='".$_SESSION['ACGCompanyId']."' and id in(".$main_store.") order by StoreCode ASC",$db);
}


 while($Storedetail=DB_fetch_array($sql_store)){
$data1.='<option value="'.$Storedetail['id'].'">'.$Storedetail['StoreName'].'</option>';
 }


$data2='';
$data2.="<option value='' >Select</option>";
$sql="select id  ,vendor_code, vendor_name from suppliers where CompanyId='".$_SESSION['ACGCompanyId']."' order by vendor_name";
    $result = DB_query($sql, $db);
    while($myrow = DB_fetch_array($result))
    { 
     $data2.="<option  value='".$myrow['id']."'>".str_replace(array("M/s ","M/S"),'',$myrow['vendor_name'])."</option>";
}
$data2.="</select>";
echo $data=$data1."__".$data2;
?>