<div>
    <h2 piwik-enriched-headline
        help-url="http://piwik.org/docs/manage-websites/#all-websites-dashboard"
        feature-name="{{ 'General_AllWebsitesDashboard'|translate }}">
        {{ 'General_AllWebsitesDashboard'|translate }}
        <span class='smallTitle'
              title="{{ 'General_EvolutionSummaryGeneric'|translate:('General_NVisits'|translate:model.totalVisits):date:model.lastVisits:model.lastVisitsDate:(model.totalVisits|evolution:model.lastVisits)}}"
              ng-bind-html="'General_TotalVisitsPageviewsActionsRevenue' | translate:('<strong>'+model.totalVisits+'</strong>'):('<strong>'+model.totalPageviews+'</strong>'):('<strong>'+model.totalActions+'</strong>'):('<strong>' + model.totalRevenue + '</strong>')">
        </span>
    </h2>

    <table id="mt" class="dataTable" cellspacing="0">
        <thead>
        <tr>
            <th id="names" class="label" ng-click="model.sortBy('label')" ng-class="{columnSorted: 'label' == model.sortColumn}">
                <span class="heading">{{ 'General_Website'|translate }}</span>
                <span ng-class="{multisites_asc: !model.reverse && 'label' == model.sortColumn, multisites_desc: model.reverse && 'label' == model.sortColumn}" class="arrow"></span>
            </th>
            <th id="visits" class="multisites-column" ng-click="model.sortBy('nb_visits')" ng-class="{columnSorted: 'nb_visits' == model.sortColumn}">
                <span ng-class="{multisites_asc: !model.reverse && 'nb_visits' == model.sortColumn, multisites_desc: model.reverse && 'nb_visits' == model.sortColumn}" class="arrow"></span>
                <span class="heading">{{ 'General_ColumnNbVisits'|translate }}</span>
            </th>
            <th id="pageviews" class="multisites-column" ng-click="model.sortBy('nb_pageviews')" ng-class="{columnSorted: 'nb_pageviews' == model.sortColumn}">
                <span ng-class="{multisites_asc: !model.reverse && 'nb_pageviews' == model.sortColumn, multisites_desc: model.reverse && 'nb_pageviews' == model.sortColumn}" class="arrow"></span>
                <span class="heading">{{ 'General_ColumnPageviews'|translate }}</span>
            </th>

            <th ng-if="displayRevenueColumn" id="revenue" class="multisites-column" ng-click="model.sortBy('revenue')" ng-class="{columnSorted: 'revenue' == model.sortColumn}">
                <span ng-class="{multisites_asc: !model.reverse && 'revenue' == model.sortColumn, multisites_desc: model.reverse && 'revenue' == model.sortColumn}" class="arrow"></span>
                <span class="heading">{{ 'General_ColumnRevenue'|translate }}</span>
            </th>

            <th id="evolution" colspan="{{ showSparklines ? 2 : 1 }}" ng-class="{columnSorted: evolutionSelector == model.sortColumn}">
                <span class="arrow" ng-class="{multisites_asc: !model.reverse && evolutionSelector == model.sortColumn, multisites_desc: model.reverse && evolutionSelector == model.sortColumn}"></span>
                <span class="evolution"
                      ng-click="model.sortBy(evolutionSelector)"> {{ 'MultiSites_Evolution'|translate }}</span>
                <select class="selector native-select" id="evolution_selector" ng-model="evolutionSelector"
                        ng-change="model.sortBy(evolutionSelector)">
                    <option value="visits_evolution">{{ 'General_ColumnNbVisits'|translate }}</option>
                    <option value="pageviews_evolution">{{ 'General_ColumnPageviews'|translate }}</option>
                    <option ng-if="displayRevenueColumn" value="revenue_evolution">{{ 'General_ColumnRevenue'|translate }}</option>
                </select>
            </th>
        </tr>
        </thead>

        <tbody id="tb" ng-if="model.isLoading">
            <tr>
                <td colspan="7" class="allWebsitesLoading">
                    {{ 'MultiSites_LoadingWebsites' | translate }}
                    <span class="allWebsitesLoadingIndicator"> </span>
                </td>
            </tr>
        </tbody>

        <tbody id="tb" ng-if="!model.isLoading">

            <tr ng-if="model.errorLoadingSites">
                <td colspan="7">
                    <div class="notification system notification-error">
                        {{ 'General_ErrorRequest'|translate:(''):('') }}

                        <br /><br />
                        {{ 'General_NeedMoreHelp'|translate }}

                        <a rel="noreferrer" target="_blank" href="https://piwik.org/faq/troubleshooting/faq_19489/">{{ 'General_Faq'|translate }}</a>
                        –
                        <a rel="noreferrer" target="_blank" href="http://forum.piwik.org/">{{ 'Feedback_CommunityHelp'|translate }}</a>
                        <span ng-show="arePiwikProAdsEnabled"> – </span>
                        <a ng-show="arePiwikProAdsEnabled" rel="noreferrer" target="_blank" href="https://piwik.pro/?pk_campaign=Help&pk_medium=AjaxError&pk_content=MultiSites&pk_source=Piwik_App">{{ 'Feedback_ProfessionalHelp'|translate }}</a>.
                    </div>
                </td>
            </tr>

            <tr website="website"
                evolution-metric="evolutionSelector"
                piwik-multisites-site
                date-sparkline="dateSparkline"
                show-sparklines="showSparklines"
                metric="model.sortColumn"
                display-revenue-column="displayRevenueColumn"
                ng-repeat="website in model.sites">
            </tr>
        </tbody>

        <tfoot>

        <tr ng-if="hasSuperUserAccess">
            <td colspan="8" class="add_new_site">
                <a href="{{ url }}?module=SitesManager&action=index&showaddsite=1&period={{ period }}&date={{ date }}&idSite={{ idSite }}">
                    <img src='plugins/Morpheus/images/add.png' alt=""/> {{ 'SitesManager_AddSite'|translate }}
                </a>
            </td>
        </tr>

        <tr ng-if="!hasSuperUserAccess">
            <td colspan="8" class="empty-row">
                <br/>
            </td>
        </tr>
        <tr>
            <td colspan="8" class="paging" ng-hide="model.numberOfPages() <= 1">
                <span id="prev" class="previous" ng-hide="model.currentPage == 0" ng-click="model.previousPage()">
                    <span style="cursor:pointer;">&#171; {{ 'General_Previous'|translate }}</span>
                </span>
                <span class="dataTablePages">
                    <span id="counter">
                        {{ 'General_Pagination'|translate:model.getCurrentPagingOffsetStart():model.getCurrentPagingOffsetEnd():model.getNumberOfFilteredSites() }}
                    </span>
                </span>
                <span id="next" class="next" ng-hide="model.currentPage >= model.getNumberOfPages()" ng-click="model.nextPage()">
                    <span style="cursor:pointer;" class="pointer">{{ 'General_Next'|translate }} &#187;</span>
                </span>
            </td>
        </tr>
        <tr row_id="last">
            <td colspan="8" class="site_search">
                <input type="text"
                       ng-model="searchTerm"
                       piwik-onenter="model.searchSite(searchTerm)"
                       placeholder="{{ 'Actions_SubmenuSitesearch' | translate }}">
                <img title="{{ 'General_ClickToSearch' | translate }}"
                     ng-click="model.searchSite(searchTerm)"
                     class="search_ico"
                     src="plugins/Morpheus/images/search_ico.png"/>
            </td>
        </tr>

        </tfoot>
    </table>
</div>
