<!--#include file="admin_conn.asp"-->
<%
chkLogin
dim action : action = be("get","action")
session("upfolder") = "../upload/vodtopic"

select case action
	case "editall" : editall
	case else : headAdmin "视频专题管理" : main
end select
dispseObj()

sub editall
	dim ids,id,t_name,t_sort,t_enname,t_template,t_pic
	ids = split(replace(be("post","t_id")," ",""),",")
	For Each id In ids
		t_name = be("post","t_name" &id)
		t_sort = be("post","t_sort" &id) 
		t_enname = be("post","t_enname" &id)
		t_template = be("post","t_template" &id)
		t_pic = be("post","t_pic" &id)
		if isN(t_name)  then   writeE "信息填写不完整!"
		if isN(t_enname)  then   writeE "信息填写不完整!"
		if isN(t_sort) then  t_sort= objdb.DB("select max(t_sort) from {pre}vod_topic","rs1")(0)+1
		if not isNum(t_sort) then writeE "信息填写不完整!"
		objdb.Update "{pre}vod_topic",Array("t_name", "t_enname","t_template","t_sort","t_pic"),Array(t_name,t_enname,t_template,t_sort,t_pic),"t_id="&id
	Next
	updateCacheFile
	writeA "修改完毕"
end sub

sub main
	Dim pagenum : pagenum = be("all","page")
	if isN(pagenum) or not isNum(pagenum) then pagenum = 1
	if pagenum < 1 then pagenum = 1
	pagenum = clng(pagenum)
	Dim sql : sql = "SELECT * FROM {pre}vod_topic ORDER BY t_sort,t_id Asc"
	Dim rs : Set rs = objdb.DB(sql,"rs1")
%>
<script language="javascript">
$(document).ready(function(){
	$("#form2").validate({
		rules:{
			t_name:{
				required:true,
				stringCheck:true,
				maxlength:64
			},
			t_enname:{
				required:true,
				stringCheck:true,
				maxlength:128
			},
			t_template:{
				required:true,
				maxlength:128
			},
			t_pic:{
				maxlength:254
			},
			t_sort:{
				number:true
			},
			t_des:{
				required:true,
				maxlength:254
			}
		}
	});
	$('#form1').form({
		onSubmit:function(){
			if(!$("#form1").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info',function(){
	        	location.href=location.href;
	        });
	    }
	});
	$('#form2').form({
		onSubmit:function(){
			if(!$("#form2").valid()) {return false;}
		},
	    success:function(data){
	        $.messager.alert('系统提示', data, 'info');
	    }
	});
	$("#btnDel").click(function(){
			if(confirm('确定要删除吗')){
				$("#form1").attr("action","admin_ajax.asp?action=del&flag=batch&tab={pre}vod_topic");
				$("#form1").submit();
			}
			else{return false}
	});
	$("#btnEdit").click(function(){
		$("#form1").attr("action","?action=editall");
		$("#form1").submit();
	});
	$("#btnAdd").click(function(){
		$('#form2').form('clear');
		$("#flag").val("add");
		$('#win1').window('open');
	});
	$("#btnCancel").click(function(){
		location.href= location.href;
	});
});
function edit(id)
{
	$('#form2').form('clear');
	$("#flag").val("edit");
	$('#win1').window('open');
	$('#form2').form('load','admin_ajax.asp?action=getinfo&tab={pre}vod_topic&col=t_id&val='+id);
}
</script>
<table class="tb">
<form action="" method="post" id="form1" name="form1">
	<tr>
	<td width="5%">&nbsp;</td>
	<td width="10%">编号</td>
	<td>名称</td>
	<td>别称</td>
	<td width="15%">模板</td>
	<td width="15%">图片</td>
	<td width="5%">排序</td>
	<td width="10%">操作</td>
	</tr>
	<%
		if rs.eof then
	%>
    <tr><td align="center" colspan="7">没有任何记录!</td></tr>
    <%
		else
			Dim i
			rs.PageSize = app_pagenum
	   		rs.AbsolutePage = pagenum
	  		for i = 1 to rs.PageSize
	  		if rs.eof then exit for
	%>
    <tr>
	  <td>
	  <input name="t_id" type="checkbox" id="t_id" value="<%=rs("t_id")%>" /></td>
      <td>
      <%=rs("t_id")%></td>
      <td>
      <input type="text" name="t_name<%=rs("t_id")%>" value="<%=rs("t_name")%>" size="20"/></td>
	  <td>
	  <input type="text" name="t_enname<%=rs("t_id")%>" value="<%=rs("t_enname")%>" size="20"/></td>
	  <td>
	  <input type="text" name="t_template<%=rs("t_id")%>" value="<%=rs("t_template")%>" size="20"/></td>
      <td>
      <input type="text" name="t_pic<%=rs("t_id")%>" value="<%=rs("t_pic")%>" size="20"/></td>
	  <td>
	  <input name="t_sort<%=rs("t_id")%>" type="text" value="<%=rs("t_sort")%>"  size="5"/></td>
      <td>
	  <a href="javascript:void(0)" onclick="edit('<%=rs("t_id")%>');return false;">修改</a> |
	  <a href="admin_ajax.asp?action=del&tab={pre}vod_topic&t_id=<%=rs("t_id")%>" onClick="return confirm('确定要删除吗?');">删除</a></td>
    </tr>
	<%
				rs.MoveNext
			next
	end if
	%>
	<tr>
	<td  colspan="8">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onClick="checkAll(this.checked,'t_id')" />
	<input type="button" value="批量删除" id="btnDel" class="input"  />
	&nbsp;<input type="button" value="批量修改" id="btnEdit" class="input" />
	&nbsp;<input type="button" value="添加" id="btnAdd" class="input" />
	</td></tr>
    <tr align="center" >
	<td colspan="8">
	<%=pagelist_manage(rs.PageCount,pagenum,rs.RecordCount,app_pagenum,"admin_vod_topic.asp?page={p}")%>
	</td>
    </tr>
