{literal}
<script language="JavaScript">
<!--
function deleteTimeEntry(time_id)
{
    if (!confirm('{/literal}{t escape=js}This action will permanently delete the specified time tracking entry.{/t}{literal}')) {
        return false;
    } else {
        var features = 'width=420,height=200,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
        var popupWin = window.open('popup.php?cat=delete_time&id=' + time_id, '_popup', features);
        popupWin.focus();
    }
}
function addTimeEntry()
{
    var features = 'width=550,height=250,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
    {/literal}
    var issue_id = {$smarty.get.id};
    var popupWin = window.open('time_tracking.php?iss_id=' + issue_id, 'time_tracking_' + issue_id, features);
    {literal}
    popupWin.focus();
}
//-->
</script>
{/literal}
<table width="100%" bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
<form name="add_time_form" method="post" action="#">
  <tr>
    <td width="100%">
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2">
        <tr>
          <td class="default" nowrap>
            <b>{t}Time Tracking{/t} ({$time_entries|@count})</b>
          </td>
          <td align="right" class="default">
          [ <a class="link" href="#top">{t}Back to Top{/t}</a> ]
            {if $browser.ie5up or $browser.ns6up or $browser.gecko or $browser.safari or $browser.opera5up or $browser.safari or $browser.opera5up}
            [ <a id="time_tracker_link" class="link" href="javascript:void(null);" onClick="javascript:toggleVisibility('time_tracker');">{get_innerhtml element_name="time_tracker" total=$time_entries|@count}</a> ]
            {/if}
          </td>
        </tr>
        <tr>
          <td colspan="2" class="default" width="100%">
            <table width="100%" cellpadding="2" cellspacing="1">
              <tr id="time_tracker1" {get_display_style element_name="time_tracker" total=$time_entries|@count} bgcolor="{$internal_color}">
                <td class="default_white" align="center" width="5">#</td>
                <td class="default_white" nowrap>{t}Date of Work{/t}</td>
                <td class="default_white" nowrap>{t}User{/t}</td>
                <td class="default_white">{t}Time Spent{/t}</td>
                <td class="default_white">{t}Category{/t}</td>
                <td width="50%" class="default_white">{t}Summary{/t}</td>
              </tr>
              {section name="i" loop=$time_entries}
              {cycle values=$cycle assign="row_color"}
              <tr id="time_tracker{$smarty.section.i.iteration+1}" {get_display_style element_name="time_tracker" total=$time_entries|@count} bgcolor="{$row_color}">
                <td class="default" align="center">{$smarty.section.i.iteration}</td>
                <td class="default" nowrap>{$time_entries[i].ttr_created_date}</td>
                <td class="default" nowrap>
                  {$time_entries[i].usr_full_name}
                  {if $current_user_id == $time_entries[i].ttr_usr_id}[ <a class="link" href="javascript:void(null);" onClick="javascript:deleteTimeEntry({$time_entries[i].ttr_id});">delete</a> ]{/if}
                </td>
                <td class="default">{$time_entries[i].formatted_time}</td>
                <td class="default" nowrap>{$time_entries[i].ttc_title}</td>
                <td class="default">{$time_entries[i].ttr_summary}</td>
              </tr>
              {if $smarty.section.i.last}
              <tr>
                <td bgcolor="{$internal_color}" colspan="3" class="default_white" align="right" width="30%">{t}Total Time Spent{/t}:</td>
                <td bgcolor="{$dark_color}" colspan="3" class="default" width="70%">{$total_time_spent}</td>
              </tr>
              {/if}
              {sectionelse}
              <tr id="time_tracker2" {get_display_style element_name="time_tracker" total=$time_entries|@count}>
                <td colspan="6" bgcolor="{$light_color}" align="center" class="default">
                  <i>{t}No time tracking entries could be found.{/t}</i>
                </td>
              </tr>
              {/section}
              {if $current_role > $roles.viewer}
              <tr>
                <td colspan="6" bgcolor="{$internal_color}" align="center" width="100%" nowrap>
                  <input type="button" value="{t}Add Time Entry{/t}" class="button" onClick="addTimeEntry()">
                </td>
              </tr>
              {/if}
            </table>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</form>
</table>
