<?php
/*
 * 74cms 猎头会员中心 
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__).'/hunter_common.php');
$smarty->assign('nav','jobs');
$act=trim($_GET["act"])?trim($_GET["act"]):"jobs";
//职位管理
if ($act=='jobs')
{
	$uid=intval($_SESSION['uid']);
	$time = intval(time());
	//排序
	$orderby = " order by recommend desc , refreshtime desc";
	//条件 
	$wheresql = " WHERE uid={$uid} AND utype=3";
	$wheresql_note =" WHERE uid={$uid} AND utype=3 ";
	$jobtype = intval($_GET['jobtype']);
	switch($jobtype){
		//已结束(已过期的和暂停的)
		case 2:
			$wheresql.=" AND (deadline<{$time} OR display=2) ";
			$wheresql_note.=" AND (deadline<{$time} OR (display=2 AND finishtime<>'')) ";
			break;
		//审核中
		case 3:
			$wheresql.=" AND audit=2 ";
			$wheresql_note.=" AND audit=2 ";
			break;
		//未通过
		case 4:
			$wheresql.=" AND audit=3 ";
			$wheresql_note.=" AND audit=3 ";
			break;
		//全部职位
		case 1:
			$wheresql.='';
			$wheresql_note.="";
			break;
		//正在发布
		default:
			$wheresql.=" AND audit=1 AND deadline>{$time} AND display=1 ";
			$wheresql_note.=" AND audit=1 AND deadline>{$time} AND display=1 ";
			break;
	}
	//查询条件
	$companyname_note = trim($_GET['companyname_note']);

	if(isset($companyname_note) && $companyname_note!="全部企业" && $companyname_note!=""){
		$wheresql.=" AND companyname_note ='".$companyname_note."'";
	}
	$jobs_name = trim($_GET['jobs_name']);
	if(isset($jobs_name) && $jobs_name<>'' && $jobs_name!="请输入职位名称"){
		$wheresql.=" AND jobs_name ='".$jobs_name."'";
	}
	//分页
	require_once(QISHI_ROOT_PATH.'include/page.class.php');
	$perpage=10;
	$total_sql="SELECT COUNT(*) AS num FROM ".table('jobs').$wheresql;
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$offset=($page->nowindex-1)*$perpage;
	$smarty->assign('title','职位管理 - 猎头会员中心 - '.$_CFG['site_name']);
	if($total_val>$perpage){
		$smarty->assign('page',$page->show(7));
	}
	//得到相应的职位
	$sql="SELECT * FROM ".table('jobs').$wheresql.$orderby;
	$smarty->assign('jobtype',$jobtype);
	$smarty->assign('act',$act);
	$smarty->assign('jobs',get_jobs($offset,$perpage,$sql,true));

	$companyname_note_sql="SELECT companyname_note FROM ".table('jobs').$wheresql_note.$orderby;
	$smarty->assign('companyname_note',get_hunter_jobs_companyname($companyname_note_sql));
	$smarty->display('member_hunter/hunter_jobs.htm');

}
//职位操作
elseif($act=='jobs_perform')
{
	global $_CFG;
	$uid = intval($_SESSION['uid']);
	$yid =!empty($_GET['y_id'])?$_GET['y_id']:$_POST['y_id'];
	$jobs_num=count($yid);
	if (empty($yid))
	{
		showmsg("你没有选择职位！",1);
	}
	//操作类型
	//获取经验规则积分规则
	$lever_rule=get_cache("hunter_level_rule");
	$points_rule=get_cache("points_rule");
	// 获取等级特权
	$lever_meal=get_hunter_level_meal($hunter_profile['level_meal']);
	$user_points=get_user_points($uid);//会员当前积分
	$refresh=trim($_GET['refresh']);
	$delete=trim($_GET['delete']);
	//刷新
    if ($refresh)
	{
		// 刷新次数
		$refresh_num=get_today_refresh_times($_SESSION['uid'],"3001");
		$refrestime=get_last_refresh_date($_SESSION['uid'],"3001");
		//最后刷新的时间距离现在的时间
		$duringtime=time()-$refrestime['max(addtime)'];
		$space = $_CFG['hunter_pointsmode_refresh_space']*60;
		if($duringtime<=$space)
		{
			showmsg($_CFG['hunter_pointsmode_refresh_space']."分钟内不能重复刷新职位！",2);	
		}
		else
		{
			if($refresh_num>$lever_meal['free_refresh_jobs'])
			{
				//刷新职位涉及到积分了
				if($points_rule['hunter_refresh_job']['value']>0)
				{
					//总共所需的积分
					$total_point=$jobs_num*$points_rule['hunter_refresh_job']['value'];
					if ($total_point>$user_points && $points_rule['hunter_refresh_job']['type']=="2")
					{
						$link[0]['text'] = "返回上一页";
						$link[0]['href'] = 'javascript:history.go(-1)';
						$link[1]['text'] = "立即充值";
						$link[1]['href'] = 'hunter_info.php?act=points_recharge';
						showmsg("您的".$_CFG['points_byname']."不足，请先充值！",0,$link);
					}
					//增减积分操作
					report_deal($_SESSION['uid'],$points_rule['hunter_refresh_job']['type'],$total_point);
					$user_points=get_user_points($uid);
					$operator=$points_rule['hunter_refresh_job']['type']=="1"?"+":"-";
					write_memberslog($_SESSION['uid'],3,2004,$_SESSION['username'],"积分剩余{$user_points}",0,"刷新了{$jobs_num}条职位",0);
					write_refresh_log($_SESSION['uid'],3001);
				}
			}
			else
			{
				write_refresh_log($_SESSION['uid'],3001);
			}
		}
		// 刷新涉及猎头经验值,每日上限100
		if($lever_rule['jobs_refresh']['value']>0)
		{
			$time=time();
			$today=mktime(0, 0, 0,date('m'), date('d'), date('Y'));
			$level=$db->getone("SELECT sum(level) num FROM ".table('members_handsel_level')." WHERE uid ='{$_SESSION['uid']}' AND htype='jobs_refresh' AND addtime>{$today}");
			$level=$level['num'];
			if($lever_rule['jobs_refresh']['type']==1 && $lever_rule['jobs_refresh']['daymax']>$level)
			{
				$level_val=$lever_rule['jobs_refresh']['value']*$jobs_num;
				level_deal($uid,$lever_rule['jobs_refresh']['type'],$level_val);
				$option=$lever_rule['jobs_refresh']['type']==1?"+":"-";
				level_meal_deal($uid);
				$db->query("INSERT INTO ".table('members_handsel_level')." (uid,htype,level,addtime) VALUES ('{$_SESSION['uid']}', 'jobs_refresh','{$level_val}','{$time}')");
				write_memberslog($_SESSION['uid'],3,2004,$_SESSION['username'],"经验：".$option.$level_val."",0,"刷新了{$jobs_num}条职位",0);
			}
			elseif($lever_rule['jobs_refresh']['type']==2)
			{
				$option=$lever_rule['jobs_refresh']['type']==1?"+":"-";
				$level_val=$lever_rule['jobs_refresh']['value']*$refresh_num;
				level_deal($uid,$lever_rule['jobs_refresh']['type'],$level_val);
				level_meal_deal($uid);
				write_memberslog($_SESSION['uid'],3,2004,$_SESSION['username'],"经验：".$option.$level_val."",0,"刷新了{$jobs_num}条职位",0);
			}
		}
		// 刷新以及操作
		// refresh_jobs($yid,$uid);
		showmsg("刷新职位成功！",2);
	}
	//恢复
	elseif (!empty($_REQUEST['display1']))
	{
		activate_jobs($yid,1,$_SESSION['uid']);
		showmsg("设置成功！",2);
	}
	//结束
	elseif (!empty($_REQUEST['display2']))
	{
		activate_jobs($yid,2,$_SESSION['uid']);
		showmsg("设置成功！",2);
	}
	//推广
	elseif(!empty($_GET['recommend1']))
	{
		if($points_rule['hunter_tg_job']['value']>0)
		{	
			$total_point=$jobs_num*$points_rule['hunter_tg_job']['value'];
			if($total_point>$user_points  && $points_rule['hunter_tg_job']['type']==2){
				showmsg("您的积分不足,不能推广职位!",1);
			}
			//增减积分操作
			report_deal($_SESSION['uid'],$company_tg_job_type,$company_tg_job_points);
			$user_points=get_user_points($_SESSION['uid']);
			$operator=$company_tg_job_type=="1"?"+":"-";
			write_memberslog($_SESSION['uid'],3,3004,$_SESSION['username'],"积分{$operator}{$total_point},剩余:{$user_points}",$_SESSION['parentuid'],"推广职位",1);
		}
		else
		{	
			write_memberslog($_SESSION['uid'],3,3004,$_SESSION['username'],"积分{$operator}{$total_point},剩余:{$user_points}",$_SESSION['parentuid'],"推广职位",1);
		}
		// 加经验
		// 经验值= jobs_generalize  有每日上限
		if($lever_rule['jobs_generalize']['value']>0 )
		{
			$time=time();
			$today=mktime(0, 0, 0,date('m'), date('d'), date('Y'));
			$info=$db->getone("SELECT sum(level) as num FROM ".table('members_handsel_level')." WHERE uid ='{$_SESSION['uid']}' AND htype='jobs_generalize' AND addtime>{$today}  LIMIT 1");
			if($lever_rule['jobs_generalize']['type']==1 && $lever_rule['jobs_generalize']['daymax']>$info['num'])
			{
				$level_val=$lever_rule['jobs_generalize']['value']*$jobs_num;
				level_deal($uid,$lever_rule['jobs_generalize']['type'],$level_val);
				level_meal_deal($uid);
				$db->query("INSERT INTO ".table('members_handsel_level')." (uid,htype,level,addtime) VALUES ('{$_SESSION['uid']}', 'jobs_generalize',{$lever_rule['jobs_generalize']['value']},'{$time}')");
				write_memberslog($_SESSION['uid'],3,1401,$_SESSION['username'],"经验".$lever_rule["jobs_generalize"]['type'].$level_val,0,"推广职位",1);
			}
			elseif($lever_rule['jobs_generalize']['type']==2)
			{
				$level_val=$lever_rule['jobs_generalize']['value']*$jobs_num;
				level_deal($uid,$lever_rule['jobs_generalize']['type'],$level_val);
				level_meal_deal($uid);
				write_memberslog($_SESSION['uid'],3,1401,$_SESSION['username'],"经验".$lever_rule["jobs_generalize"]['type'].$level_val,0,"推广职位",1);
			}
		}			
		recommend_jobs($yid,1,$_SESSION['uid']);
		showmsg("设置成功！",2);
	}
	//取消推广
	elseif (!empty($_GET['recommend2']))
	{
	$user_points=get_user_points($_SESSION['uid']);
	recommend_jobs($yid,0,$_SESSION['uid']);
	write_memberslog($_SESSION['uid'],3,3006,$_SESSION['username'],"积分+0,剩余:{$user_points}",0,"取消推广职位",1);
	showmsg("设置成功！",2);
	}
	//删除
	elseif ($delete)
	{
		if($n=del_jobs($yid,$uid))
		{
			showmsg("删除成功！共删除 {$n} 行",2);
		}
		else
		{
			showmsg("删除失败！",0);
		}
	}
}
elseif($act == 'addjobs')
{
	$smarty->assign('nav','jobs');
	$smarty->assign('title'," 发布职位 - 猎头会员中心 - ".$_CFG['site_name']);
	$uid = intval($_SESSION['uid']);
	$profile =get_hunter($uid);
	$max_jobs = $get_job_num['jobs_add'] = $db->getone("select * from ".table('hunter_level_meal')." where id = ".$profile['level_meal']);
	$get_job_num = $db->get_total("select count(*) as num from ".table('jobs')." where uid = ".$_SESSION['uid']);
	if($get_job_num  >= $max_jobs['jobs_add']){
		showmsg('你的权限最多能发'.$max_jobs['jobs_add'].'条',1);
	}
	//积分的判断 只在对积分减的情况下做判断，加积分无需判断
	$points = get_user_points($uid);
	$point_rule=get_cache("points_rule");
	if($point_rule['hunter_addjob']['type'] == '2'){
		if($points['points'] < $point_rule['hunter_addjob']['value'] ){
			showmsg('你的积分不足，请充值后在发布',1);
		}
	} 
	$smarty->display("member_hunter/hunter_addjobs.htm");	
}
elseif($act == 'editjobs')
{
	$id=intval($_GET['id']);
	$smarty->assign('nav','jobs');
	$uid = intval($_SESSION['uid']);
	$smarty->assign('title'," 修改职位 - 猎头会员中心 - ".$_CFG['site_name']);
	$jobs_show = get_jobs_one($id);
	$smarty->assign("jobs_show",$jobs_show);
	//将职位的语言单独处理一下
	$language = explode(',', $jobs_show['language']);
	$smarty->assign("jobs_lan",$language);
	//将tag单独处理一下
	$tag = explode('|', $jobs_show['tag']);
	foreach ($tag as  $value) 
	{
		$tag_info = explode(',', $value);
		$tag[]=$tag_info[1];
	}
	$smarty->assign("tag",$tag);
	$smarty->display("member_hunter/hunter_addjobs.htm");	
}
elseif ($act=='addjobs_save')
{
	$id=intval($_POST['id']);
	$uid = intval($_SESSION['uid']);	
	if($id>0)
	{	
		// $setsqlarr['companyname'] = trim($_POST['com_companyname'])? trim($_POST['com_companyname']):showmsg('请填写企业名称',1);
		// $setsqlarr['companyname_note'] = trim($_POST['com_companyname_note']);
		$setsqlarr['company_id'] = $hunter_profile['id'];
		$setsqlarr['company_addtime'] = $hunter_profile['addtime'];
		$setsqlarr['companynature'] = $_POST['com_nature']?intval($_POST['com_nature']):showmsg('请填公司性质信息',1);
		$setsqlarr['companynature_cn'] = trim($_POST['com_nature_cn'])? trim($_POST['com_nature_cn']):showmsg('请填公司性质信息',1);
		$setsqlarr['trade'] = trim($_POST['com_trade'])? trim($_POST['com_trade']):showmsg('请填行业信息',1);
		$setsqlarr['trade_cn'] = trim($_POST['com_trade_cn'])? trim($_POST['com_trade_cn']):showmsg('请填行业信息',1);
		$setsqlarr['scale'] = trim($_POST['com_scale'])? trim($_POST['com_scale']):showmsg('请填写企业规模',1);
		$setsqlarr['scale_cn'] = trim($_POST['com_scale_cn'])? trim($_POST['com_scale_cn']):showmsg('请填写企业规模',1);
		$setsqlarr['company_introduce'] =  trim($_POST['com_content'])? trim($_POST['com_content']):showmsg('请填写企业描述',1);
		$setsqlarr['jobs_name']=!empty($_POST['jobs_name'])?trim($_POST['jobs_name']):showmsg('您没有填写职位名称！',1);
		$day=intval($_CFG['hunter_add_days']);
		$setsqlarr['deadline']=time()+$day*24*3600;
		$setsqlarr['wage_min']=!empty($_POST['wage_star'])?intval($_POST['wage_star']):showmsg('请填写年薪下限！',1);
		$setsqlarr['wage_max']=!empty($_POST['wage_end'])?intval($_POST['wage_end']):showmsg('请填写年薪上限！',1);
		$setsqlarr['user_status']=$hunter_profile['user_status'];
		$setsqlarr['category']=!empty($_POST['category'])?trim($_POST['category']):showmsg('请选择职位类别！',1);
		$setsqlarr['category_cn']=trim($_POST['category_cn']);
		$setsqlarr['district']=!empty($_POST['district'])?intval($_POST['district']):showmsg('请选择所在地区！',1);
		$setsqlarr['sdistrict']=intval($_POST['sdistrict']);
		$setsqlarr['district_cn']=trim($_POST['district_cn']);  
		$setsqlarr['department']=!empty($_POST['department'])?trim($_POST['department']):showmsg('您没有填写所属部门！',1);
		check_word($_CFG['filter'],$_POST['department'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr['amount']=!empty($_POST['amount'])?intval($_POST['amount']):showmsg('请填写招聘人数！',1);
		$setsqlarr['reporter']=trim($_POST['reporter']);
		check_word($_CFG['filter'],$_POST['reporter'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr['tag']=trim($_POST['tag']);
		$setsqlarr['age_min']=intval($_POST['age_star']);		
		$setsqlarr['age_max']=intval($_POST['age_end']);
		if(intval($_POST['sex']) == '1')
		{
			$setsqlarr['sex']='1';
			$setsqlarr['sex_cn']='男';
		}
		elseif(intval($_POST['sex']) == '2')
		{
			$setsqlarr['sex']='2';
			$setsqlarr['sex_cn']='女';
		}
		elseif(intval($_POST['sex']) == '3')
		{
			$setsqlarr['sex']='3';
			$setsqlarr['sex_cn']='不限';
		}else{
			showmsg('请选择性别',1);
		}
		$setsqlarr['major']=trim($_POST['major']);
		$setsqlarr['experience']=!empty($_POST['experience'])?intval($_POST['experience']):showmsg('请选择工作经验！',1);
		$setsqlarr['experience_cn']=trim($_POST['experience_cn']);
		$setsqlarr['education']=!empty($_POST['education'])?intval($_POST['education']):showmsg('请选择学历要求！',1);		
		$setsqlarr['education_cn']=trim($_POST['education_cn']);
		$setsqlarr['uec']=intval($_POST['uec'])?intval($_POST['uec']):'';	

		$setsqlarr['language']=trim($_POST['language']);
		$setsqlarr['language_cn']=trim($_POST['language_cn']);
		$setsqlarr['contents']=!empty($_POST['contents'])?trim($_POST['contents']):showmsg('您没有填写职位描述！',1);
		check_word($_CFG['filter'],$_POST['contents'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr['email']=trim($_POST['email']);
		$setsqlarr['addtime']=$timestamp;

		$setsqlarr['refreshtime']=$timestamp;
		$setsqlarr['key']=$setsqlarr['jobs_name'].$hunter_profile['belongcompany'].$setsqlarr['category_cn'].$setsqlarr['district_cn'].$setsqlarr['contents'].$setsqlarr['company_introduce'];
		require_once(QISHI_ROOT_PATH.'include/splitword.class.php');
		$sp = new SPWord();
		$setsqlarr['key']="{$setsqlarr['jobs_name']} {$hunter_profile['belongcompany']} ".$sp->extracttag($setsqlarr['key']);
		$setsqlarr['key']=$sp->pad($setsqlarr['key']);
		if($_CFG['audit_verifyhunter_editjob']>0)
		{
			$setsqlarr['audit']=intval($_CFG['audit_verifyhunter_editjob']);
		}
		$setsqlarr_contact['contact']=$hunter_profile['fullname'];
		$setsqlarr_contact['telephone']=$hunter_profile['telephone'];
		check_word($_CFG['filter'],$_POST['telephone'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr_contact['email']=trim($_POST['email']);
		//添加职位信息
		updatetable(table('jobs'),$setsqlarr,array("id"=>$id,"uid"=>$uid));
		//添加多选行业和职位
		jobs_category_save($_SESSION['uid'],$id,$_POST['category']);
		jobs_trade_save($_SESSION['uid'],$id,$setsqlarr['trade']);
		//添加联系方式
		updatetable(table('jobs_contact'),$setsqlarr_contact,array("pid"=>$id));
		distribution_jobs($id,$uid);
		$link[0]['text'] = "已发布职位";
		$link[0]['href'] = '?act=jobs';
		$link[1]['text'] = "会员中心首页";
		$link[1]['href'] = "hunter_index.php";
		showmsg("修改职位成功",2,$link);
	}
	else
	{	
		$hunter_profile=get_hunter($uid);
		//猎头信息
		$setsqlarr['uid']=intval($_SESSION['uid']); 
		$setsqlarr['utype']='3'; 
		$setsqlarr['companyname'] = trim($_POST['com_companyname'])? trim($_POST['com_companyname']):showmsg('请填写企业名称',1);
		$setsqlarr['companyname_note'] = trim($_POST['com_companyname_note']);
		$setsqlarr['company_id'] = $hunter_profile['id'];
		$setsqlarr['company_addtime'] = $hunter_profile['addtime'];
		$setsqlarr['companynature'] = $_POST['com_nature']?intval($_POST['com_nature']):showmsg('请填公司性质信息',1);
		$setsqlarr['companynature_cn'] = trim($_POST['com_nature_cn'])? trim($_POST['com_nature_cn']):showmsg('请填公司性质信息',1);
		$setsqlarr['trade'] = trim($_POST['com_trade'])? trim($_POST['com_trade']):showmsg('请填行业信息',1);
		$setsqlarr['trade_cn'] = trim($_POST['com_trade_cn'])? trim($_POST['com_trade_cn']):showmsg('请填行业信息',1);
		$setsqlarr['scale'] = trim($_POST['com_scale'])? trim($_POST['com_scale']):showmsg('请填写企业规模',1);
		$setsqlarr['scale_cn'] = trim($_POST['com_scale_cn'])? trim($_POST['com_scale_cn']):showmsg('请填写企业规模',1);
		$setsqlarr['company_introduce'] =  trim($_POST['com_content'])? trim($_POST['com_content']):showmsg('请填写企业描述',1);
		$setsqlarr['jobs_name']=!empty($_POST['jobs_name'])?trim($_POST['jobs_name']):showmsg('您没有填写职位名称！',1);
		$day=intval($_CFG['hunter_add_days']);
		$setsqlarr['deadline']=time()+$day*24*3600;
		$setsqlarr['wage_min']=!empty($_POST['wage_star'])?intval($_POST['wage_star']):showmsg('请填写年薪下限！',1);
		$setsqlarr['wage_max']=!empty($_POST['wage_end'])?intval($_POST['wage_end']):showmsg('请填写年薪上限！',1);
		$setsqlarr['user_status']=$hunter_profile['user_status'];
		$setsqlarr['category']=!empty($_POST['category'])?trim($_POST['category']):showmsg('请选择职位类别！',1);
		$setsqlarr['category_cn']=trim($_POST['category_cn']);
		$setsqlarr['district']=!empty($_POST['district'])?intval($_POST['district']):showmsg('请选择所在地区！',1);
		$setsqlarr['sdistrict']=intval($_POST['sdistrict']);
		$setsqlarr['district_cn']=trim($_POST['district_cn']);  
		$setsqlarr['department']=!empty($_POST['department'])?trim($_POST['department']):showmsg('您没有填写所属部门！',1);
		check_word($_CFG['filter'],$_POST['department'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr['amount']=!empty($_POST['amount'])?intval($_POST['amount']):showmsg('请填写招聘人数！',1);
		$setsqlarr['reporter']=trim($_POST['reporter']);
		check_word($_CFG['filter'],$_POST['reporter'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr['tag']=trim($_POST['tag']);
		$setsqlarr['age_min']=intval($_POST['age_star']);		
		$setsqlarr['age_max']=intval($_POST['age_end']);
		if(intval($_POST['sex']) == '1')
		{
			$setsqlarr['sex']='1';
			$setsqlarr['sex_cn']='男';
		}
		elseif(intval($_POST['sex']) == '2')
		{
			$setsqlarr['sex']='2';
			$setsqlarr['sex_cn']='女';
		}
		elseif(intval($_POST['sex']) == '3')
		{
			$setsqlarr['sex']='3';
			$setsqlarr['sex_cn']='不限';
		}else{
			showmsg('请选择性别',1);
		}
		$setsqlarr['major']=trim($_POST['major']);
		$setsqlarr['experience']=!empty($_POST['experience'])?intval($_POST['experience']):showmsg('请选择工作经验！',1);
		$setsqlarr['experience_cn']=trim($_POST['experience_cn']);
		$setsqlarr['education']=!empty($_POST['education'])?intval($_POST['education']):showmsg('请选择学历要求！',1);		
		$setsqlarr['education_cn']=trim($_POST['education_cn']);
		$setsqlarr['uec']=intval($_POST['uec'])?intval($_POST['uec']):'';	

		$setsqlarr['language']=trim($_POST['language']);
		$setsqlarr['language_cn']=trim($_POST['language_cn']);
		$setsqlarr['contents']=!empty($_POST['contents'])?trim($_POST['contents']):showmsg('您没有填写职位描述！',1);
		check_word($_CFG['filter'],$_POST['contents'])?showmsg($_CFG['filter_tips'],0):'';
		$setsqlarr['email']=trim($_POST['email']);
		$setsqlarr['addtime']=$timestamp;

		$setsqlarr['refreshtime']=$timestamp;
		$setsqlarr['key']=$setsqlarr['jobs_name'].$hunter_profile['belongcompany'].$setsqlarr['category_cn'].$setsqlarr['district_cn'].$setsqlarr['contents'].$setsqlarr['company_introduce'];
		require_once(QISHI_ROOT_PATH.'include/splitword.class.php');
		$sp = new SPWord();
		$setsqlarr['key']="{$setsqlarr['jobs_name']} {$hunter_profile['belongcompany']} ".$sp->extracttag($setsqlarr['key']);
		$setsqlarr['key']=$sp->pad($setsqlarr['key']);

		$setsqlarr['audit']=intval($_CFG['audit_verifyhunter_addjob']);
		$setsqlarr_contact['contact']=$hunter_profile['fullname'];
		$setsqlarr_contact['telephone']=$hunter_profile['mobile'];
		$setsqlarr_contact['email']=trim($_POST['email']);
		//添加职位信息
		$pid=inserttable(table('jobs'),$setsqlarr,true);
		//添加多选行业和职位
		jobs_category_save($_SESSION['uid'],$pid,$_POST['category']);
		jobs_trade_save($_SESSION['uid'],$pid,$setsqlarr['trade']);
		if(empty($pid)){
			showmsg("添加失败！",0);
		}else
		{ 
			// 经验操作
			$levelRule=get_cache('hunter_level_rule');
			if ($levelRule['jobs_add']['value']>0 )
			{
				level_deal($_SESSION['uid'],$levelRule['jobs_add']['type'],$levelRule['jobs_add']['value']);
				level_meal_deal($_SESSION['uid']);
				$user_level=get_hunter($_SESSION['uid']);
				$operator=$levelRule['jobs_add']['type']=="1"?"+":"-";
				write_memberslog($_SESSION['uid'],3,2001,$_SESSION['username'],"经验：".$operator.$levelRule['jobs_add']['value'].",剩余：{$user_level[level]}",0,"发布职位",1);
			}
			// 积分操作
			$rule=get_cache('points_rule');
			if ($rule['hunter_addjob']['value']>0 )
			{
				report_deal($_SESSION['uid'],$rule['hunter_addjob']['type'],$rule['hunter_addjob']['value']);
				$user_points=get_user_points($_SESSION['uid']);
				$operator=$rule['hunter_addjob']['type']=="1"?"+":"-";
				write_memberslog($_SESSION['uid'],3,2001,$_SESSION['username'],"积分：".$operator.$rule['hunter_addjob']['value'].",剩余：{$user_points}",0,"发布职位",1);
			}
		}
		//添加联系方式
		$setsqlarr_contact['pid']=$pid;
		!inserttable(table('jobs_contact'),$setsqlarr_contact)?showmsg("添加失败！",0):'';
		distribution_jobs($pid,$setsqlarr['uid']);
		$link[0]['text'] = "已发布职位";
		$link[0]['href'] = '?act=jobs';
		$link[1]['text'] = "继续发布职位";
		$link[1]['href'] = '?act=addjobs';
		$link[3]['text'] = "会员中心首页";
		$link[3]['href'] = "hunter_index.php";
		showmsg("发布成功！",2,$link);
	}
	
}
elseif($act=="searchjobs")
{
	$smarty->assign('nav','searchjobs');
	$smarty->assign('title','职位管理 - 猎头会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_searchjobs.htm');
}
?>