<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2005-2010 GV32.COM，并保留所有权利。
 * 网站地址: http://www.gv32.com；
 * 作者: GV32.COM
 *----------------------------------------------------------------------------*
**/
class Book
{
	function Book()
	{
		//缓存
		if($GLOBALS["WebConfig"]["webtmp"]==1)
		{
			$GLOBALS['Templ'] -> caching = true;
			if($GLOBALS["WebConfig"]["webtmptime"] > 0 )
			{
				$GLOBALS['Templ'] -> cache_lifetime = $GLOBALS["WebConfig"]["webtmptime"] ;
			}else{
				$GLOBALS['Templ'] -> cache_lifetime = 3600 ;  //60 *  60 * 24
			}
			$smdirid 	= trim($_REQUEST["id"]).trim($_REQUEST["pageNum"]);
			$GLOBALS['Templ'] -> cache_dir = ROOT_PATH.$GLOBALS['cache_path'].'/'.$GLOBALS['Helpe'] -> buildsmartydir( $type = 'b',$smdirid);
		}

		$getconfig = $GLOBALS['Helpe'] -> get_config();
		$GLOBALS['Templ'] -> assign('getconfig',$getconfig);

		$getmenu = $GLOBALS['Helpe'] -> get_menu();
		$GLOBALS['Templ'] -> assign('getmenu',$getmenu);
		
		$getprosort  = $GLOBALS['Helpe'] -> get_prosort();
		$GLOBALS['Templ'] -> assign('getprosort',$getprosort);

		$getlink = $GLOBALS['Helpe'] -> get_link();
		$GLOBALS['Templ'] -> assign('getlink',$getlink);	
		
		$getads = $GLOBALS['Helpe'] -> get_ads( $instr = '1,2,3,4,5,6,7,8,9,10,11' );
		$GLOBALS['Templ'] -> assign('getads',$getads);
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$GLOBALS['Templ']->assign('getuserlink',$getuserlink);	
		
		$act = trim($_REQUEST["act"]);
		if($act=='')
		{
			$this -> infolist();
		}
	}
	
	function infolist()
	{	
		$pro_idval		= trim($_REQUEST["id"]);
		
		$webtitle = '商品在线预订';
		//处理你现在的位置
		if( $GLOBALS["WebConfig"]["webhtml"] == 1 )
		{
			$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/pro.html">商品在线预订</a>';
		}else{
			$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/?load=pro&act=infolist">商品在线预订</a>';
		}
		
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
		
		if($pro_idval!='')
		{
			$sqlQuery 	= " SELECT pro_id, pro_name  FROM  ".SQL_PREFIX."product as p   WHERE  pro_enabled = 1  and p.pro_id = ".$pro_idval." ORDER BY p.`pro_id`  ";
			$proinfo 	= $GLOBALS['MySql']  ->  selectOne($sqlQuery);
		}
		
		$GLOBALS['Templ'] -> assign('proinfo',$proinfo);
		if($sid !='' or $pageNum!='' or  $newkeyword !='')
		{
			$cache_id = $sid.'p'.$pageNum.'k'.$keyid;
		}
		$GLOBALS['Templ'] -> display('book_tpl.html',$cache_id);
	}
	
	function addinfo()
	{
		$pro_idval 				= $GLOBALS['Reque'] -> funpost("pro_id");
		$boo_nameval 			= $GLOBALS['Reque'] -> funpost("boo_name");
		$boo_phoneval  			= $GLOBALS['Reque'] -> funpost("boo_phone");
		$boo_emailval  			= $GLOBALS['Reque'] -> funpost("boo_email");	
		$boo_productval 		= $GLOBALS['Reque'] -> funpost("boo_product");
		$boo_descriptionval  	= $GLOBALS['Reque'] -> funpost("boo_description");
		
		$boo_addtimeval 			= time();
		
		$insertsql ="INSERT INTO `".SQL_PREFIX."book` (`boo_name` , `pro_id`, `boo_phone` , `boo_email` , `boo_product` , `boo_description`,`boo_addtime` ) 
		VALUES (  '$boo_nameval', '$pro_idval', '$boo_phoneval', '$boo_emailval', '$boo_productval', '$boo_descriptionval', '$boo_addtimeval')";

		$GLOBALS['MySql'] -> querySql($insertsql);
		
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse'] );
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',BASE_WEBURL."/?load=book&act=infolist&id=".$pro_idval);
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
		
	
	}	
}

$Book = new Book();

?>