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

<script type="text/javascript" src="js/tasks.js"></script>

{include file="delete_operation.tpl.js"}
{include file="delete_prjmember.js"}

{literal}
<script type="text/javascript">

      function confirm_delete(prj_id)
      {
      if (window.confirm('{/literal}{t}Are you sure you want to delete this project?{/t}{literal}')) {
      location.href = 'project.php?id='+prj_id+'&action={/literal}{$smarty.const.ACTION_PRJ_REMOVE}{literal}';
      }

      }

      function confirm_delete_file(file_id, file_info)
      {
      if (window.confirm(file_info+'\n\n{/literal}{t}Are you sure you want to delete this file?{/t}{literal}')) {
      location.href = '{/literal}{$smarty.const.PHPAGA_SELF}?action={$smarty.const.ACTION_FILE_REMOVE}{if (isset($DELETE_OP_URL_EXTRA) && strlen($DELETE_OP_URL_EXTRA))}{$DELETE_OP_URL_EXTRA}{/if}{literal}&file_id='+file_id;
      }

      }

      function confirm_delete_material(mat_id, mat_info)
      {
      if (window.confirm(mat_info+'\n\n{/literal}{t}Are you sure you want to delete this material?{/t}{literal}')) {
      location.href = '{/literal}{$smarty.const.PHPAGA_SELF}?action={$smarty.const.ACTION_MATERIAL_REMOVE}{if (isset($DELETE_OP_URL_EXTRA) && strlen($DELETE_OP_URL_EXTRA))}{$DELETE_OP_URL_EXTRA}{/if}{literal}&mat_id='+mat_id;
      }

      }

      function show_box(linkid, boxid)
      {

      v = document.getElementById(linkid);
      x = findPosX(v);
      y = findPosY(v);

      u = document.getElementById(boxid);
      w = u.offsetWidth;

      if (x > w) {
      x = x - w;
      }

      if (y > u.offsetHeight) {
      y = y - u.offsetHeight + 20;
      }

      u.style.left = x+"px";
      u.style.top = y+"px";
      u.style.visibility = "visible";

      }

      function toggle_opcatratelist()
      {

      u = document.getElementById("opcatratelist");
      a = document.getElementById("opcatratelistact");

      if (u.className.indexOf('hidden') != -1) {
      u.className = '';
      a.innerHTML = '{/literal}{t}Hide{/t}{literal}';
      } else {
      u.className = 'hidden';
      a.innerHTML = '{/literal}{t}Show{/t}{literal}';
      }

      }

</script>
{/literal}

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

{if strlen($relmap)}{$relmap}{/if}

