<%@ Page Language="vb" AutoEventWireup="false" Codebehind="AdminFileManager.aspx.vb" Inherits="AllSaints.AdminFileManager" %>
<%@ Register TagPrefix="uc1" TagName="TopPage" Src="../admins/TopPage.ascx" %>
<%@ Register TagPrefix="uc1" TagName="LeftPage" Src="LeftPage.ascx" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>File Management</title>
		<META content="text/html; charset=windows-1250" http-equiv="Content-Type">
		<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
		<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
		<LINK href="css/default.css" type="text/css" rel="STYLESHEET">
		<script language="javascript">
		function ShowAndSelect(id)
		{
			var sp = document.getElementById(id);
			sp.style.display = (sp.style.display == "inline")?"none":"inline";
		}
		function ShowHideSpan(id, bttn)
		{
			bttn.src = (bttn.src.toString().indexOf("images/folder-closed.gif")>-1)?"../images/folder-opened.gif":"../images/folder-closed.gif";
			var sp = document.getElementById(id);
			sp.style.display = (sp.style.display == "inline")?"none":"inline";
		}
		</script>
	</HEAD>
	<body>
		<form id="Form1" method="post" encType="multipart/form-data" runat="server">
			<TABLE id="Table1" cellSpacing="0" cellPadding="0" width="100%" bgColor="white" border="0">
				<tr>
					<td bgColor="white" colspan="2"><uc1:toppage id="Toppage1" runat="server"></uc1:toppage></td>
				</tr>
				<tr>
					<td style="width:210px; padding-left:10px; padding-bottom:10px;" valign="top" bgcolor="#ffffff" align="left">
						<table cellpadding="0" cellspacing="0" width="100%">
							<tr>
								<td valign="top" class="LeftLinksTd">
									<uc1:leftpage id="Toppage2" runat="server"></uc1:leftpage>
								</td>
							</tr>
						</table>
					</td>
					<td style="width:100%; padding:10px;" valign=top bgcolor="#ffffff">
						<table cellpadding="0" cellspacing="0" align=left width="100%">
							<tr>
								<td align="center">
									<label runat="server" id="ErrorLbl" style="COLOR:#ff0000;FONT-FAMILY:Verdana;"></label>
								</td>
							</tr>
							<tr>
								<td>
									<table cellspacing="0" cellpadding="0" align="center" rules="rows" bordercolor="#c1be84"
										border="1" style="BORDER-BOTTOM:#c1be84 1px; BORDER-LEFT:#c1be84 1px; BACKGROUND-COLOR:white; WIDTH:52%; BORDER-COLLAPSE:collapse; FONT-FAMILY:Verdana; COLOR:black; FONT-SIZE:11px; BORDER-TOP:#c1be84 1px; BORDER-RIGHT:#c1be84 1px">
										<tr>
											<td style="PADDING-LEFT:2px;WIDTH:85px">
												<Label><font color="red">*</font>Folder Name:</Label>
											</td>
											<td style="WIDTH:150px">
												<asp:TextBox Runat="server" ID="FolderNameTB" Width="148px"></asp:TextBox>
											</td>
											<td style="PADDING-LEFT:2px;WIDTH:80px">
												<Label>Description:</Label>
											</td>
											<td style="WIDTH:200px">
												<asp:TextBox Runat="server" ID="FolderDescTB" Width="197px"></asp:TextBox>
											</td>
											<td style="WIDTH:85px">
												<asp:Button ID="NewFolderBtn" Runat="server" Text="Create Folder" CausesValidation="False"></asp:Button>
											</td>
										</tr>
									</table>
								</td>
							</tr>
							<tr>
								<td>
									<table cellspacing="0" cellpadding="0" align="Center" rules="rows" bordercolor="#DEDFDE" border="1" id="DG_Assignments" style="color:Black;background-color:White;border-color:#DEDFDE;border-width:1px;border-style:None;font-family:Verdana;font-size:10px;width:98%;border-collapse:collapse;">
										<tr class="menustrip" style="color:White;font-weight:bold;">
											<td width="2%">&nbsp;</td>
											<td width="3%">&nbsp;</td>
											<td width="26%">Name</td>
											<td width="45%">Description</td>
											<td width="12%">Documents</td>
											<td width="12%">Action</td>
										</tr>
										<% Dim i as int32 = 1
										While resultDirs.Read()
										%>
										<tr class="incell" style="background-color:White;">
											<td>&nbsp;</td>
											<td><img src='../images/folder-closed.gif' id="bttn_common" onClick="ShowHideSpan('dir_<%= resultDirs.Item("id")%>', this);return false;"></td>
											<td><%= resultDirs.Item("name")%></td>
											<td><%= resultDirs.Item("description")%></td>
											<td><%= getFileCount(resultDirs.Item("id"))%></td>
											<td><a href="#" onclick="ShowAndSelect('upload_table_id')">Add Files</a></td>
										</tr>
										<tr class="incell" style="display:none;" id="dir_<%= resultDirs.Item("id")%>">
											<td colspan="6"><table cellspacing="0" cellpadding="0" align="Center" rules="rows" bordercolor="#DEDFDE" border="1" id="DG_Assignments" style="color:Black;width:100%;border-color:#DEDFDE;border-width:1px;border-style:None;font-family:Verdana;font-size:10px;border-collapse:collapse;">
												<% getFiles(resultDirs.Item("id")) %>
												<tr>
													<td width="4%">&nbsp;</td>
													<td width="5%"><b>#</b></td>
													<td width="10%"><b>Date</b></td>
													<td width="60%"><b>Display Name</b></td>
													<td width="21%"><b>Action</b></td>
												</tr>
												<%
												If Not resultFiles is Nothing
													while resultFiles.read()
														Dim arr As String() = Request.Url.AbsoluteUri.Replace("/Admins",",").Split((New Char() {","}))
														Dim URL As String = arr(0) & "/contents/teachers/" & CType(resultFiles.Item("classid"),String) & "/" & CType(resultDirs.Item("id"),String) & "/"
												%>
												<tr>
													<td>&nbsp;</td>
													<td><%= i%></td>
													<td><%= String.Format("{0:d}", resultFiles.item("insertdate"))%></td>
													<td><%= resultFiles.item("filename")%></td>
													<td>
														<a href="AdminFileManager.aspx?del_file=<%= resultFiles.item("id")%>" onclick="return confirm('Are you sure.')">Delete</a>&nbsp;|&nbsp;
														<a href="AdminFileManager.aspx?down_file=<%= resultFiles.item("id")%>">Download</a>&nbsp;|&nbsp;
														<a href="#" onclick="alert('Successfully copied to Clipboard'); window.clipboardData.setData('Text','<%= URL & resultFiles.item("actualname")%>')">Copy URL</a>
													</td>
												</tr>
												<%
														i = i+1
													End while
												End If
												if i = 1 then
												%>
												<tr>
													<td>&nbsp;</td>
													<td colspan="4">No File Found.</td>
												</tr>
												<%
												end if
												i=1
												%>
											</table></td>
										</tr>
										<%
										End While
										%>
									</table>
								</td>
							</tr>
						</TABLE>
						
					</td>
				</tr>
			</TABLE>
            <TABLE id="upload_table_id" cellSpacing="0" cellPadding="0" width="100%" bgColor="white"
							border="0" style="DISPLAY:none">
                <TR>
                    <TD>&nbsp;</TD>
                </TR>
                <tr>
                    <td>
                        <table cellspacing="0" cellpadding="0" align="center" style="BACKGROUND-COLOR:white; WIDTH:37%; FONT-FAMILY:Verdana; COLOR:black; FONT-SIZE:10px">
                            <tr>
                                <td width="30%"><b>Upload to folder:</b><font color="red">*</font></td>
                                <td><asp:ListBox Runat="server" Rows="1" ID="dirid">
                                        <asp:ListItem Value="">Select Destination Folder</asp:ListItem>
                                    </asp:ListBox></td>
                                <td><asp:RequiredFieldValidator Runat="server" ControlToValidate="dirid" ErrorMessage="Required" Display="Dynamic"
                                        ID="Requiredfieldvalidator1" NAME="Requiredfieldvalidator1"></asp:RequiredFieldValidator></td>
                            </tr>
                        </table>
                        <table cellspacing="0" cellpadding="0" align="center" rules="rows" bordercolor="#dedfde"
                            border="1" style="BORDER-BOTTOM:#dedfde 1px; BORDER-LEFT:#dedfde 1px; BACKGROUND-COLOR:white; WIDTH:37%; BORDER-COLLAPSE:collapse; FONT-FAMILY:Verdana; COLOR:black; FONT-SIZE:10px; BORDER-TOP:#dedfde 1px; BORDER-RIGHT:#dedfde 1px">
                            <tr class="menustrip" style="COLOR:white;FONT-WEIGHT:bold">
                                <td width="18%">Display Name</td>
                                <td width="25%">&nbsp;Select File</td>
                            </tr>
                            <tr class="incell" style="BACKGROUND-COLOR:white">
                                <td><asp:TextBox id="display_name1" runat="server" Columns="30" Wrap="False" EnableViewState="False"></asp:TextBox></td>
                                <td>&nbsp;<input id="uploadedFile1" type="file" runat="server" NAME="uploadedFile"></td>
                            </tr>
                            <tr class="incell" style="BACKGROUND-COLOR:white">
                                <td><asp:TextBox id="display_name2" runat="server" Columns="30" Wrap="False" EnableViewState="False"></asp:TextBox></td>
                                <td>&nbsp;<input id="uploadedFile2" type="file" runat="server" NAME="uploadedFile"></td>
                            </tr>
                            <tr class="incell" style="BACKGROUND-COLOR:white">
                                <td><asp:TextBox id="display_name3" runat="server" Columns="30" Wrap="False" EnableViewState="False"></asp:TextBox></td>
                                <td>&nbsp;<input id="uploadedFile3" type="file" runat="server" NAME="uploadedFile"></td>
                            </tr>
                            <tr class="incell" style="BACKGROUND-COLOR:white">
                                <td><asp:TextBox id="display_name4" runat="server" Columns="30" Wrap="False" EnableViewState="False"></asp:TextBox></td>
                                <td>&nbsp;<input id="uploadedFile4" type="file" runat="server" NAME="uploadedFile"></td>
                            </tr>
                            <tr class="incell" style="BACKGROUND-COLOR:white">
                                <td><asp:TextBox id="display_name5" runat="server" Columns="30" Wrap="False" EnableViewState="False"></asp:TextBox></td>
                                <td>&nbsp;<input id="uploadedFile5" type="file" runat="server" NAME="uploadedFile"></td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <asp:Button id="upload_files" runat="server" Text="Upload Files"></asp:Button></td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
		</form>
	</body>
</HTML>
