<?php

//******************************* M O D A L *******************************************************
$this->load->view('/partials/_saveSearchModal');
$this->load->view('/partials/_copySearchModal');
$this->load->view('/partials/_diffModal');
//******************************* M O D A L *******************************************************
?>
<h3 class="hide" id="reportLabel">{{reportLabel || 'Custom report'}}</h3>
<div class="pageTitle">
    <div ng-if="SQL.breadcrumbs" breadcrumbs data="SQL.breadcrumbs"></div>
    <div ng-if="!SQL.breadcrumbs">
        <?php $this->load->view('/partials/elements/_reportsBreadcrumb', ['breadcrumbTitle' => 'Custom report']); ?>
    </div>
    <h1 ng-if="!SQL.breadcrumbs">Results</h1>
</div>
<div class="" id="filterTree" ng-init="showFilter=false" ng-class="{'open':showFilter}">
    <div class="accordion-group">
        <div class="accordion-toggle accordion-heading" data-parent="#filterTree" data-toggle="collapse">
            <span ng-click="showFilter=!showFilter">
                <i class="icon-chevron-right" ng-show="!showFilter" style="padding: 0px 5px;"></i>
                <i class="icon-chevron-down" ng-show="showFilter" style="padding: 0px 5px;"></i>
                Filters</span>
        </div>
    </div>

    <div class="margin-left-small">
        <?php $this->load->view('/partials/_environmentFilter'); ?>
    </div>
</div>

<div style="margin-top:80px">

    <div ng-show="reportLabel != ''">
        <h3 ng-if="reportLabel != ''">{{reportLabel}}</h3>
    </div>
    <span class="muted">{{SQL.hostcontexts.name}}</span>
    <input type="hidden" value="{{SQL.SQLSTRING}}"                    id="angularSQLString">
    <input type="hidden" value="{{VIEW.sortColumn}}" id="angularSQLSortColumn">
    <input type="hidden" value="{{VIEW.sortDescending}}" id="angularSQLSortDescending">
    <input type="hidden" value="{{SQL.hostcontexts.includes | json}}"  id="angularhostsContextInclude">
    <input type="hidden" value="{{SQL.excludedHosts.excludes | json}}"  id="angularhostsContextExclude">


    <div ng-hide="SQL.ruleId">
        <?php
            $this->load->view('/partials/_pagination');
        ?>
    </div>
    <div ng-show="SQL.ruleId">
        <div class="form-inline">
            <span>Show</span>
            <span class="btn-group margin-left-small">
                 <button class="btn dropdown-toggle" data-toggle="dropdown">
                     {{SQL.type.capitalizeFirstLetter()}}
                     <i class="bi bi-chevron-down"></i>
                 </button>
                 <ul class="dropdown-menu">
                     <li ng-repeat="type in ['all', 'passing', 'failing']">
                         <a
                                 onclick="document.location.href=`/reports/open_rule_report/${this.getAttribute('type')}/${this.getAttribute('ruleId')}/${this.getAttribute('reportId')}`"
                                 ruleId="{{SQL.ruleId}}"
                                 reportId="{{SQL.reportId}}"
                                 type="{{type}}"
                         >
                             {{type.capitalizeFirstLetter()}}
                         </a>
                     </li>
                 </ul>
           </span>
        </div>
    </div>

    <?php $this->load->view('/partials/_notification'); ?>

    <div class="sql-result-block row-fluid margin-top" ng-show="VIEW.rowCount > 0">

        <div class="horizontal-scroll sql-result-table-wrapper margin-bottom">


            <table class="table table-bordered float-left margin-top" ng-if="!deleteTableView" style="margin-bottom:0">
                <thead>
                    <tr>
                        <th class="sort-head" ng-repeat="head in VIEW.tablehead" ng-click="sortReorder(head.nameToSort, $event)">{{head.name}}
                            <i ng-class="{'icon-chevron-up':head.sort<0,'icon-chevron-down':head.sort>0}"></i></th>
                    </tr>
                </thead>
                <tbody tr-rows highlight="SQL.highlight" rowdata="VIEW.rows">
                </tbody>
            </table>

            <div ng-if="deleteTableView">

            <table class="table table-bordered float-left margin-top">
                <thead>
                    <tr>
                        <th ng-class="{'sort-head':$index!=0, 'deleteCheck':$index==0}" ng-repeat="head in VIEW.tablehead" ng-click="$index !=0 ? sortReorder(head.nameToSort, $event): ''">
                            <span ng-if="$index!=0">{{head.name}}<i ng-class="{'icon-chevron-up':head.sort<0,'icon-chevron-down':head.sort>0}"></i></span>
                            <span ng-if="$index==0"><input type="checkbox" ng-model="selectedAllDeleteHost" ng-click="checkAllDeleteHost()"> </span>
                        </th>
                    </tr>
                </thead>
                <tbody >
                <tr ng-repeat="rows in VIEW.rows">
                    <td ng-repeat="col in rows" ng-class="{'deleteCheck':$index==0}">
                        <span ng-if="$index != 0" ng-bind-html="col"></span>
                        <span ng-if="$index == 0"><input type="checkbox" ng-model="deleteHostList[col].checked"></span>
                    </td>
                </tr>
                </tbody>
            </table>
            </div>

        </div>
        <?php
            $this->load->view('/partials/_pagination');
        ?>
    </div>
</div>

<div id="resultScrollTo" class="margin-top">
<?php
    $data['buttonPosition'] = "bottom";
    $this->load->view('/partials/elements/_resultPageBtn', $data);
?>
</div>
<div class="pull-right go-to-top"><i class="icon-arrow-up"></i></div>
<div class="pull-right go-to-bottom"><i class="icon-arrow-down"></i></div>
