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

{if isset($STATUSMSG) && strlen($STATUSMSG)}
{$STATUSMSG}
{/if}

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

<form action="{$smarty.const.PHPAGA_SELF}" method="post" name="form">
<input type="hidden" name="mat_id" value="{$matinfo.mat_id}">
<input type="hidden" name="prj_id" value="{$matinfo.prj_id}">

{if (!is_array($select_person)) || (count($select_person) == 0)}
<div class="msg">
{if $is_owner_or_manager}
{t}Materials can only be tracked for members. This project does currently not have any members.{/t}
{else}
{t}You are not a member of this project.{/t}
{/if}
</div>
{else}

<table class="stdtable" cellspacing="0">
  <tr>
    <td class="header nobb" colspan="4"> {if !strlen($matinfo.mat_id)}{t}Add material{/t}{else}{t}Edit material{/t}{/if} </td>
  </tr>

  <tr>
    <td class="section" colspan="4"> {t}Project{/t} </td>
  </tr>

  <tr>
    <td class="label"> {t}Project{/t}: </td>
    <td class="data" colspan="3"> <a href="project.php?id={$prjInfo.prj_id}">{$prjInfo.prj_title|wash|default:"&nbsp;"}</a> </td>
  </tr>
  <tr>
    <td class="label"> {t}Customer{/t}: </td>
    <td class="data" colspan="3"> <a href="company.php?id={$prjInfo.cpn_id}">{$prjInfo.cpn_name|wash|default:"&nbsp;"}</a> </td>
  </tr>
  <tr>
    <td class="label"> {t}Start date{/t}: </td>
    <td class="data"> {$prjInfo.prj_startdate|wash|date_format:$smarty.const.PHPAGA_DATEFORMAT_LONG|default:"&nbsp;"} </td>
    <td class="label"> {t}Projected end{/t}: </td>
    <td class="data"> {$prjInfo.prj_estimatedend|wash|default:"&nbsp;"} </td>
  </tr>
  <tr>
    <td class="label"> {t}Category{/t}: </td>
    <td class="data"> {$prjInfo.prjcat_title|wash|default:"&nbsp;"} </td>
    <td class="label"> {t}Hours{/t}: </td>
    <td class="data"> {$HOURS_SO_FAR|default:"&nbsp;"} </td>
  </tr>

  <tr>
    <td class="section" colspan="4"> {t}Material{/t} </td>
  </tr>

  <tr>
    <td class="label"> {t}Person{/t}: </td>
    <td class="data" colspan="3">
      <select name="pe_id">
        {html_options options=$select_person selected=$matinfo.pe_id}
      </select>
    </td>
  </tr>

  <tr>
    <td class="label"> {t}Product code{/t}: </td>
    <td class="data">
      <input type="text" class="tinput" name="mat_prodcode" value="{$matinfo.mat_prodcode|wash}" size="18" maxlength="18" id="mat_prodcode" onblur="getMatProdInfo();">
      <input type="hidden" name="prod_id" value="{$matinfo.prod_id|wash}" id="prod_id">
    </td>
    <td class="label"> {t}Qty.{/t}: </td>
    <td class="data">
      <input type="text" class="tinput" name="mat_qty" value="{$matinfo.mat_qty|wash}" size="4" maxlength="10" id="mat_qty">
    </td>
  </tr>

  <tr>
    <td class="label"> {t}Material{/t}: </td>
    <td class="data" colspan="3">
      <input type="text" class="tinput" name="mat_name" value="{$matinfo.mat_name|wash}" size="60" maxlength="100" id="mat_name">
    </td>
  </tr>

  <tr>
    <td class="label"> {t}Price{/t}: </td>
    <td class="data">
      <input type="text" class="tinput" name="mat_price" value="{$matinfo.mat_price|wash}" size="12" maxlength="12" id="mat_price">
    </td>
    <td class="label"> {t}Currency{/t}: </td>
    <td class="data">
      <select name="curr_id">
        {html_options options=$select_curr selected=$matinfo.curr_id}
      </select>
    </td>
  </tr>
  <tr>
    <td class="label"> {t}Description{/t}: </td>
    <td class="data" colspan="3">
      <textarea name="mat_desc" cols="50" rows="6" wrap="virtual">{$matinfo.mat_desc|wash}</textarea>
    </td>
  </tr>
  <tr>
    <td colspan="4"><input type="submit" name="submit" value="{t}Submit{/t}"> <input type="button" onclick="location.href='project.php?id={$prjInfo.prj_id}';" value="{t}Cancel{/t}"></td>
  </tr>
</table>

</form>

{literal}
<script type="text/javascript">
document.getElementById('mat_prodcode').focus();
</script>
{/literal}

{/if}

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