<?php
/*********************************************
*猎头职位详细页
* *******************************************/
function tpl_function_qishi_hunter_jobs_show($params, &$smarty)
{
	global $db,$timestamp,$_CFG;
	$arr=explode(',',$params['set']);
	foreach($arr as $str)
	{
	$a=explode(':',$str);
		switch ($a[0])
		{
		case "职位ID":
			$aset['id'] = $a[1];
			break;
		case "列表名":
			$aset['listname'] = $a[1];
			break;
		}
	}
	$aset=array_map("get_smarty_request",$aset);
	$aset['id']=$aset['id']?intval($aset['id']):0;
	$aset['listname']=$aset['listname']?$aset['listname']:"list";
	$wheresql=" WHERE id={$aset['id']} and utype=3 ";
	$sql = "select * from ".table('jobs').$wheresql." LIMIT 1";
	$val=$db->getone($sql);
	if (empty($val))
	{
		header("HTTP/1.1 404 Not Found"); 
		$smarty->display("404.htm");
		exit();
	}
	else
	{
		$val['amount']=$val['amount']=="0"?'若干':$val['amount'];
		$hunter=get_hunter($val['uid']);
		$val['hunter']=$hunter;
		$val['expire']=sub_day($val['deadline'],time());
		$val['refreshtime_cn']=daterange(time(),$val['refreshtime'],'Y-m-d',"#FF3300");
		if ($val['tag'])
		{
			$tag=explode('|',$val['tag']);
			$taglist=array();
			if (!empty($tag) && is_array($tag))
			{
				foreach($tag as $t)
				{
				$tli=explode(',',$t);
				$taglist[]=array($tli[0],$tli[1]);
				}
			}
			$val['tag']=$taglist;
		}
		else
		{
		$val['tag']=array();
		}
	}
	$db->query("update ".table('jobs')." set click=click+1 where id=$val[id] ");
	$smarty->assign($aset['listname'],$val);
}
// 获取猎头信息
function get_hunter($uid)
{
	global $db;
	$level_config = get_cache('config'); 
	$levelarr = $db->getone("select * from ".table('hunter_profile')." where uid=".intval($uid)." LIMIT 1 ");  
	$level = $levelarr['level'];  
	if($level == '0'){
		$level = '1';
	} 
	switch($level){
		case ($level < $level_config['hunter_level_1']):   ///300
			$levelarr['left'] = 174;
			$levelarr['now_Level'] = 0;
			$levelarr['next_Level'] = 1;
			$levelarr['surplus_level'] = $level_config['hunter_level_1']-$level;
		break;
		case ($level < $level_config['hunter_level_2']):  //2500
			$levelarr['left'] = 308;
			$levelarr['now_Level'] =1;
			$levelarr['next_Level'] =2;
			$levelarr['surplus_level'] = $level_config['hunter_level_2']-$level;
		break;
		case ($level < $level_config['hunter_level_3']):
			$levelarr['left'] = 442;
			$levelarr['now_Level'] = 2;
			$levelarr['next_Level'] = 3;
			$levelarr['surplus_level'] = $level_config['hunter_level_3']-$level;
		break;
		case ($level < $level_config['hunter_level_4']):
			$levelarr['left'] = 576;
			$levelarr['now_Level'] = 3;
			$levelarr['next_Level'] = 4;
			$levelarr['surplus_level'] = $level_config['hunter_level_4']-$level;
		break;
		case ($level < $level_config['hunter_level_5']):
			$levelarr['left'] = 710;
			$levelarr['now_Level'] = 4;
			$levelarr['next_Level'] = 5;
			$levelarr['surplus_level'] = $level_config['hunter_level_5']-$level;
		break;
		case ($level > $level_config['hunter_level_5']):
			$levelarr['left'] = 844;
			$levelarr['now_Level'] = 5;
			$levelarr['next_Level'] = 6;
			$levelarr['surplus_level'] = $level_config['hunter_level_5']-$level;
		break;
		default:
			$levelarr['left'] = 174;
			$levelarr['next_Level'] = 1;
			$levelarr['surplus_level'] = 0;
	}
	return $levelarr;
}
?>