#import sickgear
#import datetime
#from lib import subliminal
#from sickgear import common
##
#set global $title = 'Missing Subtitles'
#set global $header = 'Missing Subtitles'
#set global $sbPath = '..'
#set global $topmenu = 'manage'
##
#import os.path
#include $os.path.join($sickgear.PROG_DIR, 'gui/slick/interfaces/default/inc_top.tmpl')

<div id="content960">
#if $varExists('header')
	<h1 class="header">$header</h1>
#else
	<h1 class="title">$title</h1>
#end if
##
#if $which_subs
    #set subs_language = $subliminal.language.Language($which_subs, strict=False) if not $which_subs == 'all' else 'All'
#end if
#if not $which_subs or ($which_subs and not $ep_counts)
    #if $which_subs:

	<h2>All of your episodes have $subs_language subtitles.</h2>
	<br />
    #end if

	<form action="$sbRoot/manage/subtitle-missed" method="get">
		Manage episodes without
		<select name="which_subs" class="form-control form-control-inline input-sm">
			<option value="all">All</option>
    #for $sub_lang in $subliminal.language.language_list($sickgear.SUBTITLES_LANGUAGES):
			<option value="$sub_lang.alpha2">$sub_lang</option>
    #end for
		</select>
		subtitles
		<input class="btn" type="submit" value="Manage">
	</form>
#else

<script type="text/javascript" src="$sbRoot/js/manageSubtitleMissed.js?v=$sbPID"></script>
	<input type="hidden" id="selectSubLang" value="$which_subs">

	<form action="$sbRoot/manage/download-subtitle-missed" method="post">
		$xsrf_form_html

		<h2>Episodes without $subs_language subtitles.</h2>
		<br />
		Download missed subtitles for selected episodes <input class="btn btn-inline" type="submit" value="Go" />
		<div>
			<button type="button" class="btn btn-xs selectAllShows">Select all</a></button>
			<button type="button" class="btn btn-xs unselectAllShows">Clear all</a></button>
		</div>
		<br />
		<table class="sickbeardTable manageTable" cellspacing="1" border="0" cellpadding="0">
    #for $tvid_prodid in $sorted_show_ids:
			<tr id="$tvid_prodid">
				<th><input type="checkbox" class="allCheck" id="allCheck-$tvid_prodid" name="$tvid_prodid-all" checked="checked"></th>
				<th colspan="3" style="width: 100%; text-align: left;"><a class="whitelink" href="$sbRoot/home/view-show?tvid_prodid=$tvid_prodid">$show_names[$tvid_prodid]</a> ($ep_counts[$tvid_prodid]) <input type="button" class="get_more_eps btn pull-right" id="$tvid_prodid" value="Expand"></th>
			</tr>
    #end for
		</table>
	</form>
#end if
</div>
#include $os.path.join($sickgear.PROG_DIR, 'gui/slick/interfaces/default/inc_bottom.tmpl')