{include file="clearheader.html"}
<!--// $Id$ //-->
<TABLE WIDTH="100%" CELLPADDING="3" ALIGN="CENTER">
	<TR>
		<TD WIDTH="535" VALIGN="TOP">
			<H1>{$layout.pagetitle}</H1>
		</TD>
		<TD WIDTH="180" ALIGN="RIGHT" NOWRAP>
			LMS {$layout.lmsv} @ {$layout.hostname}<BR>
			{t a=trans($smarty.now|date_format:"l") b=$smarty.now|date_format:"Y-m-d"}<!date-format>$a, $b{/t}
			<br>
			{t a=$layout.logname}Prepared by: $a{/t}
		</TD>
	</TR>
</TABLE>
<BR>
<TABLE WIDTH="100%" CELLPADDING="3" BORDER="1" ALIGN="CENTER">
	<TR>
		<TD WIDTH="15" ALIGN="CENTER" CLASS="HEAD">
			{trans("No.")}
		</TD>
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{if isset($linktechnologies)}
				{trans("<!uke-income>Link technology")}
			{else}
				{trans("<!uke-income>Service type")}
			{/if}
		</TD>
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{trans("<!uke-income>Business services")}
		</TD>
		{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{trans("<!uke-income>Business income")}
		</TD>
		{/if}
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{trans("<!uke-income>Private services")}
		</TD>
		{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{trans("<!uke-income>Private income")}
		</TD>
		{/if}
		{if !empty($budgetaryunits)}
			<td width="30" class="HEAD nobr" align="CENTER">
				{trans("<!uke-income>Budgetary unit services")}
			</td>
			{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
				<td width="30" class="HEAD nobr" align="CENTER">
					{trans("<!uke-income>Budgetary unit income")}
				</td>
			{/if}
		{/if}
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{trans("<!uke-income>Total services")}
		</TD>
		{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
		<TD WIDTH="30" CLASS="HEAD nobr" ALIGN="CENTER">
			{trans("<!uke-income>Total income")}
		</TD>
		{/if}
	</TR>
	{cycle values="white,grey" print=false}
	{foreach $income as $row}
	<TR class="{cycle advance=false}">
		<TD ALIGN="CENTER">
			{counter}.
		</TD>
		<TD ALIGN="CENTER">
			{if $row.type}
				{if isset($linktechnologies)}
					{$linktechnologies[$row.type]}
				{else}
					{$_SERVICETYPES[$row.type]}
				{/if}
			{else}
				{trans("(undefined)")}
			{/if}
		</TD>
		<TD ALIGN="CENTER">
			{if empty($budgetaryunits)}
				{$row.businesscount + $row.budgetaryunitcount}
			{else}
				{$row.businesscount}
			{/if}
		</TD>
		{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
		<TD ALIGN="CENTER">
			{if empty($budgetaryunits)}
				{moneyf($row.businessincome + $row.budgetaryunitincome)}
			{else}
				{moneyf($row.businessincome)}
			{/if}
		</TD>
		{/if}
		<TD ALIGN="CENTER">
			{$row.privatecount}
		</TD>
		{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
		<TD ALIGN="CENTER">
			{moneyf($row.privateincome)}
		</TD>
		{/if}
		{if !empty($budgetaryunits)}
			<td align="center">
				{$row.budgetaryunitcount}
			</td>
			{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
				<td align="center">
					{moneyf($row.budgetaryunitincome)}
				</td>
			{/if}
		{/if}
		<TD ALIGN="CENTER">
			{$row.totalcount}
		</TD>
		{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}
		<TD ALIGN="CENTER">
			{moneyf($row.totalincome)}
		</TD>
		{/if}
	</TR>
	{if isset($bandwidth_variation) && isset($bandwidth_variation[$row.type])}
	<TR class="{cycle}">
		<TD ALIGN="CENTER">
			&nbsp;
		</TD>
		<TD ALIGN="CENTER" colspan="{if ConfigHelper::checkConfig('privileges.superuser') || !ConfigHelper::checkConfig('privileges.hide_finances')}7{else}5{/if}">
			<table width="100%" border="1">
				<thead>
					<tr>
						<td width="30" CLASS="HEAD nobr text-center">{trans("Bandwidth interval")}</td>
						<td width="30" CLASS="HEAD nobr text-center">{trans("<!link>Business links")}</td>
						<td width="30" CLASS="HEAD nobr text-center">{trans("<!link>Private links")}</td>
						{if !empty($budgetaryunits)}
							<td width="30" CLASS="HEAD nobr text-center">{trans("<!link>Budgetary unit links")}</td>
						{/if}
						<td width="30" CLASS="HEAD nobr text-center">{trans("Total")}</td>
					</tr>
				</thead>
				<tbody>
				{foreach $bandwidth_variation[$row.type] as $label => $stats}
					<tr>
						<td class="text-center">{$label}</td>
						<td class="text-center">
							{if empty($budgetaryunits)}
								{$stats.business + $stats.budgetaryunit}
							{else}
								{$stats.business}
							{/if}
						</td>
						<td class="text-center">{$stats.private}</td>
						{if !empty($budgetaryunits)}
							<td class="text-center">{$stats.budgetaryunit}</td>
						{/if}
						<td class="text-center">{$stats.total}</td>
					</tr>
				{/foreach}
				</tbody>
			</table>
		</TD>
	</TR>
	{/if}
	{foreachelse}
	<tr>
		<td colspan="8" class="empty-table">
			{trans("<!uke-income>No data.")}
		</td>
	</tr>
	{/foreach}
	{if ConfigHelper::checkConfig('privileges.superuser') || (!ConfigHelper::checkConfig('privileges.hide_finances') && !ConfigHelper::checkConfig('privileges.hide_summaries'))}
	<TR>
		<TD CLASS="HEADGREY" COLSPAN="2" ALIGN="RIGHT"><B>{trans("Total:")}</B></TD>
		<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="businesscount"}</B></TD>
		<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="businessincome" assign="businessincome"}{moneyf($businessincome)}</B></TD>
		<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="privatecount"}</B></TD>
		<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="privateincome" assign="privateincome"}{moneyf($privateincome)}</B></TD>
		{if !empty($budgetaryunits)}
			<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="budgetaryunitcount"}</B></TD>
			<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="budgetaryunitincome" assign="budgetaryunitincome"}{moneyf($budgetaryunitincome)}</B></TD>
		{/if}
		<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="totalcount"}</B></TD>
		<TD CLASS="HEADGREY" ALIGN="CENTER" NOWRAP><B>{sum array=$income column="totalincome" assign="totalincome"}{moneyf($totalincome)}</B></TD>
	</TR>
	{/if}
</TABLE>
{include file="clearfooter.html"}
