<?php
/*
 * 74cms 个人会员中心
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__) . '/personal_common.php'); 
$smarty->assign('nav',"index");
//个人会员中心首页
if ($act=='index')
{
	$uid = intval($_SESSION['uid']);
	$pid = intval(get_pid($uid));
	//统计最近查看本简历的猎头或者企业  
	$hunter_num = $db->get_total("select  count(*) as num from ".table('view_resume')." where resumeid={$pid} and utype=3");
	$company_num = $db->get_total("select  count(*) as num from ".table('view_resume')." where resumeid={$pid} and utype=1");
	$smarty->assign('title','个人会员中心 - '.$_CFG['site_name']);
	$smarty->assign('my_resume',get_resume_info($uid,$pid));
	$smarty->assign('count_apply',count_personal_jobs_apply($uid));
	$smarty->assign('count_interview',count_interview($uid));
	$smarty->assign('count_hunter',count_hunter($uid));
	$smarty->assign('count_com_downresume',count_com_downresume($uid));
	$smarty->assign('shield_company',get_shield_company($uid));
	$smarty->assign('hunter_num',$hunter_num);
	$smarty->assign('company_num',$company_num);
	$smarty->assign('user',$user); 
	$smarty->assign('next_page','3'); 
	$smarty->display('member_personal/personal_index.htm');
}
// 获取(推荐\最新\紧急)职位
elseif($act=="ajax_get_jobs_list")
{
	$uid = intval($_SESSION['uid']);
	$type=trim($_GET['type']);
	$start=0;
	$end=5;
	$time=time();
	//推荐
	if($type=='interest'){
		$interest_id = get_interest_jobs_id_by_resume($uid);   
		$orderbysql = " order by refreshtime desc ";
		if(!empty($interest_id)){ 
			$pid_in = ""; 
			foreach ($interest_id as $value) {
				$pid_in .= $value['pid'].",";
			}
			$pid_in = trim($pid_in,',');
			$wheresql = '';
			$wheresql .= " where id in (".$pid_in.") ";
			//确保职位是有效职位
			$wheresql .= " AND  jobs_type!=2 AND (audit=1 and display=1 and deadline>$time and setmeal_deadline>$time) "; 
			$sql = "select * from ".table('jobs').$wheresql.$orderbysql;  
		}	  
		if(empty($sql)){
			$sql = "select * from ".table("jobs")." where jobs_type!=2 ".$orderbysql;
		} 
		$jobs=get_jobs($start,$end,$sql,$countresume=false); 
	}
	//最新
	elseif($type=='new'){
		$sql="select * from ".table("jobs")." where jobs_type!=2 and audit=1 and display=1 and deadline>$time and setmeal_deadline>$time  order by addtime  desc  ";
		$jobs=get_jobs($start,$end,$sql,$countresume=false);
	}
	//紧急
	elseif($type=='hot'){
		$sql="select * from ".table("jobs")." where jobs_type!=2 and audit=1 and display=1 and deadline>$time and setmeal_deadline>$time  and  recommend=1  order by recommend desc ,refreshtime desc";
		$jobs=get_jobs($start,$end,$sql,$countresume=false);
	}
	
	$html .='';
	foreach ($jobs as $key=>$value) {
		$html.='<div class="need_box_item">
				<div class="jobs_name"><a href="'.$value['jobs_url'].'" title="'.$value['jobs_name'].'">'.$value['jobs_name'].'</a> <span>'.$value['district_cn'].'</span></div>
				<div class="year_money">年薪：<span>'.$value['wage_min'].'-'.$value['wage_max'].'万</span></div>
				<p class="job_content">
					所属部门：'.$value['department'].'  |  工作经验：'.$value['experience_cn'].'  |  所属行业：'.$value['trade_cn'].'
				</p>
				<div class="interview_but_box">
					<input type="button" value="投递简历" class="but85orange" />
					<a href="" class="collect" title="已收藏"></a>
				</div>
			</div>';
	}
	if(empty($jobs))
	{
		$no_html='<div class="need_box_item" id="no_nees_box" style="display: none;">
					<a href="{#"QS_jobslist"|qishi_url#}"  class="more_big_button" >查看更多职位</a>
			       </div>';
		exit($no_html);
	}
	else
	{
		exit($html);
	}
}

unset($smarty);
?>