#from kojiweb import util

#include "includes/header.chtml"

  <h4>Information for package <a href="packageinfo?packageID=$package.id">$package.name</a></h4>

  <table>
    <tr>
      <th>Name</th><td>$package.name</td>
    </tr>
    <tr>
      <th>ID</th><td>$package.id</td>
    </tr>
    
    <tr>
      <th id="buildlist">Builds</th>
      <td class="container">
        #if $len($builds) > 0
        <table class="nested data-list">
          <tr>
            <td class="paginate" colspan="4">
              #if $len($buildPages) > 1
              <form class="pageJump" action="">
                Page:
                <select onchange="javascript: window.location = 'packageinfo?buildStart=' + this.value * $buildRange + '$util.passthrough($self, 'packageID', 'buildOrder', 'tagOrder', 'tagStart')#buildlist';">
                  #for $pageNum in $buildPages
                  <option value="$pageNum"#if $pageNum == $buildCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
                  #end for
                </select>
              </form>
              #end if
              #if $buildStart > 0
              <a href="packageinfo?buildStart=#echo $buildStart - $buildRange#$util.passthrough($self, 'packageID', 'buildOrder', 'tagOrder', 'tagStart')#buildlist">&lt;&lt;&lt;</a>
              #end if
              <strong>#echo $buildStart + 1 # through #echo $buildStart + $buildCount # of $totalBuilds</strong>
              #if $buildStart + $buildCount < $totalBuilds
              <a href="packageinfo?buildStart=#echo $buildStart + $buildRange#$util.passthrough($self, 'packageID', 'buildOrder', 'tagOrder', 'tagStart')#buildlist">&gt;&gt;&gt;</a>
              #end if
            </td>
          </tr>
          <tr class="list-header">
            <th><a href="packageinfo?buildOrder=$util.toggleOrder($self, 'nvr', 'buildOrder')$util.passthrough($self, 'packageID', 'tagOrder', 'tagStart')#buildlist">NVR</a> $util.sortImage($self, 'nvr', 'buildOrder')</th>
            <th><a href="packageinfo?buildOrder=$util.toggleOrder($self, 'owner_name', 'buildOrder')$util.passthrough($self, 'packageID', 'tagOrder', 'tagStart')#buildlist">Built by</a> $util.sortImage($self, 'owner_name', 'buildOrder')</th>
            <th><a href="packageinfo?buildOrder=$util.toggleOrder($self, 'completion_time', 'buildOrder')$util.passthrough($self, 'packageID', 'tagOrder', 'tagStart')#buildlist">Finished</a> $util.sortImage($self, 'completion_time', 'buildOrder')</th>
            <th><a href="packageinfo?buildOrder=$util.toggleOrder($self, 'state', 'buildOrder')$util.passthrough($self, 'packageID', 'tagOrder', 'tagStart')#buildlist">State</a> $util.sortImage($self, 'state', 'buildOrder')</th>
          </tr>
          #for $build in $builds
          <tr class="$util.rowToggle($self)">
            <td><a href="buildinfo?buildID=$build.build_id">$build.nvr</a></td>
            <td class="user-$build.owner_name"><a href="userinfo?userID=$build.owner_id">$build.owner_name</a></td>
            <td>$util.formatTime($build.completion_ts)</td>
            #set $stateName = $util.stateName($build.state)
            <td class="$stateName">$util.stateImage($build.state)</td>
          </tr>
          #end for
        </table>
        #if $buildStart > 0
        <a href="packageinfo?buildStart=#echo $buildStart - $buildRange#$util.passthrough($self, 'packageID', 'buildOrder', 'tagOrder', 'tagStart')#buildlist">&lt;&lt;&lt;</a>
        #end if
        <strong>Builds #echo $buildStart + 1 # through #echo $buildStart + $buildCount # of $totalBuilds</strong>
        #if $buildStart + $buildCount < $totalBuilds
        <a href="packageinfo?buildStart=#echo $buildStart + $buildRange#$util.passthrough($self, 'packageID', 'buildOrder', 'tagOrder', 'tagStart')#buildlist">&gt;&gt;&gt;</a>
        #end if
        #else
        No builds
        #end if
      </td>
    </tr>
    
    <tr>
      <th id="taglist">Tags</th>
      <td class="container">
        #if $len($tags) > 0
        <table class="nested data-list">
          <tr>
            <td class="paginate" colspan="4">
              #if $len($tagPages) > 1
              <form class="pageJump" action="">
                Page:
                <select onchange="javascript: window.location = 'packageinfo?tagStart=' + this.value * $tagRange + '$util.passthrough($self, 'packageID', 'tagOrder', 'buildOrder', 'buildStart')#taglist';">
                  #for $pageNum in $tagPages
                  <option value="$pageNum"#if $pageNum == $tagCurrentPage then ' selected="selected"' else ''#>#echo $pageNum + 1#</option>
                  #end for
                </select>
              </form>
              #end if
              #if $tagStart > 0
              <a href="packageinfo?tagStart=#echo $tagStart - $tagRange#$util.passthrough($self, 'packageID', 'tagOrder', 'buildOrder', 'buildStart')#taglist">&lt;&lt;&lt;</a>
              #end if
              <strong>#echo $tagStart + 1 # through #echo $tagStart + $tagCount # of $totalTags</strong>
              #if $tagStart + $tagCount < $totalTags
              <a href="packageinfo?tagStart=#echo $tagStart + $tagRange#$util.passthrough($self, 'packageID', 'tagOrder', 'buildOrder', 'buildStart')#taglist">&gt;&gt;&gt;</a>
              #end if
            </td>
          </tr>
          <tr class="list-header">
            <th><a href="packageinfo?tagOrder=$util.toggleOrder($self, 'name', 'tagOrder')$util.passthrough($self, 'packageID', 'buildOrder', 'buildStart')#taglist">Name</a> $util.sortImage($self, 'name', 'tagOrder')</th>
            <th><a href="packageinfo?tagOrder=$util.toggleOrder($self, 'owner_name', 'tagOrder')$util.passthrough($self, 'packageID', 'buildOrder', 'buildStart')#taglist">Owner</a> $util.sortImage($self, 'owner_name', 'tagOrder')</th>
            <th><a href="packageinfo?tagOrder=$util.toggleOrder($self, 'blocked', 'tagOrder')$util.passthrough($self, 'packageID', 'buildOrder', 'buildStart')#taglist">Included?</a> $util.sortImage($self, 'blocked', 'tagOrder')</th>
            <th><a href="packageinfo?tagOrder=$util.toggleOrder($self, 'extra_arches', 'tagOrder')$util.passthrough($self, 'packageID', 'buildOrder', 'buildStart')#taglist">Extra Arches</a> $util.sortImage($self, 'extra_arches', 'tagOrder')</th>
          </tr>
          #for $tag in $tags
          <tr class="$util.rowToggle($self)">
            <td><a href="taginfo?tagID=$tag.id">$tag.name</a></td>
            <td><a href="userinfo?userID=$tag.owner_id">$tag.owner_name</a></td>
            #set $included = $tag.blocked and 'no' or 'yes'
            <td>$util.imageTag($included)</td>
            <td>$tag.extra_arches</td>
          </tr>
          #end for
        </table>
        #if $tagStart > 0
        <a href="packageinfo?tagStart=#echo $tagStart - $tagRange#$util.passthrough($self, 'packageID', 'tagOrder', 'buildOrder', 'buildStart')#taglist">&lt;&lt;&lt;</a>
        #end if
        <strong>Tags #echo $tagStart + 1 # through #echo $tagStart + $tagCount # of $totalTags</strong>
        #if $tagStart + $tagCount < $totalTags
        <a href="packageinfo?tagStart=#echo $tagStart + $tagRange#$util.passthrough($self, 'packageID', 'tagOrder', 'buildOrder', 'buildStart')#taglist">&gt;&gt;&gt;</a>
        #end if
        #else
        No tags
        #end if
      </td>
    </tr>
    
  </table>

#include "includes/footer.chtml"
