<!-- 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">
  <tr>
    <td class="header nobb" colspan="4"> {if !strlen($expinfo.exp_id)}{t}Add expense{/t}{else}{t}Edit expense{/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}Expense{/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=$expinfo.pe_id}
      </select>
    </td>
  </tr>

  <tr>
    <td class="label"> {t}Date{/t}: </td>
    <td class="data" colspan="3">
      <input type="text" class="tinput" name="exp_date" value="{$expinfo.exp_date|wash}" size="10" maxlength="10" id="sdate">
      <input type="image" src="img/phpaga/cal.png" id="btn_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><td class="section" colspan="4">{t}Applicable for expenses in foreign currency{/t}:</td></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>

  <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">
Calendar.setup({
inputField     :    "sdate",                     // id of the input field
ifFormat       :    "%Y-%m-%d",       // format of the input field
showsTime      :    false,                      // will display a time selector
button         :    "btn_sdate",                 // trigger for the calendar (button ID)
singleClick    :    true,                     // double-click mode
showOthers     :    true                       // show overlapping months
});
</script>

<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} -->
