<?php
if(!defined('IN_TM')) {exit('Access Denied');}
$id=intval(getgpc('id'));  
if($id){
	if(empty($_REQUEST['Submit'])){
		$fl = $db->fetch_all("SELECT * FROM {$tablepre}jobs");
		$tplid = 2;
		$db->close();
		include template('job.htm');
	}else{
		$email = getgpc('email');
		$age = getgpc('age');
		$doc = getgpc('doc');
		$body = getgpc('body');
		if(empty($email)){
			die("<script>alert('请填写您的邮箱!重要！'); history.go(-1);</script>");
		}elseif(empty($age)){
			die("<script>alert('请输入您的真实年龄！'); history.go(-1);</script>");
		}elseif(empty($doc)){
			die("<script>alert('附件不能为空！请选择您的简历！'); history.go(-1);</script>");
		}elseif(empty($body)){
			die("<script>alert('请输入附加内容！'); history.go(-1);</script>");
		}
		$sql = "SELECT * FROM `{$tablepre}jobs`WHERE `id` =$id";
		$zw = $db->fetch_all($sql);
		if($age < $zw[0][age] or $age > $zw[0][age2]){
			die("<script>alert('您的年龄不符合要求！'); history.go(-1);</script>");
		}
		$sql = "INSERT INTO `{$tablepre}resume` (
`email` ,
`zw` ,
`age` ,
`jl` ,
`body` ,
`time`
)
VALUES (
'$email', '{$zw[0][title]}', '$age', '$doc', '$body', '$timestamp'
);";
		$rs = $db->query($sql);
		if($rs){
			die("<script>alert('恭喜，您的简历已经提交到人事部邮箱，敬请关注您的回复邮件，谢谢！');history.go(-1);</script>");
		}else{
			die("<script>alert('服务器繁忙请稍后再试！'); history.go(-1);</script>");
		}
	}
}else{
	$page = getgpc('page');
	if(isset($page)){ $page = intval($page); }else{ $page = 1; }
	$page_size = 20; 
	$sql = "SELECT * FROM `{$tablepre}jobs`";
	$row = $db->num_rows($db->query($sql));
	$mpurl =$PHP_SELF.'?action=job&';
	$dispage =  page($row,$page_size,$page,$mpurl);
	$page_get_start = page_get_start($page,$page_size,$row);
	$sql = "SELECT * FROM {$tablepre}jobs LIMIT $page_get_start, $page_size";
	$joblist = $db->fetch_all($sql);
	$a = 'Y-m-d';
	$tplid = 1;
	$db->close();
	include template('job.htm');
}
?>