<?php
/***
 *----------------------------------------------------------------------------*
 * 版权所有 2010-2016 HuCart.COM，并保留所有权利。
 * 此程序是HuCart的一部分。  
 * 根据MIT许可证授权(在软件和软件的所有副本中都必须包含版权声明和许可声明。)
 * 官方网址:http://www.hucart.com
 *
 * 对于完整的版权和许可证信息，请参阅MIT-LICENSE.TXT
 * 程序的再发布必须保留以上版权声明。
 *
 *@author pgmk<pgmk@hucart.com>
 *@copyright pgmk<pgmk@hucart.com>
 *@link http://www.hucart.com
 *@license The MIT License.
 *----------------------------------------------------------------------------*
**/
if (!defined('HUCART_COM')) exit('HuCart.COM No direct script access allowed');
class Invite  extends HC_Controller
{
	
	function __construct()
	{
		parent::__construct();
		$this -> load_db();
		$this -> load_lang('www/invite');
		$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(  $instr = '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'] ));
		

		$this -> load_model('personal'); //加载模型
		//$dow_sort = $this -> personal_mod  -> get_sort('dow_sort');
		//$this -> view -> assign('dow_sort',$dow_sort);
		
		$contact_arr =  $this -> helper -> build_contact( $web_config );
		$this -> view -> assign('contact_arr',$contact_arr);
		
		//var_dump($web_info);
		//var_dump($GLOBALS);
	}
	/*
	function Inv()
	{
		//缓存
		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 	= intval(trim($_REQUEST["id"])).intval(trim($_REQUEST["page_num"]));
			$this -> view -> cache_dir = ROOT_PATH.$GLOBALS['cache_path'].'/'.$this -> helper -> buildsmartydir( $type = 'd', $smdirid );
		}
 

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

		$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);
		
		$getartsort = $this -> personal  -> get_artsort();
		$this -> view -> assign('getartsort',$getartsort);
		
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$this -> view ->assign('getuserlink',$getuserlink);
		
		$this -> view -> assign('sorttype','invite');
		
	}
	*/
	
	function info_list( )
	{
	
		$page_size = 16 ;
			
		if(  $GLOBALS['Reque'] -> getval["page_num"] > 1 )
		{
			$page_num  = $GLOBALS['Reque'] -> getval["page_num"];
			$limit_num = ceil( ( $GLOBALS['Reque'] -> getval["page_num"] -1 ) * $page_size );
		}else{
			$page_num  = 1;
			$limit_num = 0 ;
		}


		$webtitle = $this->lang['webtitle'];
		//处理你现在的位置
		$now_address = $this->lang['u_address'].'<a href="'.BASE_WEBURL.'/">'.$this->lang['home'].'</a> > <a href="'.BASE_WEBURL.'?/invite.html">'.$this->lang['webtitle'].'</a>';		
		//职位名称  招聘人数 	经验要求 	学历要求 	专业要求 	年龄 发布时间
			
		echo $sql_query = " SELECT inv_id, inv_position , inv_year ,inv_pay ,inv_subject ,inv_age ,inv_add_time  FROM  ".$this -> db -> prefix."invite   WHERE inv_delete = 0 AND inv_enabled = 1  GROUP BY  inv_id ORDER BY  `inv_id` LIMIT  $limit_num , $page_size ";
		
		$info 		= $this -> db ->  select_info( $sql_query );
		foreach((array)$info as $pkey => $pval )
		{
			 $info[$pkey]["get_url"]= $this -> helper  -> build_url( $valid = $pval["inv_id"],'inv');
		}
		
		
		
		$sql_query 	= " SELECT count(1) as CNUM  FROM  ".$this -> db -> prefix."invite  WHERE inv_delete = 0 AND inv_enabled = 1  ORDER BY `inv_id`  ";
		
		$infocount 	= $this -> db ->  select_one($sql_query);
		
		$url = BASE_WEBURL.'?/invite-list-'.$sid.'.html';


		$page_str 	= $GLOBALS['Page'] -> buildpage_str( $url , $page_num  , $page_size  , $result_count = $infocount["CNUM"] );
		
		
		//左则自定义内容
		$sql_query 	= " SELECT per_id,per_column,per_main  FROM  ".$this -> db -> prefix."personal  WHERE per_type = 'invlist' ORDER BY `per_id`  ";	
		$infoper 	= $this -> db ->  select_one($sql_query);
		$this -> personal_mod -> get_column($infoper["per_column"]);
		
		
		$this -> view -> assign('webtitle',$webtitle);
		$this -> view -> assign('now_address',$now_address);
		
		$this -> view -> assign('page_str',$page_str);
		$this -> view -> assign('info',$info);
		if($sid !='' or $page_num!='' or  $newkeyword !='')
		{
			$cache_id = $sid.'p'.$page_num.'k'.$keyid;
		}
		$this -> view -> display('invitelist_tpl.html',$cache_id);
		
	}
	
	function show()
	{
		
		$webtitle = $this->lang['webtitle'];
		//处理你现在的位置
		$now_address = $this->lang['u_address'].'<a href="'.BASE_WEBURL.'/">'.$this->lang['home'].'</a> > <a href="'.BASE_WEBURL.'?/invite.html">'.$this->lang['webtitle'].'</a>';	

		$this -> view -> assign('webtitle',$webtitle);
		$this -> view -> assign('now_address',$now_address);

		$id 		= intval($GLOBALS['Webur'] -> getval["idval"]);
		$page_num 	= $GLOBALS['Webur'] -> getval["page"];

		//左则自定义内容
		$sql_query 	= " SELECT per_id,per_column,per_main  FROM  ".$this -> db -> prefix."personal  WHERE per_type = 'inv' ORDER BY `per_id` ";	
		$infoper 	= $this -> db ->  select_one($sql_query);
		$this -> personal_mod -> get_column( $infoper["per_column"] );
		
		if($id  > 0 )
		{
			$sql_query 	= " SELECT * FROM  ".$this -> db -> prefix."invite  WHERE inv_id = ".$id." ORDER BY  inv_id  ";

			$infodetail = $this -> db ->  select_one($sql_query);
 
			$infodetail["inv_describe"] = nl2br($infodetail["inv_describe"]);
			
			$infodetail["inv_requests"] = nl2br($infodetail["inv_requests"]);
			
			$this -> view -> assign('info',$infodetail);
			$cache_id = $id.'d'.$page_num;
			$this -> view -> display('invite_tpl.html',$cache_id);
			
		}else{
			$this -> error('404');
		}
		
	}
	
	function act_default()
	{
		$webtitle = $this->lang['webtitle'];
		//处理你现在的位置
		$now_address = $this->lang['u_address'].'<a href="'.BASE_WEBURL.'/">'.$this->lang['home'].'</a> > <a href="'.BASE_WEBURL.'?/invite.html">'.$this->lang['webtitle'].'</a>';	
		
		//查询一级菜单分类数量
		$sql_query = " SELECT inv_id, inv_position , inv_add_time   FROM  ".$this -> db -> prefix."invite   WHERE  inv_delete = 0 AND inv_enabled = 1 GROUP BY  inv_id ORDER BY inv_add_time DESC, `inv_id` LIMIT  0 , 18 ";
		$info = $this -> db -> select_info( $sql_query );
 
		//var_dump($info);
		$this -> view -> assign('webtitle',$webtitle);
		$this -> view -> assign('now_address',$now_address);
		$this -> view -> assign('info',$info); 
		$this -> view -> display('inv_index.tpl',$cache_id);
	}
	
	
	
	
}
