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

{if ($edit)}

<script type="text/javascript" src="js/ColorPicker2.js"></script>
<script type="text/javascript">
  var cp = new ColorPicker('window'); // Popup window
  var cp2 = new ColorPicker(); // DIV style
</script>

<form action="{$FORM_ACTION}" method="post">
<input type="hidden" name="action" value="{$smarty.const.ACTION_UPDATE_OK}">
<input type="hidden" name="id" value="{$rows[0].opcat_id}">

<table class="searchtable" cellspacing="0">
  <tr>
    <th colspan="2"> {t}Edit task category{/t} </th>
  </tr>
  <tr>
    <td>{t}Category{/t}: </td>
    <td> <input type="text" class="tinput" name="opcat_title" value="{$rows[0].opcat_title|wash}" size="30" maxlength="30"> </td>
  </tr>
  <tr>
    <td> {t}Color{/t}: </td>
    <td>
      <input type="text" class="tinput" name="opcat_color" value="{$rows[0].opcat_color|wash}" size="10" maxlength="10">
      <a href="#" onclick="cp2.select(document.forms[0].opcat_color,'pick2');return false;" name="pick2" id="pick2">{t}pick{/t}</a>
    </td>
  </tr>
  <tr>
    <td> {t}Default hourly rate{/t}: </td>
    <td>
      <input type="text" class="tinput number" name="opcat_hourlyrate" value="{$rows[0].opcat_hourlyrate|wash}" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td> <input type="submit" name="submit" value="{t}Save{/t}"> </td>
    <td> <input type="button" name="cancel" onclick="location.href='opcats.php';" value="{t}Cancel{/t}"> </td>
  </tr>
</table>

</form>

<script type="text/javascript">cp.writeDiv()</script>

{else}

<form action="{$FORM_ACTION}" method="post">
<input type="hidden" name="action" value="{$smarty.const.ACTION_ADD}">

<table class="searchtable" cellspacing="0">
  <tr>
    <th colspan="2"> {t}Add a new task category{/t} </th>
  </tr>
  <tr>
    <td>{t}Category{/t}: </td>
    <td>
      <input type="text" class="tinput" name="opcat_title" value="{$opcat_title|wash}" size="30" maxlength="30">
      {t}Color{/t}: <input type="text" class="tinput" name="opcat_color" value="{$opcat_color|wash}" size="10" maxlength="10">
    </td>
  </tr>
  <tr>
    <td>{t}Default hourly rate{/t}: </td>
    <td>
      <input type="text" class="tinput" name="opcat_hourlyrate" value="{$opcat_hourlyrate|wash}" size="14" maxlength="14">
      <input type="submit" name="submit" value="{t}Add{/t}">
    </td>
  </tr>
</table>

</form>

{if count($rows) > 0}

<table class="stdtable" cellspacing="0">
  <tr>
    <td class="header" colspan="4"> {t}Task categories{/t} </td>
  </tr>
  <tr>
    <th> {t}Category{/t} </th>
    <th> {t}Color{/t} </th>
    <th class="number"> {t}Default hourly rate{/t} </th>
    <th> {t}Actions{/t} </th>
  </tr>

  {section name=opcat loop=$rows}
  <tr class="{cycle values="odd,even"}">
    <td> {$rows[opcat].opcat_title|wash} </td>
    <td> {if strlen($rows[opcat].opcat_color)}<span class="opcol" style="background: {$rows[opcat].opcat_color|wash};">&nbsp;</span>{$rows[opcat].opcat_color|wash}{else}&nbsp;{/if} </td>
    <td class="number"> {$rows[opcat].opcat_hourlyrate|wash|default:"&nbsp;"} </td>
    <td class="actions">
      <a href="opcats.php?id={$rows[opcat].opcat_id}&amp;action={$smarty.const.ACTION_UPDATE}"><img src="img/phpaga/edit.png" height="16" width="16" border="0" alt="{t}Edit{/t}" title="{t}Edit{/t}"></a>
      <a href="opcats.php?id={$rows[opcat].opcat_id}&amp;action={$smarty.const.ACTION_DELETE}"><img src="img/phpaga/delete.png" height="16" width="16" border="0" alt="{t}Delete{/t}" title="{t}Delete{/t}"></a>
    </td>
  </tr>
  {/section}

</table>

{/if}
{/if}

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