<h3>$T('menu-history') <a id="feed" href="rss?mode=history"><img id="rss" src="static/feed-icon-14x14.png" alt="rss"/></a></h3>
<div class="searchBox">
  <input id="historySearch" type="text" size="17" name="search" value="$search" onchange="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=0', 1, this.parentNode.parentNode.id, 1);" onfocus="pauseHistoryDeferer(this.parentNode.parentNode.id)" onblur="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=0',1, this.parentNode.parentNode.id, 1);">
  <a onclick="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=0',1, this.parentNode.parentNode.id);"><img class="delicon" src="static/images/key_enter.png" /></a>
  <a onclick="javascript:loadSearch('history', '', 'limit=$limit&start=$0',1, this.parentNode.parentNode.id);"><img class="delicon" src="static/images/messagebox_critical.png" /></a>
</div>

<div class="centerLinks"><br />
  <a onClick="if(confirm('$T('purgeHistConf')')){javascript:loadSearch('history/purge', 'historySearch', 'limit=$limit&start=0', -1,this.parentNode.parentNode.id);}">$T('smpl-purgehist')</a> |
  <a onClick="if(confirm('$T('smpl-purgefailhistOK?')')){javascript:loadSearch('history/purge_failed', 'historySearch', 'limit=$limit&start=0', -1,this.parentNode.parentNode.id);}">$T('smpl-purgefailhist')</a> |
  <a onClick="if(confirm('$T('smpl-purgefailhistOK?')')){javascript:loadSearch('history/purge_failed', 'historySearch', 'limit=$limit&start=0&del_files=1', -1,this.parentNode.parentNode.id);}">$T('purgeFailed-Files')</a> |
  <a onClick="javascript:loadSearch('history/tog_verbose', 'historySearch', 'limit=$limit&start=0', -1,this.parentNode.parentNode.id);"><!--#if $isverbose then $T('hideDetails') else $T('showDetails')#--></a> |
  <a onClick="javascript:loadSearch('history/tog_failed_only', 'historySearch', 'limit=$limit&start=0', -1,this.parentNode.parentNode.id);"><!--#if $failed_only then $T('showAllHis') else $T('showFailedHis')#--></a>
  </span>
</div>

<% import time %>
<% from sabnzbd.misc import time_format %>

