<!-- BEGIN {$smarty.template} -->
<script type="text/javascript">
{literal}
    $(document).ready(function() {
        $('#pmt_date').datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat: 'yy-mm-dd',
            showOn: 'both',
            buttonImage: '../img/phpaga/cal.png',
            buttonImageOnly: true
        });
    });
{/literal}
</script>

<form action="{$ACTION}" method="post" name="form">
<input type="hidden" name="bill_id" value="{$billInfo.bill_id}">
{if $curPmt.pmt_id}
<input type="hidden" name="pmt_id" value="{$curPmt.pmt_id}">
<input type="hidden" name="update_payment" value="true">
{else}
<input type="hidden" name="add_payment" value="true">
{/if}

<table cellspacing="0">
  <caption><em>{$BILL_PMTINFO}</em></caption>
  <tr>
    <td class="label"> {t}Invoice nr.{/t}: </td>
    <td class="data"> {$billInfo.bill_number|wash} </td>
    <td class="label"> {t}Invoice date{/t}: </td>
    <td class="data"> {$billInfo.bill_date|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
  </tr>
  <tr>
    <td class="label"> {t}Term of payment{/t}: </td>
    <td class="data"> {$billInfo.bill_payterm|wash|default:"&nbsp;"} </td>
    <td class="label"> {t}Date due{/t}: </td>
    {if strlen($billInfo.bill_date_due)}
    <td class="data{if $billInfo.bill_overdue} warn{/if}"> {$billInfo.bill_date_due|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
    {else}
    <td class="data recinfo"> {t}not set{/t} </td>
    {/if}
  </tr>
  <tr>
    <td class="label"> {t}Invoice type{/t}: </td>
    <td class="data"> {$billInfo.bmt_description|wash} </td>
    <td class="label"> {t}Total Payments{/t}: </td>
    {if $billPmtInfo.sum}
    <td class="data"> {$config.MONETARY_SYMBOL|wash}{$billPmtInfo.sum|wash} </td>
    {else}
    <td class="data recinfo">{t}no payments yet{/t}</td>
    {/if}
  </tr>
  <tr>
    <td class="label">{t}Company{/t}: </td>
    <td class="data">{$billInfo.cpn_name|wash}</td>
    <td class="label"> {t}Balance Due{/t}: </td>
    <td class="data"> {$config.MONETARY_SYMBOL|wash}{$billInfo.bill_balance_due|number_format:2:$config.SEPARATOR_DECIMALS:$config.SEPARATOR_THOUSANDS} </td>
  </tr>

  <tr>
    <td class="label"> {t}Payment Date{/t}: </td>
    <td class="data" colspan="3">
      <input type="text" class="tinput" id="pmt_date" name="pmt_date" value="{$curPmt.pmt_date}" size="10" maxlength="10">
    </td>
  </tr>

  <tr>
    <td class="label"> {t}Payment Amount{/t}: </td>
    {if strlen($curPmt.pmt_amt)}
    <td class="data" colspan="3"><input class="tinput no-transparency" type="text" name="pmt_amt" value={$curPmt.pmt_amt} maxlength="10"></td>
    {else}
    <td class="data" colspan="3"><input class="tinput no-transparency" type="text" name="pmt_amt" maxlength="10"></td>
    {/if}
  </tr>

  <tr>
    <td class="label"> {t}Notes{/t}: </td>
    <td class="data" colspan="3">
      <textarea cols="50" rows="5" class="tinput no-transparency" name="pmt_note" id="note">{$curPmt.pmt_note|wash}</textarea>
    </td>
  </tr>
</table>


<table cellspacing="0">
    <caption><em>{t}Payments{/t}</em></caption>
    <thead>
        <tr>
            <th> {t}Date{/t} </th>
            <th> {t}Note{/t} </th>
            <th class="number"> {t}Amount{/t} </th>
            {*<th> {t}Actions{/t} </th>*}
        </tr>
    </thead>
    <tbody>
        {section name=pmt loop=$billPmtInfo.payments}
        <tr>
            <td>
                {$billPmtInfo.payments[pmt].pmt_date|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}
            </td>
            <td>
                {$billPmtInfo.payments[pmt].pmt_note|wash|default:"&nbsp;"}
            </td>
            <td class="number">
                {$billPmtInfo.payments[pmt].pmt_amt|wash|default:"&nbsp;"}
            </td>
        </tr>
        {/section}
    </tbody>
</table>

<div class="buttons">
  <input type="submit" name="submit" value="{t}Submit{/t}">
  <input type="button" onclick="location.href='bill.php?id={$billInfo.bill_id}';" value="{t}Cancel{/t}">
</div>

</form>

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