<?php
if(!defined('IN_MYMPS')) exit('Forbidden');
require MEMBERDIR.'/include/common.func.php';

if($ac == 'delthis'){
	
	if(!$id) write_msg('','?m=resume&error=1&page='.$page);
	$db->query("DELETE FROM `{$db_mymps}resume_post` WHERE id = '$id' AND touser = '$s_uid'");
	write_msg('','?m=resume&success=3&page='.$page);
	
} elseif($resumeid){
	$xueliArr[1]='高中及以下';
	$xueliArr[2]='中专';
	$xueliArr[3]='大专';
	$xueliArr[4]='本科';
	$xueliArr[5]='硕士';
	$xueliArr[6]='博士及以上';
	$zhuangtaiArr[1]='离职';
	$zhuangtaiArr[2]='在职';
	$zhuangtaiArr[3]='在校';
	$jingyanArr[0]='无经验';
	$jingyanArr[1]='应届生';
	$jingyanArr[2]='1年以下';
	$jingyanArr[3]='1-3年';
	$jingyanArr[4]='3-5年';
	$jingyanArr[5]='5-10年';
	$jingyanArr[6]='10年以上';
	$yuexinArr[0]='面议';
	$yuexinArr[1]='2000以下';
	$yuexinArr[2]='2000-4000';
	$yuexinArr[3]='4000-6000';
	$yuexinArr[4]='6000-8000';
	$yuexinArr[5]='8000-12000';
	$yuexinArr[6]='12000-20000';
	$yuexinArr[7]='20000-50000';
	$yuexinArr[8]='50000以上';
	$r = $db->getRow("SELECT a.*,b.weixin,b.qq,b.mobile,b.sex,b.email,b.cityid,b.areaid,b.streetid FROM `{$db_mymps}resume` AS a LEFT JOIN `{$db_mymps}member` AS b ON a.userid = b.userid WHERE a.id = '$resumeid'");
	if($r[cityid]) $r['cityname']=$db->getOne("SELECT cityname FROM `{$db_mymps}city` WHERE cityid = '$r[cityid]'");
	if($r[areaid]) $r['areaname']=$db->getOne("SELECT areaname FROM `{$db_mymps}area` WHERE areaid = '$r[areaid]'");
	if($r[streetid]) $r['streetname']=$db->getOne("SELECT streetname FROM `{$db_mymps}street` WHERE streetid = '$r[streetid]'");
	if($r['id']){
		$resume_maxview = $group['resume_maxview'];
		if(empty($resume_maxview)){
			write_msg('您当前的会员级别不支持查看简历，如需查看请升级会员级别。');
		}
		if($row['resumeView']>=$resume_maxview && !strstr($r['viewed'],$s_uid.'@')){
			write_msg('您已查看'.$row['resumeView'].'条简历<br><br>您的级别只支持查看'.$resume_maxview.'条<br><br>如需查看更多请升级更高级别会员。');
		}
		if(!strstr($r['viewed'],$s_uid.'@')){
			$viewed = $r['viewed'];
			if(!strstr($viewed,$s_uid.'@')) $viewed=$viewed.$s_uid.'@';
			if($row['money_own']<$group['resume_perview_cost'] && $group['resume_perview_cost'] > 0){
				write_msg('余额不足，查看1条简历需支付'.$group['resume_perview_cost'].'个金币，请前往充值','?ac=pay&money='.$money_need);
				exit;
			}
			$db->query("UPDATE `{$db_mymps}resume` SET viewed='$viewed' WHERE id ='$resumeid'");
			$db->query("UPDATE `{$db_mymps}member` SET resumeView=resumeView+1 WHERE userid = '$s_uid'");
			$money_need = $group['resume_perview_cost']-$row['money_own'];
			if($group['resume_perview_cost']>0){
				$db->query("UPDATE `{$db_mymps}member` SET money_own=money_own-'$group[resume_perview_cost]' WHERE userid = '$s_uid'");
				write_money_use("查看编号为".$r['id']."的简历","<font color=red>扣除金币 ".$group['resume_perview_cost']." </font>");
			}
		}

		$location = location();
		include mayi_tpl('resume');
	}else{
		write_msg('该简历不存在或已被删除！');
	}
} else {
	
	$sql = "SELECT a.*,b.xingming FROM {$db_mymps}resume_post AS a LEFT JOIN `{$db_mymps}resume` AS b ON a.resumeid = b.id WHERE a.touser = '$s_uid' ORDER BY a.id DESC";
	$resume_maxview = $group['resume_maxview'];
	$rows_num = mymps_count("resume_post","WHERE touser = '$s_uid'");
	$param	  = setParam(array("m"));
	$list     = array();
	
	foreach(page1($sql) as $k => $rp){
		$arr['id']       = $rp['id'];
		$arr['infoid'] = $rp['infoid'];
		$arr['title']   = $rp['title'];
		$arr['userid']   = $rp['xingming'];
		$arr['touser']   = $rp['touser'];
		$arr['infouri']   = $rp['infouri'];
		$arr['resumeid']   = $rp['resumeid'];
		$arr['begintime']   = $rp['begintime'];
		$list[]= $arr;
	}
	$location = location();
	include mayi_tpl('resume_post');
}
?>