<?php
if(!defined('IN_TM')) 
{
	exit('Access Denied');
}
if($_SESSION["admin"]!="Silence")
{
	include template('login.htm');
    exit;
}
//¹ÜÀíÔ±²Ù×÷
$a = getgpc('do');
if($a == 'list')
{
	$page = getgpc('page');
	if(isset($page)){ $page = intval($page); }else{ $page = 1; }
	$page_size = 15; 
	$sql = "SELECT * FROM `{$tablepre}jobs`";
	$row = $db->num_rows($db->query($sql));
	$mpurl =$PHP_SELF.'?action=job&do=list&';
	$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";
	$userlist = $db->fetch_all($sql);
	$a = 'Y-m-d H:i';
	$tplid = 1;
	include template('job.htm');
	$db->close();
	exit;
}
elseif ($a == 'add')
{
	if (empty($_POST['Submit']))
	{
		include_once TM_ROOT.'./include/Editor.class.php';
		$editor=new sinaEditor('body');
		$editor->BasePath='.';
		$editor->Height=500;
		$editor->Width=700;
		$editor->AutoSave=false;
		$tplid = 2;
		include template('job.htm');
		exit;
	}
	else
	{	
		$title = getgpc('title');
		$sex = getgpc('sex');
		$age = getgpc('age');
		$age2 = getgpc('age2');
		$xueli = getgpc('xueli');
		$num = getgpc('num');
		$body = getgpc('body');
		if(empty($title) or empty($body) )
		{
			$messageid = 14;
			include template('message.htm');
			exit;
		}
		$db->query("INSERT INTO {$tablepre}jobs (title,sex,age,age2,xueli,num,body,time) VALUES 	('$title','$sex','$age','$age2','$xueli','$num','$body','$timestamp')");
		$messageid = 13;
		include template('message.htm');
		exit;
	}
}
elseif ($a == 'del')
{
	$uids = timplode(getgpc('delete'));
	$rs = $db->query("DELETE FROM {$tablepre}jobs WHERE id IN ($uids) ");
	if (!$rs) 
	{
		$messageid = 22;
		include template('message.htm');
		exit;
	}
	$messageid = 21;
	include template('message.htm');
	$db->close();
	exit;
}
elseif ($a == 'edit')
{
	if (empty($_POST['Submit']))
	{
		$id = getgpc('id');
		$userlist = $db->fetch_all("SELECT * FROM {$tablepre}jobs WHERE id = '{$id}'");
		include_once TM_ROOT.'./include/Editor.class.php';
		$editor=new sinaEditor('body');
		$editor->Value=$userlist[0][body];
		$editor->BasePath='.';
		$editor->Height=500;
		$editor->Width=700;
		$editor->AutoSave=false;
		$tplid = 3;
		include template('job.htm');
		exit;
	}
	else
	{
		$id = getgpc('id');
		$title = getgpc('title');
		$sex = getgpc('sex');
		$age = getgpc('age');
		$age2 = getgpc('age2');
		$xueli = getgpc('xueli');
		$num = getgpc('num');
		$body = getgpc('body');
		if(empty($title) or empty($body) )
		{
			$messageid = 14;
			include template('message.htm');
			exit;
		}
		$sql = "UPDATE {$tablepre}jobs SET 
		title = '{$title}',sex = '{$sex}',age = '{$age}',age2 = '{$age2}',xueli = '{$xueli}',num = '{$num}',body = '{$body}' WHERE id ={$id};";
		$db->query($sql);
		$messageid = 6;
		include template('message.htm');
		exit;
    }
}
if($a == 'resumelist')
{
	$page = getgpc('page');
	if(isset($page)){ $page = intval($page); }else{ $page = 1; }
	$page_size = 5; 
	$sql = "SELECT * FROM `{$tablepre}resume`";
	$row = $db->num_rows($db->query($sql));
	$mpurl =$PHP_SELF.'?action=job&do=resumelist&';
	$dispage =  page($row,$page_size,$page,$mpurl);
	$page_get_start = page_get_start($page,$page_size,$row);
	$sql = "SELECT * FROM {$tablepre}resume LIMIT $page_get_start, $page_size";
	$userlist = $db->fetch_all($sql);
	$a = 'Y-m-d H:i';
	$tplid = 4;
	include template('job.htm');
	$db->close();
	exit;
}
elseif ($a == 'resumedel')
{
	$uids = timplode(getgpc('id'));
	$rs = $db->query("DELETE FROM {$tablepre}resume WHERE id IN ($uids) ");
	if (!$rs) 
	{
		$messageid = 22;
		include template('message.htm');
		exit;
	}
	$messageid = 21;
	include template('message.htm');
	$db->close();
	exit;
}
?>