<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2010-2016 HuCart.COM，并保留所有权利。
 * 网站地址: http://Www.HuCart.Com；
 * 作者: HuCart.COM
 *----------------------------------------------------------------------------*
**/
class Book extends HC_Controller
{
	function __construct()
	{
		parent::__construct();
		$this -> load_db();
		$this -> load_lang('www/picture');
		$this -> load('helper');     	 	//加载辅助类
		$this -> load_model('ads'); 		//加载模型
		$this -> load_model('web_config'); 	//加载模型
		$web_config = $this -> web_config_mod -> get_sys_config();
		$this -> set_view_dir( $web_config['temp'] -> dir );
		$this -> view -> assign('web_config', $web_config);


		$this -> view -> assign('menu_info',$this -> web_config_mod -> get_web_menu());
		$this -> view -> assign('ads_info', $this -> ads_mod -> get_ads( '1,2,3,4,5,6,7,8,9,10,11'  ));
		$this -> view -> assign('user_link',$this -> session -> get_user_link( $this->lang['user_link'] ));
		

		$contact_arr =  $this -> helper -> build_contact( $web_config );
		$this -> view -> assign('contact_arr',$contact_arr);
		
	}
/*
	function Book()
	{
		//缓存
		if($GLOBALS["WebConfig"]["webtmp"]==1)
		{
			$this -> view -> caching = true;
			if($GLOBALS["WebConfig"]["webtmptime"] > 0 )
			{
				$this -> view -> cache_lifetime = $GLOBALS["WebConfig"]["webtmptime"] ;
			}else{
				$this -> view -> cache_lifetime = 3600 ;  //60 *  60 * 24
			}
			$smdirid 	= $this -> input -> req["is"].intval(trim($_REQUEST["page_num"]));
			$this -> view -> cache_dir = ROOT_PATH.$GLOBALS['cache_path'].'/'.$this -> helper -> buildsmartydir( $type = 'b',$smdirid);
		}

 

		$getmenu = $this -> helper -> get_menu();
		$this -> view -> assign('getmenu',$getmenu);
		
		$getprosort  = $this -> personal -> get_prosort();
		$this -> view -> assign('getprosort',$getprosort);

		$getlink = $this -> helper -> get_link();
		$this -> view -> assign('getlink',$getlink);	
		
		$getads = $this -> helper -> get_ads( $instr = '1,2,3,4,5,6,7,8,9,10,11' );
		$this -> view -> assign('getads',$getads);
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$this -> view ->assign('getuserlink',$getuserlink);	
		

	}
	*/
	function info_list()
	{	
		$pro_idval = intval(trim($_REQUEST["id"]));
		$webtitle  = '商品在线预订';
		//处理你现在的位置
		$now_address = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/index.php?/item.html">商品在线预订</a>';

		$this -> view -> assign('webtitle',$webtitle);
		$this -> view -> assign('now_address',$now_address);
		
		if($pro_idval!='')
		{
			$sql_query 	= " SELECT pro_id, pro_name  FROM  ".$this -> db -> prefix."product as p   WHERE  pro_enabled = 1  and p.pro_id = ".$pro_idval." ORDER BY p.`pro_id`  ";
			$proinfo 	= $this -> db ->  select_one($sql_query);
		}
		
		$this -> view -> assign('proinfo',$proinfo);
		if($sid !='' or $page_num!='' or  $newkeyword !='')
		{
			$cache_id = $sid.'p'.$page_num.'k'.$keyid;
		}
		$this -> view -> display('book.tpl',$cache_id);
	}
	
	function addinfo()
	{
		$this->add_info();
	}
	
	
	function add_info()
	{
		$pro_idval 				= $this -> input -> req["pro_id"];
		$boo_nameval 			= $this -> input -> req["boo_name"];
		$boo_phoneval  			= $this -> input -> req["boo_phone"];
		$boo_emailval  			= $this -> input -> req["boo_email"];	
		$boo_productval 		= $this -> input -> req["boo_product"];
		$boo_descriptionval  	= $this -> input -> delContent("boo_description");
		
		$boo_add_timeval 		= time();
		
		$insertsql ="INSERT INTO `".$this -> db -> prefix."book` (`boo_name` , `pro_id`, `boo_mobile` , `boo_email` , `boo_product` , `boo_description`,`boo_add_time` ) 
		VALUES('$boo_nameval', '$pro_idval', '$boo_phoneval', '$boo_emailval', '$boo_productval', '$boo_descriptionval', '$boo_addtimeval')";

		$this -> db -> query_sql($insertsql);
		
		$this -> view -> assign('info_title',$_LANG['bd_addsusse'] );
		$this -> view -> assign('URL_TIME',URL_TIME);
		$this -> view -> assign('get_url',BASE_WEBURL."/index.php?load=book&act=info_list&id=".$pro_idval);
		$this -> view -> display('suggestion.tpl');
		
	
	}	
}

/*
$Book = new Book();

if($GLOBALS['Webur'] -> getval["type"]=='infolist')
{
	$Book -> infolist();
}else if($GLOBALS['Webur'] -> getval["type"]=='add_info')
{
	$Book -> add_info();
}else{
	$this -> error('404');
}

*/