
<?php

//******************************* M O D A L *******************************************************
$this->load->view('/partials/_saveSearchModal');
$this->load->view('/partials/_copySearchModal');
//******************************* M O D A L *******************************************************
?>
<div class="pageTitle">
    <h1>
        <span>Changes</span>
        <span class="pull-right">
            <i rel="tooltip" id="tab-context-help-icon" class="CFE-context-help help icon-question-sign" data-key="changes" data-title="Changes" data data-placement='left' title="Click for help"> </i>
        </span>
    </h1>
</div>
<div 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" id="filterToggle">
                <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 ng-show="originalFilters.length" class="help-block inline" style="font-size:14px; font-style:normal">({{originalFilters.length}})</span>
            </span>
        </div>
    </div>

    <div ng-show="showFilter" class="margin-left-small margin-bottom-small">

        <div class="margin-top margin-bottom-small border-bottom border-light" id="variableFilters">
            <div class="changesfilter"
                ui  = "UI"
                filters = "filters"
                showfilterapplybtn = "true"
                >
            </div>

        </div>

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

    </div>

</div>

<div>
    <label class="pull-right">
        <input
            date-range-picker
            class="form-control date-picker pull-right"
            type="text"
            ng-model="myDateRange"
            options="dateOpts"
            min="weekDate"
            max="todayDate"
        >
        <span class="micro-copy help-block">Filter by date</span>
    </label>
</div>

<div style="margin-top:95px;">

    <div ng-show="reportLabel">
        <h3 class="margin-bottom" ng-if="reportLabel != ''">Results for {{reportLabel}}</h3>
    </div>

    <input type="hidden" value="{{SQL.SQLSTRING}}" id="angularSQLString">
    <input type="hidden" value="{{SQL.hostcontexts.includes | json}}"  id="angularhostsContextInclude">
    <input type="hidden" value="{{SQL.excludedHosts.excludes | json}}"  id="angularhostsContextExclude">
    <input type="hidden" value="{{reportCategory}}" id="reportCategory">
    <input hidden-csv type="hidden" value="{{csvArray}}" id="csvArray" onclick="showDownloadForm(); return false;">
    <?php $this->load->view('/partials/_notification'); ?>

    <div class="sql-result-block changes-result margin-top row-fluid" ng-show="result">

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

        <div class="horizontal-scroll sql-result-table-wrapper margin-bottom">
            <table id="changes-table" class="table table-bordered float-left margin-top" style="margin-bottom:0">
                <thead>
                    <tr>
                        <th id="header{{$index}}" class="sort-head" ng-repeat="column in selectedCols track by $index" ng-click="sortReorder(column.name)">
                            <div style="width:100%; margin-right:32px;position:relative">
                                <span>{{column.label}}</span>
                                <i ng-class="{'icon-chevron-up':column.sort<0,'icon-chevron-down':column.sort>0}"></i>
                                <i class="placeholder-icon icon-reorder"></i>
                            </div>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="row in result track by $index">
                        <td ng-repeat="column in selectedCols track by $index">
                            <span ng-if="column.type=='string'">
                                <span ng-show="column.name !== 'hostname'" ng-bind-html="row[column.name]">{{row[column.name]}}</span>
                                <a ng-show="column.name === 'hostname'" ng-bind-html="row[column.name]" href="<?php echo site_url('hosts/'); ?>/{{row['hostkey']}}">{{row[column.name]}}</a>
                            </span>
                            <span ng-if="column.type=='date'">{{getTime(row[column.name])}}</span>
                            <div ng-if="column.type=='slist'">
                                <span ng-bind-html="row[column.name].join(', ')"></span>
                                <span ng-if="!row[column.name].length">-</span>
                            </div>
                            <span ng-if="!row[column.name]">-</span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>

        <div style="position:relative;z-index:3">
            <div ng-repeat="head in selectedCols" ng-class="{'last':$last}" column-dropdown class="column-dropdown" column-index="{{$index}}" ng-cloak id="dropdown{{$index}}">
            </div>
        </div>

        <?php
            $this->load->view('/partials/_pagination');
        ?>
    </div>
    <div id="resultScrollTo" class="margin-top">
    <?php
        $data['buttonPosition'] = "bottom";
        $data['showEdit'] = false;
        $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>
</div>
<?php  $this->load->view('/partials/_showChartModal'); ?>
