<?php
include_once("$config[webroot]/module/offer/includes/offer_class.php");
include_once("$config[webroot]/includes/page_utf_class.php");
$offer=new offer();
//============================================================
if(!empty($_POST))
{	
	//-----------更新商铺推荐产品
	$sql="select rec_pro from ".SHOPSETTING." where company_id='$bcid'";
	$db->query($sql);
	$ids=$db->fetchField('rec_pro');
	if(is_array($_POST['offerid']))
	{
		if($ids)
		{
			$ids=explode(",",$ids);
			$ids=array_merge ($ids,$_POST['offerid']);
			$ids=array_unique($ids);
			$ids=implode(",",$ids);
		}
		else
			$ids=implode(",",$_POST['offerid']);
		$sql="update ".SHOPSETTING." set rec_pro='$ids' where company_id='$bcid'";
		$db->query($sql);
	}
}

if(isset($_GET['deid']))
{
	$offer->del_info($_GET['deid']);
}

if(!empty($_GET['update'])&&is_numeric($_GET['update']))
{
	$offer->update_info($_GET['update']);
	echo date($config['date_format'],time());die;
}
$tpl->assign("infoType",explode('|',$config['infoType']));	
$tpl->assign("re",$offer->info_list(1));
$tpl->assign("valid_time",explode('|',$config['valid_time']));
//==============================================================
$tpl->assign("config",$config);
$tpl->assign("lang",$lang);
if(empty($_GET['page']))
{
	if($_GET['ajax']==1)//标签切换时调用不带息头的信
		$output=tplfetch("admin_offer_list.htm",NULL,true);
	else
		$output=tplfetch("admin_offer_list.htm");
}
else
	$output=tplfetch("admin_add_showcase.htm",NULL,true);
?>