<%@ Page Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	<%: Html.Language("HostManagement") %>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
	<div class="easyui-layout" data-options="fit:true">
		<div title="<%: Html.Language("HostManagement") %>" style="border-right:1px solid #95B8E7;" data-options="region:'center',border:false">
			<table id="dg" class="easyui-datagrid" style="width:100%; height:auto;"
				data-options="
						toolbar: '#tbHost',
						border: false,
						singleSelect: false,
						pagination: true,
						pageSize: 20,
						rownumbers: true,
						sortName: 'HostNumber',
						sortOrder: 'asc',
						fit: true,
						fitColumns: true,
						striped: true,
						idField: 'ID',
						frozenColumns: [[
							{ field: 'ID', checkbox: true }
						]],
						url: '/Host/LoadAllByPage/',
						method: 'post',
						onDblClickRow: function(index, row) { edit(row); }
					">
				<thead>
					<tr>
						<th data-options="field:'HostNumber',sortable:true,align:'center'">
							<%: Html.Language("ID")%>
						</th>
						<th data-options="field:'RoomNumber',sortable:true,align:'center'">
								<%: Html.Language("RoomNumber") %>
						</th>
						<th data-options="field:'IP',sortable:true">
								<%: Html.Language("IP")%>
						</th>
						<th data-options="field:'MAC',sortable:true">
							<%: Html.Language("MAC")%>
						</th>
						<th data-options="field:'GroupName',sortable:true">
									<%: Html.Language("Group") %>
						</th>
						<th data-options="field:'RoomType',sortable:true">
									<%: Html.Language("RoomType") %>
						</th>
						<th data-options="field:'Version',sortable:true">
							<%: Html.Language("Version") %>
						</th>
						<th data-options="field:'RegisterDate',sortable:true,formatter:$.tools.formatDateTime">
						<%: Html.Language("RegistrationDate")%>
						</th>
						<th data-options="field:'Remark',width:100">
							<%: Html.Language("Remark") %>
						</th>
					</tr>
				</thead>
			</table>
		</div>
		<div title="	<%: Html.Language("Group") %>" style="width:200px;border-left:1px solid #95B8E7;" data-options="region:'east',split:true,border:false">
			<table id="groupTree" class="easyui-treegrid"
				data-options="
					toolbar: '#tbGroup',
					url: '/Group/LoadGroupTree/',
					method: 'post',
					idField: 'ID',
					treeField: 'Name',
					fit: true,
					fitColumns: true,
					animate: true,
					border: false,
					bodyCls: 'easyui-treegrid-no-icon',
					loadMsg: lang.LoadingData,
					onSelect: groupTreeOnSelect
				">
				<thead>
					<tr>
						<th data-options="field:'Name',width:160"><%: Html.Language("Name") %></th>
						<th data-options="field:'Sort',align:'center',width:40"><%: Html.Language("Sort")%>></th>
					</tr>
				</thead>
			</table>
		</div> 
	</div>
	
	<div id="tbHost">
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="$('#dg').datagrid('reload');"><%: Html.Language("Refresh")%></a> 
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="hostSearcher.open()"><%: Html.Language("Search")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="add()"><%: Html.Language("New")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="edit()"><%: Html.Language("Edit")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="delHost()"><%: Html.Language("Delete")%></a>
        
		<a href="/Host/ExportExcel/" class="easyui-linkbutton" data-options="iconCls:'icon-export',plain:true" target="_blank"><%: Html.Language("Export")%></a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-networksetting',plain:true" onclick="networkSetting()"><%: Html.Language("NetworkSettings")%></a>

        <% if ((bool)ViewData["EnableDataUpgrade"]) { %>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-upgrade',plain:true" onclick="updateHost()"><%: Html.Language("DataUpgrade")%></a>
        	<% } %>		
	
	</div>

	<div id="editHost" class="easyui-window"   title="<%: Html.Language("NewHost") %>" style="width:600px; height:400px;" 
		data-options="
			closed: true,
			modal: true,
			collapsible: false,
			minimizable: false,
			maximizable: false
		">
		<table id="dgSearchHost"></table>
		<div id="editHostToolbar">
			<a id="searchHost" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="hostSearcher.start()"><%: Html.Language("SearchHost")%></a>
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="registerHost()"><%: Html.Language("Registered")%></a>
		</div>
	</div>

	<div id="updateHost" title='<%: Html.Language("HostUpgrade")%>' class="easyui-window"   style="width:700px;height:400px;"
		data-options="
				closed: true,
				modal: true,
				collapsible: false,
				minimizable: false,
				maximizable: false
			"> 
		<div class="easyui-layout" fit="true">
			<div style="border-right:1px solid #95B8E7;" data-options="region:'center',border:false">
				<table id="dgUpdateHost" class="easyui-datagrid" style="width:100%; height:auto;"
					data-options="
							toolbar: '#tbUpdateHost',
							border: false,
							singleSelect: false,
							pagination: true,
							pageSize: 20,
							rownumbers: true,
							sortName: 'UploadTime',
							sortOrder: 'desc',
							fit: true,
							fitColumns: true,
							idField: 'ID',
							singleSelect: true,
							frozenColumns: [[
								{ field: 'ID', checkbox: true }
							]],
							url: '/HostUpdate/LoadAllByPage/',
							onSelect: dgUpdateHostOnSelect,
							method: 'POST',
						">
					<thead>
						<tr>
				
							<th data-options="field:'FileName',width:100,sortable:true">
								<%: Html.Language("UpgradePackageName")%>
							</th>
							<th data-options="field:'Size',width:40,sortable:true,formatter:function(value){ return (value / 1024.0 / 1024.0).toFixed(2); }">
								<%: Html.Language("Size")%>(MB)
							</th>
							<th data-options="field:'UploadTime',width:60,sortable:true,formatter:$.tools.formatDate">
								<%: Html.Language("UploadDate")%>
							</th>
							<th data-options="field:'Account',width:60,sortable:true">
									<%: Html.Language("UploadPeople")%>
							</th>
						</tr>
					</thead>
				</table>
			</div>
			<div title="'<%:Html.Language("RoomHost") %>'" style="width:200px;border-left:1px solid #95B8E7;" data-options="region:'east',border:false,split:true">
				<ul id="groupTree2" class="easyui-tree" data-options="checkbox:true,animate:true,lines:true,url:'/HostUpdate/LoadGroupTreeWithRoom/'"></ul>
			</div>
		</div>
	</div>
	
	<div id="tbUpdateHost">
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-upload',plain:true" onclick="$('#uploadForm').form('reset');$('#uploadFile').window('open')"><%: Html.Language("Upload")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="delHostUpdate()"><%: Html.Language("Delete")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-update',plain:true" onclick="update()"><%: Html.Language("ReleaseUpgrade")%></a>
	</div>
	
	<div id="uploadFile" title="'<%: Html.Language("UploadUpdatePackage")%>'" class="easyui-window"   style="width:400px;height:150px;padding:5px;"
		data-options="
			closed: true,
			modal: true,
			collapsible: false,
			minimizable: false,
			maximizable: false
		">
		<div class="easyui-layout" fit="true">
			<div style="padding-top:25px;text-align:center;" data-options="region:'center'">
				<form id="uploadForm" method="post" enctype="multipart/form-data">
					<input class="easyui-filebox" id="uf" name="file" style="width:90%;" data-options="buttonText:'<%: Html.Language("SelectUpgradePack")%>'" />
				</form>
			</div>
			<div data-options="region:'south',border:false" style="text-align: right; padding: 5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-save'" href="javascript:void(0)" onclick="uploadFile();"><%: Html.Language("Upload")%></a>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="$('#uploadFile').window('close');"><%: Html.Language("Cancel")%></a>
			</div>
		</div>
	</div>

	<div id="tbGroup">
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="group.add()"><%: Html.Language("New")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="group.edit()"><%: Html.Language("Edit")%></a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="group.del()"><%: Html.Language("Delete")%></a>
	</div>

	<div id="dialog" class="easyui-window"   style="padding: 5px;"
		data-options="
			closed: true,
			modal: true,
			collapsible: false,
			minimizable: false,
			maximizable: false
		">
		<div class="easyui-panel dlg-content" style="margin-bottom:5px;"></div>
		<div class="dlg-footer" style="text-align:right; padding:5px 5px 0 0;">
			<a class="easyui-linkbutton dlg-btn-save" data-options="iconCls:'icon-save'" href="javascript:void(0)"><%: Html.Language("Save")%></a>
			<a class="easyui-linkbutton dlg-btn-cancel" data-options="iconCls:'icon-cancel'" href="javascript:void(0)" onclick="$('#dialog').window('close');"><%: Html.Language("Cancel")%></a>
		</div>
	</div>

	<div id="dialog2" class="easyui-window"   style="padding: 5px;"
		data-options="
			closed: true,
			modal: true,
			collapsible: false,
			minimizable: false,
			maximizable: false
		">
		<div class="easyui-panel dlg-content" style="margin-bottom:5px;"></div>
	</div>

</asp:Content>

<asp:Content ID="Content3" ContentPlaceHolderID="ScriptContent" runat="server">
	<script src="/Scripts/group.js" type="text/javascript"></script>
	<script src="/Scripts/host-index.js" type="text/javascript"></script>
    <% switch ((int)Session["isCN"]){case 1: %>
    <script type="text/javascript" src="/Scripts/en-US.js"></script>
    <% break; case 2: %>
    <script type="text/javascript" src="/Scripts/zh-TW.js"></script>
    <% break;default: %>
    <script type="text/javascript" src="/Scripts/zh-CN.js"></script>
    <% break; } %>
</asp:Content>