<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>

<div class="box" style="margin-bottom:5px;">
	<div class="title"><%: Html.Language("RoomStatus")%></div>
	<div class="container">
		<div class="content">
			<table style="width:100%;">
				<tr>
					<td style="text-align:center;width:20%;"><span class="RoomNumber"><%: Model.RoomNumber %></span></td>
					<td style="text-align:center;width:20%;"><span class="RoomStatus"><%: Model.RoomStatus %></span></td>
					<td style="text-align:center;width:20%;"><span class="Status"><%: Model.HostStatus %></span></td>
					<td style="text-align:center;width:20%;"><span class="IP"><%: Model.IP %></span></td>
				</tr>
			</table>
		</div>
	</div>
</div>

<div style="height:280px;">
	<table title='' id="dgLights" class="easyui-datagrid"
		data-options="
				url: '/HostModal/LoadHostModals/',
				queryParams: { HostID: <%: Model.HostID %> }, 
				border: true,
				singleSelect: true,
				rownumbers: true,
				striped: true,
				fit: true,
				fitColumns: true,
				idField: 'HostID',
				method: 'post',
			    sortName: 'Number',
			    sortOrder: 'asc',
				tools:[{
					iconCls: 'icon-reload',
					handler: function(){ $('#dgLights').datagrid('reload') }    
				}]
			">
		<thead>
			<tr>
				<th data-options="field:'ModalAddress',resizable:false">
					  <%: Html.Language("ReturnAddress")%>
				</th>
				<th data-options="field:'Outlet',resizable:false">
					  <%: Html.Language("DeliveryOutlet")%>
				</th>
				<th data-options="field:'Name',resizable:false">
					 <%: Html.Language("Name")%>
				</th>
				<th data-options="field:'TypeName',resizable:false">
					 <%: Html.Language("Type")%>
				</th>
				<th data-options="field:'Status',align:'center',resizable:false,
					formatter: function(val){ 
						if(val == 1){
							return lang.Opened;
						} else {
							return lang.Closed;
						}
					}">
					<%: Html.Language("Status")%>
				</th>
				<th data-options="field:'Brightness',align:'center',resizable:false,
                    formatter:function(val,row){                    
						switch (row.Type) {
                            case 'Dimmer':
                            case 'Strip':
                            case 'Traic':
                            case 'PWMDimmer':
                                return val + '%';
                            case 'Relay':
                            case 'Expand':
                                return row.Status==1?'100%':'0%';
                            case 'AirDetect':
                                return val;
                            default:
                                return '';
                        }
                        }">
					<%: Html.Language("Brightness")%>
				</th>
				<th data-options="field:'SettingTemp',align:'center',resizable:false,
                    formatter: function(val,row){
                        if(row.Type=='AirConditioner' || row.Type=='FloorHot'){ 
                            return val + '℃';
                        }else return '';
                        }">
					<%: Html.Language("SettingTemp")%>
				</th>
				<th data-options="field:'FanSpeed',align:'center',resizable:false,
					formatter: function(val,row){ 
                        if(row.Type=='AirConditioner'){
						    switch (val) {
                                case 1:
                                    return lang.low;
                                case 2:
                                    return lang.Middle;
                                case 3:
                                    return lang.HighSpeed;
                                default:
                                    return lang.Automatic;
                            }
                        }else return '';
					}">
					<%: Html.Language("FanSpeed")%>
				</th>
				<th data-options="field:'Mode',align:'center',resizable:false,
					formatter: function(val,row){
                        if(row.Type=='AirConditioner'){
						    switch (val) {
                                case 1:
                                    return lang.Refrigeration;
                                case 2:
                                    return lang.Heating;
                                case 3:
                                    return lang.BlowingIn;
                                default:
                                    return lang.Automatic;
                            }
                        }else return '';
					}">
					<%: Html.Language("Mode")%>
				</th>
				<th data-options="field:'Valve',align:'center',resizable:false,
					formatter: function(val,row){ 
                        if(row.Type=='AirConditioner'){
						    if(val == 1){
							    return lang.ValveOpen;
						    } else {
							    return lang.ValveClose;
						    }
                        }else return '';
					}">
					<%: Html.Language("Valve")%>
				</th>
				<%--<th data-options="field:'Time',resizable:false,formatter:timeFormatter">
					<%: Html.Language("WhenTheDayOfOpenLong")%>
				</th>--%>
			</tr>
		</thead>
	</table>
</div>
<style type="text/css">
	.onoff {
		color: red;	
	}
</style>
<% 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; } %>
<script type="text/javascript">

	function timeFormatter(val) {
		var hour = Math.floor(val / 60);
		var minute = val % 60;
		return hour + lang.Hour + minute + lang.Minute;
	}
</script>