<?php
$int_pagesize=20;
(isset($get_page))? $get_page=intval($get_page):$get_page=1;
(isset($get_search_id))? $get_search_id=intval($get_search_id):$get_search_id=0;
$obj_tab_resumecategory=new cls_tab_hr_job_category();
$obj_tab_resume=new cls_tab_hr_resume();
$arr_userid=array();
$arr_company=array();
$arr_search_param=array();
if($get_search_id>0){
	$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_resume_search where search_id='".$get_search_id."'");
	if($obj_rs = $obj_db->fetch_array($obj_result))
	{
		$get_search_name=$obj_rs["search_name"];
		$get_search_jobtype=$obj_rs["search_jobtype"];
		$get_search_jobcategory=$obj_rs["search_jobcategory"];
		$get_search_area=$obj_rs["search_area"];
		$get_search_pubtime=$obj_rs["search_pubtime"];
		$get_search_keyword=$obj_rs["search_keyword"];
		$get_search_degree=$obj_rs["search_degree"];
		$get_search_degree_direction=$obj_rs["search_degree_direction"];
		$get_search_experience=$obj_rs["search_experience"];
		$get_search_sex=$obj_rs["search_sex"];
		$get_search_age1=$obj_rs["search_age1"];
		$get_search_age2=$obj_rs["search_age2"];
		$get_search_marry=$obj_rs["search_marry"];
		$get_search_height1=$obj_rs["search_height1"];
		$get_search_height2=$obj_rs["search_height2"];
		$get_search_school=$obj_rs["search_school"];
	}
}
$str_where=" where 1";

if(isset($get_search_experience)&&intval($get_search_experience)>0){
	$get_search_experience=intval($get_search_experience);
	$arr_search["search_experience"]=$get_search_experience;
	$str_where.=" and resume_experience>=".$get_search_experience;
	$arr_search_param["search_experience"]=urlencode($get_search_experience);
}else{
	$arr_search["search_experience"]=0;
}
(isset($get_search_degree_direction))? $arr_search["search_degree_direction"]=intval($get_search_degree_direction):$arr_search["search_degree_direction"]=0;
if(isset($get_search_degree)&&intval($get_search_degree)>0){
	$get_search_degree=intval($get_search_degree);
	$arr_search["degree"]=get_select_html($obj_tab_resume->degree,$get_search_degree);
	if($arr_search["search_degree_direction"]>0){
		$str_direction="=";
	}else if($arr_search["search_degree_direction"]<0){
		$str_direction="<";
	}else{
		$str_direction=">=";
	}
	$str_where.=" and resume_degree".$str_direction.$get_search_degree;
	$arr_search_param["resume_degree"]=urlencode($get_resume_degree);
}else{
	$arr_search["degree"]=get_select_html($obj_tab_resume->degree);
}
//取一年的时间值
$lng_year=format_date(TIME,'Y');
if(isset($get_search_age1)&&intval($get_search_age1)>0){
	$get_search_age1=intval($get_search_age1);
	$arr_search["search_age1"]=$get_search_age1;
	$lng_y=$lng_year-$get_search_age1;
	if($lng_y>0){
		$lng_y++;
		$lng_date=$lng_y."-01-01";
		$lng_y=format_date_int($lng_date);
		$str_where.=" and resume_birthday<='".$lng_y."'";
		$lng_y1=$lng_y;
	}
	$arr_search_param["search_age1"]=$get_search_age1;
}else{
	$arr_search["search_age1"]="0";
}
if(isset($get_search_age2)&&intval($get_search_age2)>0){
	$get_search_age2=intval($get_search_age2);
	$arr_search["search_age2"]=$get_search_age2;
	$lng_y=$lng_year-$get_search_age2;
	if($lng_y>0){
		$lng_date=$lng_y."-01-01";
		$lng_y=format_date_int($lng_date);
		$str_where.=" and resume_birthday>='".$lng_y."'";
		$lng_y2=$lng_y;
	}
	$arr_search_param["search_age2"]=$get_search_age2;
}else{
	$arr_search["search_age2"]="0";
}
if(isset($get_search_height1)&&intval($get_search_height1)>0){
	$str_where.=" and resume_height>='".intval($get_search_height1)."'";
	$arr_search["search_height1"]=$get_search_height1;
	$arr_search_param["search_height1"]=$get_search_height1;
}else{
	$arr_search["search_height1"]="0";
}
if(isset($get_search_height2)&&intval($get_search_height2)>0){
	$str_where.=" and resume_height<='".intval($get_search_height2)."'";
	$arr_search["search_height2"]=$get_search_height2;
	$arr_search_param["search_height2"]=$get_search_height2;
}else{
	$arr_search["search_height2"]="0";
}
if(isset($get_search_jobtype)&&$get_search_jobtype!=""){
	if(in_array($get_search_jobtype,$obj_tab_resume->jobtype)){
		$arr_search["jobtype"]=get_select_html($obj_tab_resume->jobtype,$get_search_jobtype);
		$str_where.=" and resume_jobtype='".$get_search_jobtype."'";
	}else{
		$arr_search["jobtype"]=get_select_html($obj_tab_resume->jobtype);
	}
	$arr_search_param["search_jobtype"]=urlencode($get_search_jobtype);
}else{
	$arr_search["jobtype"]=get_select_html($obj_tab_resume->jobtype);
}
if(isset($get_search_school)&&$get_search_school!=""){
	$str_where.=" and resume_school='".$get_search_school."'";
	$arr_search["search_school"]=$get_search_school;
	$arr_search_param["search_school"]=urlencode($get_search_school);
}else{
	$arr_search["search_school"]="";
}

