<% import datetime %>
<% from sabnzbd.misc import time_format %>
<script type="text/javascript">
  if (typeof( jQuery ) == 'undefined')
    window.location = "../"; // redirect to main on direct template hit

  jQuery(function($) {
    $.plush.histnoofslots      = $noofslots;
    <!--#if $loadavg#-->
    $.plush.SetLoadavg("$loadavg");
    <!--#end if#-->
    $.plush.SetHistoryStats("<!--#if $day_size#-->&nbsp;&nbsp;&nbsp;&nbsp;<strong>$day_size</strong>&nbsp;$T('today')<!--#end if #--><!--#if $week_size#-->&nbsp;&nbsp;&nbsp;&nbsp;<strong>$week_size</strong>&nbsp;$T('thisWeek')<!--#end if #--><!--#if $month_size#-->&nbsp;&nbsp;&nbsp;&nbsp;<strong>$month_size</strong>&nbsp;$T('thisMonth')<!--#end if #--><!--#if $total_size#-->&nbsp;&nbsp;&nbsp;&nbsp;<strong>$total_size</strong>&nbsp;$T('total')<!--#end if #-->");
  });

</script>

<!--#if $limit > 1 or $search#-->
<table class="queueTable" id="historyTable" cellspacing="0">
<!--#set $cur = 0#-->
<!--#for $line in $lines #-->
  <!--#set $cur = $cur + 1#-->
  <tr id="$line.nzo_id" class="<!--#if $cur%2#-->alt<!--#end if#--> <!--#if $line.action_line #-->active<!--#end if#-->">

  <td class="nzb_status_col">
    &nbsp;<div class="nzb_status <!--#if $line.action_line or $line.status=="Queued"#-->Loaded<!--#else if $line.status=="Failed"#-->main_sprite_container sprite_hv_error<!--#else#-->main_sprite_container sprite_hv_star<!--#end if#-->">&nbsp;</div>
  </td>
  <td class="historyTitle">
    <a href="scriptlog?name=$line.nzo_id" class="modal-detail" rel="details">$line.name</a>

  <div style="display:none">
    <div id="details-$line.nzo_id">

  <table width="100%" class="rssTable">
    <% compl = datetime.datetime.fromtimestamp(float(line['completed'])).strftime(time_format('%Y-%m-%d %H:%M:%S')) %>
    <tr><td><strong>$T('completed')</strong></td><td>$compl</td></tr>
    <tr class="odd"><td><strong>$T('name')</strong></td><td>$line.name<!--#if $line.action_line#--> - $line.action_line<!--#else if $line.fail_message#--> - <span class="fail_message">$line.fail_message</span><!--#end if#--></td></tr>
    <tr><td><strong>$T('size')</strong></td><td>$line.size</td></tr>
    <tr class="odd"><td><strong>$T('status')</strong></td><td>$Tx('post-'+$line.status)</td></tr>

  <!--#set $oddLine = not False#-->
  <!--#if $line.category#-->
    <!--#set $oddLine = not $oddLine#-->
    <tr <!--#if $oddLine#-->class="odd"<!--#end if#-->><td><b>$T('category')</b></td><td>$line.category</td></tr>
  <!--#end if#-->
  <!--#if $line.storage#-->
    <!--#set $oddLine = not $oddLine#-->
    <tr <!--#if $oddLine#-->class="odd"<!--#end if#-->><td><b>$T('msg-path')</b></td><td>$line.storage</td></tr>
  <!--#end if#-->
  <!--#for $stage in $line.stage_log#-->
    <!--#set $oddLine = not $oddLine#-->
    <tr <!--#if $oddLine#-->class="odd"<!--#end if#-->><td><b>$Tx('stage-'+$stage.name.title.lower())</b></td><td>
    <!--#for $action in $stage.actions#-->
      $action<br/>
    <!--#end for#-->
    </td></tr>
  <!--#end for#-->
</table>
</div>
</div>

  </td>
  <td>
    <!--#if $line.report #-->
      <a href="https://$newzbin_url/browse/post/$line.report/" target="_blank">
        <div class="icon_history_verbose main_sprite_container sprite_hv_report pointer" title='$T('Plush-openSourceURL')<br><br>https://$newzbin_url/browse/post/$line.report'>&nbsp;</div>
      </a>
    <!--#end if#-->
    <!--#if $line.url_info #-->
      <a href="$line.url_info" target="_blank">
        <div class="icon_history_verbose main_sprite_container sprite_hv_star pointer" title="$T('Plush-openInfoURL')<br><br>$line.url_info">&nbsp;</div>
      </a>
    <!--#end if#-->
    <!--#if $line.size or $line.category or $line.path or $line.storage#-->
      <div class="icon_history_verbose main_sprite_container sprite_hv_stats" title='<!--#if $line.size#-->$T('size'): $line.size<!--#end if#--><!--#if $line.category#--><br>$T('category'): $line.category<!--#end if#-->'>&nbsp;</div>
    <!--#else#-->
      <div class="icon_history_verbose main_sprite_container sprite_hv_stats hvFaded">&nbsp;</div>
    <!--#end if#-->
    <!--#for $stage in $line.stage_log#-->
      <!--#if $stage.name.lower() == "script"#-->
        <a href="scriptlog?name=$line.nzo_id" class="modal" rel="scriptlog">
          <div class="icon_history_verbose main_sprite_container sprite_hv_$stage.name.lower() pointer" title='$T('Plush-viewScriptLog')'>&nbsp;</div>
        </a>
        <!--#if not $line.action_line#-->
          <!--#for $action in $stage.actions#-->
            <h3 class="hvMessageScript"><!--#echo $action.replace("'","&rsquo;").replace("<a href","<a class='modal' rel='scriptlog2' href") #--></h3>
          <!--#end for#-->
        <!--#end if#-->
      <!--#else#-->
        <!--#if $stage.name != "Source"#-->
          <div class="icon_history_verbose main_sprite_container sprite_hv_$stage.name.lower()" title='<!--#for $action in $stage.actions#--><!--#echo $action.replace("'","&rsquo;") #--><br><!--#end for#-->'>&nbsp;</div>
        <!--#end if#-->
      <!--#end if#-->
    <!--#end for#-->
    <!--#if $line.retry#-->
      <form action="history/retry_pp" method="post" enctype="multipart/form-data">
        <input type="hidden" value="$line.nzo_id" name="job" />
        <input type="hidden" name="session" value="$session" />
        &nbsp;<a href="#" class="retry-nzbfile">$T('button-retry')</a>
      </form>
    <!--#end if#-->
    <!--#if $line.action_line#-->
    <h3 class="hvMessageAction">&raquo;&nbsp;$line.action_line&nbsp;</h3>
    <!--#end if#-->
    <!--#if $line.fail_message#-->
    <h3 class="hvMessageFail">&raquo;&nbsp;$line.fail_message&nbsp;</h3>
    <!--#end if#-->
  </td>

  <td class="options nowrap">
    <!--#if not $line.loaded#-->
    <% d = datetime.datetime.fromtimestamp(float(line['completed'])) %>
    <small class="history_added">$d</small>
    <div class="main_sprite_container icon_nzb_remove" title="$T('nzo-delete')">&nbsp;</div>
    <!--#end if#-->
  </td>

  </tr>
<!--#end for#-->
</table>
<!--#end if#-->
