<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="layout.html" />
  <xi:include href="macros.html" />
  <head>
    <script type="text/javascript" src="${chrome.htdocs_location}js/folding.js"></script>
    <script type="text/javascript">
      jQuery(document).ready(function($) {
        $("fieldset legend.foldable").enableFolding(false);
        /* Hide the filters for saved queries. */
        $("#options").toggleClass("collapsed");
      });
    </script>

    <style type="text/css">
      form fieldset.collapsed { 
        border-width: 0px;
        margin-bottom: 0px;
        padding: 0px .5em;
      }
      fieldset legend.foldable :link,
      fieldset legend.foldable :visited { 
        background: url(${chrome.htdocs_location}expanded.png) 0 50% no-repeat;
        border: none;
        color: #666;
        font-size: 110%;
        padding-left: 16px;
      }
      fieldset legend.foldable :link:hover, fieldset legend.foldable :visited:hover {
        background-color: transparent;
      }
      
      fieldset.collapsed legend.foldable :link, fieldset.collapsed legend.foldable :visited { 
        background-image: url(${chrome.htdocs_location}collapsed.png);  
      }
      fieldset.collapsed table, fieldset.collapsed div { display: none }

      table.list {
        width:100%;
        border-collapse: collapse;
        margin-bottom: 6px;
      }

      table.with-cells td {
        border: 1px solid #d7d7d7;
      }

      table.list td {
        padding:2px;
      }

      table.list thead th {
        text-align: center;
        background: #eee;
        border: 1px solid #d7d7d7;
        color: #777;
      }

      table.list tbody th {
        font-weight: bold;
        background: #eed;
        border: 1px solid #d7d7d7;
        color: #777;
      }


      .ticket {
        font-size: 10px;
      }


      .textright {
        text-align:right;
      }

      td.active {
         background-color:#fff;
      }
      .holiday {
        background-color: #f6f7f8;
        color: black;
      }
      .today {
        background-color: #ffe0e0;
      }

      .tip {
        position: static;
      }

      .tip span.popup{
        position: absolute;
        visibility: hidden;
        color: black;
        border:1px solid #555;
        background-color: #ffe;
        font-size: 8pt;
        padding: 3px;
        /*IE6 Hack*/ min-width: 400px; width: auto; _width: 400px;
      }

      .tip:hover span.popup{
        visibility: visible;
        z-index: 100;
      }

    </style>
  </head>
  <body>
    <form>
      <fieldset id="options">
        <legend class="foldable">${_('Options')}</legend>
        <table class="list">
          <tr>
            <td>
            </td>
            <td>
              <label>
              ${_('Milestone')}
              <select name="selected_milestone">
                <option py:for="m in milestones" value="${m.name}" selected="${selected_milestone==m.name or None}">${m.name}</option>
              </select>
              </label>
              <label>
              <input type="checkbox" name="show_my_ticket" checked="$show_my_ticket"
              />${_('Show only my tickets')}
              </label>
              <label>
              <input type="checkbox" name="show_closed_ticket" checked="$show_closed_ticket"
              />${_('Include closed tickets')}
              </label>
            </td>
            <td align="right">
              <input type="submit" value="${_('Update')}" />
            </td>
          </tr>
        </table>
      </fieldset>
      <table class="list">
        <tr>
          <td py:with="btntxt = weekly and '%s %s' % (_(month_tbl[prev.month]), prev.day) or _(month_tbl[prev.month])">
            <input type="button" value="&lt;&lt; ${btntxt}" ACCESSKEY="J" onclick="form.year.value = ${prev.year}; form.month.value = ${prev.month}; form.day.value = ${prev.day}; form.submit();"/>
          </td>
          <td align="center">
            <select name="year" onchange="form.day.value = 1; form.weekly.value = 0;">
              <option py:for="y in range(current.year-3,current.year+4)"
                     value="$y"
                     selected="${y==current.year or None}">$y</option>
            </select>
            ${_('Year')}
            <select name="month" onchange="form.day.value = 1; form.weekly.value = 0;">
              <option py:for="m in [1,2,3,4,5,6,7,8,9,10,11,12]"
                     value="$m" selected="${m==current.month or None}">${_(month_tbl[m])}</option>
            </select>

            <input type="submit" value="${_('Update')}" />
            <label ACCESSKEY="M" onclick="form.year.value = ${date.today().year}; form.month.value = ${date.today().month}; form.day.value = ${date.today().day}; form.submit();"/>
          <py:choose>
            <input py:when="not weekly" type="image" ACCESSKEY="I" onclick="form.weekly.value = 1" src="${href.chrome('tc/img/zoom_in.png')}" alt="${_('Zoom In')}"/>
            <input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('tc/img/zoom_in_g.png')}"/>
          </py:choose>
          <py:choose>
            <input py:when="weekly" type="image" ACCESSKEY="K" onclick="form.weekly.value = 0;" src="${href.chrome('tc/img/zoom_out.png')}" alt="${_('Zoom Out')}"/>
            <input py:otherwise="" type="image" disabled="disabled" src="${href.chrome('tc/img/zoom_out_g.png')}"/>
          </py:choose>
            <input name="day" type="hidden" value="${current.day}" />
            <input name="weekly" type="hidden" value="${weekly}" />
          </td>
          <td align="right" py:with="btntxt = weekly and '%s %s' % (_(month_tbl[next.month]), next.day) or _(month_tbl[next.month])">
            <input type="button" value="${btntxt} &gt;&gt;" ACCESSKEY="L" onclick="form.year.value = ${next.year}; form.month.value = ${next.month}; form.day.value = ${next.day}; form.submit();"/>
          </td>
        </tr>
      </table>
    </form>
    <table py:if="sum_estimatedhours != None" class="list">
      <div style="font-size:11px;">&nbsp; ${_('Total Hours')}: ${sum_totalhours}h &nbsp;/&nbsp;
      ${_('Estimated Hours')}: ${sum_estimatedhours}h</div>
    </table>
    <table class="list with-cells">
      <thead>
        <tr py:with="weekdays = [_('Monday'), _('Tuesday'), _('Wednesday'),
        _('Thursday'), _('Friday'), _('Saturday'), _('Sunday')]">
            <th></th>
          <py:for each="d in range(7)" py:with="mday= first+ timedelta(d);wk=mday.weekday();">
            <th style="width: 14%;">${weekdays[wk]}</th>
          </py:for>
        </tr>
      </thead>

      <tbody>
        <tr py:for="w in range(((last - first).days + 1)/7)" style="height: ${weekly and 300 or 60}px;">
          <th></th>
          <py:for each="d in range(7)" py:with="mday= first+ timedelta(w*7+d);holiday_desc= days[mday].get('holiday_desc');">
          <td class="${days[mday]['kind']}" style="width: 14%;" valign="top">
            <div class="textright">
              <span py:attrs="{'title':holiday_desc}" py:strip="holiday_desc==None" >
                <py:if test="weekly or mday.day==1">${mday.month}/</py:if>${mday.day}
              </span>
            </div>
            <py:for each="c in range(len(days[mday]['ticket']))">
            <div class="ticket" py:with="t=tickets[days[mday]['ticket'][c]['num']]">
              <a class="tip" href="${req.href.ticket()}/${t['id']}">
                <img src="${href.chrome('tc/img/arrow_'+days[mday]['ticket'][c]['img']+'.png')}" alt="+" />
                <s py:strip="t['status']!='closed'"><span class="type">${t['type']}</span>#${t['id']}</s>:${t['summary']}
                <span class="popup">
                  <br />
                  <s py:strip="t['status']!='closed'">  ${t['type']}#${t['id']}</s>: ${t['summary']}<br />
                  <br />
                  <strong>${_('Start date')}</strong>:      <span py:if="t['due_assign'] != None">${t['due_assign'].strftime(dateFormat)}</span>
                    <span py:if="t['status']!='closed'">(${t['status']} ${t['complete']}%)</span><br/>
                  <strong>${_('End date')}</strong>:            <span py:if="t['due_close'] != None">${t['due_close'].strftime(dateFormat)}</span>
                    <span py:if="t['status']=='closed'">(${t['status']}: ${t['resolution']})</span><br/>
                  <strong>${_('Owner')}</strong>:      ${format_author(t['owner'])}<br />
                  <strong>${_('Priority')}</strong>:            ${t['priority']}<br/>
                <py:if test="t['estimatedhours']!=None">
                  <strong>${_('Total Hours')}</strong>: ${t['totalhours']}h &nbsp;/&nbsp;
                  <strong>${_('Estimated Hours')}</strong>: ${t['estimatedhours']}h<br/>
                </py:if>
                  <pre> ${t['description']}</pre>
                </span>
              </a>
            </div>
            </py:for>

            <py:for each="c in range(len(days[mday]['milestone']))" py:if="'MILESTONE_VIEW' in req.perm">
              <div class="ticket" py:with="m=milestones[days[mday]['milestone'][c]]">
                  <a class="tip" href="${req.href.milestone()}/${m['name']}">
                    <s py:strip="m['completed']!=True"><img src="${href.chrome('tc/img/package.png')}" />${m['name']}</s>
                    <span class="popup">
                      <br />
                      <img src="${href.chrome('tc/img/package.png')}" />${m['name']}<br />
                      <br />
                      <strong>${_('Due')}</strong>: ${m['due'].strftime(dateFormat)}<br />
                      <pre> ${m['description']}</pre>
                    </span>
                  </a>
              </div>
            </py:for>
          </td>
          </py:for>
        </tr>
      </tbody>
    </table>
  </body>
</html>
