<?php
function get_temp_job($msg_name,$msg_limit1,$msg_limit2,$msg_sort,$msg_where="",$msg_pagesize=0){
	global $obj_db,$sql_return;
	$msg_limit1=intval($msg_limit1);
	$msg_limit2=intval($msg_limit2);
	if($msg_limit1<0) $msg_limit1=0;
	if($msg_limit2<$msg_limit1) $msg_limit2=$msg_limit1+10;

	$obj_tab_company=new cls_tab_hr_company();
	$obj_tab_job=new cls_tab_hr_job();
	$arr_job=array();
	$str_where=" where job_user_id=company_user_id";
	if($msg_where!="") $str_where.=" and ".$msg_where;
	$str_limit=" limit ".$msg_limit1.",".$msg_limit2;
	if($msg_pagesize>0){
		global $get_page;
		(empty($get_page) || !is_numeric($get_page))? $get_page=1 : $get_pae=intval($get_page);
		$obj_rs  = $obj_db->get_one("SELECT count(1) as num FROM ".DB_PRE."hr_job,".DB_PRE."hr_company".$str_where);
		$int_total=$obj_rs["num"];
		$int_pages= ceil($int_total/$msg_pagesize);
		$get_page = min($int_pages, $get_page);
		$get_page = max($get_page, 1);
		$page_split_page=get_pages_html($int_total, $get_page, $msg_pagesize,format_url_query(array('page'=>'')));
		$int_offset = $msg_pagesize*($get_page-1);
		$str_limit = " limit ".$int_offset.",".$msg_pagesize;
		$sql_return[$msg_name]["page"]=$page_split_page;
	}

	$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_job,".DB_PRE."hr_company".$str_where.$msg_sort.$str_limit);
	$lng_x=1;
	while($obj_rs = $obj_db->fetch_array($obj_result)){
		$obj_rs["url"]=$obj_tab_job->get_url($obj_rs["job_id"]);
		$obj_rs["updatetime"]=format_date($obj_rs["job_updatetime"],"Y-m-d");
		$obj_rs["company_url"]=$obj_tab_company->get_url($obj_rs["company_id"]);
		$arr_job[]=$obj_rs;
	}
	if($msg_pagesize>0){
		$sql_return[$msg_name]["list"]=$arr_job;
	}else{
		$sql_return[$msg_name]=$arr_job;
	}
}
function get_temp_company($msg_name,$msg_limit1,$msg_limit2,$msg_sort,$msg_where="",$msg_pagesize=0){
	global $obj_db,$sql_return;
	$msg_limit1=intval($msg_limit1);
	$msg_limit2=intval($msg_limit2);
	if($msg_limit1<0) $msg_limit1=0;
	if($msg_limit2<$msg_limit1) $msg_limit2=$msg_limit1+10;
	$str_limit=" limit ".$msg_limit1.",".$msg_limit2;

	$str_where=" where 1=1";
	if($msg_where!="") $str_where.=" and ".$msg_where;
	if($msg_pagesize>0){
		global $get_page;
		(empty($get_page) || !is_numeric($get_page))? $get_page=1 : $get_pae=intval($get_page);
		$obj_rs  = $obj_db->get_one("SELECT count(1) as num FROM ".DB_PRE."hr_company".$str_where);
		$int_total=$obj_rs["num"];
		$int_pages= ceil($int_total/$msg_pagesize);
		$get_page = min($int_pages, $get_page);
		$get_page = max($get_page, 1);
		$page_split_page=get_pages_html($int_total, $get_page, $msg_pagesize,format_url_query(array('page'=>'')));
		$int_offset = $msg_pagesize*($get_page-1);
		$str_limit = " limit ".$int_offset.",".$msg_pagesize;
		$sql_return[$msg_name]["page"]=$page_split_page;
	}
	$obj_tab_company=new cls_tab_hr_company();
	$arr_resume=array();
	$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_company ".$str_where.$msg_sort.$str_limit);
	$lng_x=1;
	while($obj_rs = $obj_db->fetch_array($obj_result)){
		$obj_rs["url"]=$obj_tab_company->get_url($obj_rs["company_id"]);
		$obj_rs["updatetime"]=format_date($obj_rs["company_updatetime"],"Y-m-d");
		$obj_rs["addtime"]=format_date($obj_rs["company_addtime"],"Y-m-d");
		$arr_resume[]=$obj_rs;
	}
	if($msg_pagesize>0){
		$sql_return[$msg_name]["list"]=$arr_resume;
	}else{
		$sql_return[$msg_name]=$arr_resume;
	}
}
function get_temp_company_job($msg_name,$msg_limit1,$msg_limit2,$msg_sort,$msg_where="",$msg_pagesize=0){
	global $obj_db,$sql_return;

	$obj_tab_job=new cls_tab_hr_job();
	$obj_tab_company=new cls_tab_hr_company();

	$arr_company=array();
	$arr_userid=array();
	$arr_job=array();
	$msg_limit1=intval($msg_limit1);
	$msg_limit2=intval($msg_limit2);
	if($msg_limit1<0) $msg_limit1=0;
	if($msg_limit2<$msg_limit1) $msg_limit2=$msg_limit1+10;
	$str_limit=" limit ".$msg_limit1.",".$msg_limit2;
	$str_where=" where company_pubtime>0";
	if($msg_where!="") $str_where.=" and ".$msg_where;
	if($msg_pagesize>0){
		global $get_page;
		(empty($get_page) || !is_numeric($get_page))? $get_page=1 : $get_pae=intval($get_page);
		$obj_rs  = $obj_db->get_one("SELECT count(1) as num FROM ".DB_PRE."hr_company".$str_where);
		$int_total=$obj_rs["num"];
		$int_pages= ceil($int_total/$msg_pagesize);
		$get_page = min($int_pages, $get_page);
		$get_page = max($get_page, 1);
		$page_split_page=get_pages_html($int_total, $get_page, $msg_pagesize,format_url_query(array('page'=>'')));
		$int_offset = $msg_pagesize*($get_page-1);
		$str_limit = " limit ".$int_offset.",".$msg_pagesize;
		$sql_return[$msg_name]["page"]=$page_split_page;
	}

	$obj_result = $obj_db->query("SELECT company_id,company_name,company_user_id,company_logo FROM ".DB_PRE."hr_company ".$str_whre.$msg_sort.$str_limit);
	while($obj_rs = $obj_db->fetch_array($obj_result))
	{
		$arr_userid[]=$obj_rs["company_user_id"];
		$arr_job["id_".$obj_rs["company_user_id"]]="";
		$obj_rs["url"]=$obj_tab_company->get_url($obj_rs["company_id"]);
		$arr_new_company[]=$obj_rs;
	}

	$str_userid=implode(",",$arr_userid);
	$lng_x=($msg_limit2-$msg_limit1)*2;
	$obj_result = $obj_db->query("SELECT job_id,job_name,job_user_id FROM ".DB_PRE."hr_job where job_user_id in(".$str_userid.") order by job_updatetime desc limit 0,".$lng_x);
	$arr_x=array();
	while($obj_rs = $obj_db->fetch_array($obj_result))
	{
		$obj_rs["url"]=$obj_tab_job->get_url($obj_rs["job_id"]);
		if(isset($arr_job["id_".$obj_rs["job_user_id"]])&&$arr_job["id_".$obj_rs["job_user_id"]]!=""){
			if($arr_x["id_".$obj_rs["job_user_id"]]<3) $arr_job["id_".$obj_rs["job_user_id"]].="/<a href='".$obj_rs["url"]."' target='_blank' title='".$obj_rs["job_name"]."'>".$obj_rs["job_name"]."</a>";
		}else{
			$arr_job["id_".$obj_rs["job_user_id"]]="<a href='".$obj_rs["url"]."' target='_blank' title='".$obj_rs["job_name"]."'>".$obj_rs["job_name"]."</a>";
			$arr_x["id_".$obj_rs["job_user_id"]]=0;
		}
		$arr_x["id_".$obj_rs["job_user_id"]]=$arr_x["id_".$obj_rs["job_user_id"]]+1;
	}
	$arr_x=array();
	foreach($arr_new_company as $item){
		if(!isset($arr_job["id_".$item["company_user_id"]])) continue;
		$item["joblist"]=$arr_job["id_".$item["company_user_id"]];
		$arr_x[]=$item;
	}
	if($msg_pagesize>0){
		$sql_return[$msg_name]["list"]=$arr_x;
	}else{
		$sql_return[$msg_name]=$arr_x;
	}
}

