{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<H1>{$layout.pagetitle}</H1>
<TABLE class="lmsbox">
    <THEAD>
	<TR class="dark">
		<TD width="100%" class="fall" colspan="2" NOWRAP>
			<IMG SRC="img/channel.gif" alt="">
			{if $channel.id}
			    <B>{$channel.name} ({$channel.id|string_format:"%04d"})</B>
			{else}
			    [{trans("default")}]
			{/if}
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR class="light">
		<TD width="1%" class="fleft" NOWRAP>
			<IMG SRC="img/downrate.gif" alt=""> <B>{trans("Downceil:")}</B>
		</TD>
		<TD width="99%" class="fright">
			{$channel.downceil} kbit/s
			({trans("night:")} {if $channel.downceil_n}{$channel.downceil_n|default:0} kbit/s{else}{trans("not defined")}{/if})
		</TD>
	</TR>
	<TR class="light">
		<TD width="1%" class="fleft" NOWRAP>
			<IMG SRC="img/uprate.gif" alt=""> <B>{trans("Upceil:")}</B>
		</TD>
		<TD width="99%" class="fright">
			{$channel.upceil} kbit/s
			({trans("night:")} {if $channel.upceil_n}{$channel.upceil_n|default:0} kbit/s{else}{trans("not defined")}{/if})
		</TD>
	</TR>
	<TR class="light">
		<TD width="1%" class="fleft" NOWRAP>
			<IMG SRC="img/options.gif" alt=""> <B>{trans("Options:")}</B>
		</TD>
		<TD width="99%" class="fright">
		    {trans("Half duplex")}: {if $channel.halfduplex}{trans("yes")}{else}{trans("no")}{/if}
		</TD>
	</TR>
	<TR class="light">
		<TD width="1%" class="fleft" NOWRAP>
			<IMG SRC="img/netdev.gif" alt=""> <B>{trans("Devices:")}</B>
		</TD>
		<TD width="99%" class="fright">
		    {$channel.devcnt|default:0}
		</TD>
	</TR>
	<TR class="light">
		<TD width="1%" class="fleft" NOWRAP>
			<IMG SRC="img/node.gif" alt=""> <B>{trans("Nodes:")}</B>
		</TD>
		<TD width="99%" class="fright">
		    {$channel.nodecnt|default:0}
		</TD>
	</TR>
	<TR class="light">
		<TD width="1%" class="fleft" NOWRAP>
			<IMG SRC="img/channel.gif" alt=""> <B>STMID:</B>
		</TD>
		<TD width="99%" class="fright">
		    {if $channel.cid}[{$channel.cid|string_format:"%04d"}]{else}-{/if}
		</TD>
	</TR>
	<TR CLASS="light">
        <TD width="100%" CLASS="fbottomu" COLSPAN="2" align="right">
            {if $channel.id}
            <A HREF="?m=ewxchedit&id={$channel.id}" accesskey="E">{trans("Edit")} <IMG SRC="img/edit.gif" ALT=""></A>
			<A id="delete-ewxch" HREF="?m=ewxchdel&id={$channel.id}">{trans("Delete")} <IMG SRC="img/delete.gif" ALT=""></A>
            {/if}
        </TD>
    </TR>
    </TBODY>
</TABLE>
<BR>
<TABLE class="lmsbox">
    <THEAD>
	<TR CLASS="dark">
        	<TD width="100%" CLASS="fall">
			<IMG SRC="img/netdev.gif" alt=""> <B>{trans("Devices:")}</B>
                </TD>
        </TR>
    </THEAD>
    <TBODY>
	<TR>
		<TD width="100%" class="fall">
			<TABLE class="lmsbox-inner">
                            <THEAD>
				<TR class="dark">
					<TD WIDTH="30%" class="fleftu"><B>{trans("Name:")}</B></TD>
	                <TD WIDTH="1%" class="fbt" align="right">{trans("ID:")}</TD>
					<TD WIDTH="1%" class="fbt" align="right">{trans("Nodes:")}</TD>
					<TD WIDTH="67%" class="fbt">{trans("Location:")}</TD>
					<TD WIDTH="1%" class="frightu">&nbsp;</TD>
				</TR>
                            </THEAD>
                            <TBODY>
				{cycle values="light,lucid" print=false}
				{foreach from=$channel.devices item=item}
				<TR class="highlight {cycle}"  >
					<TD onClick="return self.location.href='?m=netdevinfo&id={$item.id}';">
						<img src="img/netdev.gif" align="left" ALT=""><B>{$item.name}</B>
					</TD>
					<TD onClick="return self.location.href='?m=netdevinfo&id={$item.id}';">
						({$item.id|string_format:"%04d"})
					</TD>
					<TD onClick="return self.location.href='?m=netdevinfo&id={$item.id}';" align="right">
						{$item.nodes|default:0}
					</TD>
					<TD onClick="return self.location.href='?m=netdevinfo&id={$item.id}';">
						{$item.location}
					</TD>
					<TD align="right">
					    {if $channel.id}
						<A class="remove-ewxch" href="?m=ewxchedit&action=remove&id={$channel.id}&devid={$item.id}" {tip text="Remove this device from the channel"}><IMG SRC="img/delete.gif" ALT="{trans("Delete")}"></A>
					    {/if}
					</TD>
				</TR>
				{foreachelse}
					<tr>
						<td colspan="5" class="empty-table">
							{trans("No devices associated with this channel.")}
						</td>
					</tr>
				{/foreach}
				{if $channel.freedevices}
				<FORM METHOD="POST" NAME="device" ACTION="?m=ewxchedit&action=add&id={$channel.id}">
				<INPUT type="submit" class="hiddenbtn">
				<TR class="light">
				    <TD COLSPAN="3" CLASS="ftop">
						<B>{trans("Add:")}</B>
						<SELECT SIZE="1" NAME="devid" {tip text="Select device to associate with the channel"}>
						        <OPTION VALUE="">{trans("— select device —")}</OPTION>
						        {foreach from=$channel.freedevices item=item}
							<OPTION VALUE="{$item.id}">{$item.name}{if $item.producer} / {$item.producer}{/if}{if $item.location} ({$item.location}){/if}</OPTION>
			        			{/foreach}
						</SELECT>
					<TD ALIGN="RIGHT" CLASS="ftop" COLSPAN="2" NOWRAP>
						<A HREF="javascript:document.device.submit()" {tip text="Add device to the channel"}>{trans("Add")} <IMG SRC="img/save.gif" alt="{trans("Add")}"></A>
					</TD>
				</TR>
				</FORM>
				{/if}
                            </TBODY>
			</TABLE>
		</TD>
	</TR>
    </TBODY>
</TABLE>
	<script>
		$('#delete-ewxch').click(function() {
			confirmDialog($t("Are you sure, you want to delete this channel?"), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
		$('.remove-ewxch').click(function() {
			confirmDialog($t("Are you sure, you want to remove this assignment?"), this).done(function() {
				location.href = $(this).attr('href');
			});
			return false;
		});
	</script>
{/block}
