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

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

  <fieldset class="search">
    <legend>{t}Search invoices{/t}</legend>

    <label for="bill_number">{t}Invoice nr.{/t}:</label>
    <input type="text" class="tinput" id="bill_number" name="bill_number" value="{$billInfo.bill_number|wash}" size="10" maxlength="10">
    <br>

    <label for="bill_paid">{t}Payment status{/t}:</label>
    <select id="bill_paid" name="bill_paid">
      {html_options options=$select_paid selected=$billInfo.bill_paid}
    </select>
    <br>

    <label for="cpn_id">{t}Recipient (company){/t}:</label>
    <select id="cpn_id" name="cpn_id">
      {html_options options=$select_cpn selected=$billInfo.cpn_id}
    </select>
    <br>

    <label for="bill_datefrom">{t}Between{/t}:</label>
    <input type="text" class="tinput format-y-m-d divider-dash no-transparency" id="bill_datefrom" name="bill_datefrom" value="{$billInfo.bill_datefrom|wash}" size="10" maxlength="10" title="yyy-mm-dd">
    <br>

    <label for="bill_dateto">{t}And{/t}:</label>
    <input type="text" class="tinput format-y-m-d divider-dash no-transparency" id="bill_dateto" name="bill_dateto" value="{$billInfo.bill_dateto|wash}" size="10" maxlength="10" title="yyyy-mm-dd">
    <br>

    <input type="submit" name="submit" value="{t}Search{/t}">
  </fieldset>
</form>

<form action="bill_pdf.php" method="get" onsubmit="hideElement('printbill');">
{include file="bill_print.tpl.html"}

<table class="stdtable" cellspacing="0">
  <caption><em>{t}Invoices{/t}</em>
    {if $perm_invoices}[ <a href="add_bill.php">{t}Add invoice{/t}</a>
    | <a href="operations.php?op_billed={$smarty.const.PHPAGA_BILL_NOTBILLED}">{t}Add invoice with tasks{/t}</a>
    | <a href="bills_csv.php?{$search_args}">{t}CSV Export{/t}</a>
    | <a class="ptr" onclick="showElement('printbill');">{t}Export selected to PDF{/t}</a>]
    {/if}
  </caption>
  {if (count($rows) > 0)}
  <tr>
    <th class="number"> {t}Invoice nr.{/t} </th>
    <th class="number"> {t}Recurring invoice nr.{/t} </th>
    <th class="time"> {t}Invoice date{/t} </th>
    <th> {t}Recipient (company){/t} </th>
    <th> {t}Amount{/t} </th>
    <th class="time"> {t}Date due{/t} </th>
    <th class="time"> {t}Date paid{/t} </th>
    <th> <img src="img/phpaga/page_white_acrobat.png" height="16" width="16" border="0" alt="{t}PDF{/t}" title="{t}PDF{/t}"> </th>
    <th> {t}Actions{/t} </th>
  </tr>
  {section name=invoices loop=$rows}
  <tr class="{cycle values="odd,even"}">
    <td class="number"{if strlen($rows[invoices].hoverinfo)} onmouseover="return escape('{$rows[invoices].hoverinfo|wash|phpaga_popup_sanitizestr}')"{/if}> <a href="bill.php?id={$rows[invoices].bill_id}">{$rows[invoices].bill_number|wash}</a> </td>
    <td class="number">{$rows[invoices].rbill_id|wash|default:"&nbsp;"}</td>
    <td class="time"> <a href="bill.php?id={$rows[invoices].bill_id}">{$rows[invoices].bill_date|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}</a> </td>
    <td> <a href="company.php?id={$rows[invoices].cpn_id}">{$rows[invoices].cpn_name|wash}</a> </td>
    <td class="number"> {$rows[invoices].bill_endsum|wash|phpaga_formatamount} {$rows[invoices].curr_name|default:"&nbsp;"} </td>
    <td class="time{if $rows[invoices].bill_overdue} warn{/if}"> {$rows[invoices].bill_date_due|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
    <td class="time"> {$rows[invoices].bill_paydate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
    <td class="last"> {if !strlen($rows[invoices].bill_paydate)}<input type="checkbox" name="id[]" value="{$rows[invoices].bill_id}">{else}&nbsp;{/if} </td>
    <td class="actions">
      <a href="bill.php?id={$rows[invoices].bill_id}"><img src="img/phpaga/view.png" height="16" width="16" border="0" alt="{t}View{/t}" title="{t}View{/t}"></a>
    </td>
  </tr>
  {/section}
  {else}
  <tr>
    <td class="last" colspan="9"> {t}No bills matching your search criteria were found.{/t} </td>
  </tr>
  {/if}
  {if strlen($BROWSE)}
  <tr>
    <td class="browse" colspan="8"> {$BROWSE} </td>
  </tr>
  {/if}
</table>

</form>

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