</table>
</form>

<div id="win1" class="easyui-window" title="窗口" style="padding:5px;width:500px;" closed="true" closable="false" minimizable="false" maximizable="false">
<form action="admin_ajax.asp?action=save&tab={pre}vod_topic" method="post" name="form2" id="form2">
<table class="tb">
	<input id="t_id" name="t_id" type="hidden" value="">
	<input id="flag" name="flag" type="hidden" value="">
	<tr>
	<td width="20%">专题名称：</td>
	<td><input id="t_name" size=50 value="" name="t_name">
	</td>
	</tr>
	<tr>
	<td>专题别名：</td>
	<td><input id="t_enname" size=50 value="" name="t_enname" >
	</td>
    </tr>
	<tr>
	<td>模版文件：</td>
	<td><input id="t_template" size=50 value="" name="t_template" >
	</td>
	</tr>
	<tr>
     <td>专题图片：</td>
      <td><input id="t_pic" size=50 value="" name="t_pic" ><br>&nbsp;<iframe src="editor/uploadshow.asp?action=vod&id=t_pic" scrolling="no" topmargin="0" width="320" height="24" marginwidth="0" marginheight="0" frameborder="0" align="center"></iframe>
	  </td>
    </tr>
	<tr>
     <td>排序：</td>
      <td><input id="t_sort" size=10 value="" name="t_sort" >
	  </td>
    </tr>
	<tr>
     <td>描述信息：</td>
      <td>
      <TEXTAREA id="t_des" NAME="t_des" ROWS="8" style="width:300px;table-layout:fixed; word-wrap:break-word;"></TEXTAREA>
	  </td>
    </tr>
    <tr align="center" >
      <td colspan="2"><input class="input" type="submit" value="保存" id="btnSave"> <input class="input" type="button" value="返回" id="btnCancel"></td>
    </tr>
</table>
</form>
</div>
</body>
</html>
<%
objdb.C(rs)
end sub
%>