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

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

{if ($edit)}

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

  <fieldset class="search">
    <legend>{t}Edit task category{/t}</legend>

    <label for="">{t}Category{/t}:</label>
    <input type="text" class="tinput" id="opcat_title" name="opcat_title" value="{$rows[0].opcat_title|wash}" size="30" maxlength="30">
    <br>

    <label for="opcat_color">{t}Color{/t}:</label>
    <input type="text" class="tinput" id="opcat_color" name="opcat_color" value="{$rows[0].opcat_color|wash}" size="10" maxlength="10">
    <a href="#" onclick="cp2.select(getEl('opcat_color'),'pick2');return false;" name="pick2" id="pick2">{t}pick{/t}</a>
    <script type="text/javascript">cp.writeDiv()</script>
    <br>

    <label for="opcat_hourlyrate">{t}Default hourly rate{/t}:</label>
    <input type="text" class="tinput number" id="opcat_hourlyrate" name="opcat_hourlyrate" value="{$rows[0].opcat_hourlyrate|wash}" size="10" maxlength="10">
    <br>

    <div class="buttons">
      <input type="submit" name="submit" value="{t}Save{/t}">
      <input type="button" name="cancel" onclick="location.href='opcats.php';" value="{t}Cancel{/t}">
    </div>
  </fieldset>
</form>

{else}

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

  <fieldset class="search">
    <legend>{t}Add a new task category{/t}</legend>

    <label for="opcat_title">{t}Category{/t}:</label>
    <input type="text" class="tinput" id="opcat_title" name="opcat_title" value="{$opcat_title|wash}" size="30" maxlength="30">
    <br>

    <label for="opcat_color">{t}Color{/t}:</label>
    <input type="text" class="tinput" id="opcat_color" name="opcat_color" value="{$opcat_color|wash}" size="10" maxlength="10">
    <a href="#" onclick="cp2.select(getEl('opcat_color'),'pick2');return false;" name="pick2" id="pick2">{t}pick{/t}</a>
    <script type="text/javascript">cp.writeDiv()</script>
    <br>

    <label for="opcat_hourlyrate">{t}Default hourly rate{/t}:</label>
    <input type="text" class="tinput" id="opcat_hourlyrate" name="opcat_hourlyrate" value="{$opcat_hourlyrate|wash}" size="14" maxlength="14">
    <br>

    <input type="submit" name="submit" value="{t}Add{/t}">
  </fieldset>
</form>

{if count($rows) > 0}

<table class="stdtable" cellspacing="0">
  <caption><em>{t}Task categories{/t}</em></caption>
  <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} -->
