<?php
/*
 * 74cms 企业会员中心
 * ============================================================================
 * 版权所有: 骑士网络，并保留所有权利。
 * 网站地址: http://www.74cms.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
*/
define('IN_QISHI', true);
require_once(dirname(__FILE__).'/hunter_common.php');
$act=$_GET['act']?trim($_GET["act"]):"profile";
// 刚注册猎头 创建猎头名片 基本信息
if($act=='create_hunter')
{
	$smarty->assign('title'," 创建猎头名片 - 猎头会员中心 - ".$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_reg_step1.htm');
}
// 保存 猎头名片 基本信息
elseif($act=="create_hunter_save")
{
	$uid=intval($_SESSION['uid']);
	$setarry["fullname"]=trim($_POST['fullname'])?trim($_POST['fullname']):showmsg("填写真实姓名！",1);
	$setarry["sex"]=intval($_POST['sex'])?intval($_POST['sex']):showmsg("选择性别！",1);
	if($setarry["sex"]==1)
	{
		$setarry["sex_cn"]="男";
	}
	else
	{
		$setarry["sex_cn"]="女";
	}
	$setarry["birthdate"]=trim($_POST['birthdate'])?trim($_POST['birthdate']):showmsg("选择出生年份！",1);
	$setarry["education"]=intval($_POST['education'])?intval($_POST['education']):showmsg("选择最高学历！",1);
	$setarry["education_cn"]=trim($_POST['education_cn']);
	$setarry["trade"]=trim($_POST['trade'])?trim($_POST['trade']):showmsg("选择擅长行业！",1);
	$setarry["trade_cn"]=trim($_POST['trade_cn']);
	$setarry["category"]=trim($_POST['category'])?trim($_POST['category']):showmsg("选择擅长职能！",1);
	$setarry["category_cn"]=trim($_POST['category_cn']);
	$setarry["district"]=intval($_POST['district'])?intval($_POST['district']):showmsg("选择所在地区！",1);
	$setarry["sdistrict"]=intval($_POST['sdistrict']);
	$setarry["district_cn"]=trim($_POST['district_cn']);
	$setarry["rank"]=intval($_POST['rank'])?intval($_POST['rank']):showmsg("选择目前头衔",1);
	$setarry["rank_cn"]=trim($_POST['category_cn']);
	$setarry["worktime"]=trim($_POST["worktime"])?trim($_POST["worktime"]):showmsg("请选择从业年份！",1);
	$setarry["mobile"]=trim($_POST["mobile"])?trim($_POST["mobile"]):showmsg("填写手机号！",1);
	$setarry["email"]=$user['email'];//猎头信息的邮箱调取 members 中的邮箱
	$setarry["email_audit"]=$user['email_audit'];
	require_once(QISHI_ROOT_PATH.'include/splitword.class.php');
	$sp = new SPWord();
	$setarry['likekey']=$setarry["fullname"].",".$setarry["education_cn"].",".$setarry["trade_cn"].",".$setarry["category_cn"];	
	$rst=updatetable(table("hunter_profile"),$setarry,array('uid' =>$uid ));
	$hunter=get_hunter($uid);
	$trade=hunter_trade_save($uid,$hunter['id'],$setarry["trade"]);//行业多选
	$category=hunter_category_save($uid,$hunter['id'],$setarry["category"]);//擅长只能多选
	if($rst && $trade && $category)
	{
		$link[0]['text'] = "认证猎头";
		$link[0]['href'] = '?act=auth_info';
		showmsg("您已成功创建猎头名片！",1,$link);
	}
	else
	{
		showmsg("创建猎头名片失败！",1);
	}
}
//完善猎头信息
elseif($act == 'profile')
{
	$uid=intval($_SESSION['uid']);
	$hunter_profile=get_hunter($uid);
	$smarty->assign('title'," 完善猎头信息 - 猎头会员中心 - ".$_CFG['site_name']);
	$smarty->assign('hunter_profile',$hunter_profile);
	$smarty->assign('hunter_collaborative',get_hunter_collaborative($uid));
	$smarty->display('member_hunter/hunter_profile.htm');
}
elseif($act == "profile_save")
{
	$uid=intval($_SESSION['uid']);
	$setarry["birthdate"]=trim($_POST['birthdate'])?trim($_POST['birthdate']):showmsg("选择出生年份！",1);
	$setarry["education"]=intval($_POST['education'])?intval($_POST['education']):showmsg("选择最高学历！",1);
	$setarry["education_cn"]=trim($_POST['education_cn']);
	$setarry["trade"]=trim($_POST['trade'])?trim($_POST['trade']):showmsg("选择擅长行业！",1);
	$setarry["trade_cn"]=trim($_POST['trade_cn']);
	$setarry["category"]=trim($_POST['category'])?trim($_POST['category']):showmsg("选择擅长职能！",1);
	$setarry["category_cn"]=trim($_POST['category_cn']);
	$setarry["district"]=intval($_POST['district'])?intval($_POST['district']):showmsg("选择所在地区！",1);
	$setarry["sdistrict"]=intval($_POST['sdistrict']);
	$setarry["district_cn"]=trim($_POST['district_cn']);
	$setarry["rank"]=intval($_POST['rank'])?intval($_POST['rank']):showmsg("选择目前头衔",1);
	$setarry["rank_cn"]=trim($_POST['category_cn']);
	$setarry["mobile"]=trim($_POST["mobile"])?trim($_POST["mobile"]):showmsg("填写手机号！");
	$setarry["contents"]=trim($_POST["contents"])?trim($_POST["contents"]):showmsg("填写猎头介绍！");
	$setarry['likekey']=$hunter_profile['fullname'].",".$setarry["education_cn"].",".$setarry["trade_cn"].",".$setarry["category_cn"];	

	$rst=updatetable(table("hunter_profile"),$setarry,array("uid"=>$uid));
	$trade=hunter_trade_save($uid,$hunter_profile['id'],$setarry["trade"]);//行业多选
	$category=hunter_category_save($uid,$hunter_profile['id'],$setarry["category"]);//擅长只能多选 	

	if($rst && $trade && $category)
	{
		showmsg("修改猎头信息成功！",2);
	}
	else
	{
		showmsg("创建猎头名片失败！",0);
	}
}
// 猎头认证页面
elseif($act == 'auth_info')
{
	$uid=intval($_SESSION['uid']); 
	$hunter_info=get_hunter($uid);
	$smarty->assign('hunter_info',get_hunter($uid));
	$smarty->assign('points',get_user_points($uid));
		//距离下个等级的 经验值
	$level=$hunter_info['level'];
	$level_config=get_cache("config");

	switch($level){
		case ($level < $level_config['hunter_level_1']):   ///300
		$smarty->assign('next_level',$level_config['hunter_level_1']-$level);
		break;
		case ($level < $level_config['hunter_level_2']):  //2500
			$smarty->assign('next_level',$level_config['hunter_level_2']-$level);
		break;
		case ($level < $level_config['hunter_level_3']):
			$smarty->assign('next_level',$level_config['hunter_level_3']-$level);
		break;
		case ($level < $level_config['hunter_level_4']):
			$smarty->assign('next_level',$level_config['hunter_level_4']-$level);
		break;
		case ($level < $level_config['hunter_level_5']):
			$smarty->assign('next_level',$level_config['hunter_level_5']-$level);
		break;
		case ($level > $level_config['hunter_level_5']):
			$smarty->assign('next_level',"all");
		break;
	}
	$smarty->assign('title',"猎头认证 - 猎头会员中心 - ".$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_auth_info.htm');
}
elseif($act == 'auth_name_update')
{
	// print_r($_POST);
	$uid=intval($_SESSION['uid']);
	$setsqlarr['fullname'] = $_POST['fullname']?trim($_POST['fullname']):showmsg("请填写个人真实姓名",1); 
	$setsqlarr['card'] = $_POST['card']?trim($_POST['card']):showmsg("请填写身份证号",1); 
	$setsqlarr['card_img'] = $_POST['card_img']?trim($_POST['card_img']):showmsg("请上传证件图片",1);
	$setsqlarr['card_audit'] =2; //审核中
	updatetable(table('hunter_profile'),$setsqlarr," uid = $uid ")?showmsg("实名认证信息已提交,请等待管理员审核！",1):showmsg("提交失败！",1);
}
//实名认证 图片保存
elseif($act == 'auth_name_card_save')
{	
	$auth=get_hunter($_SESSION['uid']); 
	if ($auth['card_audit'] == '1')
	{
		exit("您已经认证通过，无需修改！");
	}
	else
	{
		if($_FILES['CardImg']['name'])
		{
			$up_dir="../../data/hunter/card_img/"; 
			make_dir($up_dir.date("Y/m/d/"));
			require_once(QISHI_ROOT_PATH.'include/cut_upload.php');
			$setsqlarr['card_img']=_asUpFiles($up_dir.date("Y/m/d/"),"CardImg",500,'gif/jpg/bmp/png',$_SESSION['uid']);
			$setsqlarr['card_img']=date("Y/m/d/").$setsqlarr['card_img'];
			if ($setsqlarr['card_img'])
			{  
				makethumb($up_dir.$setsqlarr['card_img'],$up_dir.date("Y/m/d/"),500,500);
				$wheresql=" uid='".$_SESSION['uid']."'";
				updatetable(table('hunter_profile'),$setsqlarr,$wheresql)?exit($setsqlarr['card_img']):exit('保存失败！'); 
			}
			else
			{
				exit("上传失败！");
			}
		}
	} 
}
//从业认证
elseif($act == 'auth_work_save')
{
	$uid=intval($_SESSION['uid']);
	$setsqlarr['belongcompany'] = $_POST['belongcompany']?trim($_POST['belongcompany']):showmsg("请填写所属公司！",1); 
	$setsqlarr['companytelephone'] = $_POST['companytelephone']?trim($_POST['companytelephone']):showmsg("请填写所属公司电话！",1); 
	$setsqlarr['belongcompany_audit'] =2;
	updatetable(table('hunter_profile'),$setsqlarr," uid = $uid")?showmsg("提交从业认证成功,请等待管理员审核！",1):showmsg("提交失败",1);
}
elseif($act == 'auth_photo_save')
{
	$auth=get_hunter($_SESSION['uid']); 
	if ($auth['avatars_audit'] == '1')
	{
		exit("您已经认证通过，无需修改！");
	}
	else
	{
		if($_FILES['PhotoImg']['name'])
		{
			$up_dir="../../data/hunter/photo_img/"; 
			make_dir($up_dir.date("Y/m/d/"));
			require_once(QISHI_ROOT_PATH.'include/cut_upload.php');
			$setsqlarr['avatars']=_asUpFiles($up_dir.date("Y/m/d/"),"PhotoImg",500,'gif/jpg/bmp/png',$_SESSION['uid']);
			$setsqlarr['avatars']=date("Y/m/d/").$setsqlarr['avatars'];
			if ($setsqlarr['avatars'])
			{  
				makethumb($up_dir.$setsqlarr['avatars'],$up_dir.date("Y/m/d/"),100,100);
				$wheresql=" uid='".$_SESSION['uid']."'";
				updatetable(table('hunter_profile'),$setsqlarr,$wheresql)?exit($setsqlarr['avatars']):exit('保存失败！'); 
			}
			else
			{
				exit("上传失败！");
			}
		}
	} 
}
// 照片认保存
elseif($act=="avatars_update")
{
	$uid=intval($_SESSION['uid']);
	$setsqlarr['avatars'] = $_POST['avatars']?trim($_POST['avatars']):showmsg("请上传照片！",1); 
	$setsqlarr['avatars_audit'] =2;
	updatetable(table('hunter_profile'),$setsqlarr," uid = $uid")?showmsg("提交照片认证成功,请等待管理员审核！",1):showmsg("提交失败",1);
}
//上传头像
else if($act == 'hunter_logo_preloading'){
	$uid=intval($_SESSION['uid']);
	//图片的预处理
	require_once(QISHI_ROOT_PATH.'include/upload.php');
	if($_FILES['upload_file']['name']){
		$uphunterpreload_dir="../../data/hunter/preload/".date("Y/m/d/");
		make_dir($uphunterpreload_dir);
		$setsqlarr['hunterpreload']=_asUpFiles($uphunterpreload_dir, "upload_file",$_CFG['hunter_photo_max'],'jpg/jpeg/gif/bmp/png',$uid);
		if ($setsqlarr['hunterpreload'])
		{
			$setsqlarr['hunterpreload']=date("Y/m/d/").$setsqlarr['hunterpreload'];
			$hunter_src="../../data/hunter/preload/".$setsqlarr['hunterpreload'];
			exit($hunter_src);
		}
		else
		{
			exit("上传失败!");
		}
	}
} 
// 头像保存
else if($act == 'hunter_logo_save'){
	$uid=intval($_SESSION['uid']);
	require_once(QISHI_ROOT_PATH.'include/upload.php');
	require_once(QISHI_ROOT_PATH.'include/imageresize.class.php');
	
	$uplogo_dir="../../data/hunter/photo_img/";
	$uphunter_header = $uplogo_dir.date("Y/m/d/");
	make_dir($uphunter_header);
	$logopre_src=$_POST['url'];
	$imgresize = new ImageResize();
	$imgresize->load($logopre_src);
	 
	$logopre = substr($logopre_src, strrpos($logopre_src, '.')); 
	$w = intval($_POST['x2']) - intval($_POST['x1']);
	$imgresize->cut($w,$w, intval($_POST['x1']), intval($_POST['y1'])); 
	$mtsrc = $uphunter_header.$uid.$logopre;
	$imgresize->save($mtsrc);
	
	$pic_format = array(200,100,50);
	for($i=0;$i<count($pic_format);$i++){   
		$uplogo_dir="../../data/hunter/photo_img/thumb/".$pic_format[$i].'/'.date("Y/m/d/");
		make_dir($uplogo_dir);
		makethumb($mtsrc,$uplogo_dir,$pic_format[$i],$pic_format[$i]);
	} 
	$setsqlarr['avatars']=substr($mtsrc,28); // 去除logo路径日期前面的路径
	$setsqlarr['avatars_audit']=2;
	if (updatetable(table('hunter_profile'),$setsqlarr," uid='".$uid."'")) {
		echo $mtsrc;
	} else {
		echo '保存失败！';
	} 
}
elseif($act == 'binding')
{	
	$smarty->assign('title',"帐号绑定 - 猎头会员中心 - ".$_CFG['site_name']);
	$smarty->assign('user',get_user_info(intval($_SESSION['uid'])));
	$smarty->assign('hunter',get_hunter(intval($_SESSION['uid'])));
	$smarty->display('member_hunter/hunter_binding.htm');
}
elseif ($act=='del_qq_binding')
{
	$db->query("UPDATE ".table('members')." SET qq_openid = ''  WHERE uid='{$_SESSION[uid]}' LIMIT 1");
	showmsg('操作成功！',2);
}
elseif ($act=='del_sina_binding')
{
	$db->query("UPDATE ".table('members')." SET sina_access_token = ''  WHERE uid='{$_SESSION[uid]}' LIMIT 1");
	showmsg('操作成功！',2);
}
elseif ($act=='del_taobao_binding')
{
	$db->query("UPDATE ".table('members')." SET taobao_access_token = ''  WHERE uid='{$_SESSION[uid]}' LIMIT 1");
	showmsg('操作成功！',2);
}
elseif($act == 'password')
{  
	$smarty->assign('title',"修改密码 - 猎头会员中心 - ".$_CFG['site_name']);
	$smarty->assign('user',get_user_info(intval($_SESSION['uid'])));
	$smarty->display('member_hunter/hunter_password.htm');
}
elseif($act == 'password_save')
{
	$uid = $_SESSION['uid'];
	$opassword = trim($_POST['opassword'])?trim($_POST['opassword']):showmsg('请填写你的旧密码',1);
	$npassword = $_POST['npassword']?$_POST['npassword']:showmsg('请填写你的新密码',1);
	$napassword = $_POST['napassword']?$_POST['napassword']:showmsg('请填写确认新密码',1);
	$user_info = get_user_inid($uid);
	$opass = md5(md5($opassword).$user_info['pwd_hash'].$QS_pwdhash); 
	if($npassword !== $napassword){
		showmsg('两次密码输入不一致!~',1);
	}else{
		if(strlen($npassword) < 6){
			showmsg('密码过短，请重新输入!~',1);
		}else{ 
			$npass = md5(md5($npassword).$user_info['pwd_hash'].$QS_pwdhash);  
			if($opass !== $user_info['password'] ){
				showmsg('旧密码输入错误！',1);
			}else{ 
				$setsqlarr['password'] = $npass;  
				updatetable(table('members'),$setsqlarr,'uid='.$uid);
				showmsg("密码修改成功",1);
			}
		}
	} 
}
elseif($act == 'level_privilege')
{
	$uid  = intval($_SESSION['uid']);	
	$level_config = get_cache('config'); 
	$levelarr = get_hunter($uid);
	$my_levelmeal = get_hunter_level_meal($levelarr['level_meal']);
	$smarty->assign('level',$levelarr);
	$smarty->assign('level_config',$level_config);
	$smarty->assign('my_levelmeal',$my_levelmeal);
	//各等级的特权
	$sql="select * from ".table("hunter_level_meal")." order by id asc ";
	$level_meal=$db->getall($sql);
	$smarty->assign('level_meal',$level_meal);
	$smarty->assign('title',"等级特权 - 猎头会员中心 - ".$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_level_privilege.htm');
}
//我的积分
elseif($act == 'my_points'){
	$uid = intval($_SESSION['uid'])>0?intval($_SESSION['uid']):showmsg('参数错误！',1);
	$points = get_user_points($uid);
	$smarty->assign('points',$points);
	$wheresql = " where log_mode=1 and log_uid=".$uid." and log_utype=3 ";
	$log_type = $_GET['log_type'];

	$starttime = strtotime($_GET['starttime']);
	$endtime = strtotime($_GET['endtime']);
	if($starttime){
		$wheresql .= " and log_addtime>".$starttime." ";
	}
	if($endtime){
		$wheresql .= " and log_addtime<".($endtime+3600*24)." ";
	}
	$type_sql = " ";
	$type_str = "";
	foreach($log_type as $v){
		$type_sql .= 'or log_type='.$v.' ';
		$type_str .= ",".$v;
	}
	$type_str = ltrim($type_str,",");
	if(!empty($type_arr)){
		$type_json = json_encode($type_arr);
	}
	$type_sql = trim($type_sql)!=""?" and (".ltrim(trim($type_sql),"or").") ":"";
	$wheresql .= $type_sql;
	require_once(QISHI_ROOT_PATH.'include/page.class.php'); 
	$perpage=10;
	$total_sql="select COUNT(*) AS num from qs_members_log ".$wheresql." ";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$offset=($page->nowindex-1)*$perpage;
	$sql = "select * from qs_members_log ".$wheresql." order by log_id desc limit ".$offset.",".$perpage;
	$log = $db->getall($sql);
	$smarty->assign('type_str',$type_str);
	$smarty->assign('starttime',$_GET['starttime']);
	$smarty->assign('endtime',$_GET['endtime']);
	$smarty->assign('log',$log);
	$smarty->assign('page',$page->show(7)); 
	$smarty->assign('title','积分消费查询 - 猎头会员中心-'.$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_my_points.htm');
}
//我的订单列表-----以及选择支付方式和金额
elseif($act == 'points_recharge')
{
	$uid = intval($_SESSION['uid']);
	$points = get_user_points($uid);
	$smarty->assign('points',$points);
	
	$pay_type = get_payment();
	$smarty->assign("pay_type",$pay_type);

	require_once(QISHI_ROOT_PATH.'include/page.class.php'); 
	$perpage=3;
	$total_sql="select COUNT(*) AS num from ".table('order')." where  uid = {$uid}";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$offset=($page->nowindex-1)*$perpage;
	
	$sql = "select o.*,p.typename,p.byname from ".table('order')." as o right join ".table('payment')." as p on p.typename = o.payment_name where o.uid = {$uid}  order by o.id desc limit ".$offset.",".$perpage;
	$order = $db->getall($sql);  
	$smarty->assign('order',$order);
	$smarty->assign('title','订单列表 - 猎头会员中心'.$_CFG['site_name']);  
	$smarty->assign('page',$page->show(7)); 
	$smarty->display('member_hunter/hunter_points_recharge.htm');
}
//选择支付方式和金额
elseif($act == 'order_add')
{	
	$myorder=get_user_order($_SESSION['uid'],1);
	$order_num=count($myorder);
	if ($order_num>=5)
	{
	$link[0]['text'] = "立即查看";
	$link[0]['href'] = '?act=order_list&is_paid=1';
	showmsg("未处理的订单不能超过 5 条，请先处理后再次申请！",1,$link,true,8);
	}
	$points=(trim($_POST['points'])).(intval($_POST['points']))?trim($_POST['points']):showmsg('请填写充值积分！',1);
	if($_CFG['hunter_payment_rate']>0)
	{
		$amount=$points/$_CFG['hunter_payment_rate'];
	}
	else
	{
		$amount=$points;
	}
	($amount<$_CFG['hunter_payment_min'])?showmsg("单笔充值金额不能少于 ".$_CFG['hunter_payment_min']." 元！",1):'';
	$payment_name=empty($_POST['payment_name'])?showmsg("请选择付款方式！",1):$_POST['payment_name'];
	$paymenttpye=get_payment_info($payment_name);
	if (empty($paymenttpye)) showmsg("支付方式错误！",0);
	$fee=number_format(($amount/100)*$paymenttpye['fee'],1,'.','');//手续费
	$order['oid']= strtoupper(substr($paymenttpye['typename'],0,1))."-".date('ymd',time())."-".date('His',time());//订单号
	$order['v_url']=$_CFG['main_domain']."include/payment/respond_".$paymenttpye['typename'].".php";
	$order['v_amount']=$amount+$fee; 
	$order_id=add_order($_SESSION['uid'],$order['oid'],$amount,$payment_name,"充值积分:".$points,$timestamp,$points,'',$_SESSION['utype']);
		if ($order_id)
			{
			header("location:?act=payment&order_id=".$order_id);
			}
			else
			{
			showmsg("添加订单失败！",0);
			}
}
elseif($act=="order_del")
{
	$id=intval($_GET["id"]);
	$uid=intval($_SESSION['uid']);
	del_order($uid,$id)?showmsg("取消订单成功！",1):showmsg("取消订单失败！",1);
}
//付款
elseif ($act=='payment')
{
	$smarty->assign('payment',get_payment());
	$order_id=intval($_GET['order_id']);
	$myorder=get_order_one($_SESSION['uid'],$order_id);
	$payment=get_payment_info($myorder['payment_name']);
	if (empty($payment)) showmsg("支付方式错误！",0);
	$fee=number_format(($amount/100)*$payment['fee'],1,'.','');//手续费
	$order['oid']=$myorder['oid'];//订单号
	$order['v_url']=$_CFG['main_domain']."include/payment/respond_".$payment['typename'].".php";
	$order['v_amount']=$myorder['amount']+$fee;
	if ($myorder['payment_name']!='remittance')//假如是非线下支付，
	{
		require_once(QISHI_ROOT_PATH."include/payment/".$payment['typename'].".php");
		$payment_form=get_code($order,$payment);
		if (empty($payment_form)) showmsg("在线支付参数错误！",0);
	}
	$smarty->assign('points',get_user_points($_SESSION['uid']));
	$smarty->assign('title','付款 - 猎头会员中心 - '.$_CFG['site_name']);
	$smarty->assign('fee',$fee);
	$smarty->assign('amount',$myorder['amount']);
	$smarty->assign('o_points',$myorder['points']);
	$smarty->assign('oid',$order['oid']);
	$smarty->assign('byname',$payment);
	$smarty->assign('payment_form',$payment_form);
	$smarty->display('member_hunter/hunter_order_pay.htm');
}
//猎头积分规则
elseif($act == 'rules_point')
{ 
	$q_rule = $db->getall("select * from ".table("members_points_rule")." where utype=3");
	foreach($q_rule as $key=>$val){
		$rule[$val['name']]["value"]=$val["value"];
		if($val['operation'] == '1'){
			$rule[$val['name']]["value_cn"]="+".$val['value']; 
		}
		else
		{
			$rule[$val['name']]["value_cn"]="-".$val['value']; 
		}
		if($val['daymax']=="0")
		{
			$rule[$val['name']]["daymax"]="-";
		}
		else
		{
			$rule[$val['name']]["daymax"]=$val['daymax'];
		}
	}
	$smarty->assign('rule',$rule);
	$smarty->assign('title','积分规则 - 猎头会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_rules_point.htm');
}
//猎头经验规则
elseif($act == 'rules_exp')
{
	$leave_rule = $db->getall("select * from ".table("hunter_level_rule"));
	foreach($leave_rule as $key => $val)
	{	
		$rule[$val['name']]["value"]=$val["value"];
		if($val['operation'] == '1')
		{
			$rule[$val['name']]['value_cn']="+".$val['value'];
		}else{
			$rule[$val['name']]['value_cn']="-".$val['value']; 
		}
		if($val['daymax']=="0")
		{
			$rule[$val['name']]["daymax"]="-";
		}
		else
		{
			$rule[$val['name']]["daymax"]=$val['daymax'];
		}
	}
	$smarty->assign('leave_rule',$rule);
	$smarty->assign('title','经验规则 - 猎头会员中心 - '.$_CFG['site_name']);
	$smarty->display('member_hunter/hunter_rules_exp.htm');
}
// 添加合作过的客户
elseif($act=="collaborative_save")
{
	$collaborative_id=$_POST["id"]?intval($_POST["id"]):0;
	if($collaborative_id>0)
	{
		$setarr["company_name"]=$_POST['company_name']?trim($_POST['company_name']):exit("err");
		$uid=intval($_SESSION["uid"]);
		$rst=updatetable(table("hunter_collaborative"),$setarr,array("id"=>$collaborative_id,"hunter_uid"=>$uid));
		if($rst)
		{
			$row=get_hunter_collaborative($uid);
			$html='';
			foreach ($row as $key => $value) {
				$html.='<div class="teamwork link_blue clearfix">
							<span class="team_com_name" title="'.$value['company_name_'].'" id="'.$value['id'].'">'.$value['company_name'].'</span>
							<div class="op_link">
								<a href="javascript:void(0);" class="change" title="修改"></a><a href="?act=collaborative_del&id='.$value['id'].'" class="del" title="删除"></a>
							</div>
						</div>';
			}
			exit($html);
		}
		else
		{
			exit("err");
		}
	}
	else
	{
		$setarr["company_name"]=$_POST['company_name']?trim($_POST['company_name']):exit("err");
		$setarr["hunter_uid"]=intval($_SESSION["uid"]);
		$id=inserttable(table("hunter_collaborative"),$setarr,1);
		if($id)
		{
			exit("ok");
		}
		else
		{
			exit("err");
		}
	}
}
//删除合作过的客户
elseif($act=="collaborative_del")
{
	$hunter_uid=intval($_SESSION['uid']);
	$id=intval($_GET["id"]);
	$sql="delete from ".table("hunter_collaborative")." where id=$id and hunter_uid=$hunter_uid limit 1 ";
	$db->query($sql)?showmsg("删除成功！",1):showmsg("删除失败！",1);
}
// 猎头账户资金
elseif($act== 'hunter_accounts')
{
	$smarty->assign('act',$act);
	$smarty->assign('title',"账户金额 - 猎头会员中心 - ".$_CFG['site_name']);
	// 账户情况
	$account=get_user_account(intval($_SESSION['uid']));
	if(empty($account))
	{
		$account['available_funds']=0;
		$account['blocked_funds']=0;
		$smarty->assign('account',$account);
	}
	else
	{
		$smarty->assign('account',get_user_account(intval($_SESSION['uid'])));
	}
	$smarty->assign('userinfo',get_user_info(intval($_SESSION['uid'])));
	$smarty->assign('ip_address',$ip_address);
	// 账户资金日志
	$wheresql=" where uid=".intval($_SESSION['uid']);
	require_once(QISHI_ROOT_PATH.'include/page.class.php'); 
	$perpage=5;
	$total_sql="select COUNT(*) AS num from ".table("account_log").$wheresql." ";
	$total_val=$db->get_total($total_sql);
	$page = new page(array('total'=>$total_val, 'perpage'=>$perpage));
	$offset=($page->nowindex-1)*$perpage;
	$smarty->assign('account_log_list',get_account_log($offset,$perpage,$wheresql));
	if($total_val>$perpage)
	{
		$smarty->assign('page',$page->show(7));
	}
	$smarty->display('member_hunter/hunter_account_money.htm');
}
//提现表单
elseif($act=="company_withdrawals")
{
	$smarty->assign('act',$act);
	$smarty->assign('title',"账户金额 - 申请提现 - 猎头会员中心 - ".$_CFG['site_name']);
	// 账户情况
	$account=get_user_account(intval($_SESSION['uid']));
	if(empty($account))
	{
		$account['available_funds']=0;
		$account['blocked_funds']=0;
		$smarty->assign('account',$account);
	}
	else
	{
		$smarty->assign('account',get_user_account(intval($_SESSION['uid'])));
	}
	$smarty->assign('userinfo',get_user_info(intval($_SESSION['uid'])));
	$smarty->assign('ip_address',$ip_address);
	// 支付方式
	$pay_type=get_payment();
	foreach ($pay_type as $key => $value)
	{
		if($value['typename']=="alipay" || $value['typename']=="tenpay")
		{
			$arr[]=$value;
		}
	}
	$smarty->assign('pay_type',$arr);
	$smarty->display('member_hunter/hunter_withdrawals.htm');
}
elseif($act=="company_withdrawals_order_add")
{
	$myorder=get_account_withdrawal(intval($_SESSION['uid']),1);
	if (!empty($myorder))
	{
	$link[0]['text'] = "立即查看";
	$link[0]['href'] = "?act=hunter_withdrawals_order_show&order_id=".$myorder['id'];
	showmsg("您的账户有未处理的申请提现记录,不能申请提现！",1,$link);
	}
	$payment_name=empty($_POST['pay_type'])?showmsg("请选择付款方式！",1):$_POST['pay_type'];
	$paymenttpye=get_payment_info($payment_name);
	if (empty($paymenttpye)) showmsg("支付方式错误！",0);
	$extract_money=floatval($_POST['extract_money']);
	$fee=number_format(($extract_money/100)*$paymenttpye['fee'],1,'.','');//手续费
	$setarr['oid']= "TX".date('ymd',time())."-".date('His',time());//订单号
	$setarr['uid']=intval($_SESSION['uid']);
	$setarr['utype']=intval($_SESSION['utype']);
	$setarr['username']=$_SESSION['username'];
	$setarr['extract_money']=$extract_money-$fee;
	$setarr['extract_pay_type']=$_POST['pay_type'];
	$setarr['extract_pay_account']=empty($_POST['extract_pay_account'])?showmsg("请输入提现帐号！",1):$_POST['extract_pay_account'];
	$setarr['extract_pay_uname']=empty($_POST['extract_pay_uname'])?showmsg("请输入真实姓名！",1):$_POST['extract_pay_uname'];
	$setarr['addtime']=time();
	$order_id=inserttable(table("account_withdrawal"),$setarr,1);
	if ($order_id)
		{
		header("location:?act=hunter_withdrawals_order_show&order_id=".$order_id);
		}
		else
		{
		showmsg("添加订单失败！",0);
		}
}
elseif($act=="hunter_withdrawals_order_show")
{
	$smarty->assign('payment',get_payment());
	$order_id=intval($_GET['order_id']);
	$order_one=get_account_withdrawa_one($_SESSION['uid'],$order_id);
	$payment=get_payment_info($order_one['extract_pay_type']);
	if (empty($payment)) showmsg("支付方式错误！",0);
	$fee=number_format(($order_one['extract_money']/100)*$payment['fee'],1,'.','');//手续费
	$smarty->assign('title','申请提现 - 企业会员中心 - '.$_CFG['site_name']);
	$smarty->assign('fee',$fee);
	$smarty->assign('order_one',$order_one);
	$smarty->assign('byname',$payment['byname']);
	$smarty->assign('userinfo',get_user_info(intval($_SESSION['uid'])));
	$smarty->assign('ip_address',$ip_address);
	// 账户情况
	$account=get_user_account(intval($_SESSION['uid']));
	if(empty($account))
	{
		$account['available_funds']=0;
		$account['blocked_funds']=0;
		$smarty->assign('account',$account);
	}
	else
	{
		$smarty->assign('account',get_user_account(intval($_SESSION['uid'])));
	}
	$smarty->display('member_hunter/hunter_withdrawals_order_show.htm');

}