<?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($get_store_id!='')
     {
        $store_sql = "select * from storetype where Store_Site = '".$_GET['site']."' and id in(".$main_store.",".$get_store_id.") order by id ASC";
     }
     else if($main_store!='')
     {
          $store_sql = "select * from storetype where Store_Site = '".$_GET['site']."' and id in(".$main_store.") order by id ASC";
     }
     else
     {
     	 $store_sql = "select * from storetype order by id ASC";
     }
        
	
	$data2="ddd";
	$data1='';
		$data1.="<select name='store1' onChange='' style='width:98%;'>";
             "<option value='0'>--Select--</option>";
 			$store_result = DB_query($store_sql,$db);
			while($store_row = DB_fetch_array($store_result))
			{
				$p='';
				if($store_row['id'] == $_POST['store1'])
				$p="selected";
		$data1.="<option value=".$store_row['id']." ".$p.">".$store_row['StoreName']."</option>";
			 }
			
			$data1.="</select>";

$data3.="<select name='vendor' id='vendor'  style='width:150px;'>";
$data3.="<option value=''>All</option>";

$ven_query=DB_query("SELECT id,vendor_name FROM suppliers WHERE site='".$_GET['site']."' ",$db);

while($ven_name=DB_fetch_array($ven_query))
{
	$data3.="<option value=".$ven_name['id']." ".$p.">".$ven_name['vendor_name']."</option>";
}
$data3.="</select>";
echo  $data=$data1."__".$data2."__".$data3;
?>
