{* DO NOT EDIT THIS FILE! Use an override template instead. *}
<form action={concat("/shop/statistics")|ezurl} method="post" name="Statistics">
<div class="maincontentheader">
  <h1>{"Statistics"|i18n("design/standard/shop")}</h1>
</div>

<select name="Year">
    <option value="0" {section show=eq($year,0)}selected="selected"{/section}>[{"All Years"|i18n("design/standard/shop")}]</option>
    {section var=YearValue loop=$year_list}
        <option value="{$YearValue}" {section show=eq($YearValue,$year)}selected="selected"{/section}>{$YearValue}</option>
    {/section}
</select>
&nbsp;

<select name="Month">
    <option value="0" {section show=eq($month,0)}selected="selected"{/section}>[{"All Months"|i18n("design/standard/shop")}]</option>
    {section var=MonthItem loop=$month_list}
        <option value="{$MonthItem.value}" {section show=eq($MonthItem.value,$month)}selected="selected"{/section}>{$MonthItem.name}</option>
    {/section}
</select>
&nbsp;

<input class="button" type="submit" name="View" value="{'View'|i18n('design/standard/shop')}" />

{if $statistic_result}
{def $currency = false()
     $locale = false()
     $symbol = false()
     $quantity_text = ''
     $sum_ex_vat_text = ''
     $sum_inc_vat_text = ''
     $br_tag = ''}

<table class="list" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
	<th>
	{"Product"|i18n("design/standard/shop")}
	</th>
	<th>
	{"Amount"|i18n("design/standard/shop")}
	</th>
	<th>
	{"Total ex. VAT"|i18n("design/standard/shop")}
	</th>
	<th>
	{"Total inc. VAT"|i18n("design/standard/shop")}
	</th>
</tr>

{section var=Product loop=$statistic_result[0].product_list sequence=array(bglight,bgdark)}

    {set quantity_text = ''
         sum_ex_vat_text = ''
         sum_inc_vat_text = ''
         br_tag = ''}

    {foreach $Product.product_info as $currency_code => $info}
        {if $currency_code}
            {set currency = fetch( 'shop', 'currency', hash( 'code', $currency_code ) )}
        {else}
            {set currency = false()}
        {/if}

        {if $currency}
            {set locale = $currency.locale
                 symbol = $currency.symbol}
        {else}
            {set locale = false()
                 symbol = false()}
        {/if}

        {set quantity_text = concat( $quantity_text, $br_tag, $info.sum_count) }
        {set sum_ex_vat_text = concat($sum_ex_vat_text, $br_tag, $info.sum_ex_vat|l10n( 'currency', $locale, $symbol )) }
        {set sum_inc_vat_text = concat($sum_inc_vat_text, $br_tag, $info.sum_inc_vat|l10n( 'currency', $locale, $symbol )) }

        {if $br_tag|not()}
            {set br_tag = '<br />'}
        {/if}

    {/foreach}

    <tr>
        <td class="{$Product.sequence}">{content_view_gui view=text_linked content_object=$Product.product}</td>
        <td class="{$Product.sequence}">{$quantity_text}</td>
        <td class="{$Product.sequence}">{$sum_ex_vat_text}</td>
        <td class="{$Product.sequence}">{$sum_inc_vat_text}</td>
    </tr>

{/section}

{set sum_ex_vat_text = ''
     sum_inc_vat_text = ''
     br_tag = ''}

{foreach $statistic_result[0].total_sum_info as $currency_code => $info}

    {if $currency_code}
        {set currency = fetch( 'shop', 'currency', hash( 'code', $currency_code ) )}
    {else}
        {set currency = false()}
    {/if}

    {if $currency}
        {set locale = $currency.locale
             symbol = $currency.symbol}
    {else}
        {set locale = false()
             symbol = false()}
    {/if}

    {set sum_ex_vat_text = concat($sum_ex_vat_text, $br_tag, $info.sum_ex_vat|l10n( 'currency', $locale, $symbol )) }
    {set sum_inc_vat_text = concat($sum_inc_vat_text, $br_tag, $info.sum_inc_vat|l10n( 'currency', $locale, $symbol )) }

    {if $br_tag|not()}
        {set br_tag = '<br />'}
    {/if}

{/foreach}

<tr>
  	<td class="bgdark"><h2>{"SUM:"|i18n("design/standard/shop")}</h2></td>
    <td class="bgdark"></td>
	<td class="bgdark"><b>{$sum_ex_vat_text}</b></td>
	<td class="bgdark"><b>{$sum_inc_vat_text}</b></td>
</tr>

</table>
{undef}
{/if}
</form>