<!-- BEGIN {$smarty.template} -->
{include file="search_companies.tpl.html"}

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

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

<table class="stdtable" cellspacing="0">
  <tr>
    <td class="header" colspan="4"> {t}Companies{/t} </td>
    <td class="headeraction" colspan="4"> [ <a href="add_company.php">{t}Add company{/t}</a> ] </td>
  </tr>

  <tr>
    <th> <a href="{$location}{$sort.name}"{if $porder == $smarty.const.ORDER_CPN_NAME_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_CPN_NAME_DESC} class="sortdesc"{/if}>{t}Name{/t}</a> </th>
    <th> <a href="{$location}{$sort.address}"{if $porder == $smarty.const.ORDER_CPN_ADDRESS_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_CPN_ADDRESS_DESC} class="sortdesc"{/if}>{t}Address{/t}</a> </th>
    <th> <a href="{$location}{$sort.city}"{if $porder == $smarty.const.ORDER_CPN_CITY_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_CPN_CITY_DESC} class="sortdesc"{/if}>{t}City{/t}</a> </th>
    <th> <a href="{$location}{$sort.country}"{if $porder == $smarty.const.ORDER_CPN_COUNTRY_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_CPN_COUNTRY_DESC} class="sortdesc"{/if}>{t}Country{/t}</a> </th>
    <th> <a href="{$location}{$sort.ccat}"{if $porder == $smarty.const.ORDER_CPN_CCAT_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_CPN_CCAT_DESC} class="sortdesc"{/if}>{t}Category{/t}</a> </th>
    <th> {t}Phone{/t} </th>
    <th> <a href="{$location}{$sort.email}"{if $porder == $smarty.const.ORDER_CPN_EMAIL_ASC} class="sortasc"{elseif $porder == $smarty.const.ORDER_CPN_EMAIL_DESC} class="sortdesc"{/if}>{t}Email{/t}</a> </th>
    <th> {t}Actions{/t}</th>
  </tr>

  {section name=companies loop=$rows}
  <tr class="{cycle values="odd,even"}">
    <td> <a href="company.php?id={$rows[companies].cpn_id}">{$rows[companies].cpn_name|wash|default:"&nbsp;"}</a> </td>
    <td> {$rows[companies].cpn_address|wash|default:"&nbsp;"} </td>
    <td> {$rows[companies].cpn_city|wash|default:"&nbsp;"} </td>
    <td> <img src="img/flags/{$rows[companies].ctr_code|strtolower|wash}.png" alt="{$rows[companies].ctr_name|wash|default:"&nbsp;"}" title="{$rows[companies].ctr_name|wash|default:"&nbsp;"}" /> {$rows[companies].ctr_name|wash|default:"&nbsp;"} </td>
    <td> {$rows[companies].ccat_title|wash|default:"&nbsp;"} </td>
    <td> {$rows[companies].cpn_phone|wash|default:"&nbsp;"} </td>
    <td> {$rows[companies].cpn_email|wash|default:"&nbsp;"} </td>
    <td class="actions"> {strip}
      <a href="company.php?id={$rows[companies].cpn_id}"><img src="img/phpaga/view.png" height="16" width="16" border="0" alt="{t}View{/t}" title="{t}View{/t}"></a>
      {if ($perm_companies) || ($rows[companies].pe_id == $smarty.session.auth_user.pe_id)}
      <a href="edit_company.php?id={$rows[companies].cpn_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_company({$rows[companies].cpn_id}, '{$rows[companies].cpn_name|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}
  </tr>
  {/section}

  {if (strlen($BROWSE))}
  <tr>
    <td class="browse" colspan="9"> {$BROWSE} </td>
  </tr>
  {/if}
</table>

{/if}

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

