{extends "base_full.tpl.html"}
{block page_classes}list_issues{/block}

{function name="sort_link" field="" link="" title=""}
  <a title="{$title}" href="{$sorting.links.$field}" class="white_link">{$link|escape:"html"}</a>
  {if $sorting.order.$field|default:''}
    {if $sorting.order.$field == "desc"}
      {assign var="icon" value="fa-arrow-down"}
    {else}
      {assign var="icon" value="fa-arrow-up"}
    {/if}
    <a title="{$title}" href="{$sorting.links.$field}">
      <i class="fa {$icon}" aria-hidden="true"></i>
    </a>
  {/if}
{/function}

{block "content"}
{if $core.current_role != $core.roles.customer}
{include file="quick_filter_form.tpl.html"}
{/if}
{include file="current_filters.tpl.html"}
{* Figure out how many columns there are *}
{assign var="col_count" value=$columns|@count}
{if $list_info.custom_fields|@count > 1}
{math assign="col_count" equation="x+y-1" x=$col_count y=$list_info.custom_fields|@count}
{/if}
{if $core.current_role > $core.roles.developer}
    {math assign="col_count" equation="x+1" x=$col_count}
{/if}
  <form id="list_form" method="post"
        data-current-page="{$list_info.current_page|default:0}"
        data-last-page="{$list_info.last_page|default:0}" data-refresh-rate="{$refresh_rate}">
  <input type="hidden" name="cat" value="bulk_update">
      <table class="bordered grid">
        <tr class="title">
            <th colspan="{$col_count}">
                  {* TRANSLATORS: %1: total rows, 2: range start, 3: range end *}
                  {if $list_info.end_offset > 0}
                  {t 1=$list_info.total_rows 2=$list_info.start_offset+1 3=$list_info.end_offset}Search Results (%1 issues found, %2 - %3 shown){/t}
                  {else}
                  {* TRANSLATORS: %1: total rows *}
                  {t 1=$list_info.total_rows}Search Results (%1 issues found){/t}
                  {/if}
                  {include file="help_link.tpl.html" topic="list"}
                {if $core.current_role != $core.roles.customer}
                <span class="menu">
                  {t}hide/show{/t}:
                  [ <span class="js_link" title="{t}hide / show the quick search form{/t}" id="toggle_quick_filter">{t}quick search{/t}</span> ]
                  {if $core.current_role > $core.roles.reporter}[ <span class="js_link" id="toggle_current_filters"> {t}current filters{/t}</span> ]{/if}
                  {if $core.current_role > $core.roles.developer}[ <span class="js_link" id="toggle_bulk_update"> {t}bulk update tool{/t}</span> ]{/if}
                </span>
                {/if}
          </th>
        </tr>
        <tr>
          {if $core.current_role > $core.roles.developer}
          <th width="1%">
            <input type="button" value="{t}All{/t}" class="select_all">
          </th>
          {/if}
          {foreach from=$columns item=column key=field_name}
          {if $field_name == 'custom_fields'}
            {foreach from=$list_info.custom_fields key=fld_id item=fld_title}
              {assign var="fld_name_id" value="custom_field_`$fld_id`"}
                <th align="{$column.align|default:'center'}" nowrap class="cstm_{$fld_id}">
                  {sort_link field=$fld_name_id link=$fld_title title="{t 1=$fld_title}sort by %1{/t}"}
                </th>
              {/foreach}
          {else}
          <th align="{$column.align|default:'center'}" nowrap {if $column.width != ''}width="{$column.width}"{/if}
            class="{$field_name}">
            {if $field_name == 'iss_summary'}
              {sort_link field="iss_summary" link="{t}Summary{/t}" title="{t}sort by summary{/t}"}
              <span id="export_csv" class="right">{t}Export Data:{/t}
                <i class="fa fa-file-excel-o" aria-hidden="true"></i>
              </span>
            {elseif $sorting.links[$field_name]|default:'' != ''}
              {sort_link field=$field_name link=$column.title title="{t 1=$column.title}sort by %1{/t}"}
            {else}
              {$column.title|default:''}
            {/if}
          </th>
          {/if}
          {/foreach}
        </tr>
        {section name="i" loop=$list}
        <tr {if $core.current_role >= $core.roles.developer AND $list[i].iqu_status > 0}style="text-decoration: line-through;"{/if} data-issue-id="{$list[i].iss_id}">
          {if $core.current_role > $core.roles.developer}
          <td style="background: {$list[i].status_color}" width="1%" align="center"><input type="checkbox" name="item[]" value="{$list[i].iss_id}"></td>
          {/if}
          {foreach from=$columns item=column key=field_name}
          {if $field_name == 'custom_fields'}
            {foreach from=$list[i].custom_field key=fld_id item=cf}
                <td style="background: {$list[i].status_color}" align="{$column.align|default:'center'}" class="custom_field cstm_{$fld_id}">
                  {$cf.formatted_value}
                </td>
              {/foreach}
          {else}
          <td style="background: {$list[i].status_color}" align="{$column.align|default:'center'}" class="{$field_name}">
            {if $field_name == 'iss_id'}
              <a href="view.php?id={$list[i].iss_id}" title="{t}view issue details{/t}">{$list[i].iss_id}</a>
            {elseif $field_name == 'pri_rank'}
              {if $list[i].pri_icon > 0}<span class="priority_icon priority-icon-{$list[i].pri_icon}"></span> {/if}{$list[i].pri_title|escape:"html"}
            {elseif $field_name == 'sev_rank'}
              {$list[i].sev_title|escape:"html"}
            {elseif $field_name == 'grp_name'}
              {$list[i].grp_name}
            {elseif $field_name == 'assigned'}
              {$list[i].assigned_users}
            {elseif $field_name == 'time_spent'}
              {$list[i].time_spent}
            {elseif $field_name == 'prc_title'}
              {$list[i].prc_title}
            {elseif $field_name == 'pre_title'}
              {$list[i].pre_title|escape:"html"}
            {elseif $field_name == 'iss_customer_id'}
              <a href="list.php?view=customer&customer_id={$list[i].iss_customer_id}"
              title="View other issues from this customer">
              {$list[i].customer_title|default:''|escape:"html"}</a>
            {elseif $field_name == 'support_level'}
              {$list[i].support_level|escape:"html"|default:''}
            {elseif $field_name == 'sta_rank'}
              {$list[i].sta_title|escape:"html"}
            {elseif $field_name == 'iss_created_date'}
              {$list[i].iss_created_date|timeago}
            {elseif $field_name == 'iss_status_change_date'}
              {$list[i].iss_status_change_date|timeago}
            {elseif $field_name == 'iss_dev_time'}
              {$list[i].iss_dev_time|escape:"html"}
            {elseif $field_name == 'status_action_date'}
              {$list[i].status_action_date|escape:"html"}
            {elseif $field_name == 'last_action_date'}
              {* TRANSLATORS: %1: last action data label, %2: last action date diff *}
              {t 1=$list[i].last_action_date_label 2=$list[i].last_action_date_diff}%1:
