{extends file="layout.html"}
{block name=title}LMS: {$layout.pagetitle|striphtml}{/block}
{block name=module_content}
<!--// $Id$ //-->
<style>

	[for="showips"] {
		white-space: normal;
	}

</style>

<H1>{$layout.pagetitle}</H1>
{if $bars}
{if ($download || $upload) && function_exists('imagecreate')}
<P align="center">
	<IMG src="?m=trafficgraph&amp;bar={$bar}{if $customer}&customer={$customer}{/if}{if $net}&net={$net}{/if}{if $datefrom}&from={$datefrom}{/if}{if $dateto}&to={$dateto}{/if}" alt="{trans("Network Statistics")}">
</P>
{/if}
<TABLE WIDTH="100%" ALIGN="center" CELLPADDING="3">
	<TR>
		<TD style="vertical-align:top" WIDTH="50%">
			<TABLE class="lmsbox">
                            <THEAD>
				<TR>
					<TD align="center" COLSPAN="2">
						<P><B>{trans("Download")}</B></P>
					</TD>
				</TR>
                            </THEAD>
                            <TBODY>
				{section name=download loop=$download.name}
				<TR>
					<TD WIDTH="1%" NOWRAP>
						<B><A HREF="?m=nodeinfo&id={$download.nodeid[download]}">{if $showips}{$download.ipaddr[download]}{else}{$download.name[download]|truncate:25:"&hellip;":true}{/if}</A></B>
					</TD>
					<TD CLASS="fright hand" WIDTH="99%" NOWRAP>
						<IMG SRC="img/redpx.gif" HEIGHT="12" WIDTH="{$download.bar[download]}" BORDER="1" ALT="" {tip a=$download.nodeid[download] b=$bar c=$datefrom d=$dateto sticky=1 popup='?m=trafficgraph&nodeid=$a&amp;bar=$b&from=$c&to=$d'}>
						{$download.data[download]|string_format:"%.2f"}&nbsp;{$download.unit[download]} ({$download.avg[download]|string_format:"%d"}&nbsp;kbit/s)
					</TD>
				</TR>
				{/section}
                            </TBODY>
                            <TFOOT>
				<TR>
					<TD ALIGN="center" COLSPAN="2">
						<P><B>{trans("Total:")} {$download.sum.data|string_format:"%.2f "}{$download.sum.unit} ({$download.avgsum|string_format:"%d"}&nbsp;kbit/s)</B></P>
					</TD>
				</TR>
                            </TFOOT>
			</TABLE>
		</TD>
		<TD style="vertical-align:top" WIDTH="50%">
			<TABLE class="lmsbox">
                            <THEAD>
				<TR>
					<TD align="center" COLSPAN="2">
						<P><B>{trans("Upload")}</B></P>
					</TD>
				</TR>
                            </THEAD>
                            <TBODY>
				{section name=upload loop=$upload.name}
				<TR>
					<TD WIDTH="1%" NOWRAP>
						<B><A HREF="?m=nodeinfo&id={$upload.nodeid[upload]}">{if $showips}{$upload.ipaddr[upload]}{else}{$upload.name[upload]|truncate:25:"&hellip;":true}{/if}</A></B>
					</TD>
					<TD CLASS="fright hand" WIDTH="99%" NOWRAP>
						<IMG SRC="img/bluepx.gif" HEIGHT="12" WIDTH="{$upload.bar[upload]}" BORDER="1" ALT="" {tip a=$upload.nodeid[upload] b=$bar c=$datefrom d=$dateto sticky=1 popup='?m=trafficgraph&nodeid=$a&amp;bar=$b&from=$c&to=$d'}>
						{$upload.data[upload]|string_format:"%.2f"}&nbsp;{$upload.unit[upload]} ({$upload.avg[upload]|string_format:"%d"}&nbsp;kbit/s)
					</TD>
				</TR>
				{/section}
                            </TBODY>
                            <TFOOT>
				<TR>
					<TD ALIGN="center" COLSPAN="2">
						<P><B>{trans("Total:")} {$upload.sum.data|string_format:"%.2f "}{$upload.sum.unit} ({$upload.avgsum|string_format:"%d"}&nbsp;kbit/s)</B></P>
					</TD>
				</TR>
                            </TFOOT>
			</TABLE>
		</TD>
	</TR>
	{if $smarty.section.download.index_next}
	<TR><TD WIDTH="100%" COLSPAN="2" ALIGN="center">{t a=$smarty.section.download.index_next}Rows: $a{/t}</TD></TR>
	{/if}
