<?php
if (!defined('GV32_COM')) exit('GV32.COM No direct script access allowed');
class Employ
{
	function Employ()
	{

	}
	
	function infolist(  )
	{
		$pageSize = 20 ;
		
		$invidval 	= $GLOBALS['Reque'] -> getval["invid"];
		$pageNumval = $GLOBALS['Reque'] -> getval["pageNum"];

		
		if( $pageNumval > 1 )
		{
			$pageNum  = $pageNumval;
			$LIMITnum = ceil( ( $pageNumval -1 ) * $pageSize );
		}else{
			$pageNum  = 1;
			$LIMITnum = 0 ;
		}
		$whereadd = '';
		if($GLOBALS['Reque'] -> getval["invid"] !='')
		{   
			$invidval 	= $GLOBALS['Reque'] -> getval["invid"];
			$whereadd  .= " AND ( inv_id =  ".$invidval." )";
			$endArray["invid"] = $invidval;  
		}

		$sqlQuery = " SELECT eml_id,  eml_position, eml_name, eml_year, eml_sex, eml_subject ,eml_educational ,eml_birthday , eml_addtime, eml_status FROM  ".SQL_PREFIX."employ  WHERE 1  $whereadd  GROUP BY eml_id ORDER BY eml_addtime DESC , `eml_id` LIMIT  $LIMITnum , $pageSize ";
		
		$info = $GLOBALS['MySql'] -> selectInfo( $sqlQuery );
		
		$sqlQuery = " SELECT count(1) as CNUM  FROM  ".SQL_PREFIX."employ  WHERE 1 $whereadd  ORDER BY `eml_id`  ";
		
		$infocount = $GLOBALS['MySql'] -> selectOne( $sqlQuery );

		$PageStr = $GLOBALS['Page']->buildPageStr( $url = '?load=employ&act=infolist', $pageNum  , $pageSize  , $resultCount = $infocount["CNUM"] ,$endArray );
		
		$GLOBALS['Templ']->assign('PageStr',$PageStr);
		$GLOBALS['Templ']->assign('info',$info);
		$GLOBALS['Templ']->display('employ_tpl.html');
		
	}
	
	function add(   )
	{
		$GLOBALS['Templ'] -> caching = true;
		$GLOBALS['Templ'] -> cache_lifetime = 86400 ;  //60 *  60 * 24

		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=employ&act=addinfo");
		
		$GLOBALS['Templ']->display('employadd_tpl.html');
	}
	
