#from kojiweb import util

#def printOption(value, label=None)
#if not $label
#set $label = $value
#end if
<option value="$value"#if $value == $days then ' selected="selected"' else ''#>$label</option>
#end def

#include "includes/header.chtml"

  <h4>Builds by Target#if $days != -1 then ' in the last %i days' % $days else ''#</h4>
  <table class="data-list">
    <tr style="text-align: left">
      <td colspan="3">
        <form action="">
          Show last
          <select onchange="javascript: window.location = 'buildsbytarget?days=' + this.value + '$util.passthrough($self, 'order')';">
            $printOption(1)
            $printOption(3)
            $printOption(5)
            $printOption(7)
            $printOption(14)
            $printOption(30)
            $printOption(60)
            $printOption(90)
            $printOption(120)
            $printOption(-1, 'all')
          </select> days
        </form>
      </td>
    </tr>
    <tr>
      <td class="paginate" colspan="3">
        #if $len($targetPages) > 1
        <form class="pageJump" action="">
          Page:
          <select onchange="javascript: window.location = 'buildsbytarget?start=' + this.value * $targetRange + '$util.passthrough($self, 'days', 'order')';">
            #for $pageNum in $targetPages
            <option value="$pageNum"#if $pageNum == $targetCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
            #end for
          </select>
        </form>
        #end if
        #if $targetStart > 0
        <a href="buildsbytarget?start=#echo $targetStart - $targetRange #$util.passthrough($self, 'days', 'order')">&lt;&lt;&lt;</a>
        #end if
        #if $totalTargets != 0
        <strong>Build Targets #echo $targetStart + 1 # through #echo $targetStart + $targetCount # of $totalTargets</strong>
        #end if
        #if $targetStart + $targetCount < $totalTargets
        <a href="buildsbytarget?start=#echo $targetStart + $targetRange#$util.passthrough($self, 'days', 'order')">&gt;&gt;&gt;</a>
        #end if
      </td>
    </tr>
    <tr class="list-header">
      <th><a href="buildsbytarget?order=$util.toggleOrder($self, 'name')$util.passthrough($self, 'days')">Name</a> $util.sortImage($self, 'name')</th>
      <th><a href="buildsbytarget?order=$util.toggleOrder($self, 'builds')$util.passthrough($self, 'days')">Builds</a> $util.sortImage($self, 'builds')</th>
      <th>&nbsp;</th>
    </tr>
    #if $len($targets) > 0
    #for $target in $targets
    <tr class="$util.rowToggle($self)">
      <td><a href="buildtargetinfo?name=$target.name">$target.name</a></td>
      <td width="#echo $graphWidth + 5#"><img src=$util.themePath('images/1px.gif') width="#echo $increment * $target.builds#" height="15" class="graphrow" alt="graph row"/></td>
      <td>$target.builds</td>
    </tr>
    #end for
    #else
    <tr class="row-odd">
      <td colspan="3">No builds</td>
    </tr>
    #end if
    <tr>
      <td class="paginate" colspan="3">
        #if $len($targetPages) > 1
        <form class="pageJump" action="">
          Page:
          <select onchange="javascript: window.location = 'buildsbytarget?start=' + this.value * $targetRange + '$util.passthrough($self, 'days', 'order')';">
            #for $pageNum in $targetPages
            <option value="$pageNum"#if $pageNum == $targetCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
            #end for
          </select>
        </form>
        #end if
        #if $targetStart > 0
        <a href="buildsbytarget?start=#echo $targetStart - $targetRange #$util.passthrough($self, 'days', 'order')">&lt;&lt;&lt;</a>
        #end if
        #if $totalTargets != 0
        <strong>Build Targets #echo $targetStart + 1 # through #echo $targetStart + $targetCount # of $totalTargets</strong>
        #end if
        #if $targetStart + $targetCount < $totalTargets
        <a href="buildsbytarget?start=#echo $targetStart + $targetRange#$util.passthrough($self, 'days', 'order')">&gt;&gt;&gt;</a>
        #end if
      </td>
    </tr>
  </table>

#include "includes/footer.chtml"
