{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<H1>{$layout.pagetitle}</H1>
<script type="text/javascript">
<!--
	function filter() {
		document.page.action="?m=nodesessionlist";
		document.page.target="";
		document.page.submit();
	}

{if ConfigHelper::checkConfig('phpui.short_pagescroller')}
	function pagechange1() {
		document.page.action="?m=nodesessionlist&page=" + document.forms['page'].elements['page1'].value;
		document.page.target="";
		document.page.submit();
	}

	function pagechange2() {
		document.page.action="?m=nodesessionlist&page=" + document.forms['page'].elements['page2'].value;
		document.page.target="";
		document.page.submit();
	}
{/if}
//-->
</script>
<FORM METHOD="POST" NAME="page">
<INPUT type="submit" class="hiddenbtn">
<table style="width: 100%" class="lmsbox lms-ui-background-cycle">
	<thead>
		<tr>
			<td colspan="11">
				<table style="width: 100%">
					<colgroup>
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 1%;">
						<col style="width: 95%;">
					</colgroup>
					<tr>
						<td class="nobr">
							<label>
								<strong>{trans("Filter:")}</strong>
								<SELECT name="filtertype">
									<OPTION value="">{trans("— none —")}</OPTION>
									<OPTION value="ip"{if $filtertype == 'ip'} selected{/if}>{trans("<!nodesession-search>IP address")}</OPTION>
									<OPTION value="mac"{if $filtertype == 'mac'} selected{/if}>{trans("<!nodesession-search>MAC address")}</OPTION>
									<OPTION value="customer"{if $filtertype == 'customer'} selected{/if}>{trans("<!nodesession-search>customer")}</OPTION>
									<OPTION value="nodeid"{if $filtertype == 'nodeid'} selected{/if}>{trans("<!nodesession-search>node ID")}</OPTION>
									<option value="location"{if $filtertype == 'location'} selected{/if}>{trans("<!nodesession-search>location")}</option>
								</SELECT>&nbsp;
								<input type="text" size="16" maxlength="32" name="filtervalue" value="{$filtervalue}">
							</label>
						</td>
						<td class="nobr">
							<label>
							</label>
						</td>
						<td class="nobr">
							<label>
								{trans("Type:")}
								<SELECT name="type">
									<OPTION value="0">{trans("— all —")}</OPTION>
									{foreach $_SESSIONTYPES as $typeidx => $typeval}
									<OPTION value="{$typeidx}"{if $type == $typeidx} selected{/if}>{$typeval.label}</OPTION>
									{/foreach}
								</SELECT>
							</label>
						</td>
						<td>
							<span class="lms-ui-date-period-container">
								{date_period_preset from="#datefrom" to="#dateto" time=true}
								<span>{trans("Started:")}</span>
								<input type="text" id="datefrom" name="datefrom" size="20" maxlength="20"
									value="{$datefrom}"
									{tip class="lms-ui-datetime" text="Enter date in 'yyyy/mm/dd hh:mm' format (empty field means current date) or click to choose date from calendar"}>
							</span>
						</td>
						<td>
							<span class="lms-ui-date-period-container">
								<span>{trans("Finished:")}</span>
								<input type="text" id="dateto" name="dateto" size="20" maxlength="20"
									value="{$dateto}"
									{tip class="lms-ui-datetime" text="Enter date in 'yyyy/mm/dd hh:mm' format (empty field means current date) or click to choose date from calendar"}>
							</span>
						</td>
						<td class="nobr">
							<a href="javascript:filter();">&raquo;&raquo;&raquo;</a>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td class="fbt bold">{trans("IP Address:")}</td>
			<td class="fbt">{trans("Customer:")}</td>
			<td class="fbt">{trans("MAC:")}</td>
			<td class="fbt">{trans("Type:")}</td>
			<td class="fbt">{trans("Location")}</td>
			<td class="fbt bold">{trans("Started:")}</td>
			<td class="fbt bold">{trans("Finished:")}</td>
			<td class="fbt bold">{trans("Time Duration:")}</td>
			<td class="fbt bold">{trans("Terminate Cause:")}</td>
			<td class="fbt">{trans("Downloaded:")}</td>
			<td class="fbt">{trans("Uploaded:")}</td>
		</tr>
		{if $listdata.total != 0}
		<TR>
			<TD class="lms-ui-pagination" COLSPAN="11">
				{include file="scroller.html" loop=$nodesessions scrollerno=1}
			</TD>
		</TR>
		{/if}
	</thead>
	<tfoot>
		{if $listdata.total != 0}
		<TR>
			<TD class="lms-ui-pagination" COLSPAN="11">
				{include file="scroller.html" loop=$nodesessions scrollerno=2}
			</TD>
		</TR>
		{/if}
	</tfoot>
	<tbody>
		{section name=nodesession loop=$nodesessions start=$start max=$pagelimit}
		{assign var=session value=$nodesessions[nodesession]}
		<tr class="highlight">
			<td class="bold nobr">
				{if $session.nodeid}<a href="?m=nodeinfo&id={$session.nodeid}">{/if}
				{long_ip($session.ipaddr)}
				{if $session.nodeid}</a>{/if}
			</td>
			<td class="nobr">
				{if $session.customerid}
				<a href="?m=customerinfo&id={$session.customerid}">{$session.lastname} {$session.name}</a>
				{else}-{/if}
			</td>
			<td>
				{$session.mac}
				{$producer = EtherCodes::GetProducer($session.mac)}
				{if $producer}
					<span class="lms-ui-font-smaller">
						({$producer})
					</span>
				{/if}
			</td>
			<td class="nobr">
				{$unknowntype=1}{$firsttype=1}
				{foreach $_SESSIONTYPES as $sessiontypeid => $sessiontype}
					{if ($session.type & $sessiontypeid) == $sessiontypeid}
					{if !$firsttype}, {/if}{$sessiontype.label}
					{$firsttype=0}
					{$unknowntype=0}
					{/if}
				{/foreach}
				{if $unknowntype}-{/if}
			</td>
			<td>
				{if $session.location}
					{$session.location|escape}
				{else}
					—
				{/if}
			</td>
			<td class="nobr">
				<span class="bold">{$session.start|date_format:"Y.m.d"}</span> {$session.start|date_format:"H:i:s"}
			</td>
			<td class="nobr">
				{if $session.stop}
				<span class="bold">{$session.stop|date_format:"Y.m.d"}</span> {$session.stop|date_format:"H:i:s"}
				{else}-{/if}
			</td>
			<TD class="bold nobr">{$session.duration}</TD>
			<TD class="bold nobr">{$session.terminatecause}</TD>
			<TD class="nobr">{$session.download}</TD>
			<TD class="nobr">{$session.upload}</TD>
		</tr>
		{sectionelse}
		<tr>
			<td class="empty-table" colspan="11">
				<P>&nbsp;</P>
				<P>{trans("There are no sessions matching defined filter.")}</P>
				<P>&nbsp;</P>
			</td>
		</tr>
		{/section}
	</tbody>
</table>
</form>
{/block}
