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

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

{if (count($rows) == 0)}
<div>
{t}No persons matching your search criteria were found.{/t}<br />
{if $perm_persons}[ <a href="add_person.php">{t}Add person{/t}</a> ]{/if}
</div>
{else}

{include file="delete_person.tpl.js"}

<table class="stdtable" cellspacing="0">
  <caption><em>{t}Persons{/t}</em> [ <a href="add_person.php">{t}Add person{/t}</a> ]</caption>
  <tr>
    <th> <a href="{$location}{$sort.name}"{if $porder == $smarty.const.ORDER_PE_NAME_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_PE_NAME_DESC} class="sortdesc"{/if}>{t}Name{/t}</a> </th>
    <th> <a href="{$location}{$sort.address}"{if $porder == $smarty.const.ORDER_PE_ADDRESS_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_PE_ADDRESS_DESC} class="sortdesc"{/if}>{t}Address{/t}</a> </th>
    <th> <a href="{$location}{$sort.city}"{if $porder == $smarty.const.ORDER_PE_CITY_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_PE_CITY_DESC} class="sortdesc"{/if}>{t}City{/t}</a> </th>
    <th> <a href="{$location}{$sort.country}"{if $porder == $smarty.const.ORDER_PE_COUNTRY_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_PE_COUNTRY_DESC} class="sortdesc"{/if}>{t}Country{/t}</a> </th>
    <th> <a href="{$location}{$sort.cpn}"{if $porder == $smarty.const.ORDER_PE_COMPANY_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_PE_COMPANY_DESC} class="sortdesc"{/if}>{t}Company{/t}</a> </th>
    <th> <a href="{$location}{$sort.email}"{if $porder == $smarty.const.ORDER_PE_EMAIL_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_PE_EMAIL_DESC} class="sortdesc"{/if}>{t}Email{/t}</a> </th>
    <th> {t}Actions{/t} </th>
  </tr>
  {section name=persons loop=$rows}
  <tr class="{cycle values="odd,even"}">
    <td> <a href="person.php?id={$rows[persons].pe_id}">{$rows[persons].pe_person|wash|default:"&nbsp;"}</a> </td>
    <td> {$rows[persons].pe_address|wash|default:"&nbsp;"} </td>
    <td> {$rows[persons].pe_city|wash|default:"&nbsp;"} </td>
    <td> <img src="img/flags/{$rows[persons].ctr_code|strtolower|wash}.png" alt="{$rows[persons].ctr_name|wash|default:"&nbsp;"}" title="{$rows[persons].ctr_name|wash|default:"&nbsp;"}" /> {$rows[persons].ctr_name|wash|default:"&nbsp;"} </td>
    <td> <a href="company.php?id={$rows[persons].cpn_id}">{$rows[persons].cpn_name|wash|default:"&nbsp;"}</a> </td>
    <td>
      {if (isset($rows[persons].pe_email) && strlen($rows[persons].pe_email))}
      <a href="mailto:{$rows[persons].pe_email}">{$rows[persons].pe_email}</a>
      {else}
      &nbsp;
      {/if}
    </td>
    <td class="actions"> {strip}
      <a href="person.php?id={$rows[persons].pe_id}"><img src="img/phpaga/view.png" height="16" width="16" border="0" alt="{t}View{/t}" title="{t}View{/t}"></a>
      {if ($perm_persons) || ($rows[persons].pe_pe_id == $smarty.session.auth_user.pe_id)}
      <a href="edit_person.php?id={$rows[persons].pe_id}"><img src="img/phpaga/edit.png" height="16" width="16" border="0" alt="{t}Edit{/t}" title="{t}Edit{/t}"></a>
      <a class="ptr" onclick="confirm_delete_person({$rows[persons].pe_id}, '{$rows[persons].pe_person|phpaga_popup_sanitizestr}');"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
      {/if}
      {/strip}
    </td>
  </tr>
  {/section}
  {if (strlen($BROWSE))}
  <tr>
    <td class="browse" colspan="7"> {$BROWSE} </td>
  </tr>
  {/if}
</table>
{/if}

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