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

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

<table class="stdtable" cellspacing="0">
  <tr>
    <td class="header"> {t}Company{/t}: {$cpnInfo.cpn_name|wash} </td>
    <td class="headeraction">
      {if ($perm_companies) || ($cpnInfo.pe_id == $smarty.session.auth_user.pe_id)}
      [ <a class="ptr" onclick="confirm_delete_company({$cpnInfo.cpn_id}, '{$cpnInfo.cpn_name|phpaga_popup_sanitizestr}');">{t}Delete{/t}</a>
      | <a href="edit_company.php?id={$cpnInfo.cpn_id}">{t}Edit{/t}</a> ]
      {else}
      &nbsp;
      {/if}
    </td>
  </tr>

  <tr>
    <td class="label">{t}Company{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_name|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Address{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_address|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Address 2{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_address2|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Location{/t}: </td>
    <td class="data"> {$cpnInfo.full_location|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Country{/t}: </td>
    <td class="data"> <img src="img/flags/{$cpnInfo.ctr_code|strtolower|wash}.png" alt="{$cpnInfo.ctr_name|wash|default:"&nbsp;"}" title="{$cpnInfo.ctr_name|wash|default:"&nbsp;"}" /> {$cpnInfo.ctr_name|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Category{/t}: </td>
    <td class="data"> {$cpnInfo.ccat_title|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Tax number{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_taxnr|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label"> {t}Default term of payment{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_defaultpayterm|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Phone{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_phone|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Fax{/t}: </td>
    <td class="data"> {$cpnInfo.cpn_fax|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label">{t}Url{/t}: </td>
    <td class="data"> {if strlen($cpnInfo.cpn_url)}{$cpnInfo.cpn_url|wash|phpaga_urlmodifier}{else}&nbsp;{/if} </td>
  </tr>
  <tr>
    <td class="label">{t}Email{/t}: </td>
    <td class="data"> {if strlen($cpnInfo.cpn_email)}<a href="mailto:{$cpnInfo.cpn_email|wash}">{$cpnInfo.cpn_email|wash}</a>{else}&nbsp;{/if} </td>
  </tr>
  <tr>
    <td class="label recinfo"> {t}Record owner{/t}: </td>
    <td class="data recinfo"> {$cpnInfo.owner_pe_person|wash|default:"&nbsp;"} </td>
  </tr>

  {if ($opcatresult && isset($opcats) && (count($opcats) > 0))}

  <tr>
    <td class="section"> {t}Task categories{/t} </td>
    <td class="sectionaction"> [ <a href="company.php?id={$cpnInfo.cpn_id}&amp;detail={if $opcat_byproject == 0}{$smarty.const.PHPAGA_OPCGRP_PROJECT}{else}0{/if}">{if $opcat_byproject == 0}{t}Details{/t}{else}{t}Overall{/t}{/if}</a> ] </td>
  </tr>
  <tr>
    <td align="left" valign="top" colspan="2">
      {if ($opcat_byproject == 0)}
      <table class="substdtable" cellspacing="0">
        <tr>
          <td class="opcat">
            <table cellspacing="0">
              {section name=opcdet loop=$opcats}
              <tr>
                <td class="label op">{$opcats[opcdet].opcat_title|wash}:&nbsp;</td>
                <td class="numdesc">&nbsp;{$opcats[opcdet].opcat_duration|phpaga_minutes2duration}&nbsp;</td>
              </tr>
              {/section}
              <tr>
                <td class="op" colspan="2">&nbsp;</td>
              </tr>
              <tr>
                <td class="label op">{t}Total duration{/t}: </td>
                <td class="numdesc"> {$TOTAL_DURATION|phpaga_minutes2duration} </td>
              </tr>
            </table>
          </td>

          <td class="desc last"><img src="opcat_graph.php?cpn_id={$cpnInfo.cpn_id}" alt="{t}Task categories{/t}" title="{t}Task categories{/t}" /></td>
        </tr>
      </table>
      {else}
      <table class="opcattable" cellspacing="0">
        <tr>
          <td class="fillerul">&nbsp;</td>
          {foreach item=prj from=$opcats.projects}
          <td class="projects"> <a href="project.php?id={$prj.prj_id}">{$prj.prj_title|wash}</a></td>
          {/foreach}
          <td class="fillerur">&nbsp;</td>
        </tr>
        {foreach key=opckey item=opc from=$opcats.opcats}
        <tr class="{cycle values="oodd,oeven"}">
          <td class="opcats"> {$opc.opcat_title|wash} </td>
          {foreach item=row from=$opcats.rows[$opckey]}
          <td> {if strlen($row.opcat_duration)}{$row.opcat_duration|phpaga_minutes2duration}{else}&nbsp;{/if} </td>
          {/foreach}
          <td class="opcatsduration"> {$opc.duration|phpaga_minutes2duration} </td>
        </tr>
        {/foreach}
        <tr>
          <td class="fillerll">&nbsp;</td>
          {foreach item=prj from=$opcats.projects}
          <td class="prjduration"> {$prj.duration|phpaga_minutes2duration}</td>
          {/foreach}
          <td class="totalduration"> {$TOTAL_DURATION|phpaga_minutes2duration} </td>
        </tr>
      </table>
      {/if}

    </td>
  </tr>
  {/if}

  {if (isset($cpnInfo.projects) && is_array($cpnInfo.projects) && (count($cpnInfo.projects) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Projects{/t} </td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Title{/t} </th>
          <th> {t}Status{/t} </th>
          <th> {t}Start date{/t} </th>
          <th> {t}Projected end{/t} </th>
          <th> {t}End date{/t} </th>
          <th> {t}Category{/t} </th>
          <th> {t}Hours{/t} </th>
          <th> {t}Actions{/t} </th>
        </tr>
        {section name=prjs loop=$cpnInfo.projects}
        <tr class="{cycle values="odd,even"}">
          <td> <a href="project.php?id={$cpnInfo.projects[prjs].prj_id}">{$cpnInfo.projects[prjs].prj_title|wash}</a> </td>
          <td> {$cpnInfo.projects[prjs].prjstat_title|wash} </td>
          <td class="time"> {$cpnInfo.projects[prjs].prj_startdate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
          <td class="time"> {if strlen($cpnInfo.projects[prjs].prj_estimatedend)}<span{if (($cpnInfo.projects[prjs].prj_status != 2) && phpaga_dategreater($cpnInfo.projects[prjs].prj_estimatedend, $cpnInfo.projects[prjs].prj_enddate))} class="overdue"{/if}>
            {$cpnInfo.projects[prjs].prj_estimatedend|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}</span>{else}&nbsp;{/if}
          </td>
          <td class="time"> {if strlen($cpnInfo.projects[prjs].prj_enddate)}{$cpnInfo.projects[prjs].prj_enddate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}{else}&nbsp;{/if} </td>
          <td nowrap> {$cpnInfo.projects[prjs].prjcat_title|wash} </td>
          <td class="time"> {$cpnInfo.projects[prjs].prj_duration|phpaga_minutes2duration} </td>
          <td class="actions"> {strip}
            <a href="project.php?id={$cpnInfo.projects[prjs].prj_id}"><img src="img/phpaga/view.png" height="16" width="16" border="0" alt="{t}View{/t}" title="{t}View{/t}"></a>
            <a href="edit_project.php?prj_id={$cpnInfo.projects[prjs].prj_id}"><img src="img/phpaga/edit.png" height="16" width="16" border="0" alt="{t}Edit{/t}" title="{t}Edit{/t}"></a>
            <a href="add_operation.php?prj_id={$cpnInfo.projects[prjs].prj_id}"><img src="img/phpaga/task_add.png" height="16" width="16" border="0" alt="{t}Add task{/t}" title="{t}Add task{/t}"></a>
            {/strip}
          </td>
        </tr>
        {/section}
      </table>
    </td>
  </tr>
  {/if}

  {if (isset($cpnInfo.billing_summary) && is_array($cpnInfo.billing_summary))}
  {if (isset($cpnInfo.billing_summary.issued) && is_array($cpnInfo.billing_summary.issued) && (count(($cpnInfo.billing_summary.issued)) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Invoices issued{/t} </td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Nr. of invoices{/t} </th>
          <th> {t}Time frame{/t} </th>
          <th> {t}Total amount{/t} </th>
          <th> {t}Currency{/t} </th>
        </tr>
        {section name=isum loop=$cpnInfo.billing_summary.issued}
        <tr class="{cycle values="odd,even"}">
          <td class="number"> {$cpnInfo.billing_summary.issued[isum].count|default:"&nbsp;"} </td>
          <td class="number"> {$cpnInfo.billing_summary.issued[isum].min_date|wash|default:"&nbsp;"} - {$cpnInfo.billing_summary.issued[isum].max_date|default:"&nbsp;"}</td>
          <td class="number"> {$cpnInfo.billing_summary.issued[isum].amount|phpaga_formatamount|default:"&nbsp;"} </td>
          <td class="last"> {$cpnInfo.billing_summary.issued[isum].curr_name|wash|default:"&nbsp;"} </td>
        </tr>
        {/section}
      </table>
    </td>
  </tr>
  {/if}
  {if (isset($cpnInfo.billing_summary.outstanding) && is_array($cpnInfo.billing_summary.outstanding) && (count(($cpnInfo.billing_summary.outstanding)) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Outstanding invoices{/t} </td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Nr. of invoices{/t} </th>
          <th> {t}Time frame{/t} </th>
          <th> {t}Total amount{/t} </th>
          <th> {t}Currency{/t} </th>
        </tr>
        {section name=isum loop=$cpnInfo.billing_summary.outstanding}
        <tr class="{cycle values="odd,even"}">
          <td class="number"> {$cpnInfo.billing_summary.outstanding[isum].count|default:"&nbsp;"} </td>
          <td class="number"> {$cpnInfo.billing_summary.outstanding[isum].min_date|wash|default:"&nbsp;"} - {$cpnInfo.billing_summary.outstanding[isum].max_date|default:"&nbsp;"}</td>
          <td class="number"> {$cpnInfo.billing_summary.outstanding[isum].amount|phpaga_formatamount|default:"&nbsp;"} </td>
          <td class="last"> {$cpnInfo.billing_summary.outstanding[isum].curr_name|wash|default:"&nbsp;"} </td>
        </tr>
        {/section}
      </table>
    </td>
  </tr>
  {/if}
  {/if}

  {if (isset($cpnInfo.bills) && is_array($cpnInfo.bills) && (count($cpnInfo.bills) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Invoices{/t} </td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Invoice nr.{/t} </th>
          <th> {t}Invoice date{/t} </th>
          <th> {t}Amount{/t} </th>
          <th> {t}Currency{/t} </th>
          <th> {t}Date paid{/t} </th>
        </tr>
        {section name=inv loop=$cpnInfo.bills}
        <tr class="{cycle values="odd,even"}">
          <td class="number"> <a href="bill.php?id={$cpnInfo.bills[inv].bill_id}">{$cpnInfo.bills[inv].bill_number|wash}</a> </td>
          <td class="time"> <a href="bill.php?id={$cpnInfo.bills[inv].bill_id}">{$cpnInfo.bills[inv].bill_date|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}</a> </td>
          <td class="number"> {$cpnInfo.bills[inv].bill_endsum|phpaga_formatamount|default:"&nbsp;"} </td>
          <td> {$cpnInfo.bills[inv].curr_name|wash|default:"&nbsp;"} </td>
          <td class="time last"> {$cpnInfo.bills[inv].bill_paydate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
        </tr>
        {/section}
      </table>
    </td>
  </tr>
  {/if}

  {if (isset($cpnInfo.quotations) && is_array($cpnInfo.quotations) && (count($cpnInfo.quotations) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Quotations{/t} </td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Quotation nr.{/t} </th>
          <th> {t}Quotation date{/t} </th>
          <th> {t}Amount{/t} </th>
          <th> {t}Currency{/t} </th>
        </tr>
        {section name=quot loop=$cpnInfo.quotations}
        <tr class="{cycle values="odd,even"}">
          <td class="number"> <a href="quotation.php?id={$cpnInfo.quotations[quot].quot_id}">{$cpnInfo.quotations[quot].quot_number|wash}</a> </td>
          <td class="time"> <a href="quotation.php?id={$cpnInfo.quotations[quot].quot_id}">{$cpnInfo.quotations[quot].quot_date|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}</a> </td>
          <td class="number"> {$cpnInfo.quotations[quot].quot_endsum|phpaga_formatamount|default:"&nbsp;"} </td>
          <td class="last"> {$cpnInfo.quotations[quot].curr_name|wash|default:"&nbsp;"}  </td>
        </tr>
        {/section}
      </table>
    </td>
  </tr>
  {/if}

  {if (isset($persons) && is_array($persons) && (count($persons) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Employees{/t} </td>
  </tr>
  <tr>
    <td colspan="2">
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Name{/t} </th>
          <th> {t}Address{/t} </th>
          <th> {t}City{/t} </th>
          <th> {t}Country{/t} </th>
          <th>{t}Work phone{/t}: </th>
          <th> {t}Email{/t} </th>
        </tr>
        {section name=idx loop=$persons}
        <tr class="{cycle values="odd,even"}">
          <td> <a href="person.php?id={$persons[idx].pe_id}">{$persons[idx].pe_person|wash}</a> </td>
          <td> {$persons[idx].pe_address|wash|default:"&nbsp;"} </td>
          <td> {$persons[idx].pe_location|wash|default:"&nbsp;"} </td>
          <td> {$persons[idx].ctr_name|wash|default:"&nbsp;"} </td>
          <td> {$persons[idx].pe_phonework|wash|default:"&nbsp;"} </td>
          <td class="last"> {if (isset($persons[idx].pe_email) && strlen($persons[idx].pe_email))}<a href="mailto:{$persons[idx].pe_email|wash}">{$persons[idx].pe_email|wash}{else}&nbsp;{/if}</a> </td>
        </tr>
        {/section}
      </table>
    </td>
  </tr>
  {/if}
</table>

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

