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

{if strlen($STATUSMSG)}<p>{$STATUSMSG}</p>{/if}

{if ($prjinfo.prj_id == 0)}
{literal}
<script type="text/javascript">
    function setSelCompany() {

    newcpn1 = document.getElementById("newcpn");
    field = document.getElementById('s_cpn_id');
    newval = field.options[field.selectedIndex].value;

    if (newval == -10) {
        document.getElementById('new_cpn').value = 1;
        newcpn1.style.display = 'block';
        document.getElementById("cpn_name").focus();
    } else {
        document.getElementById('new_cpn').value = 0;
        newcpn1.style.display = 'none';
    }
}
</script>
{/literal}
{/if}

<form action="{$FORM_ACTION}" method="post" name="editprj" id="editprj">
  <input type="hidden" name="prj_id" value="{$prjinfo.prj_id}">
  <input type="hidden" name="quot_id" value="{$prjinfo.quot_id}">
  <input type="hidden" id="new_cpn" name="new_cpn" value="{$prjinfo.new_cpn}">

  <table class="stdtable" cellspacing="0">
    <caption><em>{if ($prjinfo.prj_id == 0)}{t}Add project{/t}{else}{t}Edit project{/t}{/if}</em></caption>
    <tr>
      <td class="label req">{t}Title{/t}: </td>
      <td class="data"><input type="text" class="tinput" name="prj_title" id="prj_title" value="{$prjinfo.prj_title|wash}" size="50" maxlength="200"></td>
    </tr>
    <tr>
      <td class="label req">{t}Customer{/t}: </td>
      <td class="data">
        <select name="cpn_id" id="s_cpn_id"{if ($prjinfo.prj_id == 0)} onchange="setSelCompany();"{/if}>
	  {html_options options=$select_cpn selected=$prjinfo.cpn_id}
        </select>
        {if ($prjinfo.prj_id == 0)}
        <div id="newcpn">
          {include file="edit_company.tpl.html"}
        </div>
        {/if}
      </td>
    </tr>
    <tr>
      <td class="label req">{t}Category{/t}: </td>
      <td class="data">
        <select name="prjcat_id">
	  {html_options options=$select_prjcat selected=$prjinfo.prjcat_id}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label">{t}Status{/t}: </td>
      <td class="data">
        <select name="prj_status">
	  {html_options options=$select_prjstat selected=$prjinfo.prj_status}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label">{t}Priority{/t}: </td>
      <td class="data">
        <select name="prj_priority">
	  {html_options options=$select_priority selected=$prjinfo.prj_priority}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label"> {t}Billable{/t}: </td>
      <td class="data">
        <select name="prj_billabletype">
	  {html_options options=$select_prj_billabletype selected=$prjinfo.prj_billabletype}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label"> {t}Billing company{/t}: </td>
      <td class="data">
        <select name="cpn_id_issuebill">
	  {html_options options=$select_cpn_issuebill selected=$prjinfo.cpn_id_issuebill}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label"> {t}Parent project{/t}: </td>
      <td class="data">
        <select name="prj_prj_id">
	  {html_options options=$select_parent_project selected=$prjinfo.prj_prj_id}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label">{t}Description{/t}: </td>
      <td class="data">
        <textarea name="prj_desc" cols="50" rows="3" wrap="virtual">{$prjinfo.prj_desc|wash}</textarea>
      </td>
    </tr>
    <tr>
      <td class="label"> {t}Project manager{/t}: </td>
      <td class="data">
        <select name="prj_manager_pe_id">
	  {html_options options=$select_prj_manager selected=$prjinfo.prj_manager_pe_id}
        </select>
      </td>
    </tr>
    <tr>
      <td class="label">{t}Start date{/t}: </td>
      <td class="data"><input type="text" class="tinput format-y-m-d divider-dash no-transparency" name="prj_startdate" value="{$prjinfo.prj_startdate|wash}" size="10" maxlength="10" id="sdate"></td>
    </tr>
    <tr>
      <td class="label">{t}Estimated end{/t}: </td>
      <td class="data"><input type="text" class="tinput format-y-m-d divider-dash no-transparency" name="prj_estimatedend" value="{$prjinfo.prj_estimatedend|wash}" size="10" maxlength="10" id="cdate"></td>
    </tr>
    <tr>
      <td class="label">{t}Deadline Date{/t}: </td>
      <td class="data"><input type="text" class="tinput format-y-m-d divider-dash no-transparency" name="prj_deadline" value="{$prjinfo.prj_deadline|wash}" size="10" maxlength="10" id="ddate"></td>
    </tr>
    {if ($prjinfo.prj_id != 0)}
    <tr>
      <td class="label">{t}End date{/t}: </td>
      <td class="data"><input type="text" class="tinput format-y-m-d divider-dash no-transparency" name="prj_enddate" value="{$prjinfo.prj_enddate|wash}" size="10" maxlength="10" id="edate"></td>
    </tr>
    {/if}
    <tr>
      <td class="label">{t}Estimated manhours{/t}: </td>
      <td class="data"><input type="text" class="tinput number" name="prj_planned_manhours" value="{$prjinfo.prj_planned_manhours|wash}" size="12" maxlength="15">
      </td>
    </tr>
    <tr>
      <td class="label">{t}Estimated cost manhours{/t}: </td>
      <td class="data"><input type="text" class="tinput number" name="prj_planned_cost_manhours" value="{$prjinfo.prj_planned_cost_manhours|wash}" size="12" maxlength="15">
      </td>
    </tr>
    <tr>
      <td class="label">{t}Estimated cost material{/t}: </td>
      <td class="data"><input type="text" class="tinput number" name="prj_planned_cost_material" value="{$prjinfo.prj_planned_cost_material|wash}" size="12" maxlength="15">
      </td>
    </tr>
  </table>

  <div class="buttons">
    <input type="submit" name="submit" value="{t}Submit{/t}">
    <input type="button" name="cancel" value="{t}Cancel{/t}" onclick="location.href='{if strlen($prjinfo.prj_id) && ($prjinfo.prj_id != 0)}project.php?id={$prjinfo.prj_id}{else}projects.php{/if}';">
  </div>

  <table class="stdtable" cellspacing="0">
    <caption><em>{t}Hourly rates per task category (optional){/t}</em></caption>
    <tr>
      <td colspan="2" class="data datawrap">{t}You can define default hourly rates per task type for this project.{/t} <br />
        {t}These rates are taken in consideration when no hourly rate per task type is configured for a project member.{/t}</td>
    </tr>
    {foreach item=opcat from=$prjinfo.opcatlist}
    <tr>
      <td class="label"> {$opcat.opcat_title|wash}
        <span class="opcol" style="background: {if strlen($opcat.opcat_color)}{$opcat.opcat_color|wash}{else}transparent{/if};">&nbsp;</span>
      </td>
      <td class="data">
        <input type="text" class="tinput number" name="opcat_rates[{$opcat.opcat_id}]" value="{$opcat.opcat_hourlyrate|wash}">
      </td>
    </tr>
    {/foreach}
  </table>
</form>

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

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