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

{include file="createinvoicebox.tpl.html"}

<form action="{$smarty.const.PHPAGA_SELF}" method="get">

{if (count($summary.rows) > 0)}
<table class="stdtable" cellspacing="0">
  <caption><em>{t}Unbilled hours{/t}</em>
    {t}Group by{/t}:
    <select name="groupby">
      {html_options options=$phpaga_groupby selected=$groupby_sel}
    </select>
    <input type="submit" value="{t}Search{/t}" />
  </caption>
  <tr>
    <th> {t}Customer{/t} </th>
    {if !$percustomer}
    <th> {t}Project{/t} </th>
    {/if}
    <th class="time"> {t}Hours{/t} </th>
    <th class="number"> {t}Amount{/t} </th>
    <th class="number"> {t}Materials{/t} </th>
    <th class="time"> {t}Between{/t} </th>
    <th class="time"> {t}And{/t} </th>
    <th> {t}Actions{/t} </th>
  </tr>
  {section name=i loop=$summary.rows}
  <tr class="{cycle values="odd,even"}">
    <td> <a href="company.php?id={$summary.rows[i].cpn_id}">{$summary.rows[i].cpn_name|wash}</a> </td>
    {if !$percustomer}
    <td{if ((strlen($summary.rows[i].prj_title) > $smarty.const.PHPAGA_SHOWPRJTITLELENGHT))} onmouseover="return escape('{$summary.rows[i].prj_title|phpaga_popup_sanitizestr}')"{/if}>
      <a href="project.php?id={$summary.rows[i].prj_id}"> {$summary.rows[i].prj_title|wash|trnc:$smarty.const.PHPAGA_SHOWPRJTITLELENGHT:"...":true} </a>
    </td>
    {/if}
    <td class="time"> {$summary.rows[i].prj_duration|phpaga_minutes2duration} </td>
    <td class="number"> {$summary.rows[i].prj_amount|phpaga_formatamount|default:"&nbsp;"} </td>
    <td class="number"> {$summary.rows[i].material_price|phpaga_formatamount|default:"&nbsp;"} </td>
    <td class="time"> {$summary.rows[i].op_min_start|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
    <td class="time"> {$summary.rows[i].op_max_end|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
    <td class="actions">
      {if phpaga_user_hasperm($smarty.const.PHPAGA_PERM_MANAGE_INVOICES)}<a href="add_bill.php?{if !$percustomer}prj_id={$summary.rows[i].prj_id}{else}cpn_id={$summary.rows[i].cpn_id}{/if}&amp;op_billed={$smarty.const.PHPAGA_BILL_NOTBILLED}&amp;prj_billabletype=0&amp;op_billabletype=0&amp;action={$smarty.const.ACTION_BILL_WITHOPERATIONS}">{t}Create invoice{/t}</a> | {/if}
      {if phpaga_user_hasperm($smarty.const.PHPAGA_PERM_MANAGE_INVOICES) and !$percustomer}<a id="createinvoice" class="ptr" onclick="document.invoiceboxfrm.prj_id.value={$summary.rows[i].prj_id};document.invoiceboxfrm.cpn_id.value={$summary.rows[i].cpn_id};show_box('createinvoice', 'invoicebox');">{t}Show Choices{/t}</a> | {/if}
      <a href="operations.php?{if !$percustomer}prj_id={$summary.rows[i].prj_id}{else}cpn_id={$summary.rows[i].cpn_id}{/if}&amp;op_billed={$smarty.const.PHPAGA_BILL_NOTBILLED}">{t}View tasks{/t}</a>
    </td>
  </tr>
  {/section}
  <tr>
    <td{if !$percustomer} colspan="2"{/if}> &nbsp;</td>
    <td class="time"> {$summary.sum_duration|phpaga_minutes2duration} </td>
    <td class="number"> {$summary.sum_amount|phpaga_formatamount|default:"&nbsp;"} </td>
    <td class="number"> {$summary.sum_material|phpaga_formatamount|default:"&nbsp;"} </td>
    <td colspan="4"> &nbsp; </td>
  </tr>
</table>
</form>
{else}
<div class="msg">{t}Currently there are no unbilled hours.{/t}</div>
{/if}

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