<%@ Page CodeBehind="allshare.aspx.cs" Language="c#" AutoEventWireup="True" Inherits="Webdisk.allshare" %>
    <%@ import namespace="Webdisk" %>
    <%@ Import Namespace="Global" %>
    <link href="<%=xml.GetStyle()%>" type="text/css" rel="Stylesheet"/>
    <style type="text/css">
        .STYLE1
        {
            color: #0000ff;
        }
    </style>
    <form id="Form1" method="post" runat="server">
    <div class="menuBlock">
       <div class="menuHead" style="overflow:hidden;border-bottom: 1px dashed #cfcfcf;">
			<a id="getSearch" class="floatR" onclick="getSearch();" href="javascript:void(0);">↓高级查找↓</a>
			<h2 style="font-size: 18px;color: #1EA7DF;"><img src="pics/menu_file_cut.gif" align="absMiddle"> 共享给我的文件</h2>
		</div>
		<div  id="search" class="clear search-con" style="DISPLAY: none;">
			<table class="form-table" style="margin:0;width:100%;">
				<tr>
					<td class="label" style="width: 60px;">文件名：</td>
					<td colspan="3">
						<input name="key" class="input3" id="key" style="width: 250px;" >
						（可模糊输入，不填为不限，多个关键字用半角空格分隔）
						 <input class="but1 floatR" id="submit2" type="button" value=" 查 找 " name="submit22" />
					</td>
				</tr>
				<tr>
					<td  class="label">
							用户名：
					</td>
					<td colspan="3">
						<input name="user" class="input3" id="user" style="width: 250px;" >
						（精确输入，不填为不限）
					</td>
				</tr>
				<tr>
					<td class="label">
							文件类型：
					</td>
					<td colspan="3">
						<input name="txttype" class="input3"  style="width: 250px;" id="txttype" />（输入扩展名，用半角,分隔，不填为不限）
					</td>
				</tr>
				<tr>
					<td class="label">
							文件注释：
					</td>
					<td colspan="3">
						<input name="txtnote" class="input3"  style="width: 250px;" id="txtnote" >（不填为不限）
					</td>
				</tr>
				<tr>
					<td class="label"> 更新时间：
					</td>
					<td >
						<input name="txttime1" id="txttime1" style="width: 80px;"  class="input3 dateinput"/>
						－
						<input name="txttime2" id="txttime2" style="width: 80px;"  class="input3 dateinput"/>（不填为不限）
					</td>
					<td class="label" style="width:80px;">
							文件大小：
					</td>
					<td >
						<input name="txtsize1" class="input3"  style="width: 60px;" id="txtsize1" >
						KB－
						<input name="txtsize2" class="input3" style="width: 60px;" id="txtsize2" >
						KB（不填为不限）
					</td>
				</tr>
				<tr>
					<td class="label">
							签收时间：
					</td>
					<td >
						<input name="qstime1" id="qstime1" style="width: 80px;" class="input3 dateinput" />
						－
						<input name="qstime2" id="qstime2" style="width: 80px;" class="input3 dateinput"/>
						（不填为不限）
					</td>
					<td class="label">
							签收状态：
					</td>
					<td>
						<select name="isqs" class="input4"  id="isqs">
							<option value="" selected>全部</option>
							<option value="1">已签收</option>
							<option value="0">未签收</option>
						</select>
					</td>
				</tr>
				<tr>
					<td class="label">
						所属学校：
					</td>
					<td>
						<select name="school"  class="input4" id="school" runat="server" >
							<option value="" Selected>全部学校</option>
						</select>
					</td>
					<td class="label">
							所属部门：
					</td>
					<td>
						<select name="dept" class="input4"  id="dept" runat="server" >
							<option value="" Selected>全部部门</option>
						</select>
					</td>
				</tr>
            </table>
		</div>
		<div class="clear" style="margin:10px;">
			<div class="mListT">
				<span class="l8">
					<a id="fileExt"  data-sort = "desc" data-type="fileExt" href="javascript:void(0);">类型
						<img class="sortImg" src="images/up01.gif" style="display:none"/></a>
				</span>
				<span class="l5">
					<a id="fileName"  data-sort = "desc" data-type="fileName" href="javascript:void(0);">文件名
						<img class="sortImg" src="images/up01.gif" style="display:none"/></a>
				</span>
				<span class="l6">
					<a id="userName"  data-sort = "desc" data-type="userName" href="javascript:void(0);">所属用户
						<img class="sortImg" src="images/up01.gif" style="display:none"/></a>
				</span>
				<span class="l6">
					<a id="fileSize" data-sort = "desc" data-type="fileSize" href="javascript:void(0);">大小
						<img class="sortImg" src="images/up01.gif" style="display:none"/></a>
				</span>
				<span class="l3">
					<a id="lastTime" data-sort = "asc" data-type="lastTime" href="javascript:void(0);">更新时间
						<img class="sortImg" src="images/down01.gif"/>
					</a>
				</span>
				<%--<span class="l6">查看目录</span>--%>
			</div>
			<div id="content" style="">
						</div>
			<div class="pageList" id="page"> 
			</div> 
			<input id="type" type="hidden" runat="server" value="lastTime"/>
			<input id="asc" type="hidden" runat="server" value="desc"/>
	        <input type="hidden" id="hiddenUser" value ='<%=Session["username"]==null?"":Session["username"].ToString() %>'/>
		</div> 
    </div>
    </form>
    <script type="text/javascript">
		$.datepick.setDefaults({prevText:"上月",todayText :"今天",clearText:"清除",nextText:"下月",closeText:"关闭",dateFormat :"yyyy-mm-dd",dayNamesMin :["日","一","二","三","四","五","六"],
		monthNames:["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"]});
		$('.dateinput').datepick();