%2 ago{/t}
            {elseif $field_name == 'usr_full_name'}
              <a href="list.php?view=reporter&reporter_id={$list[i].iss_usr_id}"
              title="View other issues from this reporter">
              {$list[i].usr_full_name|escape:"html"}</a>
            {elseif $field_name == 'iss_percent_complete'}
              <div class="iss_percent_complete ui-progressbar" data-percent="{$list[i].iss_percent_complete}"><div class="progress-label">&nbsp;{$list[i].iss_percent_complete|escape:"html"} %</div></div>
            {elseif $field_name == 'iss_expected_resolution_date'}

              {if $list[i].iss_expected_resolution_date != 0}
                <div class="inline_date_pick" id="expected_resolution_date|{$list[i].iss_id}">{$list[i].iss_expected_resolution_date|escape:"html"}&nbsp</div>
              {/if}

            {elseif $field_name == 'iss_summary'}
              <a href="view.php?id={$list[i].iss_id}" title="{t}view issue details{/t}">{$list[i].iss_summary|escape:"html"}</a>
              {if $list[i].redeemed|default:0}
                  [{t}Redeemed{/t}]
              {/if}
              {if $list[i].iss_access_level != 'normal'}
                  <b>[{t}{$list[i].access_level_name}{/t}]</b>
              {/if}
            {/if}
          </td>
          {/if}
          {/foreach}
        </tr>
        {if $list[i].excerpts != ''}
        <tr>
          <td colspan="{$col_count}" style="background: {$list[i].status_color}">
            {if $list[i].excerpts|@count > 0}
              {include file="list_excerpts.tpl.html"}
            {/if}
          </td>
        </tr>
        {/if}
        {sectionelse}
        <tr class="no_results">
          <td colspan="{$col_count}">
            {t}No issues could be found.{/t}
          </td>
        </tr>
        {/section}
        <tr class="buttons">
          <td colspan="{$col_count}">
            <table width="100%">
              <tr>
                <td width="30%" nowrap>
                  {if $core.current_role > $core.roles.developer}
                  <input type="button" value="{t}All{/t}" class="select_all">
                  {/if}
                </td>
                <td width="40%" align="center" nowrap>
                  <nobr>
                  <input name="first" type="button" value="|&lt;">
                  <input name="previous" type="button" value="&lt;&lt;"">
                  <input type="text" name="page" size="3" maxlength="3" value="{if $list_info.current_page == ''}1{else}{math equation="x + 1" x=$list_info.current_page}{/if}"  class="paging_input" onKeyPress="return checkPageField(event);">
                  <input name="go" type="button" value="{t}Go{/t}">
                  <input name="next" type="button" value="&gt;&gt;">
                  <input name="last" type="button" value="&gt;|">
                  </nobr>
                </td>
                <td nowrap>
                  <span>{t}Rows per Page{/t}:</span>
                  <select name="page_size" id="page_size">
                    <option value="5" {if $options.rows == 5}selected{/if}>5</option>
                    <option value="10" {if $options.rows == 10}selected{/if}>10</option>
                    <option value="25" {if $options.rows == 25}selected{/if}>25</option>
                    <option value="50" {if $options.rows == 50}selected{/if}>50</option>
                    <option value="100" {if $options.rows == 100}selected{/if}>100</option>
                    <option value="ALL" {if $options.rows == "ALL"}selected{/if}>{t}ALL{/t}</option>
                  </select>
                  <input type="button" value="{t}Set{/t}" id="resize_page">
                </td>
                <td width="30%" align="right">
                  <input type="checkbox" id="hide_closed" name="hide_closed" {if $options.hide_closed}checked{/if}> <label for="hide_closed">{t}Hide Closed Issues{/t}</label>&nbsp;
                  {if $core.current_role >= $core.roles.developer}
                    <input type="checkbox" id="show_all_projects" name="show_all_projects"
                        {if $options.show_all_projects}checked{/if}><label for="show_all_projects">{t}Show all projects{/t}</label>&nbsp;
                  {/if}
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
  {if $core.current_role > $core.roles.developer}
      {include file="bulk_update.tpl.html"}
  {/if}
  </form>
  <form target="_csvWindow" method="post" action="csv.php" name="csv_form" id="csv_form">
  <input type="hidden" name="csv_data" value="{$csv_data}">
  </form>
{/block}