function get_temp_resume($msg_name,$msg_limit1,$msg_limit2,$msg_sort,$msg_where="",$msg_pagesize=0){
	require_once(SYS_ROOT.'/cls_tab/tab.hr.resume.php');
	global $obj_db,$sql_return;
	$msg_limit1=intval($msg_limit1);
	$msg_limit2=intval($msg_limit2);
	if($msg_limit1<0) $msg_limit1=0;
	if($msg_limit2<$msg_limit1) $msg_limit2=$msg_limit1+10;
	$str_limit=" limit ".$msg_limit1.",".$msg_limit2;
	$str_where=" where resume_state>0";
	if($msg_where!="") $str_where.=" and ".$msg_where;
	if($msg_pagesize>0){
		global $get_page;
		(empty($get_page) || !is_numeric($get_page))? $get_page=1 : $get_pae=intval($get_page);
		$obj_rs  = $obj_db->get_one("SELECT count(1) as num FROM ".DB_PRE."hr_resume".$str_where);
		$int_total=$obj_rs["num"];
		$int_pages= ceil($int_total/$msg_pagesize);
		$get_page = min($int_pages, $get_page);
		$get_page = max($get_page, 1);
		$page_split_page=get_pages_html($int_total, $get_page, $msg_pagesize,format_url_query(array('page'=>'')));
		$int_offset = $msg_pagesize*($get_page-1);
		$str_limit = " limit ".$int_offset.",".$msg_pagesize;
		$sql_return[$msg_name]["page"]=$page_split_page;
	}

	$obj_tab_resume=new cls_tab_hr_resume();
	$arr_resume=array();
	$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_resume ".$str_where.$msg_sort.$str_limit);
	$lng_x=1;
	$arr_degree=$obj_tab_resume->degree;
	while($obj_rs = $obj_db->fetch_array($obj_result)){
		$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;
	}
	if($msg_pagesize>0){
		$sql_return[$msg_name]["list"]=$arr_resume;
	}else{
		$sql_return[$msg_name]=$arr_resume;
	}
}
?>