	function addinfo()
	{
		$eml_positionval 		= $GLOBALS['Reque'] -> funpost("eml_position");
		$eml_nameval 			= $GLOBALS['Reque'] -> funpost("eml_name");
		$eml_sexval 			= $GLOBALS['Reque'] -> funpost("eml_sex");
		$eml_nativeval 			= $GLOBALS['Reque'] -> funpost("eml_native");
		$eml_educationalval 	= $GLOBALS['Reque'] -> funpost("eml_educational");	
		$eml_birthdayval 		= $GLOBALS['Reque'] -> funpost("eml_birthday");
		$eml_schoolval 			= $GLOBALS['Reque'] -> funpost("eml_school");
		$eml_startworkval 		= $GLOBALS['Reque'] -> funpost("eml_startwork");
		$eml_payval 			= $GLOBALS['Reque'] -> funpost("eml_pay");
		$eml_yearval 			= $GLOBALS['Reque'] -> funpost("eml_year");
		$eml_phoneval 			= $GLOBALS['Reque'] -> funpost("eml_phone");
		$eml_emailval 			= $GLOBALS['Reque'] -> funpost("eml_email");
		$eml_marriageval 		= $GLOBALS['Reque'] -> funpost("eml_marriage");
		$eml_subjectval 		= $GLOBALS['Reque'] -> funpost("eml_subject");
		$eml_resumeval 			= $GLOBALS['Reque'] -> funpost("eml_resume");
		$eml_enclosurefileval 	= $GLOBALS['Reque'] -> funpost("eml_enclosurefile");
		$eml_enclosureval 		= $GLOBALS['Reque'] -> funpost("eml_enclosure");
		$eml_statusval 			= $GLOBALS['Reque'] -> funpost("eml_status");
		
		$eml_addtimeval 		= time();
		
		if($eml_positionval !='' and $eml_nameval !='' and $eml_sexval !='' and $eml_nativeval != '' )
		{

				$insertip ="INSERT INTO `".SQL_PREFIX."employ` (`eml_position` , `eml_name` , `eml_sex` , `eml_native` , `eml_educational`,`eml_birthday` , `eml_school` , `eml_startwork` , `eml_pay` , `eml_year` , `eml_phone` , `eml_email`,`eml_marriage` , `eml_subject` , `eml_resume` , `eml_enclosurefile` , `eml_enclosure`,`eml_addtime`,`eml_status`) VALUES (  '$eml_positionval', '$eml_nameval', '$eml_sexval', '$eml_nativeval', '$eml_educationalval', '$eml_birthdayval', '$eml_schoolval', '$eml_startworkval', '$eml_payval' , '$eml_yearval', '$eml_phoneval', '$eml_emailval', '$eml_marriageval', '$eml_subjectval', '$eml_resumeval', '$eml_enclosurefileval', '$eml_enclosureval', '$eml_addtimeval','$eml_statusval')";
				
				$GLOBALS['MySql'] -> querySql($insertip);
				$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_addsusse']);
				$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
				$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employ&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=employ&act=add");
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');		}
			//var_dump($_REQUEST);
	}
	
	function del( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];

		$deletesql ="DELETE FROM `".SQL_PREFIX."employ` WHERE `".SQL_PREFIX."employ`.`eml_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=employ&act=infolist");
		$GLOBALS['Templ'] -> display('suggestion_tpl.html');
	}
	
	function info( )
	{
		$infoid = $GLOBALS['Reque'] -> getval["id"];
		$sqlQuery = " SELECT *  FROM  ".SQL_PREFIX."employ  WHERE eml_id = '".$infoid."' ORDER BY `eml_id` ";
		$info = $GLOBALS['MySql'] -> selectOne($sqlQuery);
		$GLOBALS['Templ']->assign('actUrl',EMPLOYEE_WEBURL."/index.php?load=employ&act=editinfo");
		$GLOBALS['Templ'] -> assign('info',$info);
		$GLOBALS['Templ'] -> display('employedit_tpl.html');
	
	}
	
	
	function editinfo(  )
	{	
	
		$eml_idval 				= $GLOBALS['Reque'] -> funpost("eml_id");	
		$eml_positionval 		= $GLOBALS['Reque'] -> funpost("eml_position");
		$eml_nameval 			= $GLOBALS['Reque'] -> funpost("eml_name");
		$eml_sexval 			= $GLOBALS['Reque'] -> funpost("eml_sex");
		$eml_nativeval 			= $GLOBALS['Reque'] -> funpost("eml_native");
		$eml_educationalval 	= $GLOBALS['Reque'] -> funpost("eml_educational");	
		$eml_birthdayval 		= $GLOBALS['Reque'] -> funpost("eml_birthday");
		$eml_schoolval 			= $GLOBALS['Reque'] -> funpost("eml_school");
		$eml_startworkval 		= $GLOBALS['Reque'] -> funpost("eml_startwork");
		$eml_payval 			= $GLOBALS['Reque'] -> funpost("eml_pay");
		$eml_yearval 			= $GLOBALS['Reque'] -> funpost("eml_year");
		$eml_phoneval 			= $GLOBALS['Reque'] -> funpost("eml_phone");
		$eml_emailval 			= $GLOBALS['Reque'] -> funpost("eml_email");
		$eml_marriageval 		= $GLOBALS['Reque'] -> funpost("eml_marriage");
		$eml_subjectval 		= $GLOBALS['Reque'] -> funpost("eml_subject");
		$eml_resumeval 			= $GLOBALS['Reque'] -> funpost("eml_resume");
		$eml_enclosurefileval 	= $GLOBALS['Reque'] -> funpost("eml_enclosurefile");
		$eml_enclosureval 		= $GLOBALS['Reque'] -> funpost("eml_enclosure");	
		
		$eml_statusval 			= $GLOBALS['Reque'] -> funpost("eml_status");
		
		if($eml_idval !='' and $eml_positionval !='' and $eml_nameval !='' and $eml_sexval !='' and $eml_nativeval != ''  )
		{
			
			$updateemp = "UPDATE `".SQL_PREFIX."employ` SET  eml_position = '".$eml_positionval."' , eml_name = '".$eml_nameval."', eml_sex = '".$eml_sexval."', eml_native = '".$eml_nativeval."', eml_educational = '".$eml_educationalval."' , eml_birthday = '".$eml_birthdayval."', eml_school = '".$eml_schoolval."', eml_startwork = '".$eml_startworkval."', eml_pay = '".$eml_payval."' ,eml_year ='".$eml_yearval."', eml_phone = '".$eml_phoneval."' , eml_email = '".$eml_emailval."', eml_marriage = '".$eml_marriageval."', eml_subject = '".$eml_subjectval."', eml_resume = '".$eml_resumeval."' , eml_enclosurefile = '".$eml_enclosurefileval."', eml_enclosure = '".$eml_enclosureval."',eml_status = '".$eml_statusval."'  WHERE  eml_id = '".$eml_idval."' ";
			
			
			$GLOBALS['MySql'] -> querySql( $updateemp );
			
			$GLOBALS['Templ'] -> assign('infomessage',$GLOBALS['_LANG']['bd_editsusse']);
			$GLOBALS['Templ'] -> assign('URL_TIME',URL_TIME);
			$GLOBALS['Templ'] -> assign('geturl',EMPLOYEE_WEBURL."/index.php?load=employ&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=employ&act=info&id=".$eml_idval);
			$GLOBALS['Templ'] -> display('suggestion_tpl.html');
			
		}
		
		
	}
		
}

$Employ = new Employ();

?>