(isset($get_search_pubtime))? $arr_search["search_pubtime"]=intval($get_search_pubtime):$arr_search["search_pubtime"]=0;
if($arr_search["search_pubtime"]!=0){
	$lng_time2=0;
	if($arr_search["search_pubtime"]>1){
		$lng_time=TIME-$arr_search["search_pubtime"]*86400;
	}else{
		switch($arr_search["search_pubtime"]){
			case 1:{
				$lng_time=format_date_int(date("Y-m-d",TIME));//当天
				break;
			}
			case -1:{
				$lng_time=get_toweek_time();//本周
				break;
			}
			case -2:{
				$str_date=date("Y-m",TIME)."-01";
				$lng_time=format_date_int($str_date);//本月
				break;
			}
			case -3:{
				$str_date=date("Y",TIME)."-01-01";
				$lng_time=format_date_int($str_date);//今年
				break;
			}
			case -4:{
				$lng_year=intval(date("Y",TIME))-1;
				$str_date=$lng_year."-01-01";
				$lng_time=format_date_int($str_date);//今年
				$str_date=date("Y",TIME)."-01-01";
				$lng_time2=format_date_int($str_date);//今年
				break;
			}
		}
	}
	$str_where.=" and resume_updatetime>='".$lng_time."'";
	if($lng_time2>0) $str_where.=" and resume_updatetime<'".$lng_time2."'";
	$arr_search_param["search_pubtime"]=$get_search_pubtime;
}
if(isset($get_search_sex)&&$get_search_sex!=""){
	if(in_array($get_search_sex,array("男","女"))){
		$str_where.=" and resume_sex='".$get_search_sex."'";
	}
	$arr_search["search_sex"]=$get_search_sex;
	$arr_search_param["search_sex"]=urlencode($get_search_sex);
}else{
	$arr_search["search_sex"]="";
}
if(isset($get_search_marry)&&$get_search_marry!=""){
	if(in_array($get_search_marry,array("未婚","已婚"))){
		$str_where.=" and resume_marry='".$get_search_marry."'";
	}
	$arr_search["search_marry"]=$get_search_marry;
	$arr_search_param["search_marry"]=urlencode($get_search_marry);
}else{
	$arr_search["search_marry"]="";
}
if(isset($get_search_keyword)&&$get_search_keyword!=""){
	$arr_search["search_keyword"]=$get_search_keyword;
	$str_word=format_sql_safe($get_search_keyword);
	$str_where.=" and (resume_name like '%".$str_word."%' or resume_jobname like '%".$str_word."%')";
	$arr_search_param["search_keyword"]=urlencode($get_search_keyword);
}else{
	$arr_search["search_keyword"]="";
}
if(isset($get_search_jobcategory)&&trim($get_search_jobcategory)!=""){
	$arr_search["search_jobcategory"]=$get_search_jobcategory;
	$arr_search["jobcategorytxt"]=format_len($get_search_jobcategory,40,"...");
	$arr_category=explode("|",$get_search_jobcategory);
	$arr_x=array();
	foreach($arr_category as $item){
		if($item!=""){
			$item=format_sql_safe($item);
			$item=str_replace(" ","%",$item);
			$arr_x[]="resume_jobcategory like '%".$item."%'";
		}
	}
	if(count($arr_x)>0){
		$str_x=implode(" or ",$arr_x);
		$str_where.=" and (".$str_x.")";
	}
}else{
	$arr_search["jobcategorytxt"]="不限";
	$arr_search["search_jobcategory"]="";
}
if(isset($get_search_area)&&$get_search_area!=""){
	$arr_search["search_area"]=$get_search_area;
	$arr_search["areatxt"]=format_len($get_search_area,40,"...");
	$get_search_area=format_sql_safe($get_search_area);
	$get_search_area=str_replace(" ","%",$get_search_area);
	$str_where.=" and resume_area like '%".$get_search_area."%'";
}else{
	$arr_search["areatxt"]="不限";
	$arr_search["search_area"]="";
}

$this_param="";
$arr_x=array();
foreach($arr_search_param as $item=>$key){
	$arr_x[]=$item."=".$key;
}
$this_param=implode("&",$arr_x);
if($this_param!="") $this_param="&".$this_param;


$arr_resume = array();
$obj_rs  = $obj_db->get_one("SELECT count(*) as num FROM ".DB_PRE."hr_resume".$str_where);
$int_total=$obj_rs["num"];
$int_pages= ceil($int_total/$int_pagesize);
$get_page = min($int_pages, $get_page);
$get_page = max($get_page, 1);
$page_split_page=get_pages_html($int_total, $get_page, $int_pagesize,"?app=resumelist".$this_param);
$int_offset = $int_pagesize*($get_page-1);
$str_limit = " limit ".$int_offset.",".$int_pagesize;
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_resume".$str_where." order by resume_updatetime desc".$str_limit);
$lng_x=1;
$arr_degree=$obj_tab_resume->degree;
while($obj_rs = $obj_db->fetch_array($obj_result)){
	if($lng_x==0){
		$lng_x=1;
		$obj_rs["rowid"]=1;
	}else{
		$lng_x=0;
		$obj_rs["rowid"]=2;
	}
	$obj_rs["age"]="";
	$lng_year_now=format_date(TIME,"Y");
	$lng_year=format_date($obj_rs["resume_birthday"],"Y");
	if($lng_year>0) $obj_rs["age"]=$lng_year_now-$lng_year;
	$obj_rs["degree"]=array_search($obj_rs["resume_degree"],$arr_degree);
	$obj_rs["updatetime"]=format_date($obj_rs["resume_updatetime"],"Y-m-d");
	$obj_rs["url"]=$obj_tab_resume->get_url($obj_rs["resume_id"]);
	$arr_resume[]=$obj_rs;
}

?>