<!-- начало багтрекер -->
<div id="bt_main">

	<div id="rss_feeds" class="btn-group" style="width:100%">
		{foreach $feed_rss as $item}
		<a class="btn btn-default" href="{$item.path}" title="{$item.name|escape}"><img src="/skins/default/images/icons/simple_rss.png" alt="" /></a>
		{/foreach}
	</div>
{include file="bug_tracker/toolbar.tpl"}
	
	{if $filter.type || $filter.importance || $filter.status || $filter.version_id || $filter.author_id}{assign var="filtered" value=true}{/if}

	<div class="form-horizontal col-lg-5" id="filters"{if !$filtered} style="display:none"{/if}>
		<form method="get" action="" id="filter_form">
			{if $filter.author_id}<input type="hidden" name="author_id" value="{$filter.author_id|escape}" />{/if}
			<input type="hidden" name="order" value="{$filter.order|escape}" />
			<input type="hidden" name="direction" value="{$filter.direction|escape}" />
			<label for="type-0" class="col-lg-3 control-label">{t}Тип{/t}</label>
			<div class="col-lg-9">
				<select class="form-control" id="type-0" name="type">
					<option value=''>{t}нет{/t}</option>
					{html_options options=$bug_types selected=$filter.type}
				</select>
			</div>
			<label for="importance-0" class="col-lg-3 control-label">{t}Важность{/t}</label>
			<div class="col-lg-9">
				<select class="form-control" id="importance-0" name="importance">
					<option value=''>{t}нет{/t}</option>
					{html_options options=$importances selected=$filter.importance}
				</select>
			</div>
			<label for="status-0" class="col-lg-3 control-label">{t}Статус{/t}</label>
			<div class="col-lg-9">
				<select class="form-control" id="status-0" name="status">
					<option value=''>{t}нет{/t}</option>
					{html_options options=$statuses selected=$filter.status}
				</select>
			</div>
			<label for="version_id-0" class="col-lg-3 control-label">{t}Версия{/t}</label>
			<div class="col-lg-9">
				<select class="form-control" id="version_id-0" name="version_id">
					<option value=''>{t}нет{/t}</option>
					{html_options options=$versions selected=$filter.version_id}
				</select>
			</div>

			<div>
				<a class="btn btn-default" onclick="document.getElementById('filter_form').submit();" href="javascript:void(0)">{t}применить{/t}</a>
				{if $filtered}<a class="btn btn-warning" href="{url var1=1}">{t}снять фильтр{/t}</a>{/if}
			</div>
			
		</form>
	</div>

	<table class="bug_list table">
	<colgroup>
		<col width="30" />
		<col />
		<col width="70" />
		<col width="110" />
		<col width="30" />
		<col width="70" />
		<col width="70" />
		<col width="60" />
		{if access('moderator')}<col width="15" />{/if}
	</colgroup>
	<thead>
		<tr>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('id')}">№</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('theme')}">{t}тема{/t}</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('author_id')}">{t}автор{/t}</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('update')}">{t}дата{/t}</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('version')}">{t}версия{/t}</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('approver_id')}">{t}подтвердил{/t}</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('performer_id')}">{t}закрыл{/t}</a></th>
			<th><a href="{url var1=$pager.current query=bugTrackerGetFilters('type')}">{t}тип{/t}</a></th>
			{if access('moderator')}<th></th>{/if}
		</tr>
	</thead>
	<tbody>
	{foreach $bugs as $bug}
	<tr class="status{$bug->status} importance{$bug->importance}{if !$_user->isGuest() && $_user->last_visit<$bug->last_update} new{/if}">
		<td><a href="{url action="item" var1=$bug->id}">#{$bug->id}</a></td>
		<td><a href="{url action="item" var1=$bug->id}">{$bug->summary|escape}</a></td>
		<td>{include file="login/user_item_small.tpl" user=$bug->author}</td>
		<td>{$bug->last_update|date_format:"%H:%M %d.%m.%y"}</td>
		<td>{$bug->version|escape}</td>
		<td>{if $bug->approver}{include file="login/user_item_small.tpl" user=$bug->approver}{/if}</td>
		<td>{if $bug->performer}{include file="login/user_item_small.tpl" user=$bug->performer}{/if}</td>
		<td>{$bug_types[$bug->type]}</td>
		{if access('moderator')}<td><a class="btn btn-default btn-xs" href="{url action="delete_bug" var1=$bug->id token=1}" onclick="return confirm('{t}удалить?{/t}');"><img class="icon" src="/skins/default/images/icons/simple_delete.png" alt="удалить" /></a></td>{/if}
	</tr>
	{foreachelse}
	<tr><td></td></tr>
	{/foreach}
	</tbody>
	</table>
	
	{if $pager.pages}
	<div class="navigate">
		{foreach $pager.pages as $page}
			{if !$page} ... {elseif $page==$pager.current}
				<b>{$page}</b>	
			{else}
				<a href="{url var1=$page var2=$filter.order var3=$filter.type var4=$filter.importance var5=$filter.status var6=$filter.version_id}">{$page}</a>
			{/if}
			{if !$page@last}|{/if}
		{/foreach}
	</div>
	{/if}
	
	<div style="margin-top:30px;" id="tracker_legend">
		<table class="bug_list" style="width:200px;float:left;">
			<tr><td><b>{t}Статусы{/t}:</b></td></tr>
			{foreach $statuses as $key=>$status}
			<tr class="status{$key}"><td>{$status|escape}</td></tr>
			{/foreach}
		</table>
		<table class="bug_list" style="width:200px;float:left;">
			<tr><td><b>{t}Важность{/t}:</b></td></tr>
			{foreach $importances as $key=>$importance}
			<tr class="importance{$key}"><td>{$importance|escape}</td></tr>
			{/foreach}
		</table>
	</div>
</div>
<!-- конец багтрекер -->