<?php
require "inc.php";
$is_err=0;
if(!isset($get_userid)) $get_userid="";
if(!$obj_ctl_user->is_login()){
	$obj_msg->alert("您还没有登录，不能发送应聘邀请！");
	$obj_msg->js("div_hide_show_parent('winJobInvite');");
	$is_err=1;
}
if($obj_ctl_user->type!="company"){
	$obj_msg->alert("您不是企业会员，不能发送应聘邀请！");
	$obj_msg->js("div_hide_show_parent('winJobInvite');");
	$is_err=1;
}
if(!isset($get_userid)||$get_userid==""){
	$obj_msg->alert("请选择邀请的对象！");
	$obj_msg->js("div_hide_show_parent('winJobInvite');");
	$is_err=1;
}
if(isset($get_act)&&$get_act=="save"&&$is_err==0){
	$arr_id=explode(",",$get_userid);
	$obj_tab_job_apply=new cls_tab_hr_job_invite();
	//过滤userid
	$arr_userid=array();
	foreach($arr_id as $item){
		$lng_userid=intval($item);
		if($lng_userid>0){
			$arr_userid[]=$lng_userid;
		}
	}
	$str_msg="";
	if(count($arr_userid)>0){
		$str_userid=implode(",",$arr_userid);
		$obj_result = $obj_db->query("SELECT resume_user_id,resume_id FROM ".DB_PRE."hr_resume where resume_user_id in(".$str_userid.")");
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$arr_fields=array();
			$arr_fields["invite_resume_user_id"]=$obj_rs["resume_user_id"];
			$arr_fields["invite_intro"]=$get_apply_intro;
			$arr_fields["invite_user_id"]=$obj_ctl_user->id;
			$arr_msg=$obj_tab_job_apply->on_save($arr_fields);
			if($arr_msg["err"]!=""){
				$str_msg=$arr_msg["err"];
			}
		}
		if($str_msg!=""){
			$obj_msg->alert($str_msg);
			$obj_msg->js("div_hide_show_parent('winJobInvite');");
		}else{
			$obj_msg->alert("成功发送邀请！");
			$obj_msg->js("div_hide_show_parent('winJobInvite');");
		}
	}else{
		$obj_msg->alert("受邀请的人不存在！");
		$obj_msg->js("div_hide_show_parent('winJobInvite');");
	}

}
$this_letter="";
$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."hr_letter where letter_user_id='".$obj_ctl_user->id."'");
if($obj_rs = $obj_db->fetch_array($obj_result))
{
	$this_letter = $obj_rs["letter_content"];
}
include 'tpl/job.invite.tpl.php';
?>