<table class="stdtable" border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td class="header" colspan="2"> {t}Project{/t}: {$project.prj_title|wash} </td>
    <td class="headeraction datawrap" colspan="2"> {if $prjmanage || $perm_invoice}[ {if $perm_invoice}<a id="createinvoice" class="ptr" onclick="show_box('createinvoice', 'invoicebox');">{t}Create invoice{/t}</a> | {/if}<a class="ptr" onclick="confirm_delete({$project.prj_id});">{t}Delete{/t}</a> | <a href="edit_project.php?prj_id={$project.prj_id}">{t}Edit{/t}</a> | <a href="prjmember.php?prj_id={$project.prj_id}">{t}Add project member{/t}</a> | {/if}{if $prjmember || $prjmanage}<a href="add_material.php?prj_id={$project.prj_id}">{t}Add material{/t}</a> | <a href="add_expense.php?prj_id={$project.prj_id}">{t}Add expense{/t}</a> | <a href="add_operation.php?prj_id={$project.prj_id}">{t}Add task{/t}</a> | <a id="uplink" class="ptr" onclick="show_box('uplink', 'upload');">{t}Add file{/t}</a> ]{else}&nbsp;{/if}</td>
  </tr>
  <tr>
    <td align="left" valign="top" colspan="4">

      <table cellspacing="0" width="100%">
        <tr>
          <td class="label" width="20%"> {t}Title{/t}: </td>
          <td class="data" colspan="3"> {$project.prj_title|wash|default:"&nbsp;"} </td>
        </tr>
        <tr>
          <td class="label"> {t}Description{/t}: </td>
          <td class="data datawrap" colspan="3"> {$project.prj_desc|wash|default:"&nbsp;"} </td>
        </tr>
        <tr>
          <td class="label"> {t}Customer{/t}: </td>
          <td class="data" colspan="3"> <a href="company.php?id={$project.cpn_id}">{$project.cpn_name|wash|default:"&nbsp;"}</a> </td>
        </tr>
        <tr>
          <td class="label"> {t}Category{/t}: </td>
          <td class="data"> {$project.prjcat_title|wash|default:"&nbsp;"} </td>
          <td class="label"> {t}Status{/t}: </td>
          <td class="data"> {$project.prjstat_title|wash|default:"&nbsp;"} </td>
        </tr>
        <tr>
          <td class="label"> {t}Created by{/t}: </td>
          <td class="data"> {if strlen($project.prj_owner)}<a href="person.php?id={$project.pe_id}">{$project.prj_owner|wash}</a>{else}&nbsp;{/if} </td>
          <td class="label"> {t}From quotation{/t}: </td>
          <td class="data"> {if strlen($project.quot_id)}<a href="quotation.php?id={$project.quot_id}">{$project.quot_number|wash|default:"&nbsp;"}/{$project.quot_date|wash|default:"&nbsp;"}</a>{else}&nbsp;{/if} </td>
        </tr>
        <tr>
          <td class="label"> {t}Project manager{/t}: </td>
          <td class="data"> {if strlen($project.prj_manager_pe_id)}<a href="person.php?id={$project.prj_manager_pe_id}">{$project.prj_manager|wash}</a>{else}&nbsp;{/if} </td>
          <td class="label" width="10%"> {t}Billable{/t}: </td>
          <td class="data"> {$project.prj_billabletype_text|wash|default:"&nbsp;"} </td>
        </tr>
        <tr>
          <td class="label"> {t}Priority{/t}: </td>
          <td class="data"> {$project.prj_priority|wash|default:"&nbsp;"} </td>
          <td class="label" onmouseover="return escape('{t}Company that issues the invoice{/t}')"> {t}Billing company{/t}: </td>
          <td class="data"> {if strlen($project.cpn_id_issuebill)}<a href="company.php?id={$project.cpn_id_issuebill}">{$project.cpn_name_issuebill|wash|default:"&nbsp;"}</a>{else}&nbsp;{/if} </td>
        </tr>

        <tr>
          <td class="label"> {t}Start date{/t}: </td>
          <td class="data"> {if strlen($project.prj_startdate)}{$project.prj_startdate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}{else}&nbsp;{/if} </td>
          <td class="label"> {t}Estimated end{/t}: </td>
          <td class="data"> {if strlen($project.prj_estimatedend)}{if $project.prj_overdue}<span class="overdue">{$project.prj_estimatedend|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}</span>{else}{$project.prj_estimatedend|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}{/if}{else}&nbsp;{/if} </td>
        </tr>
        <tr>
          <td class="label"> {t}End date{/t}: </td>
          <td class="data"> {if strlen($project.prj_enddate)}{$project.prj_enddate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}{else}&nbsp;{/if} </td>
          <td class="label"> {t}Deadline Date{/t}: </td>
          <td class="data"> {if strlen($project.prj_deadline)}{if $project.prj_overdue}<span class="overdue">{$project.prj_deadline|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}</span>{else}{$project.prj_deadline|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}{/if}{else}&nbsp;{/if} </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr><td colspan="4" class="section"> {t}Progress{/t} </td></tr>
  <tr>
    <td align="left" valign="top" colspan="4">

      <table cellspacing="0" width="100%">
        <tr>
          <td class="label"> {t}Estimated manhours{/t}: </td>
          <td class="data num"> &nbsp;{$project.prj_planned_manhours|wash|phpaga_hours2duration|default:"&nbsp;"} </td>
          <td class="label"> {t}Estimated cost manhours{/t}: </td>
          <td class="data num"> {$project.prj_planned_cost_manhours|wash|phpaga_formatamount|default:"&nbsp;"} </td>
          <td class="label"> {t}Estimated cost material{/t}: </td>
          <td class="data num"> {$project.prj_planned_cost_material|wash|phpaga_formatamount|default:"&nbsp;"} </td>
        </tr>
        <tr>
          <td class="label"> {t}Tracked manhours{/t}: </td>
          <td class="data num"> &nbsp;{$project.prj_duration_minutes|phpaga_minutes2duration|default:"&nbsp;"} </td>
          <td class="label"> {t}Tracked cost manhours{/t}: </td>
          <td class="data num"> {$project.humancost.total_amount|phpaga_formatamount|default:"&nbsp;"} </td>
          <td class="label"> {t}Tracked cost material{/t}: </td>
          <td class="data num"> {$project.materials.total_amount|phpaga_formatamount|default:"&nbsp;"} </td>

        </tr>
        <tr>
          <td class="label"> {t}Complete{/t}: </td>
          <td class="data num{if (is_numeric($project.prj_perc_manhours) && ($project.prj_perc_manhours > 100))} warn{/if}"> {$project.prj_perc_manhours|phpaga_formatpercentage|default:"&nbsp;"} %</td>
          <td class="label"> {t}Complete{/t}: </td>
          <td class="data num{if (is_numeric($project.prj_perc_cost_manhours) && ($project.prj_perc_cost_manhours > 100))} warn{/if}"> {$project.prj_perc_cost_manhours|phpaga_formatpercentage|default:"&nbsp;"} %</td>
          <td class="label"> {t}Complete{/t}: </td>
          <td class="data num{if (is_numeric($project.prj_perc_cost_material) && ($project.prj_perc_cost_material > 100))} warn{/if}"> {$project.prj_perc_cost_material|phpaga_formatpercentage|default:"&nbsp;"} %</td>

        </tr>

      </table>
    </td>
  </tr>

  <tr><td colspan="4" class="section"> {t}Relations{/t} </td></tr>
  <tr>
    <td class="label"> {t}Parent project{/t}: </td>
    <td class="data" colspan="3"> {if strlen($project.parent_prj_title)}<a href="project.php?id={$project.prj_prj_id}">{$project.parent_prj_title|wash}</a>{else}&nbsp;{/if} </td>
  </tr>
  <tr>
    <td class="label"> {t}Child projects{/t}: </td>
    <td class="data datawrap" colspan="3"> {if (isset($project.childs) && (count($project.childs) > 0))}{foreach name=fchilds item=child from=$project.childs}<a href="project.php?id={$child.prj_id}">{$child.prj_title|wash}</a>{if !($smarty.foreach.fchilds.last)} | {/if}{/foreach}{else}&nbsp;{/if} </td>
  </tr>
  {if $use_graphviz}
  <tr>
    <td class="label"> {t}Relationship{/t}: </td>
    <td class="data datawrap" colspan="3"> <img src="prjrelations_graph.php?prj_id={$project.prj_id}" alt="{t}Project relationship{/t}" usemap="#G" /> </td>
  </tr>
  {/if}
{*
  <!--
      <tr><td colspan="4" class="section"> {t}Current activities{/t} </td></tr>
    <tr>
      <td colspan="4">
        <div class="imgcontainer">
        <div class="spacer">
        <div class="imgfloat"><img width="{$smarty.const.PHPAGA_MHRSGRAPH_SMALL_WIDTH}" height="{$smarty.const.PHPAGA_MHRSGRAPH_SMALL_HEIGHT}" src="manhours_graph.php?prj_id={$project.prj_id}}&type={$smarty.const.PHPAGA_MANHOURS_DISPLAY_YEAR}&size={$smarty.const.PHPAGA_MANHOURS_GRAPH_SMALL}" /></div>
        <div class="imgfloat"><img width="{$smarty.const.PHPAGA_MHRSGRAPH_SMALL_WIDTH}" height="{$smarty.const.PHPAGA_MHRSGRAPH_SMALL_HEIGHT}" src="manhours_graph.php?prj_id={$project.prj_id}}&type={$smarty.const.PHPAGA_MANHOURS_DISPLAY_MONTH}&size={$smarty.const.PHPAGA_MANHOURS_GRAPH_SMALL}" /></div>
        </div>
        </div>
      </td>
    </tr>
    -->
*}
  {if count($project.files) > 0}
  <tr>
      <td class="section" colspan="4"> {t}Files{/t} </td>
    </tr>

    <tr>
      <td colspan="4">
	<table class="substdtable" cellspacing="0" width="100%">

	  <tr>
	    <th> {t}Name{/t} </th>
	    <th> {t}Date{/t} </th>
	    <th> {t}Person{/t} </th>
	    <th> {t}Type{/t} </th>
	    <th> {t}Actions{/t} </th>
	  </tr>

	  {section name=file loop=$project.files}
	  <tr class="{cycle values="odd,even"}">
	    <td{if ((strlen($project.files[file].file_original_name) > $smarty.const.PHPAGA_SHOWOPDESCLENGHT))} onmouseover="return escape('{$project.files[file].file_original_name|phpaga_popup_sanitizestr}')"{/if}>
	      <a href="download.php?id={$project.files[file].file_id}">{$project.files[file].file_original_name|wash|truncate:$smarty.const.PHPAGA_SHOWOPDESCLENGHT:"...":true}</a>

              {if $smarty.const.PHPAGA_FILES_PREVIEW && $project.files[file].preview}
              <br />
              <a href="download.php?id={$project.files[file].file_id}">
                <img class="preview" src="preview.php?id={$project.files[file].file_id}" alt="{$project.files[file].file_original_name}" title="{$project.files[file].file_original_name|wash}">
              </a>
              {/if}

	    </td>
	    <td> {$project.files[file].file_added|date_format:$smarty.const.PHPAGA_DATETIMEFORMAT_LONG} </td>
	    <td> <a href="person.php?id={$project.files[file].pe_id}">{$project.files[file].pe_person|wash|default:"&nbsp;"}</a> </td>
	    <td> {$project.files[file].file_mimetype|default:"&nbsp;"} </td>
	    <td class="last">
              <a class="ptr" onclick="confirm_delete_file({$project.files[file].file_id}, '{t}File{/t}: {$project.files[file].file_original_name|phpaga_jsmessage_sanitizestr}\n{$project.files[file].file_added|date_format:$smarty.const.PHPAGA_DATETIMEFORMAT_SHORT}');"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
	    </td>
	  </tr>
	  {/section}

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

    {if (isset($opcats) && (count($opcats) > 0))}
    <tr>
      <td class="section" colspan="2"> {t}Task categories{/t} </td>
      <td class="sectionaction" colspan="2"> [ <a href="project.php?id={$project.prj_id}&amp;detail={if $opcat_byperson == 0}{$smarty.const.PHPAGA_OPCGRP_PERSON}{else}0{/if}">{if $opcat_byperson == 0}{t}Details{/t}{else}{t}Overall{/t}{/if}</a> ] </td>
    </tr>
    <tr>
      <td align="left" valign="top" colspan="4">
        {if ($opcat_byperson == 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"> {$project.prj_duration_minutes|phpaga_minutes2duration} </td>
                </tr>
              </table>
            </td>

            <td class="desc last"><img src="opcat_graph.php?prj_id={$project.prj_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=pe from=$opcats.persons}
            <td class="projects"> <a href="person.php?id={$pe.pe_id}">{$pe.pe_person|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=pe from=$opcats.persons}
            <td class="prjduration"> {$pe.duration|phpaga_minutes2duration}</td>
            {/foreach}
            <td class="totalduration"> {$project.prj_duration_minutes|phpaga_minutes2duration} </td>
          </tr>
        </table>
        {/if}
      </td>
    </tr>
    {/if}

    {if ($prjmanage && (isset($project.opcatlist) && (count($project.opcatlist) > 0)))}
    <tr>
      <td class="section" colspan="3"> {t}Task categories: default hourly rates{/t} </td>
<td class="sectionaction">[ <a class="ptr" onclick="toggle_opcatratelist()"><span id="opcatratelistact">{t}Show{/t}</span></a> ]</td>
    </tr>
    <tr>
      <td align="left" valign="top" colspan="4">
<div id="opcatratelist" class="hidden">
        <table class="substdtable" cellspacing="0">
          {section name=opc loop=$project.opcatlist}
          <tr>
            <td class="label last"> {if strlen($project.opcatlist[opc].opcat_color)}<span class="opcol" style="background: {$project.opcatlist[opc].opcat_color|wash};">&nbsp;</span>{else}&nbsp;{/if} </td>
            <td class="label"> {$project.opcatlist[opc].opcat_title|wash} </td>
            {if strlen($project.opcatlist[opc].opcat_hourlyrate|wash)}
            <td class="data number"> {$project.opcatlist[opc].opcat_hourlyrate|wash} </td>
            {else}
            <td class="data">{t}no default rate set{/t}</td>
            {/if}
          </tr>
          {/section}
        </table>
</div>
      </td>
    </tr>

    {/if}

    {if count($project.prj_members) > 0}
    <tr>
      <td class="section" colspan="2"> {t}Project members{/t} </td>
      <td class="sectionaction" colspan="2"> {if $prjmanage}[ <a href="prjmember.php?prj_id={$project.prj_id}">{t}Add project member{/t}</a> ]{else}&nbsp;{/if} </td>
    </tr>
    <tr>
      <td colspan="4">
	<table class="substdtable" cellspacing="0" width="100%">
          <tr>
	    <th> {t}Member{/t} </th>
	    <th> {t}Role{/t} </th>
            {if $prjmanage}
	    <th class="number"> {t}Default hourly rate{/t} </th>
	    <th> {t}Actions{/t} </th>
            {/if}
	  </tr>
	  {section name=members loop=$project.prj_members}
	  <tr class="{cycle values="odd,even"}">
	    <td> <a href="person.php?id={$project.prj_members[members].pe_id}">{$project.prj_members[members].pe_person|wash}</a> </td>
	    <td> {$project.prj_members[members].jcat_title|wash} </td>
            {if $prjmanage}
	    <td class="number"> {if strlen($project.prj_members[members].prjmem_hourlyrate)}{$project.prj_members[members].prjmem_hourlyrate|phpaga_formatamount}{else}&nbsp;{/if} </td>
	    <td class="last">
              <a href="prjmember.php?prj_id={$project.prj_id}&amp;pe_id={$project.prj_members[members].pe_id}&amp;edit={$smarty.const.ACTION_EDIT}"><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="del_prjmember({$project.prj_id},{$project.prj_members[members].pe_id},'{$project.prj_members[members].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>
            </td>
            {/if}
	  </tr>
	  {/section}
	</table>
      </td>
    </tr>
    {/if}

    {if ($prjmanage && isset($project.humancost.details) && (count($project.humancost.details) > 0))}
    <tr>
      <td class="section" colspan="4"> {t}Human cost{/t} </td>
    </tr>

    <tr>
      <td colspan="4">
	<table class="substdtable" cellspacing="0" width="100%">

	  <tr>
	    <th> {t}Person{/t} </th>
	    <th class="number"> {t}Duration{/t} </th>
	    <th class="number"> {t}Cost{/t} </th>
	  </tr>

	  {section name=members loop=$project.humancost.details}
	  <tr class="{cycle values="odd,even"}">
	    <td nowrap> <a href="person.php?id={$project.humancost.details[members].pe_id}">{$project.humancost.details[members].pe_person|wash}</a> </td>
	    <td class="time"> {$project.humancost.details[members].sum_duration|phpaga_minutes2duration} </td>
	    <td class="number last"> {$project.humancost.details[members].amount|phpaga_formatamount} </td>
	  </tr>
	  {/section}

	  <tr>
	    <td> {t}Total{/t} </td>
	    <td class="time"> {$project.humancost.total_duration|phpaga_minutes2duration} </td>
	    <td class="number last"> {$project.humancost.total_amount|phpaga_formatamount} </td>
	  </tr>

	</table>
      </td>
    </tr>

    {/if}

    {if count($project.materials.details) > 0}

    <tr>
      <td class="section" colspan="2"> {t}Material{/t} </td>
      <td class="sectionaction" colspan="2"> {if $prjmember || $prjmanage}[<a href="add_material.php?prj_id={$project.prj_id}">{t}Add material{/t}</a> ]{else}&nbsp;{/if} </td>
    </tr>

    <tr>
      <td colspan="4">
	<table class="substdtable" cellspacing="0" width="100%">

	  <tr>
	    <th> {t}Date{/t} </th>
	    <th class="number"> {t}Prod. code{/t} </th>
	    <th> {t}Material{/t} </th>
	    <th> {t}Description{/t} </th>
	    <th> {t}Person{/t} </th>
	    <th class="number"> {t}Qty.{/t} </th>
	    <th class="number"> {t}Price{/t} </th>
	    <th> {t}Currency{/t} </th>
	    <th> {t}Actions{/t} </th>
	  </tr>

	  {section name=mat loop=$project.materials.details}
          {if ($prjmanage || ($auth_user.pe_id == $project.materials.details[mat].pe_id))}
	  <tr class="{cycle values="odd,even"}">
	    <td> {$project.materials.details[mat].mat_added|date_format:$smarty.const.PHPAGA_DATETIMEFORMAT_SHORT} </td>
	    <td class="number"> {$project.materials.details[mat].mat_prodcode|wash|default:"&nbsp;"} </td>
            <td> {$project.materials.details[mat].mat_name|wash|default:"&nbsp;"} </td>
	    <td{if ((strlen($project.materials.details[mat].mat_desc|wash) > $smarty.const.PHPAGA_SHOWOPDESCLENGHT))} onmouseover="return escape('{$project.materials.details[mat].mat_desc|phpaga_popup_sanitizestr}')"{/if}>
	      {$project.materials.details[mat].mat_desc|wash|truncate:$smarty.const.PHPAGA_SHOWOPDESCLENGHT:"...":true|default:"&nbsp;"}
	    </td>
	    <td> <a href="person.php?id={$project.materials.details[mat].pe_id}">{$project.materials.details[mat].pe_person|wash}</a> </td>
	    <td class="number"> {$project.materials.details[mat].mat_qty|wash|default:"&nbsp;"} </td>
	    <td class="number"> {$project.materials.details[mat].mat_price|wash|phpaga_formatamount|default:"&nbsp;"} </td>
	    <td> {$project.materials.details[mat].curr_name|wash|default:"&nbsp;"} </td>
	    <td class="last"> {strip}
              {if ($project.materials.details[mat].mat_canedit)}
               <a class="ptr" onclick="confirm_delete_material({$project.materials.details[mat].mat_id}, '{t}Product code{/t}: {$project.materials.details[mat].mat_prodcode}\n{$project.materials.details[mat].mat_name|phpaga_jsmessage_sanitizestr}\n{$project.materials.details[mat].mat_added|date_format:$smarty.const.PHPAGA_DATETIMEFORMAT_SHORT}');"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
              {/if}
              {if (isset($project.materials.details[mat].bill_id) && is_numeric($project.materials.details[mat].bill_id)) }
              <a href="bill.php?id={$project.materials.details[mat].bill_id}"><img src="img/phpaga/bill.png" height="16" width="16" border="0" alt="{t}Invoice{/t}" title="{t}Invoice{/t}"></a>
              {/if}

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

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

    {if count($project.expenses) > 0}

    <tr>
      <td class="section" colspan="2"> {t}Expenses{/t} </td>
      <td class="sectionaction" colspan="2"> {if $prjmember || $prjmanage}[<a href="add_expense.php?prj_id={$project.prj_id}">{t}Add expense{/t}</a> ]{else}&nbsp;{/if} </td>
    </tr>

    <tr>
      <td colspan="4">
	<table class="substdtable" cellspacing="0" width="100%">

	  <tr>
	    <th> {t}Description{/t} </th>
	    <th> {t}Date{/t} </th>
	    <th> {t}Person{/t} </th>
	    <th class="number"> {t}Cost{/t} </th>
	    <th> {t}Currency{/t} </th>
	    <th> {t}Actions{/t} </th>
	  </tr>

	  {section name=exp loop=$project.expenses}
          {if ($prjmanage || ($auth_user.pe_id == $project.expenses[exp].pe_id))}
	  <tr class="{cycle values="odd,even"}">
	    <td{if ((strlen($project.expenses[exp].exp_desc) > $smarty.const.PHPAGA_SHOWOPDESCLENGHT))} onmouseover="return escape('{$project.expenses[exp].exp_desc|phpaga_popup_sanitizestr}')"{/if}>
	      {$project.expenses[exp].exp_desc|wash|truncate:$smarty.const.PHPAGA_SHOWOPDESCLENGHT:"...":true}
	    </td>
	    <td> {$project.expenses[exp].exp_date|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
	    <td> <a href="person.php?id={$project.expenses[exp].pe_id}">{$project.expenses[exp].pe_person}</a> </td>
	    <td class="number"> {$project.expenses[exp].exp_sum|phpaga_formatamount} </td>
	    <td> {$project.expenses[exp].curr_name|wash} </td>
	    <td class="last"> &nbsp;
	    </td>
	  </tr>
          {/if}
	  {/section}

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

    {if (isset($project.operations) && (count($project.operations) > 0))}
  <tr>
    <td class="section" colspan="2"> {t}Tasks{/t} </td>
    <td class="sectionaction" colspan="2"> [ {if $ophide}<a href="project.php?id={$project.prj_id}&amp;detail={$opcat_byperson}&amp;ophide=1">{t}Show tasks{/t}</a>{else}<a href="project.php?id={$project.prj_id}&amp;detail={$opcat_byperson}">{t}Hide tasks{/t}</a>{/if}
      {if $prjmember || $prjmanage}| <a href="add_operation.php?prj_id={$project.prj_id}">{t}Add task{/t}</a>{/if} ] </td>
  </tr>
  {if !$ophide}
  <tr>
    <td colspan="4">
      <div id="opdetails"> </div>
      <table class="substdtable" cellspacing="0" width="100%">
        <tr>
          <th> {t}Task{/t} </th>
          <th> {t}Date{/t} </th>
          <th> {t}Person{/t} </th>
          <th> {t}Category{/t} </th>
          <th class="number"> {t}Hours{/t} </th>
          <th> {t}Actions{/t} </th>
        </tr>
        {section name=projects loop=$project.operations}
        <tr class="{cycle values="odd,even"}">
          <td{if ((strlen($project.operations[projects].op_desc) > $smarty.const.PHPAGA_SHOWOPDESCLENGHT))} onmouseover="return escape('{$project.operations[projects].op_desc|phpaga_popup_sanitizestr}')"{/if}>
            {$project.operations[projects].op_desc|wash|truncate:$smarty.const.PHPAGA_SHOWOPDESCLENGHT:"...":true}
          </td>
          <td> {$project.operations[projects].op_startdate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT} </td>
          <td> <a href=person.php?id={$project.operations[projects].pe_id}>{$project.operations[projects].op_person|wash}</a> </td>
          <td> {$project.operations[projects].opcat_title|wash} </td>
          <td class="time"> {$project.operations[projects].op_duration_hrs} </td>
          <td class="last"> {strip}
            <a class="ptr" onclick="viewTaskDetails({$project.operations[projects].op_id}, 'vimg')"><img id="vimg{$project.operations[projects].op_id}" src="img/phpaga/view.png" height="16" width="16" border="0" alt="{t}View{/t}" title="{t}View{/t}"></a>
            {if ($project.operations[projects].op_canedit)}
            <a href="operation.php?id={$project.operations[projects].op_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_op({$project.operations[projects].op_id}, '{$project.operations[projects].op_startdate|date_format:$smarty.const.PHPAGA_DATEFORMAT_SHORT}\n{t}Project{/t}: {$project.operations[projects].prj_title}\n{t}Task{/t}: {$project.operations[projects].op_desc|phpaga_jsmessage_sanitizestr}');"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
            {/if}

            {if (isset($project.operations[projects].bill_id) && is_numeric($project.operations[projects].bill_id)) }
            <a href="bill.php?id={$project.operations[projects].bill_id}"><img src="img/phpaga/bill.png" height="16" width="16" border="0" alt="{t}Invoice{/t}" title="{t}Invoice{/t}"></a>
            {/if}

            {/strip}
          </td>
        </tr>
        {/section}

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

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