[%# 1.0@bugzilla.org %]

[% title = "Today Worktime" %]

[% style_urls = [ "skins/standard/buglist.css" ] %]

[% PROCESS global/header.html.tmpl
  title = title
  style = style
%]

<style>
.worktime { border-collapse: collapse; }
.worktime td { font-family: "Lucida Console", monospace; font-size: 9pt; }
.worktime textarea { font-family: monospace; font-size: 10pt; }
.worktime .rowP1 { background-color: rgb(250,240,240); }
.worktime .rowP2 { background-color: rgb(240,240,240); }
.worktime .rowP3 { background-color: rgb(230,240,240); }
.worktime .rowP4 { background-color: rgb(220,230,240); }
</style>

<table>
  <tr>
    <td align="left" width="30%">
      My Bugs for last [% lastdays %] days.
    </td>
    <td width="20%">
      <form name="lastdaysform" action="fill-day-worktime.cgi" method="get">
      <input value="Select last days" type="submit">
      <select name="lastdays">
        <option value="1" [% " selected=\"selected\"" IF (!lastdays)||(lastdays==1) %]>1</option>
        <option value="2" [% " selected=\"selected\"" IF (lastdays==2) %]>2</option>
        <option value="3" [% " selected=\"selected\"" IF (lastdays==3) %]>3</option>
        <option value="4" [% " selected=\"selected\"" IF (lastdays==4) %]>4</option>
        <option value="5" [% " selected=\"selected\"" IF (lastdays==5) %]>5</option>
        <option value="6" [% " selected=\"selected\"" IF (lastdays==6) %]>6</option>
        <option value="7" [% " selected=\"selected\"" IF (lastdays==7) %]>7</option>
      </select>
      </form>
    </td>
    <td width="60%">
      &nbsp;
    </td>
    <td width="10%">
      <a href="[% Param('wiki_url') %]Today_Worktime"><b>Help</b></a>
    </td>
  </tr>
</table>

<form name="worktimeform" action="fill-day-worktime.cgi" method="post">
  <input name="lastdays" type="hidden" value=[% lastdays %]>
  <table class="bz_buglist worktime" cellspacing="2" cellpadding="3" border="1" style="border-style:groove" width="100%">
    <tr bgcolor="lightgrey">
      <th width="30">Bug</th>
      <th>Prod/Comp</th>
      <th>Summary</th>
      <th width="130" colspan="3"><small>[% PROCESS today_or_lastdays %]</small><br/>Hours Worked</th>
      <th width="320" >Comment</th>
      <th width="100" colspan="2"><small>total hours</small><br/>Worked/Left</th>
    </tr>

[% parity = 0 %]

[% FOREACH bug = bugs %]
  [% parity = (parity+1) % 3 %]
  <tr class="row[% bug.priority %]">
    <td class="first-child" align="right">
      [% bug.bug_id FILTER bug_link(bug.bug_id) %]
    </td>
    <td>
      [% bug.product | html %]/[% bug.component | html %]
    </td>
    <td>
      [% bug.short_desc FILTER html %]
    </td>
    <td align="right"[% IF bug.product_notimetracking %] style="background-color: #FFC0C0"[% END %]>
      [% bug.today_work_time %]
    </td>
    <td[% IF bug.product_notimetracking %] style="background-color: #FFC0C0"[% END %]>
      +
    </td>
    <td[% IF bug.product_notimetracking %] style="background-color: #FFC0C0"[% END %]>
      <input name="wtime_[% bug.bug_id %]" type="text" size="3" align="right" value="0"
             onchange="javascript: document.worktimeform.newrtime_[% bug.bug_id %].value=Math.round(Math.max(0,[% bug.remaining_time %] - bzParseTime(this.value))*100)/100;"
      >
    </td>
    <td><textarea name="comm_[% bug.bug_id %]" rows="1" cols="50"></textarea></td>
    <td align="right">[% bug.all_work_time %]</td>
    <td align="right">
      <input name="oldrtime_[% bug.bug_id %]" type="hidden" value="[% bug.remaining_time %]">
      <input name="newrtime_[% bug.bug_id %]" readonly="true" type="text" size="3" align="right" value="[% bug.remaining_time %]">
    </td>
  </tr>
[% END %]
</table>

<table style="margin: 0 auto"><tr>
  <td><textarea rows="8" cols="80" wrap="virtual" name="worktime" style="font-family: monospace"></textarea></td>
  <td>
    <p><b>&larr; Import worktime from text line-by-line.</b> Available formats:</p>
    <ul>
      <li style="margin-bottom: 8px">
        <tt style="border: 1px solid gray; background: white; padding: 2px">BUGID TIME COMMENT</tt><br />
        TIME is <tt>HH:MM</tt> or simply a floating point number. Time also may be negative.
      </li>
      <li>
        <tt style="border: 1px solid gray; background: white; padding: 2px">DD.MM.YYYY HH:MM - HH:MM classification - Bug BUGID COMMENT</tt><br />
        (start time - end time, "Bug" word is optional, this is old standard)
      </li>
    </ul>
  </td>
</tr></table>

<table width="100%"><tr>
  <td align="center">
    [% PROCESS today_or_lastdays %]
    Hours Worked: <b><font size="+1"><tt>[% totaltime %]</tt></font></b>
  </td><td width="150px" align="right">
    [% IF prevdate1 %]
      Worked Hours for the
      <a href="summarize_time.cgi?start_date=[% prevdate1 %]&end_date=[% prevdate1 %]&my_activity=1&do_report=1">[% prevdate1 %]</a>
    [% END %]
  </td></tr>
  <tr></td>
  <td align="center">
<input value="Commit" type="submit">
</td></tr></table>
</form>

[%############################################################################%]
[%# Page Footer                                                              #%]
[%############################################################################%]

[% PROCESS global/footer.html.tmpl %]

[% BLOCK today_or_lastdays %]
    [% IF lastdays>1 %]
      Last [% lastdays %] Days
    [% ELSE %]
      Today
    [% END %]
[% END %]
