<?php
session_start();
include "header.html";
require_once "../MessageBox.php";
include "../datasource.inc.php";
include "../Function.php";
$Message = new MessageBox;
if ( empty($_SESSION["usernumber"]) and $_SESSION["userjs"] != "1") {
    $Message->setMessage("对不起，您没有权限进入后台管理!","logout.php");
    $Message->showMessage();
}
$page    = $_REQUEST['page'];
$body    = $_REQUEST['body'];
$commet  = str_replace("\n", "<BR>", $_REQUEST['commet']);
$date     = Date("Y-m-d");
$datetime = Date("Y-m-d H:i:s");
$page     = $_REQUEST['page'];
$body     = $_REQUEST['body'];
if ( $_REQUEST['action'] == "insert") {
	$sql    = "insert into en_zht_job values ('','$_REQUEST[job]','$_REQUEST[how]','$_REQUEST[age]','$_REQUEST[sex]','$_REQUEST[schoolage]','$body','$_REQUEST[branch]','$_REQUEST[email]','$date')";
	$result = mysql_query($sql);
	$Message->setMessage("添加成功！","en_job.php");
	$Message->showMessage();
}
if ( $_REQUEST['action'] == 'update') {
	$sql     = "update en_zht_job set job='$_REQUEST[job]',how='$_REQUEST[how]',age='$_REQUEST[age]',sex='$_REQUEST[sex]',schoolage='$_REQUEST[schoolage]',body='$body',branch='$_REQUEST[branch]',email='$_REQUEST[email]' where id='$_REQUEST[id]'";
	mysql_query($sql);
	$Message->setMessage("编辑成功！","en_job.php");
	$Message->showMessage();
}
?>
<table width="700" border="0" cellspacing="0" cellpadding="0">
        <tr>
         <TD vAlign=top><FONT color=#565656><IMG height=14 
      src="../images/closedfold.gif" width=14>&nbsp;&nbsp;您当前的位置<BR><IMG 
      height=15 src="../images/bar.gif" width=15><IMG height=14 
      src="../images/openfold.gif" width=14>&nbsp;&nbsp;人才招聘管理(英文版)</FONT></TD>
        </tr>
