<?php
require 'inc.php';
$obj_tab_search=new cls_tab_hr_job_search();

if(!isset($get_s_addtime1)) $get_s_addtime1="";
if(!isset($get_s_addtime2)) $get_s_addtime2="";
if(!isset($get_s_name)) $get_s_name="";

$page_footer_info=<<<HTML
HTML;


if($get_act=="del"){
	$arr_return=$obj_tab_search->on_del($get_id);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="del_sel"){
	$arr_return=$obj_tab_search->on_del($get_pageid);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
//·ÖÒ³
$str_where=" where 1";
$get_issearch=0;
if($get_s_name!=""){
	$get_s_name=str_replace(" ","%",$get_s_name);
	$str_x_where="search_name like '%".$get_s_name."%'";
	$get_issearch="1";
	$arr_s_uid=array();
	$obj_result = $obj_db->query("SELECT resume_user_id FROM ".DB_PRE."hr_resume where resume_name like '%".$get_s_name."%'");
	while($obj_rs = $obj_db->fetch_array($obj_result))
	{
		$arr_s_uid[]=$obj_rs["resume_user_id"];
	}
	if(count($arr_s_uid)>0){
		$str_s_company_uid=implode(",",$arr_s_uid);
		$str_where.=" and (".$str_x_where." or search_user_id in(".$str_s_company_uid."))";
	}else{
		$str_where.=" and ".$str_x_where;
	}
}
if(is_date($get_s_addtime1)){
	$str_where.=" and FROM_UNIXTIME(search_addtime)>='".$get_s_addtime1."'";
	$get_issearch="1";
}
if(is_date($get_s_addtime2)){
	$lng_x=format_date_int($get_s_addtime2)+86400;
	$str_s_regtime2=format_date($lng_x,"Y-m-d");
	$str_where.=" and FROM_UNIXTIME(search_addtime)<'".$str_s_regtime2."'";
	$get_issearch="1";
}
if(isset($get_fz_id) && intval($get_fz_id)>=0){
	$str_where.=" and search_fz_id='".$get_fz_id."'";
}

$arr_search=array();
$arr_userid=array();
$obj_rs   = $obj_db->get_one("SELECT count(*) as num FROM ".DB_PRE."hr_job_search".$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($int_total, $get_page, $int_pagesize);
$int_offset = $int_pagesize*($get_page-1);
$str_limit = " limit ".$int_offset.",".$int_pagesize;
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_job_search".$str_where." order by search_addtime desc".$str_limit);
while($obj_rs = $obj_db->fetch_array($obj_result))
{
	$arr_userid[]=$obj_rs["search_user_id"];
	$obj_rs["search_addtime"]=format_date($obj_rs["search_addtime"],"Y-m-d H:i");
	$arr_resume["id_".$obj_rs["search_user_id"]]="";
	$arr_search[] = $obj_rs;
}
if(count($arr_userid)>0){
	$str_userid=implode(",",$arr_userid);
	$obj_result = $obj_db->query("SELECT resume_user_id,resume_name FROM ".DB_PRE."hr_resume where resume_user_id in(".$str_userid.")");
	while($obj_rs = $obj_db->fetch_array($obj_result))
	{
		$arr_resume["id_".$obj_rs["resume_user_id"]]=$obj_rs["resume_name"];
	}
}
include "tpl/job_search.tpl.php";

?>