</TABLE>
{else}
<form name="traffic" id="traffic" method="POST" action="?m=traffic&bar=user">
<INPUT type="submit" class="hiddenbtn">
<TABLE class="lmsbox">
	<colgroup>
		<col style="width: 1%;">
		<col style="width: 1%;">
		<col style="width: 98%;">
	</colgroup>
    <THEAD>
	<TR>
		<TD COLSPAN="3">
			<B>{trans("Enter search criteria:")}</B>
		</TD>
	</TR>
    </THEAD>
    <TBODY>
	<TR {tip text="Limit results to selected period"}>
		<TD>
			<IMG src="img/calendar.gif">
		</TD>
		<td class="bold nobr">
			{trans("From")}
		</td>
		<TD class="nobr">
			<input type="text" id="datefrom" name="from" size="20" maxlength="20" value="{$starttime|date_format:"Y/m/d H:i"}"
					{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"}>
		</TD>
	</TR>
	<TR {tip text="Limit results to selected period"}>
		<TD>
			<IMG src="img/calendar.gif">
		</TD>
		<td class="bold nobr">
			{trans("To")}
		</td>
		<TD class="nobr">
			<input type="text" id="dateto" name="to" size="20" maxlength="20" value="{$endtime|date_format:"Y/m/d H:i"}"
				{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"}>
		</TD>
	</TR>
	<TR>
		<td colspan="2">
		</td>
		<td>
			{date_period_preset from="#datefrom" to="#dateto" time=true
				periods="previous-year,previous-month,current-year,current-month,next-month,next-year"}
		</td>
	</TR>
	<TR {tip text="Limit results to selected network"}>
		<TD>
			<IMG src="img/network.gif">
		</TD>
		<TD class="bold nobr">
			{trans("Network:")}
		</TD>
		<TD>
			<SELECT SIZE="1" NAME="net">
				<OPTION VALUE="0">{trans("— all —")}</OPTION>
				{section name="netlist" loop=$netlist}
				<OPTION VALUE="{$netlist[netlist].id}" {if $netlist[netlist].id == $trafficnet}SELECTED{/if}>{$netlist[netlist].name|truncate:30:"&hellip;":true}</OPTION>
				{/section}
			</SELECT>
		</TD>
	</TR>
	<TR>
		<TD>
			<IMG src="img/customer.gif">
		</TD>
		<TD class="bold nobr">
			{trans("Customer:")}
		</TD>
		<TD>
			{customerlist form="traffic" customers=$customers selectname="custid" version=2
				inputname="customerid" firstoption="— all customers —"}
		</TD>
	</TR>
	<TR {tip text="Select results sorting order"}>
		<TD>
			<IMG src="img/view.gif">
		</TD>
		<TD class="bold nobr">
			<B>{trans("Sorting:")}</B>
		</TD>
		<TD>
			<SELECT SIZE="1" NAME="order">
				<OPTION VALUE="name"{if $trafficorder == "name"} SELECTED{/if}>{trans("Node name")}</OPTION>
				<OPTION VALUE="ip"{if $trafficorder == "ip"} SELECTED{/if}>{trans("Node IP address")}</OPTION>
				<OPTION VALUE="nodeid"{if $trafficorder == "nodeid"} SELECTED{/if}>{trans("Node number")}</OPTION>
				<OPTION VALUE="download"{if $trafficorder == "download"} SELECTED{/if}>{trans("Download")}</OPTION>
				<OPTION VALUE="upload"{if $trafficorder == "upload"} SELECTED{/if}>{trans("Upload")}</OPTION>
			</SELECT>
		</TD>
	</TR>
	<TR {tip text="Limit results to n computers"}>
		<TD>
			<IMG src="img/node.gif">
		</TD>
		<TD class="bold nobr">
			{trans("Nodes limit:")}
		</TD>
		<TD>
			<INPUT TYPE="text" NAME="limit" SIZE="3">
		</TD>
	</TR>
	<tr {tip text="Nodes depiction way on charts"}>
		<td>
			<img src="img/ip.gif">
		</td>
		<td>
			<label for="showips">
				<strong>{trans("IP addresses instead of nodes names")}</strong>
			</label>
		</td>
		<td>
			<input type="checkbox" name="showips" id="showips" value="1">
		</td>
	</tr>
	<TR>
		<TD colspan="3" class="lms-ui-box-buttons">
			{button icon="save" label="Submit" onclick="document.traffic.submit();"}
		</TD>
	</TR>
    </TBODY>
</TABLE>
</form>
{/if}
{/block}
