<!-- BEGIN {$smarty.template} -->

<form action="{$FORM_ACTION}" method="get">

<table class="searchtable" cellspacing="0">
  <tr>
    <th> {t}Select fiscal year and currency{/t} </th>
  </tr>
  <tr>
    <td>{t}Fiscal year{/t}:
      {html_select_date reverse_years=true time=$time start_year=$minYear end_year=$maxYear display_months=false display_days=false prefix=fin_}

      {t}Currency{/t}:
      <select name="curr_id">
        {html_options options=$currencies selected=$curr_id}
      </select>
      <input type="submit" value="{t}Search{/t}">
    </td>
  </tr>
</table>

</form>

{if count($cpndetails.details) < 1}

<div class="msg">{t}No data matching your search criteria was found.{/t}</div>

{else}

<table class="stdtable" cellspacing="0">
  <tr>
    <td class="header"> {$FINANCES_INFO} {t escape="0" 1=$curr_name 2=$YEAR 3=$fy_dates.start 4=$fy_dates.end}Amounts invoiced and received in %1, FY %2 (%3-%4){/t}</td>
  </tr>
  <tr>
    <td>
      <div class="imgcontainer">
      <div class="spacer">
      <div class="imgfloat"> <img alt="Billed per customer" src="finances_bpc_graph.php?year={$YEAR}&amp;currency={$CURRENCY}" width="{$smarty.const.PHPAGA_FINGRAPH_WIDTH}" height="{$smarty.const.PHPAGA_FINGRAPH_HEIGHT}" /></div>
      <div class="imgfloat"><img alt="Billed/received per month" src="finances_bprpm_graph.php?year={$YEAR}&amp;currency={$CURRENCY}" width="{$smarty.const.PHPAGA_FINGRAPH_WIDTH}" height="{$smarty.const.PHPAGA_FINGRAPH_HEIGHT}" /></div>
      </div>
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <table class="substdtable" cellspacing="0">
        <tr>
          <td class="section" colspan="4"> {t}Per customer{/t} </td>
        </tr>

        {if count($cpndetails) > 0}
        <tr>
          <th> {t}Customer{/t} </th>
          <th class="number"> {t escape="0" 1=$YEAR}Invoiced in FY %1{/t} </th>
          <th class="number"> {t escape="0" 1=$YEAR}Received in FY %1{/t} </th>
          <th class="number"> {t}Still unpaid{/t} </th>
        </tr>
        {section name=i loop=$cpndetails.details}
        <tr class="{cycle values="odd,even"}">
          <td class="desc"> <a href="company.php?id={$cpndetails.details[i].cpn_id}">{$cpndetails.details[i].cpn_name|wash}</a> </td>
          <td class="number"> {$cpndetails.details[i].sum_billed|phpaga_formatamount} </td>
          <td class="number"> {$cpndetails.details[i].sum_paid|phpaga_formatamount} </td>
          <td class="number"> {$cpndetails.details[i].sum_missing|phpaga_formatamount} </td>
        </tr>
        {/section}
        <tr class="summary">
          <td class="desc"> {t}Totals{/t} </td>
          <td class="number"> {$cpndetails.totals.billed|phpaga_formatamount} </td>
          <td class="number"> {$cpndetails.totals.paid|phpaga_formatamount} </td>
          <td class="number"> {$cpndetails.totals.missing|phpaga_formatamount} </td>
        </tr>
        {/if}

      </table>
    </td>
  </tr>
</table>

{/if}

<!-- END {$smarty.template} -->
