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

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

     function getMemberParm() {

    showPageStatus();

    AjaxRequest.get(
    {
        'url':'service.php?saction={/literal}{$smarty.const.ACTION_SERVICE_MEMBERPARM}{literal}&id=' + document.getElementById("person").value,
            'onSuccess':function(req){

            var response = req.responseText;
            if(response.indexOf('||' != -1)) {
                var update = new Array();
                update = response.split('||');
                document.getElementById("jobcat").value = update[0];
                document.getElementById("rate").value = update[1];
            }
            hidePageStatus();

        },

            'onError':function(req){
                alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);
                hidePageStatus();
            }
    }
  );
}

 </script>
{/literal}

<form action="{$SELF}" method="post">
  {if $mode_edit}
  <input type="hidden" name="action" value="{$smarty.const.ACTION_UPDATE}">
  {else}
  <input type="hidden" name="action" value="{$smarty.const.ACTION_PRJ_MEMBER_ADD}">
  {/if}
  <input type="hidden" name="prj_id" value="{$member.prj_id}">
  <input type="hidden" name="substatus" value="1">

  <table class="stdtable" cellspacing="0">
    <tr>
      <td colspan="2" class="header"> {if $mode_edit}{t}Edit project member{/t}{else}{t}Add project member{/t}{/if} </td>
    </tr>
    <tr>
      <td class="label"> {t}Person{/t}: </td>
      <td class="data">
        {if $mode_edit}
        <input type="hidden" name="pe_id" value="{$member.pe_id}">
        {$member.pe_person|wash|default:"&nbsp;"}
        {else}
        <select name="pe_id" id="person" onchange="getMemberParm();">
          {html_options options=$persons selected=$member.pe_id}
        </select>
        {/if}
      </td>
    </tr>
    <tr>
      <td class="label">{t}Job category{/t}: </td>
      <td class="data">
        <select name="jcat_id" id="jobcat">
          {html_options options=$jobcats selected=$member.jcat_id}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label">{t}Hourly wage rate{/t}: </td>
      <td class="data datawrap">
        <input type="text" class="tinput number" name="prjmem_hourlyrate" id="rate" value="{$member.prjmem_hourlyrate|wash}" size="10" maxlength="14">
        <br />
        {t}This value has precedence over the project's default hourly rates per task category, but not over the member's hourly rate per task category for this specific project (below).{/t} <br />
        {t}Leave this field empty if you want this project's default settings to apply to this member. See below for more information.{/t}
      </td>
    </tr>
    <tr>
      <td colspan="2" class="section">{t}Hourly rates per task category (optional){/t}</td>
    </tr>
    <tr>
      <td colspan="2" class="data datawrap">{t}You can define default hourly rates per task category for this project member.{/t} <br />
        {t}The precedence of hourly rates is as follows:{/t}
        <ol>
          <li>{t}Member's hourly rate for a specific task category and project{/t}</li>
          <li>{t}Member's hourly wage rate for the given project, independent of the task category{/t}</li>
          <li>{t}Default rate for the given task category and project{/t}</li>
        </ol>
      </td>
    </tr>
    <tr>
      <td colspan="2">
        <table class="substdtable" cellspacing="0">
          <tr>
            <th colspan="2">{t}Category{/t}</th>
            <th>{t}Member's hourly rate{/t}</th>
            <th>{t}Project's default hourly rate{/t}</th>
          </tr>
          {foreach item=opcat from=$opcatlist}
          <tr>
            <td class="label last">
              {if strlen($opcat.opcat_color)}<span class="opcol" style="background: {$opcat.opcat_color|wash};">&nbsp;</span>{else}&nbsp;{/if}
            </td>

            <td class="label"> {$opcat.opcat_title} </td>
            <td class="data">
              <input type="text" class="tinput number" name="opcat_rates[{$opcat.opcat_id}]" value="{$opcat.opcat_hourlyrate_person|wash}">
            </td>
            <td class="data number"> {$opcat.opcat_hourlyrate_project|wash|default:"&nbsp;"}</td>
          </tr>
          {/foreach}
        </table>
      </td>
    </tr>
    <tr><td colspan="2">&nbsp;</td></tr>
    <tr>
      <td colspan="2">
        <input type="submit" value="{t}Submit{/t}">
        <input type="button" value="{t}Cancel{/t}" onclick="location.href='project.php?id={$member.prj_id}';">
      </td>
    </tr>
  </table>

</form>

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