<?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();
	EXIT;
}
$date     = Date("Y-m-d");
$datetime = Date("Y-m-d H:i:s");
$page     = $_REQUEST['page'];
$commet    = str_replace("\n", "<BR>", $_REQUEST['commet']);
$re_commet  = str_replace("\n", "<BR>", $_REQUEST['re_commet']);
if ( $_REQUEST['action'] == "update") {
	$sql     = "update zht_art set re_commet='$re_commet' where id='$_REQUEST[id]';";
	mysql_query($sql);
	$Message->setMessage("回覆成功!","support.php");
	$Message->showMessage();
}
if ( $_REQUEST['action'] == "del") {
	$sql     = " delete from zht_art where id='$_REQUEST[id]';";
	mysql_query($sql);
	$Message->setMessage("删除成功!","javascript:history.go(-1)");
	$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>
<?php
if ( $_REQUEST['action'] == "re"){
	$sql    = "select * from zht_art where id='$_REQUEST[id]';";
	$result = mysql_query($sql);
	$row    = mysql_fetch_array($result);
	$re_commet  = str_replace("<BR>", "\n", $row['re_commet']);
?>
<script language=javascript>
function check_input()
{

    if (document.form.re_commet.value=='') {
		alert("提示：\n\n回覆内容不能为空!");
		return false;
	}

 return true;
}
</script>
<form action="support.php?action=update" method=post name=form onsubmit="return check_input()">
<table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td width="25%" align="center" bgcolor="#dddddd"><font color="#FF0000">提问主题：</font></td>
    <td width="75%" bgcolor="#dddddd"><? echo $row['title']?></td>
  </tr>
  <tr>
    <td width="25%" align="center" bgcolor="#FFFFFF">昵称：</td>
    <td width="75%" bgcolor="#FFFFFF"><? echo $row['name']." ";if ($row['sex']=="1") echo "先生"; else echo "女士";?></td>
  </tr>
  <tr>
    <td width="25%" align="center" bgcolor="#dddddd">联系电话</td>
    <td width="75%" bgcolor="#dddddd"><? echo $row['phone']?></td>
  </tr>
  <tr>
    <td width="25%" align="center" bgcolor="#FFFFFF">E-Mail</td>
    <td width="75%" bgcolor="#FFFFFF"><? echo $row['email']?></td>
  </tr>
  <tr>
    <td width="25%" align="center" bgcolor="#dddddd">提问内容</td>
    <td width="75%" bgcolor="#dddddd"><? echo $row['commet']?></td>
  </tr>
  <tr>
    <td width="25%" align="center" bgcolor="#FFFFFF">回覆内容</td>
    <td width="75%" bgcolor="#FFFFFF"><textarea name="re_commet" cols="50" rows="5"><? echo $re_commet?></textarea></td>
  </tr>
</table>
<center><br>
<input type="hidden" name="id" value="<? echo $row['id']?>">
<input type="submit" name="submit" value="回 覆">&nbsp;&nbsp;<input type="reset" name="reset" value="取 消">
</center>
</form>
<?php
} else {
	$sql      = "select * from zht_art 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="600" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
  <tr>
    <td width="98" align="center" bgcolor="#AABFFF"><b>主题：</b></td>
    <td width="340" bgcolor="#AABFFF"><? echo $row['title']?>&nbsp;&nbsp;&nbsp;&nbsp;<a title=点击回复本条记录 href=support.php?action=re&id=<? echo $row['id']?>><font color="#FF0000">回复</font></a>&nbsp;&nbsp;<a title=点击删除本条记录 href=support.php?action=del&id=<? echo $row['id']?> onclick="return confirm('确定要删除吗？')"><font color="#FF0000">删除</font></a></td>
    <td width="140" align="center" bgcolor="#AABFFF">(<? echo $row['datetime']?>)</td>
  </tr>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><b>电话：</b></td>
    <td colspan="2" bgcolor="#FFFFFF"><? echo $row['phone']?>&nbsp;&nbsp;&nbsp;&nbsp;<b>E-Mail：</b><? echo $row['email']?></td>
  </tr>
  <tr>
    <td align="center" bgcolor="#AABFFF"><? echo $row['name']." ";if ($row['sex']=="1") echo "先生"; else echo "女士";?></td>
    <td colspan="2" bgcolor="#AABFFF"><? echo $row['commet']?></td>
  </tr>
<?php
		if ($row['re_commet']){
?>
  <tr>
    <td align="center" bgcolor="#FFFFFF"><b>回复：</b></td>
    <td colspan="2" bgcolor="#FFFFFF"><? echo $row['re_commet']?></td>
  </tr>
<?php
		}
?>
</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=support.php?page=1>第一页</a></td>";
		echo "<td align=center><a href=support.php?page=".($page-1).">上一页</a></td>";
	}
	if ( $page <> $last ) {
		echo "<td align=center><a href=support.php?page=".($page+1).">下一页</a></td>";
		echo "<td align=center><a href=support.php?page=$last>[末页]</a></td>";
	}
	echo "</tr></table></center>";
	}
}
?>