<?php
echo ahead("网站帮助管理");
?>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tableBorder">
  <tr>
    <th height="25">网站帮助管理</th>
  </tr>
  <tr>
    <td height=25 class="pl20"><b>管理选项：</b><a href="?do=add">添加帮助信息</a> | <a href="other_help.php">帮助信息管理</a> | <a href="other_help.php?do=sort">帮助分类管理</a> | [<a href="javascript:location.reload()">刷新页面</a>]</td>
  </tr>
  </tr>
  <tr><form name="searchForm" action="?cid=<?php echo $cid;?>&cname=<?php echo $cname;?>" method="post">
    <td height=25 class="pl20"><b>操作选项：</b>搜索关键字：<input name="keywords" type="text" class="txt" value="<?php echo $keywords;?>">&nbsp;所属类别：<select name="sid" size="1">
<option value="" selected="selected">所有栏目</option>
<?php echo ahelpsort($sid);?>
</select> <input name="submit" type="submit" class="inputs" id=submit value="立刻查找"></td></form>
  </tr>
</table>
<?php
if($do=="sort"){
?>
<script language="javascript" type="text/javascript">
function setid(){
    strs1='';strs2='';strs3='';
	if(!window.listform.tcount.value){
		window.listform.tcount.value=1;
    }
    maxorder=window.listform.torder.value-1;
	for(i=1;i<=window.listform.tcount.value;i++){
        maxorder++;
		strs1+='<input maxlength="50" size="30" name="tname[]" class="txt" value="" /><br><br>';
        strs2+='<input maxlength="10" size="4" name="torder[]" class="txt" value="'+maxorder+'" /><br><br>';
	}
    window.upid1.innerHTML=strs1;
    window.upid2.innerHTML=strs2;
}
</script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder mt6">
<form name="listform" action="?do=savesort" method="post">
<tr>
    <th colspan=4 height=25>帮助分类列表</th>
</tr>
<tr align="center"> 
    <td width="40" height="22">编号</td>
    <td>分类名称</td>
    <td width="80">显示顺序</td>
    <td width="40">操作</td>
</tr>
<?php echo $syslist;?>
<tr>
    <th colspan=4 height=25>批量新增分类（新增<input type="text" name="tcount" size="4" onBlur="setid();" value="1" class="txt">项，不新增请不要填写以下内容。)</th>
</tr>
<tr align="center"> 
    <td width="40" height="22">新增<input type="hidden" name="torder" value="<?php echo $maxorder;?>" /></td>
    <td align="left" id="upid1"><input maxlength="50" size="30" name="tname[]" class="txt" value="" /></td>
    <td width="80" id="upid2"><input maxlength="10" size="4" name="torder[]" class="txt" value="<?php echo $maxorder;?>" /></td>
    <td>　</td>
</tr>
<tr>
    <td colspan=5 height=25 class="tdpage"><input name="submit" type="submit" class="inputs" value="批量修改添加"></td>
</tr>
</form>
</table>
<?php
}elseif($do=="add"||$do=="edit"){
?>
<script charset="utf-8" src="../freditor/kindeditor.js"></script>
<script>
	KE.show({id : 'content',width : "100%",height : "300px",resizeMode : 1,
		afterCreate : function(id) {
			KE.event.ctrl(document, 13, function() {
				KE.util.setData(id);
				document.forms['addform'].submit();
			});
			KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
				KE.util.setData(id);
				document.forms['addform'].submit();
			});
		}
	});
</script>
<script language="javascript" type="text/javascript">
function check()
{
	if(document.addform.title.value==""){
		alert("请输入帮助标题!");
		document.addform.title.focus();
		return (false);
	}
	if(document.addform.sid.value==""){
		alert("请选择帮助类别!");
		return (false);
	}
	if (document.addform.content.value=="") {   
        alert("请输入帮助内容！");   
        return false; 
	}   
}
</script>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder">
<form name="addform" action="?do=savedata" method="post" onSubmit="return check();">
<input type="hidden" name="hid" value="<?php echo $hid;?>">
<tr>
    <th colspan=2 height=25><?php if($hid!=''){echo '修改';}else{echo '添加';}?>帮助信息</th>
