<?php
/**
 * Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 *  all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 *
 */

/** @var $this \Zend\View\Renderer\PhpRenderer */

$this->headScript()
    ->appendFile('//cdnjs.cloudflare.com/ajax/libs/autosize.js/3.0.18/autosize.min.js')
    ->appendFile('/js/jquery.cookie.js')
    ->appendFile('/js/underscore-min.js')
    ->appendFile('/js/c3.min.js')
    ->appendFile('/js/d3.min.js')
    ->appendFile('/js/datepicker.min.js')
    ->appendFile('/js/bootstrap-tokenfield.js')
    ->appendFile('/js/script-reports-conf.js')
    ->appendFile('/js/script-reports-charts.js')
    ->appendFile('/js/script-reports-table.js')
    ->appendFile('/js/script-reports.js')
;

$this->headLink()
    ->appendStylesheet('/css/styles-cabinet.css')
    ->appendStylesheet('/css/styles-cabinet-550.css', 'all and (max-width: 550px)')
    ->appendStylesheet('/css/styles-cabinet-stats.css')
    ->appendStylesheet('/css/c3.css')    
    ->appendStylesheet('/css/styles-support-index.css')
    ->appendStylesheet('/css/datepicker.min.css')
;

$periodStat = $this->periodStat;

?>

<textarea id="period-stats" style="display: none;"><?= ($periodStat ? json_encode($periodStat) : '')?></textarea>

<div class="wrapp" style="margin-bottom: 50px;">
    
    <?= $this->partial('adm::reports/_metrictype', ['lang' => $this->lang, 'dates' => $this->dates,'listMetrics' => $this->listMetrics, 'metricType' => $this->metricType]) ?>
    
    <?= $this->partial('adm::reports/_filters') ?>
    
    <div class="b-content__traffic-filter">
        <div>
            <div class="b-filter__switch display time" style="display: none;">
                <span class="b-filter__switch-item text" data-filter-category="min"><?= _t('Минуты')?></span>
                <span class="b-filter__switch-item text" data-filter-category="hour"><?= _t('Часы')?></span>
            </div>
            <div class="b-filter__switch display days" style="display: none;">
                <span class="b-filter__switch-item text" data-filter-category="day"><?= _t('Дни')?></span>
                <span class="b-filter__switch-item text" data-filter-category="week"><?= _t('Недели')?></span>
                <span class="b-filter__switch-item text" data-filter-category="month"><?= _t('Месяцы')?></span>
            </div>
        </div>
        
        <?php foreach($variables as $metric => $categories): ?>
            <?php $current_class = ($this->metricType == $metric) ? 'current-metric' : ''; ?>
            <?php $current_style = ($this->metricType != $metric) ? 'style="display: none;"' : ''; ?>
        
            <?php if($metric == 'minstat'): ?>
                <?php /* Показы/Клики/CTR/Деньги/CPM/CPC/Ratio */ ?>
                <div class="b-filter__switch display metric-cat current <?= $current_class ?>" data-metric="<?= $metric ?>" <?= $current_style ?>>
                    <span class="b-filter__switch-item text" data-filter-category="sspViewsCnt" title="sspViewsCnt">Показы</span>
                    <span class="b-filter__switch-item text" data-filter-category="sspClicksCnt" title="sspClicksCnt">Клики</span>
                    <span class="b-filter__switch-item text" data-filter-category="ctr" title="ctr">CTR</span>
                    <span class="b-filter__switch-item text" data-filter-category="money" title="money">Деньги</span>
                    <span class="b-filter__switch-item text" data-filter-category="cpm" title="cpm">CPM</span>
                    <span class="b-filter__switch-item text" data-filter-category="cpc" title="cpc">CPC</span>
                    <span class="b-filter__switch-item text" data-filter-category="ratio" title="ratio">Ratio</span>
                </div>
                <?php /* Сумма/Сайт/Система */ ?>
                <div class="b-filter__switch display metric-cat current metric-data <?= $current_class ?>" data-metric="<?= $metric ?>" <?= $current_style ?>>
                    <span class="b-filter__switch-item text" data-filter-category="sum" title="sum">Сумма</span>
                    <span class="b-filter__switch-item text" data-filter-category="site" title="site">Сайт</span>
                    <span class="b-filter__switch-item text" data-filter-category="system" title="system">Система</span>
                </div>
            <?php else : ?>
                <div class="b-filter__switch display metric-cat current <?= $current_class ?>" data-metric="<?= $metric ?>" <?= $current_style ?>>
                    <?php foreach($categories as $name => $title): ?>
                    <span class="b-filter__switch-item text" data-filter-category="<?= $name ?>" title="<?= $name ?>"><?= $title ?></span>
                    <?php endforeach ?>
                </div>
            <?php endif; ?>
        
        <?php endforeach ?>
        
        <?php /* ?>
        <div class="b-filter__switch display short current" data-metric="<?= $this->metricType?>">
            <?php foreach($variables as $name => $title): ?>
            <span class="b-filter__switch-item text" data-filter-category="<?= $name ?>"><?= $title ?></span>
            <?php endforeach ?>
        </div>
        <?php */ ?>
        
    </div>
    
    <div class="chart-graph-stat-info">
        <h2>По заданным параметрам статистика отсутствует</h2>
    </div>
    <div class="chart-graph-stat-error">
        <h2>Ошибка в статистике</h2>
        <div class="message"></div>
    </div>
    
    <div id="chart-graph-stat" style="height: 370px;"></div>
    
    <div class="chart-graph-stat-loading"></div>
    
</div>

<?php /* Таблица */ ?>
<?php if (true/*!$isProvidersMetric*/): ?>
    <?= $this->partial('adm::reports/_table') ?>
<?php endif; ?>
