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

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

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

{if (!is_array($select_person)) || (count($select_person) == 0)}
<div class="msg">
{if $is_owner_or_manager}
{t}Expenses 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">
  <caption><em>{if !strlen($expinfo.exp_id)}{t}Add expense{/t}{else}{t}Edit expense{/t}{/if}</em></caption>
  <tr>
    <th colspan="4"> {t}Project{/t} </th>
  </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>
    <th colspan="4"> {t}Expense{/t} </th>
  </tr>

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

  <tr>
    <td class="label"> {t}Date{/t}: </td>
    <td class="data" colspan="3">
      <input type="text" class="tinput format-y-m-d divider-dash no-transparency" name="exp_date" value="{$expinfo.exp_date|wash}" size="10" maxlength="10" id="sdate">
    </td>
  </tr>

  <tr>
    <td class="label"> {t}Amount{/t}: </td>
    <td class="data">
      <input type="text" class="tinput" name="exp_sum" value="{$expinfo.exp_sum|wash}" size="10" maxlength="10">
    </td>
    <td class="label"> {t}Currency{/t}: </td>
    <td class="data">
      <select name="curr_id">
        {html_options options=$select_curr selected=$expinfo.curr_id}
      </select>
    </td>
  </tr>
  <tr>
    <td class="label"> {t}Description{/t}: </td>
    <td class="data" colspan="3">
      <textarea name="exp_desc" cols="50" rows="6" wrap="virtual">{$expinfo.exp_desc|wash}</textarea>
    </td>
  </tr>

  <tr><th colspan="4">{t}Applicable for expenses in foreign currency{/t}:</th></tr>

  <tr>
    <td class="label">{t}Amount{/t}: </td>
    <td class="data">
      <input type="text" class="tinput" name="exp_sum_foreign" value="{$expinfo.exp_sum_foreign|wash}" size="10" maxlength="10">
    </td>
    <td class="label"> {t}Foreign currency{/t}: </td>
    <td class="data">
      <select name="curr_id_foreign">
        {html_options options=$select_curr_foreign selected=$expinfo.curr_id_foreign}
      </select>
    </td>
  </tr>

  <tr>
    <td class="label">{t}Exchange rate{/t}: </td>
    <td class="data" colspan="3">
      <input type="text" class="tinput" name="exp_exchange_rate" value="{$expinfo.exp_exchange_rate|wash}" size="10" maxlength="10">
      <input type="button" name="btn_calcamount" onClick="calcamount()"; value="{t}Calculate{/t}">
  </tr>
</table>

<div class="buttons">
  <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}">
</div>

</form>

{literal}
<script type="text/javascript">
function calcamount() {
    document.form.exp_sum.value = document.form.exp_sum_foreign.value * document.form.exp_exchange_rate.value;
}
</script>
{/literal}

{/if}

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