</tr>
<tr><td width="80" height="25" align="right">帮助标题：</td>
<td><input maxlength="100" size="50" name="title" class="txt" value="<?php echo $title;?>" /></td>
</tr>
<tr>
    <td height="25" align="right">帮助分类：</td>
    <td>
    <select name="sid" size="1">
    <option value="" selected="selected">请选择分类</option>
    <?php echo ahelpsort($sid);?>
    </select>
    </td>
</tr>
<tr>
    <td height="25" align="right">帮助内容：</td>
    <td><textarea name="content" cols="60" rows="10" class="txt"><?php echo $content;?></textarea></td>
</tr>
  <tr>
    <td align="right">责任编辑：</td>
    <td><input type="text" name="editor" value="<?php echo $editor;?>" /> <font color='blue'><=【<font color='green' onclick="document.addform.editor.value='<?php echo $admin_name;?>'" style="cursor:pointer;"><?php echo $admin_name;?></font>】</font></td>
  </tr>
<tr>
	<td height="25" align="center" colspan="2"><input name="Submit" type="submit" class="inputs" value="<?php if($hid!=''){echo ' 修改帮助 ';}else{echo ' 添加帮助 ';}?>"></td>
</tr>
</form>
</table>
<?php }else{ ?>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableBorder mt6">
<form name="form" action="?" method="post">
<tr>
    <th colspan=7 height=25><?php echo $cname;?>列表</th>
</tr>
<tr align="center"> 
    <td width="5%" height="22">编号</td>
    <td width="50%">标题</td> 
    <td width="14%">所属栏目</td>
    <td width="20%">发布日期</td>
    <td width="6%">操作</td>
    <td width="5%"><input name="checkSelect" type="checkbox" class="checkbox" onClick="javascript: checkAll(this)" value="checkbox"></td>
</tr>
<?php
foreach($rsdb as $key=>$rs){
?>
<tr align="center"> 
    <td height=25><?php echo $rs["h_id"];?></td>
    <td align="left"><a href="?do=edit&hid=<?php echo $rs["h_id"];?>"><?php echo $rs["h_title"];?></a></td>
    <td><a href="?sid=<?php echo $rs["s_id"];?>"><?php echo $rs["s_name"];?></a></td>
    <td><?php echo $rs["h_addtime"];?></td>
    <td><a href="?do=edit&hid=<?php echo $rs["h_id"];?>"><img src="images/white_edit.png" alt="编辑" width="16" height="16" border="0" align="absmiddle"></a> <a href="?do=del&hids=<?php echo $rs["h_id"];?>"><img src="images/white_delete.png" alt="删除" width="16" height="16" border="0" align="absmiddle"></a></td>
    <td><input type="checkbox" name="hid" value="<?php echo $rs["h_id"]; ?>" class="checkbox" /></td>
</tr>
<?php 
}
?>
<tr><td height="25" align="right" colspan="8"> <input type="hidden" name="hids" value="">
      <input name="button" type="button" class="inputs" onClick="confirmX(1);" value=" 删除 "></td></tr>
<tr>
<td height="25" align="center" colspan="8" class="tdpage"><?php echo $getpageinfo['pagecode'];?></td></tr>
</form>
</table>
<?php } ?>
<?php
echo acopy();
?>
<script language="javascript">
function confirmX(num)
{
	var ids = document.getElementsByName("hid");
	var check=false;
	var allSel="";
	if (ids != null) {
		for (i=0; i<ids.length; i++) 
		{
			var obj = ids[i];
			if (obj.checked==true)
			{
				if(allSel==""){
				allSel=obj.value;
				}else{
				allSel=allSel+","+obj.value;
				}
				form.hids.value = allSel;
				check=true;
				
			}
		}
		if(check==false){alert("请选择操作对象！");return false;}
	}
	if(num==1)
	{
		document.form.action="?do=del";
		document.form.submit();
	}
	return false;	
}
function checkAll(box1) {
    var ids = document.getElementsByName("hid");
	if (ids != null) {
		for (i=0; i<ids.length; i++) {
			var obj = ids[i];
			obj.checked = box1.checked;
		}
	}
}
</script>