<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>问答分类</title>
<link href="css_body.css" rel="stylesheet" type="text/css" />
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<style type="text/css">
<!--
.STYLE1 {
	color: #FF0000;
	font-weight: bold;
}
-->
</style>
</head>
<body>

<div class="bodytitle">
	<div class="bodytitleleft"></div>
  <div class="bodytitletxt">互动模块</div>
</div>
<?php
if(empty($action))
{
?>
<form name="form1" action="asktype.php" method="post">
	<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">

      <tr>
        <td colspan="2" bgcolor="#EDF9D5"><strong>&nbsp;添加一级分类</strong>
        <input type="hidden" name="action" value="add" />
        <input type="hidden" name="reid" value="0" /></td>
      </tr>
      <tr>
        <td width="150" height="20" align="right" bgcolor="#FFFFFF">分类名称：</td>
        <td height="20" bgcolor="#FFFFFF"><input type="text" name="name" value="" />(分类名称长度最好不要超过10个字符，也就是5个汉字)</td>
      </tr>
      <tr>
        <td height="35" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="35" bgcolor="#FFFFFF"><input type="submit" name="submit1" value="提交" class="inputbut"/></td>
      </tr>
    </table>

</form>
<form name="form2" action="asktype.php" method="post">
	<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">

      <tr>
        <td colspan="2" bgcolor="#EDF9D5"><strong>&nbsp;添加二级分类</strong>
        <input type="hidden" name="action" value="add" /></td>
      </tr>
      <tr>
        <td width="150" height="20" align="right" bgcolor="#FFFFFF">分类名称：</td>
        <td height="20" bgcolor="#FFFFFF"><input type="text" name="name" value="" />(分类名称长度最好不要超过10个字符，也就是5个汉字)</td>
      </tr>
      <tr>
        <td height="20" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="20" bgcolor="#FFFFFF"><select name="reid">
          <option value="0">所属一级分类</option>
          <?php echo $sectorscache; ?>
        </select>        </td>
      </tr>
      <tr>
        <td height="35" bgcolor="#FFFFFF">&nbsp;</td>
        <td height="20" bgcolor="#FFFFFF"><input type="submit" name="submit2" value="提交" class="inputbut"/></td>
      </tr>
    </table>

</form>
<form name="merge" action="asktype.php" method="post">
<input type="hidden" name="action" value="merge" />
<table width="96%" border="0" align="center" cellpadding="1" cellspacing="1" class="tbtitle" style="background:#E2F5BC;">
	<tr>
        <td colspan="2" bgcolor="#EDF9D5"><strong>&nbsp;问答分类合并</strong></td>
      </tr>
      <tr>
        <td width="150" height="20" align="right" bgcolor="#FFFFFF">源分类：</td>
        <td bgcolor="#FFFFFF"><select name="sourcetype" >
<?php
foreach($sectors as $sector)
{
	if($sector['reid'] == 0)
	{
		echo "<option value='$sector[id]'>$sector[name]</option>";
	}else
	{
		echo "<option value='$sector[id]'>|-- $sector[name]</option>";

	}
}
?>
</select>
        (源分类不能有下级分类，否则不能合并；合并后源分类将被删除且不可恢复，请谨慎操作) </td>
        </tr>
      <tr>
        <td height="20" align="right" bgcolor="#FFFFFF">目标分类：</td>
        <td bgcolor="#FFFFFF"><select name="targettype" >
          <?php
foreach($sectors as $sector)
{
	if($sector['reid'] == 0)
	{
		echo "<option value='$sector[id]'>$sector[name]</option>";
	}else
	{
		echo "<option value='$sector[id]'>|-- $sector[name]</option>";

	}
}
?>
        </select></td>
      </tr>
      <tr>
        <td height="20" bgcolor="#FFFFFF">&nbsp;</td>
        <td bgcolor="#FFFFFF"><input type="submit" name="submit2" value="提交" class="inputbut"/></td>
      </tr>
</table>
</form>
<form name="form3" action="asktype.php" method="post">
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
      <tr>
        <td bgcolor="#EDF9D5"><strong>&nbsp;编辑分类</strong>
<input type="hidden" name="action" value="update" /></td>
    </tr>
      <tr>
        <td bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="1" cellspacing="1" align="center" style="margin:0px auto" class="tblist">

          <tr>
            <td>id</td>
            <td>name</td>
            <td>排序</td>
            <td>管理操作</td>
          </tr>
<?php
foreach($sectors as $sector)
{
	if($sector['reid'] == 0)
	{
		echo "<tr><td>$sector[id]</td><td><input type=\"text\" name=\"names[$sector[id]]\" value=\"$sector[name]\" /></td><td><input type=\"text\" name=\"disorders[$sector[id]]\" value=\"$sector[disorder]\" /></td><td><a href=\"asktype.php?action=edit&amp;id=$sector[id]\">修改</a> <a href=\"asktype.php?action=delete&amp;id=$sector[id]\">删除</a></td></tr>";
	}else
	{
		echo "<tr><td>$sector[id]</td><td>|- <input type=\"text\" name=\"names[$sector[id]]\" value=\"$sector[name]\" /></td><td><input type=\"text\" name=\"disorders[$sector[id]]\" value=\"$sector[disorder]\" /></td><td><a href=\"asktype.php?action=edit&amp;id=$sector[id]\">修改</a> <a href=\"asktype.php?action=delete&amp;id=$sector[id]\">删除</a></td></tr>";

	}
}
?>
        </table>        </td>
      </tr>
      <tr>
        <td height="35" align="center" bgcolor="#FFFFFF"><input name="submit3" type="submit" value="提交" class="inputbut"/></td>
      </tr>
    </table>
</form>
<?php
}elseif($action == 'edit')
{
?>
<form name="form4" action="asktype.php" method="post">
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
    <tr>
        <td colspan="2" bgcolor="#EDF9D5"><strong>&nbsp;修改</strong>
        <input type=hidden name=action value=edit />
        <input type=hidden name=step value=2 />
        <input type=hidden name=id value=<?php echo $id; ?> /></td>
    </tr>
      <tr>
        <td width="150" align="right" bgcolor="#FFFFFF">所属分类：</td>
        <td bgcolor="#FFFFFF"><select name="reid">
          <?php echo $sectorscache; ?>
        </select>        </td>
    </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF">分类名称：</td>
        <td bgcolor="#FFFFFF"><input type=text name=name value=<?php echo $sector['name']; ?> /></td>
    </tr>
      <tr>
        <td align="right" bgcolor="#FFFFFF">顺序：</td>
        <td bgcolor="#FFFFFF"><input type=text name=disorder value=<?php echo $sector['disorder']; ?> /></td>
    </tr>
      <tr>
        <td height="35" bgcolor="#FFFFFF">&nbsp;</td>
        <td bgcolor="#FFFFFF"><input name="submit4" type="submit" value="提交" class="inputbut"/></td>
    </tr>
    </table>

<br>
<br>
</form>
<?php
}elseif($action == 'delete')
{
?>
<form action=asktype.php method=post name=form5>
<table width="96%" border="0" cellpadding="1" cellspacing="1" align="center" class="tbtitle" style="	background:#E2F5BC;">
    <tr>
        <td height="20" bgcolor="#EDF9D5"><strong>&nbsp;删除分类确认</strong>
          <input type=hidden name=action value=delete />
          <input type=hidden name=step value=2 />
          <input type=hidden name=id value=<?php echo $id; ?> /></td>
    </tr>
      <tr>
        <td height="60" align="center" bgcolor="#FFFFFF"><span class="STYLE1">删除分类时将删除该行业的所有下级分类，且不能恢复操作，请确认删除！</span></td>
    </tr>
      <tr>
        <td height="35" align="center" bgcolor="#FFFFFF"><input name="submit5" type="submit" value="确认删除" class="inputbut"/>
        <input type='button' value='返 回 继 续 操 作' onclick='javascript:history.go(-1);' class="inputbut"></td>
    </tr>
    </table>

</form>

<?php
}
?>
</body>
</html>