<?php
/**
 * powered by b2bbuilder
 * copyright http://www.b2b-builder.com
 * Auther:brad zhang;
 * Des:inquery
 */
//===================================
//数据类型验证
if(!empty($_POST['submit']))
{
	if(strtolower($_POST["yzm"])!=strtolower($_SESSION["auth"]))
		msg("$config[weburl]/?m=message&s=inquire&contype=1&pid=$_GET[pid]&etype=1");
		
	include_once("includes/plugin_msg_class.php");
	$msg=new msg();
	$res=$msg->send_email();
	if($res)
		header("Location:$config[weburl]/?m=message&s=inquire&1=1&type=1");
	else
		header("Location:$config[weburl]/?m=message&s=inquire&1=1&type=2");
}
if(!empty($_GET['offerid'])&&empty($_GET['type']))
{
	$offerid=explode(",",$_GET['offerid']);
	foreach($offerid as $key=>$v)
	{
		$offerid[$key]=$v*1;
	}
	$pid=implode(",",$offerid);
	
	$sql="select title,pic,id,userid,user,company from ".INFO." where id in ($pid)";
	$db->query($sql);
	$re=$db->getRows();
	$tpl->assign("receive",$re);
}
//----------------------询盘篮提交，批量询盘
if($_POST['inquire']=='Send'&&empty($_GET['type']))
{
	//----询产品
	if(!empty($_POST['offerid']))
	{
		$va=explode(",",$_COOKIE['offer_inquery']);
		$ar=$_POST['offerid'];
		foreach($va as $key=>$v)
		{
			if(!$v) unset($va[$key]);
			if(in_array($v,$ar))
			
			unset($va[$key]);
		}		
		setcookie("offer_inquery",implode(",",$va),NULL,"/",$config['baseurl']);
		
		$oid=implode(",",$_POST['offerid']);
		$sql="select title,id,userid from ".INFO."  where id in ($oid)";
		$db->query($sql);
		$re=$db->getRows();
		$tpl->assign("receive",$re);
	}
}
//---------------
include_once("lang/$config[language]/company_type_config.php");
$tpl->assign("receive_type",$receive_type);
//---------------
$tpl->assign("country",country_list());
$tpl->assign("time",time()+3600*24*3);
//======================================
$tpl->assign("current","offer");
include_once("footer.php");
$out=tplfetch("inquire.htm");
?>