<?php
include_once("$config[webroot]/module/offer/includes/offer_class.php");
//===================================================
if(!empty($_GET["id"])&&is_numeric($_GET["id"]))
	$id=$_GET["id"];
else
	msg($config['weburl'].'/404.php');
//----------------------------------------------
$offer=new offer();
$de=$offer->space_offer_detail($id);
if(empty($de['id']))
	msg($config['weburl'].'/404.php');

//-------------------------------------扩展字段显示
if($config['opentype']*1==1)
{  //在商铺中打开产品详情
	//$_GET['uid']=$de['userid'];
	//$_GET['action']='offer_detail';
	//include($config['webroot'].'/shop.php');
}
else
{	
	//在独立页面中打开产品详情页
	include_once("module/company/includes/company_class.php");
	//----------------------------------------------------
	$ifpay=isset($_SESSION["IFPAY"])?$_SESSION['IFPAY']:1;
	if(!empty($config['infotype_'.$ifpay]))
		$de['view_right']=true;
	else
		$de['view_right']=false;
		
	$tpl->assign("de",$de);
	//----------------------------------------------------
	$user=new user();
	$tpl->assign("cominfo",$cominfo=$user->get_cominfo($de['userid']));
	
	$guide=GetCatName($de['catid'],true,OCAT);
	$tpl->assign("guide",$guide?$guide:"");
	
	$db->query("select intro from ".CDETAIL." where company_id='$de[company_id]'");
	$intro=$db->fetchField('intro');
	$tpl->assign("intro",$intro);
	//-----------------------------------扩展字段
	$parcat=substr($de['catid'],0,4);
	$sql="select catid,cat,ext_table from ".OCAT." where catid='$de[catid]'";
	$db->query($sql);
	$ocats=$db->fetchRow();
	$tpl->assign("pcat",$ocats);
		
	$ext_table=$ocats['ext_table'];
	include_once("$config[webroot]/includes/plugin_add_field_class.php");
	$addfield = new AddField('offer');
	$extfiled=$addfield->addfieldinput($id,$ext_table,true);
	$tpl->assign("extfiled",$extfiled);
	//-------------------------------------Seo config
	$ar1=array('[type]','[catname]','[title]','[keyword]','[des]');
	$ar2=array($de['offertype'],$ocats['cat'],$de['title'],$de['keywords'],strip_tags($de['con']));
	$config['title']=str_replace($ar1,$ar2,$config['title3']);
	$config['keyword']=str_replace($ar1,$ar2,$config['keyword3']);
	$config['description']=str_replace($ar1,$ar2,$config['description3']);
	$tpl->assign("current","offer");
	include_once("footer.php");
	$out=tplfetch("offer_detail.htm");
}
?>