</table>
<script language="JavaScript">
function chin()
{
	if (document.form1.title.value=='') {
		alert("请输入文章标题！");
		return false;
	}
 return true;
}
</script>
<?php
switch ($page){
	case "add":
?>
<center>
<p align="center">&nbsp;<b><font size="3">请输入招聘信息</font></b></p>
<form action="en_job.php?action=insert" method="post" name="form1" onsubmit="return chin()">
<table border=0 cellpadding=0 cellspacing=1 bgcolor="#6795B4" width=550>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>招聘职位：</b></center></td>
    <td width="80%" bgcolor=ffffff><input type="text" size="30" name="job" /></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>数量：</b></center></td>
    <td width="80%" bgcolor=ffffff><input type="text" size="8" name="how"> 位</td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>年龄：</b></center></td>
    <td width="80%" bgcolor=ffffff><input type="text" size="15" name="age"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>性别：</b></center></td>
    <td width="80%" bgcolor=ffffff><select name="sex">
      <option value="不限">不限</option>
      <option value="男">男</option>
      <option value="女">女</option>
    </select>
    </td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>学历：</b></center></td>
    <td width="80%" bgcolor=ffffff><input type="text" size="15" name="schoolage"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>其他要求：</b></center></td>
    <td width="80%" bgcolor=ffffff><textarea name="body" rows="5" cols="50"></textarea></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>招聘部门：</b></center></td>
    <td width="80%" bgcolor=ffffff><input type="text" size="20" name="branch"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>联系信箱：</b></center></td>
    <td width="80%" bgcolor=ffffff><input type="text" size="30" name="email"></td>
  </tr>
</table>
<br>
<input type="submit" value="提 交" >&nbsp;&nbsp;<input type="reset"  value="取 消">
</form>
</center>
<?
		break;
	case "delete":
		$query    = "delete from en_zht_job where id='$_REQUEST[id]'";
		mysql_query($query);
		$Message->setMessage("删除成功!","javascript:history.go(-1)");
		$Message->showMessage();
		break;
	case "update":
		$sql      = "select * from en_zht_job where id='$_REQUEST[id]'";
		$result   = mysql_query($sql);
		$row      = mysql_fetch_array($result);
		$body     = str_replace("<BR>", "\n", $row['body']);
?>
<center>
<p align="center">&nbsp;<b><font size="3">请修改招聘信息</font></b></p>
<form action="en_job.php?action=update" method="post" name="form" onsubmit="return chin()">
<table border="0" cellpadding="0" cellspacing="1" bgcolor="#6795B4" width="550">
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>招聘职位：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><input type="text" size="30" name="job" value="<? echo $row['job']?>"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>数量：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><input type="text" size="8" name="how" value="<? echo $row['how']?>">
      位</td>
  </tr>
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>年龄：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><input type="text" size="15" name="age" value="<? echo $row['age']?>"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgColor=#EBF1F5><center><b>性别：</b></center></td>
    <td width="80%" bgcolor=ffffff><select name="sex">
      <? echo "<option value=\"$row[sex]\">$row[sex]</option>"?>
	  <option value="不限">不限</option>
      <option value="男">男</option>
      <option value="女">女</option>
    </select>
    </td>
  </tr>
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>学历：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><input type="text" size="15" name="schoolage" value="<? echo $row['schoolage']?>"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>其他要求：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><textarea name="textarea" rows="5" cols="50"><? echo $body?></textarea></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>招聘部门：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><input type="text" size="20" name="branch" value="<? echo $row['branch']?>"></td>
  </tr>
  <tr>
    <td width="20%" height="20" bgcolor="#EBF1F5"><center>
      <b>联系信箱：</b>
    </center></td>
    <td width="80%" bgcolor="ffffff"><input type="text" size="30" name="email" value="<? echo $row['email']?>"></td>
  </tr>
</table>
<br>
<input type="hidden" value="update" name="action">
<?php echo "<input type=hidden name=id  value=$row[id]>"; ?>
<input type="submit" value="编 辑" >&nbsp;&nbsp;<input type="reset"  value="取 消">
</form>
</center>
<?php
		break;
	case "text":
		$sql     = "select * from zht_news where id='$id'";
		$result  = mysql_query($sql);
		$row     = mysql_fetch_array($result);
		$imagetype = ( substr($row['picpath'],-3,3));
		if ( $imagetype=="gif" or $imagetype=="GIF" or $imagetype=="jpg" or $imagetype=="JPG" or $imagetype=="png" or $imagetype=="PNG" or $imagetype=="bmp" or $imagetype=="BMP" or $imagetype=="jpe" or $imagetype=="JPE") {
			$size    = getimagesize ("../upload-images/$row[picpath]");
			$arr     = imgspec( 400, $size[0], $size[1]);
			$imgwidth  = $arr[0];
			$imgheight = $arr[1];
			$pic       = "<img src=../upload-images/$row[picpath] width=$imgwidth height=$imgheight align=center>";
		} else {
			$pic       = "";
		}
?>
<br>
<center>
<table border=0 cellpadding=0 cellspacing=0 width=620>
  <tr height=22> 
    <td><b>类型：</b><?php echo $row['fl']; ?></td>
  </tr>
  <tr> 
    <td align="center"><font size=3><b><?php echo $row['title']?></b></font><br><hr><?php echo "发布时间：<font color=red>$row[date]</font><br>"; ?></td>
  </tr>
  <tr>
    <td height=10></td>
  </tr>
  <tr>
    <td align="center"><?php echo $pic?></td>
  </tr>
  <tr>
    <td height=10></td>
  </tr>
  <tr> 
    <td style="line-height:150%"><?php echo $row['body']?></td>
  </tr>
</table>
<br><a href="news.php">返回</a>
</center>
<?php
		break;
	default:
	$sql      = "select * from en_zht_job order by id desc;";
	$result   = mysql_query($sql);
	$num      = mysql_num_rows($result);
	if ( $num <= 0 ) {
		echo "<center>暂时没有记录!</center>";
	} else {
		$last   = intval(($num-1)/12)+1;
		if ( $page < 1 ) $page     = 1;
		if ( $page > $last ) $page = $last;
		mysql_data_seek($result,($page-1)*12);
		for ($i=1;$i<=12;$i++) {
			$row=mysql_fetch_array($result);
			if ( $row['id'] ) {
?>
<table width="95%"  border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#e1e1e1">
  <tr align="left" bgcolor="#ECECD5">
    <td colspan="8" bgcolor="#f1f1f1">&nbsp;&nbsp;<strong><? echo $row['job']?></strong></td>
  </tr>
  <tr>
    <td width="11%" align="center" bgcolor="#f5f5f5">数量</td>
    <td width="16%" align="left" bgcolor="#FFFFFF"><? echo $row['job']."位"?></td>
    <td width="8%" align="center" bgcolor="#f5f5f5">年龄</td>
    <td width="16%" align="left" bgcolor="#FFFFFF"><? echo $row['age']?></td>
    <td width="10%" align="center" bgcolor="#f5f5f5">性别</td>
    <td width="15%" align="left" bgcolor="#FFFFFF"><? echo $row['sex']?></td>
    <td width="8%" align="center" bgcolor="#f5f5f5">学历</td>
    <td width="16%" align="left" bgcolor="#FFFFFF"><? echo $row['schoolage']?></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#f5f5f5">其他要求</td>
    <td colspan="3" align="left" bgcolor="#FFFFFF"><? echo $row['body']?></td>
    <td align="center" bgcolor="#f5f5f5">招聘部门</td>
    <td colspan="3" align="left" bgcolor="#FFFFFF"><? echo $row['branch']?></td>
  </tr>
  <tr align="center" bgcolor="#ffffff">
    <td align="center" bgcolor="#f5f5f5">联系信箱 </td>
    <td colspan="3" align="left" bgcolor="#FFFFFF"><? echo $row['email']?></td>
    <td colspan="3" align="center" bgcolor="#FFFFFF">&nbsp;</td>
    <td align="center" bgcolor="#FFFFFF"><a title=点击编辑本条记录 href=en_job.php?page=update&id=<? echo $row['id']?>><font color="#FF0000">编辑</font></a>&nbsp;&nbsp;<a title=点击删除本条记录 href=en_job.php?page=del&id=<? echo $row['id']?> onclick="return confirm('确定要删除吗？')"><font color="#FF0000">删除</font></a></td>
  </tr>
</table>
<table width="90%" height="5" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="5"></td>
  </tr>
</table>
<br>
<?php
			}
		}
	echo "<center><table width=520 border=0 cellpadding=0 cellspacing=0 class=back>";
	echo "<tr><td colsapn=4 align=center>";
	echo "总共找到<font color=red>$num</font>条记录,第<font color=red>$page</font>页,共<font color=red>$last</font>页。"; 
	echo "</td></tr></table>";
	echo "<table width=520 border=0 cellpadding=0 cellspacing=0 class=back>";
	echo "<tr>";
	if ( $page <> 1 ) {
		echo "<td align=center>&nbsp;&nbsp;&nbsp;<a href=en_job.php?page=1>第一页</a></td>";
		echo "<td align=center><a href=en_job.php?page=".($page-1).">上一页</a></td>";
	}
	if ( $page <> $last ) {
		echo "<td align=center><a href=en_job.php?page=".($page+1).">下一页</a></td>";
		echo "<td align=center><a href=en_job.php?page=$last>[末页]</a></td>";
	}
	echo "</tr></table></center>";
	}
	break;
}
?>
