<?php
$obj_tab_resume=new cls_tab_hr_resume();

(isset($get_id))? $get_id=intval($get_id):$get_id=0;
(isset($get_uid))? $get_uid=intval($get_uid):$get_uid=0;
if($get_id>1){
	$str_where=" where resume_id='".$get_id."'";
}else if($get_uid>0){
	$str_where=" where resume_user_id='".$get_uid."'";
}else if($obj_ctl_user->id>0){
	$str_where=" where resume_user_id='".$obj_ctl_user->id."'";
}else{
	$obj_msg->alert("没有找到相关简历！");
	exit;
}


$arr_degree=$obj_tab_resume->degree;

if(!$obj_tab_resume->ishtml||(isset($get_appdir)&&$get_appdir=="label")){
	//更新浏览次数
	$str_sql="update ".DB_PRE."hr_resume set resume_hits=resume_hits+1".$str_where;
	$obj_db->execute($str_sql);
}

$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_resume".$str_where);
if($obj_rs = $obj_db->fetch_array($obj_result)){
	$obj_rs["updatetime"]=format_date($obj_rs["resume_updatetime"],"Y-m-d");
	$obj_rs["birthday"]=format_date($obj_rs["resume_birthday"],"Y-m");
	$obj_rs["degree"]=array_search($obj_rs["resume_degree"],$arr_degree);
	if(strlen($obj_rs["resume_voucherid"])>14){
		$obj_rs["voucherid"]=substr($obj_rs["resume_voucherid"],0,-6)."******";
	}else if(strlen($obj_rs["resume_voucherid"])>4){
		$obj_rs["voucherid"]=substr($obj_rs["resume_voucherid"],0,-4)."****";
	}
	$obj_rs["resume_photo"]=get_html_url($obj_rs["resume_photo"]);
	$this_resume=$obj_rs;
}else{
	$obj_msg->alert("没有找到相关简历！");
	exit;
}

$obj_rs=$obj_db->get_one("select sum(verify_type) as val from ".DB_PRE."sys_verify where verify_user_id=".$this_resume["resume_user_id"]);
$this_verify=$obj_rs["val"];

//个人保密设置
$this_privacy["power"]=0;
if($this_resume["resume_privacy"]<0){
	//用户关闭了简历
	$this_privacy["power"]=0;
}else{
	//企业VIP类型
	$this_privacy["power"]=1;
	$this_vip["power"]=0;
	//用户是否已登录
	$this_vip["islogin"]=0;
	if($obj_ctl_user->id>0){
		$this_vip["islogin"]=1;
	}
	//只有企业或管理员才有权查看联系方式
	if($obj_ctl_user->is_admin()){
		$this_vip["power"]=1;
	}else if($obj_ctl_user->type=="company"){
		if(!$obj_tab_resume->ishtml||(isset($get_appdir)&&stristr($get_appdir,"label"))){
			$obj_result = $obj_db->query("SELECT b.*,a.company_vip_time,company_vip_endtime FROM ".DB_PRE."hr_company a inner join ".DB_PRE."hr_company_vip b on a.company_vip_id=b.vip_id where a.company_user_id='".$obj_ctl_user->id."'");
			if($obj_rs = $obj_db->fetch_array($obj_result)){
				//无特殊情况，允许查看
				$this_vip["power"]=1;
				if($obj_rs["vip_viewresume"]!=1){
					//VIP权限不够
					$this_vip["power"]=-3;
				}
				if(TIME>$obj_rs["company_vip_time"]){
					//VIP过期
					$this_vip["power"]=-2;
				}
			}else{
				//保密设置为只允许VIP企业会员查看
				if($this_resume["resume_privacy"]>2){
					$this_privacy["power"]=-2;
				}
			}
			$str_time=format_date(TIME,"Y-m-d");
			$lng_time=format_date_int($str_time);
			$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_resume_view where view_company_id=".$obj_ctl_user->id." and view_resume_id=".$this_resume["resume_id"]." and  view_addtime>".$lng_time);
			if(!$obj_rs = $obj_db->fetch_array($obj_result)){
				$arr_fields=array();
				$arr_fields["view_company_id"]=$obj_ctl_user->id;
				$arr_fields["view_resume_id"]=$this_resume["resume_id"];
				$arr_fields["view_state"]=0;
				$obj_resume_view=new cls_tab_hr_resume_view();
				$arr_return=$obj_resume_view->on_save($arr_fields);
				unset($obj_resume_view);
			}
		}
	}else{
		//非企业会员
		$this_vip["power"]=-1;
		//保密设置为只允许企业会员查看
		if($this_resume["resume_privacy"]>1){
			$this_privacy["power"]=-1;
		}
	}
}
if($this_resume["resume_user_id"]==$obj_ctl_user->id){
	$this_vip["power"]=1;
}

//是否生成html文件
$this_html=$obj_tab_resume->get_htmlinfo($this_resume["resume_id"]);

?>