<?php
$obj_tab_job_view=new cls_tab_hr_job_view();

if(isset($get_act)&&$get_act=="del"&&isset($get_id)&&$get_id>0){
	$arr_msg=$obj_tab_job_view->on_del($get_id);
	if($arr_msg["err"]!="")
	{
		$obj_msg->alert($arr_msg["err"]);
	}
}
if(isset($get_act)&&$get_act=="del_s"&&isset($get_viewids)){
	$arr_msg=$obj_tab_job_view->on_del($get_viewids);
	if($arr_msg["err"]!="")
	{
		$obj_msg->alert($arr_msg["err"]);
	}
}
$str_where=" where view_company_id='".$obj_ctl_user->get_company_id()."'";
$arr_view=array();
$arr_user_id=array();
$arr_job_id=array();
$arr_job=array();

(isset($get_page))? $get_page=intval($get_page):$get_page=1;
$int_pagesize=10;
$obj_rs  = $obj_db->get_one("SELECT count(*) as num FROM ".DB_PRE."hr_job_view".$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_view".$str_where." order by view_state,view_updatetime desc".$str_limit);
while($obj_rs = $obj_db->fetch_array($obj_result))
{
	$obj_rs["updatetime"]=format_date($obj_rs["view_updatetime"]);
	$arr_user_id[]=$obj_rs["view_user_id"];
	$arr_job_id[]=$obj_rs["view_job_id"];
	$arr_view[]=$obj_rs;
}
if(count($arr_user_id)>0){
	$str_user_ids=implode(",",$arr_user_id);
	$obj_result = $obj_db->query("SELECT resume_id,resume_user_id,resume_name,resume_sex,resume_birthday FROM ".DB_PRE."hr_resume where resume_user_id in(".$str_user_ids.")");
	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;
		$arr_resume["id_".$obj_rs["resume_user_id"]]=$obj_rs;
	}
	$str_job_ids=implode(",",$arr_job_id);
	if($str_job_ids!=""){
		$obj_result = $obj_db->query("SELECT job_id,job_name FROM ".DB_PRE."hr_job where job_id in(".$str_job_ids.")");
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$arr_job["id_".$obj_rs["job_id"]]=$obj_rs;
		}
	}
}
//设置状态被查看过
$obj_db->execute("update ".DB_PRE."hr_job_view set view_state=1".$str_where);
?>