var Allshare = {};
Allshare.iframeDialog = null;
Allshare.init = function(){
	this.addEvent();
	this.page();
}
Allshare.addEvent = function(){
	var that = this ;
	//排序
	$("#fileExt").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	$("#fileName").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	$("#userName").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	$("#fileSize").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	$("#lastTime").click(function(){
		var tag = $(this);
		var sort = tag.data("sort");
		tag.data("sort",sort == "asc" ? "desc" : "asc");
		$("#asc").val(sort);
		$("#type").val(tag.data("type"));
		$(".sortImg").hide();
		tag.find(".sortImg").show().attr("src",sort == "asc" ? "images/up01.gif":"images/down01.gif");
		that.page();
	});
	//级联学校
	$("#school").change(function () {
		var school = $("#school").val();
		$.ajax({
			type: "post",
			url: "FileSpaceHandler.ashx?cmd=getClassBySchoolId",
			data:{ "schoolId" :school},
			cache:false,
			error: function () { alert("服务器异常！") },
			dataType : "json",
			success: function (data) {
				var _dept = $("#dept").empty()[0] ;
				_dept.options[0] = new Option("全部部门",0);
				for(var index = 0 ;index<data.length ; index ++ ){
					_dept.options[index +1 ] = new Option(data[index].kname,data[index].id)
				}
			}
		});
	});
	$("#submit2").click(function(){
		that.search();
	});
}
Allshare.addListEvent = function(){
	var that = this ;
	$("#dsUl .showPath").bind("click",function(){
			getHtml($(this).data("href"));
		});
	$("#dsUl .getUser").click(function(){
		that.dialogShow($(this).data("href"),"查看用户信息");
	});
}
Allshare.page = function (currentPage) {
	var that = this ;
	var type = $("#type").val();
	var asc = $("#asc").val();
	currentPage = currentPage ? currentPage : 0;
	function ajax(page, callback) {
		//var d = dialog();
		$.ajax({
			url: "allShareList.aspx",
			data: { pageindex: page, type: type, asc: asc},
			dataType : "html",
			cache:false,
			type : "POST",
			beforeSend: function () {
			//	d.showModal();
			},
			success: function (data) {
			//	d.close().remove();
				$("#content").empty().append(data);
				that.addListEvent();
				typeof callback == "function" && callback(data);
			}
		});
	}
	ajax(currentPage, function (data) {
		var maxlength = parseInt($("#H_itemtCount").val());
		$("#page").pagination(maxlength, {
			prev_text: '< 上一页',
			next_text: '下一页 >',
			items_per_page: parseInt($("#H_pageSize").val()),
			num_display_entries: <%=Session["username"] == null ? 10 : Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %>,
			current_page: 0,
			num_edge_entries: 2,
			link_to: "javascript:void(0);",
			callback: function (page_id, panel) {
				var self = this;
				ajax(page_id, function (vdata) {
					self.maxentries = parseInt($("#H_itemtCount").val());
				});
			}
		});
	});
};
Allshare.search = function (currentPage) {
	var that = this ;
	var type = $("#type").val();
	var asc = $("#asc").val();
	currentPage = currentPage ? currentPage : 0;
	var str = "",  friend = "", key = "", user = "", txttime1 = "", txttime2 = "", txtsize1 = "", txtsize2 = "", txttype = "", txtnote = "", qstime1 = "", qstime2 = "", isqs = "", company = "", dept = "";
	
	key = encodeURI($.trim($("#key").val()));
	user =encodeURI($("#user").val());
	txttime1 = encodeURI($.trim($("#txttime1").val()));
	txttime2 = encodeURI($.trim($("#txttime2").val()));
	txtsize1 = encodeURI($.trim($("#txtsize1").val()));
	txtsize2 = encodeURI($.trim($("#txtsize2").val()));
	txttype = encodeURI($.trim($("#txttype").val()));
	txtnote = encodeURI($.trim($("#txtnote").val()));
	qstime1 = encodeURI($.trim($("#qstime1").val()));
	qstime2 = encodeURI($.trim($("#qstime2").val()));
	isqs = $.trim($("#isqs").val());
	company = $("#school").val() != "0" ?  $("#school").val() : "" ;
	dept = $("#dept").val()!= "0" ?  $("#dept").val() : "" ;
		var d = dialog();
	function ajax(page, callback) {
		$.ajax({
			url: "allShareList.aspx",
			data: { pageindex: page,  key: key, type: type, asc: asc, txttime1: txttime1, txttime2: txttime2, txtsize1: txtsize1, txtsize2: txtsize2, txttype: txttype, txtnote: txtnote, qstime1: qstime1, qstime2: qstime2, isqs: isqs, company: company, dept: dept, user: user },
			dataType : "html",
			type : "POST",
			cache:false,
			beforeSend: function () {
				d.showModal();
			},
			success: function (data) {
				d.close().remove();
				$("#content").empty().append(data);
				that.addListEvent();
				typeof callback == "function" && callback(data);
			}
		});
	}
	ajax(currentPage, function (data) {
		var maxlength = parseInt($("#H_itemtCount").val());
		$("#page").pagination(maxlength, {
			prev_text: '< 上一页',
			next_text: '下一页 >',
			items_per_page:parseInt($("#H_pageSize").val()),
			num_display_entries: <%=Session["username"] == null ? 10 : Convert.ToInt32(Common.GetListCount(Session["username"].ToString())) %>,
			current_page: 0,
			num_edge_entries: 2,
			link_to: "javascript:void(0);",
			callback: function (page_id, panel) {
				var self = this;
				ajax(page_id, function (vdata) {
					self.maxentries = parseInt($("#H_itemtCount").val());
				});
			}
		});
	});
	
}
Allshare.dialogShow = function(href,title){
	var that = this ;
	var d = this.iframeDialog = dialog({
		content: "<iframe src='" +href + "' style='border:none;width:500px;height:350px;'></iframe>",
		title: title
	});
	d.showModal();
}
/***
**刷新窗口 
***/
Allshare.refreshDialog = function(href ,title){
	this.iframeDialog.content( "<iframe src='" +href + "' style='border:none;width:500px;height:350px;'></iframe>");
	this.iframeDialog.title(title );
}
/**
*关闭模态窗口
*/
Allshare.closeWindow = function(flag){
	if(this.iframeDialog){
		this.iframeDialog.close().remove();
		this.iframeDialog = null ;
	}
} 
var refreshWindow = function(href,title){
	Allshare.refreshDialog(href ,title);
}
var closeWindow = function(flag){
	Allshare.closeWindow(flag);
}
Allshare.init();
function getSearch(){
	var tag = $('#search');
	var bTag = $("#getSearch");
	if(bTag.text() == "↓高级查找↓"){
		bTag.text("↑高级查找↑");
		tag.slideDown(500);
	}else{
		bTag.text("↓高级查找↓");
		tag.slideUp(500);
	}
}
        
    </script>
