<?php
/**
 *----------------------------------------------------------------------------*
 * 版权所有 2005-2010 GV32.COM，并保留所有权利。
 * 网站地址: http://www.gv32.com；
 * 作者: GV32.COM
 *----------------------------------------------------------------------------*
**/
class Invite
{
	function Invite()
	{
		//缓存
		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 = 'd', $smdirid );
		}
		$getconfig = $GLOBALS['Helpe'] -> get_config();
		$GLOBALS['Templ'] -> assign('getconfig',$getconfig);

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

		$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);
		
		$getprosort  = $GLOBALS['Helpe'] -> get_prosort();
		$GLOBALS['Templ'] -> assign('getprosort',$getprosort);
		
		
		$getuserlink = $GLOBALS['WebSe']->getuserlink();
		$GLOBALS['Templ']->assign('getuserlink',$getuserlink);
		
		$actval = trim($_REQUEST["act"]);
		if($actval=='')
		{
			$this -> infolist();
		}
	}
	
	function infolist( )
	{
	
		$pageSize = 16 ;
			
		if(  $GLOBALS['Reque'] -> getval["pageNum"] > 1 )
		{
			$pageNum  = $GLOBALS['Reque'] -> getval["pageNum"];
			$LIMITnum = ceil( ( $GLOBALS['Reque'] -> getval["pageNum"] -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}
		
		$webtitle = '人才招聘';
		//处理你现在的位置
		if( $GLOBALS["WebConfig"]["webhtml"] == 1 )
		{
			$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/invite.html">人才招聘</a>';
		}else{
			$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/?load=invite&act=infolist">人才招聘</a>';
		}
		
		//职位名称  招聘人数 	经验要求 	学历要求 	专业要求 	年龄 发布时间
			
		$sqlQuery = " SELECT inv_id, inv_position , inv_year ,inv_pay ,inv_subject ,inv_age ,inv_addtime  FROM  ".SQL_PREFIX."invite   WHERE inv_enabled = 1  GROUP BY  inv_id ORDER BY  `inv_id` LIMIT  $LIMITnum , $pageSize ";
		
		$info 		= $GLOBALS['MySql']  ->  selectInfo( $sqlQuery );
		foreach((array)$info as $pkey => $pval )
		{
			 $info[$pkey]["get_url"]= $GLOBALS['Helpe']  -> buildUrl( $valid = $pval["inv_id"],'inv');
		}
		
		
		
		$sqlQuery 	= " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."invite  WHERE inv_enabled = 1  ORDER BY `inv_id`  ";
		
		$infocount 	= $GLOBALS['MySql']  ->  selectOne($sqlQuery);
		
		if( $GLOBALS["WebConfig"]["webhtml"] == 1 )
		{
			$url = BASE_WEBURL.'/invite-list';
			$endArray["sid"] = $sid;
		}else{
			$url = './?load=invite&act=infolist'.$addpage.$addurl;
		}
		$PageStr 	= $GLOBALS['Page'] -> buildPageStr( $url , $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"] );
		
		
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
		
		$GLOBALS['Templ'] -> assign('PageStr',$PageStr);
		$GLOBALS['Templ'] -> assign('info',$info);
		if($sid !='' or $pageNum!='' or  $newkeyword !='')
		{
			$cache_id = $sid.'p'.$pageNum.'k'.$keyid;
		}
		$GLOBALS['Templ'] -> display('invitelist_tpl.html',$cache_id);
		
	}
	
	function detail()
	{
		
		$webtitle = '人才招聘';
		//处理你现在的位置
		if( $GLOBALS["WebConfig"]["webhtml"] == 1 )
		{
			$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/?load=invite&act=infolist">人才招聘</a>';
		}else{
			$nowaddress = '您的位置：<a href="'.BASE_WEBURL.'/">首页</a> > <a href="'.BASE_WEBURL.'/?load=invite&act=infolist">人才招聘</a>';
		}
		$GLOBALS['Templ'] -> assign('webtitle',$webtitle);
		$GLOBALS['Templ'] -> assign('nowaddress',$nowaddress);
		
		
		$id  = $GLOBALS['Reque'] -> getval["id"];
		
		if($id  > 0 )
		{
			$sqlQuery 	= " SELECT *  FROM  ".SQL_PREFIX."invite  WHERE inv_id = ".$id." ORDER BY  inv_id  ";

			$infodetail = $GLOBALS['MySql']  ->  selectOne($sqlQuery);
			
			$infodetail["inv_describe"] = nl2br($infodetail["inv_describe"]);
			
			$infodetail["inv_requests"] = nl2br($infodetail["inv_requests"]);
			
			$GLOBALS['Templ'] -> assign('info',$infodetail);
			$cache_id = $id.'d'.$pageNum;
			$GLOBALS['Templ'] -> display('invite_tpl.html',$cache_id);
			
		}else{
			$GLOBALS['Helpe'] -> error404();
		}
		
	}
	
}

$Invite = new Invite();
?>