<!--#if $lines#-->
<table id="historyTable">
<tr>
<th class="expandColumn"></th>
<th>$T('name')</th>
<th class="linksColumn">$T('smpl-links')</th>
<th class="sizeColumn">$T('smpl-size')</th>
<th class="statusColumn">$T('status')</th>
<th class="actionsColumn"></th>
</tr>
  <!--#for $line in $lines #-->
  <tbody id="$line.nzo_id">
  <tr>
    <td class="center"><a id="tog_$line.nzo_id" class="expander" onclick="javascript:loadSearch('history/tog_verbose', 'historySearch', 'jobs=$line.nzo_id&limit=$limit&start=$start',-1, this.parentNode.parentNode.parentNode.parentNode.parentNode.id);">
    <!--#if $line.show_details then '-' else '+'#-->
    </a></td>
    <td>$line.name<!--#if $line.action_line#--> - <span class="action_message">$line.action_line</span><!--#else if $line.fail_message#--> - <span class="fail_message">$line.fail_message</span><!--#end if#--></td>
    <td>
      <!--#if $line.report#-->
        <a href="https://$newzbin_url/browse/post/$line.report"><img class="imglink" src="static/images/newzbin.png" /></a>
      <!--#end if#-->
      <!--#if $line.url_info#-->
        <a href="$line.url_info"><img class="imglink" src="static/images/browser.png" /></a>
      <!--#end if#-->
    </td>
    <td>$line.size</td>
    <td>$Tx('post-'+$line.status)</td>
    <td class="right_align">
      <!--#if not $line.loaded#-->
        <!--#if $line.retry#-->
          <a onClick="if(confirm('$T('confirm').replace("'","`") ')){ if (confirm('$T('delFiles').replace("'","`") ')) deletehistoryitem('$line.nzo_id', 1, this.parentNode.parentNode.parentNode.parentNode.parentNode.id); else deletehistoryitem('$line.nzo_id', 0, this.parentNode.parentNode.parentNode.parentNode.parentNode.id); return false;}"><img class="delicon" src="static/images/messagebox_critical.png" /></a>
        <!--#else#-->
          <a onClick="deletehistoryitem('$line.nzo_id', 0, this.parentNode.parentNode.parentNode.parentNode.parentNode.id);"><img class="delicon" src="static/images/messagebox_critical.png" /></a>
        <!--#end if#-->
      <!--#end if#-->
    </td>

  </tr>
<!--#if $line.show_details#-->
<tr id="row_$line.nzo_id">
  <td></td>
  <td colspan="5">
  <%
completed = time.localtime(float(line['completed']))
t = time.strftime(time_format("%H:%M:%S on %A %d %B %Y"), completed)

  %>
  <div class="left-margin line-height">
    Completed at $t
    <br />
    <!--#for $stage in $line.stage_log#-->
      <span class="bold">$Tx('stage-'+$stage.name.title.lower()): </span><br />
      <!--#for $item in $stage.actions #-->
        <span class="left-margin">$item</span><br />
      <!--#end for#-->
    <!--#end for#-->
    <!--#if $line.category#-->
      <span class="bold">$T('category'): </span><br />
      <span class="left-margin">$line.category</span><br />
    <!--#end if#-->
    <!--#if $line.storage#-->
      <span class="bold">$T('smpl-path'): </span><br />
      <span class="left-margin">$line.storage</span>
    <!--#end if#-->
    <br />
    <!--#if $line.retry#-->
      <form action="retry_pp" method="post" enctype="multipart/form-data">
      <input type="file" style="width:221px" name="nzbfile">
      <input type="hidden" value="$line.nzo_id" name="job">
      <input type="hidden" name="session" value="$session">
      <input type="submit" class="submitindent2" value="$T('button-retry')"></form>
    <!--#end if#-->

  </div>
  </td>
</tr>
<!--#end if#-->
</tbody>
<!--#end for#-->
<!--#end if#-->
</table>
<div class="centerLinks">
  <!--#if $have_quota#-->
    $T('quota-left'):&nbsp;<strong>$left_quota&nbsp;&frasl;&nbsp;$quota</strong>&nbsp;|
  <!--#end if#-->
  $T('smpl-size'): <span class="bold">$total_size</span> |  $T('thisMonth'): <span class="bold">$month_size</span> | $T('thisWeek'): <span class="bold">$week_size</span> | $T('today'): <span class="bold">$day_size</span>
</div>
<br />
<!--#if $finish == 0#-->
$T('smpl-noresult')
<!--#elif $finish == 1#-->
$T('smpl-oneresult')
<!--#else#-->

  <!--#if $finish > 0#-->
    <!--#set $x = $start+1#-->
  <!--#else#-->
    <!--#set $x = 0#-->
  <!--#end if#-->

  <!--#if $finish > $noofslots#-->
    <!--#set $y = $start+1#-->
  <!--#else#-->
    <!--#set $y = $finish#-->
  <!--#end if#-->

  <!--#set $numres = $T('smpl-numresults@3') % ($x, $y, $noofslots)#-->
  $numres
<!--#end if#-->
<br />
<div class="centerLinks">
  <!--#if $limit and $noofslots#-->
    <!--#set $total = $noofslots#-->
    <!--#while ($total % $limit)#-->
      <!--#set $total = $total+1#-->
    <!--#end while#-->
    <!--#set $pages = ($total / $limit)#-->
    <!--#set $newfinish = $finish#-->
    <!--#while ($newfinish % $limit)#-->
      <!--#set $newfinish = $newfinish+1#-->
    <!--#end while#-->
    <!--#set $currentpage = int($newfinish / $limit)#-->
    <!--#set $offset = 0#-->
    <!--#if $currentpage == 1#-->
      <span class="unselected">&laquo;$T('smpl-first')</span>
      <span class="unselected">&lsaquo;$T('smpl-previous')</span>
    <!--#else#-->
      <!--#set $new_start = $start-$limit#-->
      <a class="unselected" onclick="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=0', 1,this.parentNode.parentNode.id);">&laquo;$T('smpl-first')</a>
      <a class="unselected" onclick="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=$new_start', 1,this.parentNode.parentNode.id);">&lsaquo;$T('smpl-previous')</a>
    <!--#end if#-->
    <!--#for $i in $range($pages)#-->
      <!--#set $i = $i+1#-->
      <!--#if  $currentpage == $i#-->
        <span class="selected">$i</span>
      <!--#elif $i >= 0 and $i > $currentpage-3 and $i < $currentpage+6#-->
        <a class="unselected" onclick="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=$offset', 1,this.parentNode.parentNode.id);">$i</a>
      <!--#end if#-->
      <!--#set $offset = $offset + $limit#-->
    <!--#end for#-->
    <!--#if $currentpage == $pages#-->
      <span class="unselected">$T('smpl-next')&rsaquo;</span> <span class="unselected">$T('smpl-last')&raquo;</span>
    <!--#else#-->
      <!--#set $first_start = $start+$limit#-->
      <!--#set $second_start = (($pages-1)*$limit)#-->
      <a class="unselected" onclick="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=$first_start', 1,this.parentNode.parentNode.id);">$T('smpl-next')&rsaquo;</a>
      <a class="unselected" onclick="javascript:loadSearch('history', 'historySearch', 'limit=$limit&start=$second_start', 1,this.parentNode.parentNode.id);">$T('smpl-last')<!--#if $pages > 1#-->($pages)<!--#end if#-->&raquo;</a>
    <!--#end if#-->
  <!--#end if#-->
</div>

