<?php
if(!defined('IN_TM'))exit('Access Denied');
if($id){
	if(!$dosubmit){
		//$fl = $db->get_one("SELECT * FROM ".DB_PRE."jobs");
		$fl = get('jobs','','id DESC', 1, 100);
		$tplid = 2;
		$db->close();
		include view('job');
	}else{
		if(empty($info[email])){
			die("<script>alert('请填写您的邮箱!重要！'); history.go(-1);</script>");
		}elseif(empty($age)){
			die("<script>alert('请输入您的真实年龄！'); history.go(-1);</script>");
		}elseif(empty($info[body])){
			die("<script>alert('请输入附加内容！'); history.go(-1);</script>");
		}
		if($_FILES){
            require_once TM_ROOT.'include/upload.class.php';
        	$upload = new upload('uploadfile', 'doc|docx|rar|zip|7z', 1);   
			$infi[jl] = $upload->up();
			if(!$infi[jl])die("<script>alert('".$upload->error()."'); history.go(-1);</script>");   
        }else{
			die("<script>alert('附件不能为空！请选择您的简历！'); history.go(-1);</script>");
		} 
		$zw = $db->get_one("SELECT * FROM ".DB_PRE."jobs WHERE `id` =$id"); 
		if($age < $zw[age] or $age > $zw[age2]){
			die("<script>alert('您的年龄不符合要求！'); history.go(-1);</script>");
		}
		$info[zw] = $zw[title];
		$info[time] = TIME;
		$db->insert(DB_PRE.'resume', $info);
        $id = $db->insert_id();
        $http = load('http.class.php');
        $email_message = "新简历：<BR/>姓名 ：".$info[name]."<BR/>年龄：".$age."<BR/>邮箱：".$info[email]."<BR/>附加内容：".$info[body]."<BR/><a href =".$TM[siteurl]."admin.php >点击登陆网站后台查看</a>";
	    $is_ok = $http->post('http://www.newsteng.com/license/to.php?charset='.CHARSET.'&domain='.urlencode($business[xtcmsdomain]).'&sub='.urlencode('简历').'&email_message='.urlencode($email_message));
	    if($id){
			die("<script>alert('恭喜，您的简历已经提交到人事部邮箱，敬请关注您的回复邮件，谢谢！');history.go(-1);</script>");
		}else{
			die("<script>alert('服务器繁忙请稍后再试！'); history.go(-1);</script>");
		}
	}
}else{
	$page = max(intval($page), 1);
	$page_size = 20; 
	$r = $db->get_one("SELECT count(*) as num FROM ".DB_PRE."jobs");
	$mpurl =$PHP_SELF.'?file=job&';
	$dispage =  page($r['num'],$page_size,$page,$mpurl);
	$joblist = get('jobs','','id DESC', $page, $page_size);
	$a = 'Y-m-d';
	$tplid = 1;
	$db->close();
	include view('job');
}
?>