<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Invite
{
	function Invite()
	{
		//$GLOBALS['WebSe'] -> isOnLine();
		//$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php/login/actlogin");
	}
		
	function infolist()
	{
		$pageSize = 20 ;
		
		$keywordval 	= $GLOBALS['Reque'] -> funpost("keyword");
		$pageNumval 	= $GLOBALS['Reque'] -> getval["pageNum"];
		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}


		
		if($GLOBALS['Reque'] -> getval["keyword"] !='')
		{   
			$keywordval 	= $GLOBALS['Reque'] -> getval["keyword"];
			$keywordval  	= urldecode($keywordval); 
		}
		
		if($keywordval!='')
		{ 	
			$endArray["keyword"] =$keywordval;
			$endurl 	   .= '&keyword='.urlencode($keywordval);
			$whereadd .= " AND ( inv_position LIKE  '%".$keywordval."%' )";  
		}

		$listval  = $GLOBALS['Reque'] -> getval["listval"];
		$listtype = $GLOBALS['Reque'] -> getval["listtype"];

		$orderbyval = "";
		if($listval!='' and $listtype =='DESC' )
		{
			$endArray["listtype"] = 'DESC';
			$endArray["listval"]  = $listval;
			$orderbyval = $listval ."  DESC ";
			$listhtml = '';	//反向排序参数
			
		}elseif($listval!='' )
		{
			$orderbyval = $listval;
			$listhtml = 'DESC';
			
			$endArray["listtype"] = '';
			$endArray["listval"]  = $listval;

		}else{
			$endArray["listtype"] = 'DESC';
			$endArray["listval"]  = 'inv_addtime';
			$orderbyval = " inv_addtime DESC , `inv_id` DESC ";	
		}

		//职位名称 	招聘人数 	经验要求 	学历要求 专业要求 年龄	发布时间
		$sqlQuery = " SELECT inv_id, inv_position, inv_num, inv_year, inv_educational ,	inv_subject ,inv_age ,inv_addtime,inv_enabled FROM  ".SQL_PREFIX."invite  WHERE 1  $whereadd GROUP BY inv_id ORDER BY $orderbyval LIMIT  $LIMITnum , $pageSize ";
		
		$info = $GLOBALS['MySql'] -> selectInfo($sqlQuery);
		
		$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."invite  WHERE 1 $whereadd  ORDER BY `inv_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		//var_dump($info);
		
		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=invite&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"] );
		
		$GLOBALS['Templ']->assign('listhtml',$listhtml);
		$GLOBALS['Templ']->assign('listval',$listval);
		$GLOBALS['Templ']->assign('listtype',$listtype);

		$GLOBALS['Templ']->assign('keywordval',$keywordval);
		
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		$GLOBALS['Templ']->display('invite_tpl.html');
		
		
	}
	
	function add(  )
	{
		//$GLOBALS['Templ'] -> caching = true;
		//$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'inv_describe' ,'','Basic' );	//加载文本编辑器  具体描述
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'inv_requests' ,'','Basic',$uiColor = '#D3D3D3', $width = '800',$height = '120', $ckeditorLoadName = 'reqckeditorLoad');	//加载文本编辑器  岗位要求	

		
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=invite&act=addinfo");
		
		$GLOBALS['Templ']->display('inviteadd_tpl.html');
	}
	
	function addinfo()
	{
		$inv_positionval 	= $GLOBALS['Reque'] -> funpost("inv_position");
		$inv_numval 		= $GLOBALS['Reque'] -> funpost("inv_num");
		$inv_typeval 		= $GLOBALS['Reque'] -> funpost("inv_type");
		$inv_payval 		= $GLOBALS['Reque'] -> funpost("inv_pay");
		$inv_yearval 		= $GLOBALS['Reque'] -> funpost("inv_year");
		$inv_educationalval = $GLOBALS['Reque'] -> funpost("inv_educational");
		$inv_sexval 		= $GLOBALS['Reque'] -> funpost("inv_sex");
		$inv_ageval 		= $GLOBALS['Reque'] -> funpost("inv_age");
		$inv_marriageval 	= $GLOBALS['Reque'] -> funpost("inv_marriage");
		$inv_subjectval 	= $GLOBALS['Reque'] -> funpost("inv_subject");
		$inv_describeval 	= html_entity_decode($GLOBALS['Reque'] -> funpost("inv_describe"));
		$inv_requestsval 	= html_entity_decode($GLOBALS['Reque'] -> funpost("inv_requests"));
		
		$inv_enabledval 	= $GLOBALS['Reque'] -> funpost("inv_enabled");

		$inv_provinceval 	= $GLOBALS['Reque'] -> funpost("idprovince");
		$inv_cityval 		= $GLOBALS['Reque'] -> funpost("idcity");
		$inv_districtval 	= $GLOBALS['Reque'] -> funpost("iddistrict");
		$inv_pcdallval		= $GLOBALS['Reque'] -> funpost("hiprovince").$GLOBALS['Reque'] -> funpost("hicity").$GLOBALS['Reque'] -> funpost("hidistrict");
		
		
		//$hiprovince 		= $GLOBALS['Reque'] -> funpost("hiprovince");
		//$hicity 			= $GLOBALS['Reque'] -> funpost("hicity");
		//$hidistrict 		= $GLOBALS['Reque'] -> funpost("hidistrict");
		
		//exit();
		
		$inv_activetimeval 	= strtotime($GLOBALS['Reque'] -> funpost("inv_activetime"));

		if( $inv_positionval !='' and $inv_numval !='' and $inv_typeval !='' and $inv_yearval !='' )
		{
			$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."invite  WHERE inv_position = '".$inv_positionval."' ORDER BY `inv_id` ";
			
			$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
			
			if( $info["CNUM"] < 1 )
			{
				$inv_addtimeval 	= time();
				
				$insertsql ="INSERT INTO `".SQL_PREFIX."invite` (`inv_position` , `inv_num` , `inv_type` , `inv_pay` , `inv_year`,`inv_educational` , `inv_sex` , `inv_age` , `inv_marriage` , `inv_subject` , `inv_province` ,`inv_city` ,`inv_district` ,inv_pcdall ,`inv_describe` , `inv_requests`  , `inv_addtime`,`inv_activetime`,`inv_enabled`) VALUES (  '$inv_positionval', '$inv_numval', '$inv_typeval', '$inv_payval', '$inv_yearval', '$inv_educationalval', '$inv_sexval', '$inv_ageval', '$inv_marriageval', '$inv_subjectval', '$inv_provinceval', '$inv_cityval','$inv_districtval','$inv_pcdallval','$inv_describeval','$inv_requestsval', '$inv_addtimeval','$inv_activetimeval','$inv_enabledval')";
				
				$GLOBALS['MySql'] -> querySql($insertsql);
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=infolist");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
			}else{
				
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_isrealyerror']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=add");
				$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
			}
			
		}else{
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=add");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');		
		}
		
		
	}
	
	function del( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];

		$deletesql ="DELETE FROM `".SQL_PREFIX."invite` WHERE `".SQL_PREFIX."invite`.`inv_id` in ( $infoid ) ";
		
		$GLOBALS['MySql'] -> querySql($deletesql);
		
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_delsusse']);
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=infolist");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function show( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];

		$upshow = " UPDATE `".SQL_PREFIX."invite` SET inv_enabled = 1  WHERE `".SQL_PREFIX."invite`.`inv_id` in ( $infoid ) ";

		$GLOBALS['MySql'] -> querySql($upshow);
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_showsusse'] );
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=infolist");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function hide( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		
		$uphide = " UPDATE `".SQL_PREFIX."invite` SET inv_enabled = 0  WHERE `".SQL_PREFIX."invite`.`inv_id` in ( $infoid ) ";

		$GLOBALS['MySql'] -> querySql($uphide);
		$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_hidesusse'] );
		$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
		$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=infolist");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	
	
	function info(  )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		$sqlQuery = " SELECT *  FROM  ".SQL_PREFIX."invite  WHERE inv_id = '".$infoid."' ORDER BY `inv_id` ";
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		
		$info["inv_activetime"] =   date('Y-m-d',$info["inv_activetime"]);
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'inv_describe' ,$info["inv_describe"],'Basic' );	//加载文本编辑器  具体描述
		
		$GLOBALS['Helpe'] -> load_ckeditor( $textName = 'inv_requests' ,$info["inv_requests"],'Basic',$uiColor = '#D3D3D3', $width = '800',$height = '120', $ckeditorLoadName = 'reqckeditorLoad');	//加载文本编辑器  岗位要求	

		
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=invite&act=editinfo");
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('inviteedit_tpl.html');
	
	}
	
	
	function editinfo( )
	{	
	
		$inv_idval 			= $GLOBALS['Reque'] -> funpost("inv_id");
		
		$inv_positionval 	= $GLOBALS['Reque'] -> funpost("inv_position");
		$inv_numval 		= $GLOBALS['Reque'] -> funpost("inv_num");
		$inv_typeval 		= $GLOBALS['Reque'] -> funpost("inv_type");
		$inv_payval 		= $GLOBALS['Reque'] -> funpost("inv_pay");
		$inv_yearval 		= $GLOBALS['Reque'] -> funpost("inv_year");
		$inv_educationalval = $GLOBALS['Reque'] -> funpost("inv_educational");
		$inv_sexval 		= $GLOBALS['Reque'] -> funpost("inv_sex");
		$inv_ageval 		= $GLOBALS['Reque'] -> funpost("inv_age");
		$inv_marriageval 	= $GLOBALS['Reque'] -> funpost("inv_marriage");
		$inv_subjectval 	= $GLOBALS['Reque'] -> funpost("inv_subject");
		$inv_describeval 	= html_entity_decode($GLOBALS['Reque'] -> funpost("inv_describe"));
		$inv_requestsval 	= html_entity_decode($GLOBALS['Reque'] -> funpost("inv_requests"));
		
		$inv_enabledval 			= $GLOBALS['Reque'] -> funpost("inv_enabled");
		
		$inv_provinceval 	= $GLOBALS['Reque'] -> funpost("idprovince");
		$inv_cityval 		= $GLOBALS['Reque'] -> funpost("idcity");
		$inv_districtval 	= $GLOBALS['Reque'] -> funpost("iddistrict");
		$inv_pcdallval		= $GLOBALS['Reque'] -> funpost("hiprovince").$GLOBALS['Reque'] -> funpost("hicity").$GLOBALS['Reque'] -> funpost("hidistrict");
		
		$hiprovince 		= $GLOBALS['Reque'] -> funpost("hiprovince");
		$hicity 			= $GLOBALS['Reque'] -> funpost("hicity");
		$hidistrict 		= $GLOBALS['Reque'] -> funpost("hidistrict");
		
		if($inv_positionval !='' and $inv_numval !='' and $inv_typeval !='' and $inv_yearval !='' )
		{
			
			$updatesql = " UPDATE `".SQL_PREFIX."invite` SET  inv_position = '".$inv_positionval."' , inv_num = '".$inv_numval."'  , inv_type = '".$inv_typeval."'  , inv_pay = '".$inv_payval."'  , inv_year = '".$inv_yearval."'  , inv_educational = '".$inv_educationalval."'  , inv_sex = '".$inv_sexval."'  , inv_age = '".$inv_ageval."'  , inv_marriage = '".$inv_marriageval."'  , inv_subject = '".$inv_subjectval."'  , inv_describe = '".$inv_describeval."' , inv_requests = '".$inv_requestsval."' , inv_enabled = '".$inv_enabledval."'  WHERE  inv_id = '".$inv_idval."' ";
			
			$GLOBALS['MySql'] -> querySql( $updatesql );
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=infolist");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
				
		}else{
		
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_losssusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=invite&act=info&id=".$inv_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');	
		}
	}
	
	
		
}

//nmon_x86_rhel4

$Invite = new Invite();

?>