<?php
/*
    Таблица
*/
?>

<section id="b-content__traffic-table" class="b-content__traffic metrics" style="display: none;">
    <div class="b-content__loading"></div>
    <div class="wrapp">
        <div class="b-filter__switch display time-table">
            <span class="b-filter__switch-item text" data-filter-category="min"><?= _t('Поминутно')?></span>
            <span class="b-filter__switch-item text" data-filter-category="sum"><?= _t('Суммарно')?></span>
        </div>
        
        <?php if ($this->metricType == 'minstat') : ?>
        <div class="b-filter__switch display count-sites">
            <span class="b-filter__switch-item text" data-filter-category="50">50</span>
            <span class="b-filter__switch-item text" data-filter-category="100">100</span>
            <span class="b-filter__switch-item text" data-filter-category="150">150</span>
        </div>
        
        <div class="b-filter__switch display category-table">
            <span class="b-filter__switch-item text" data-filter-category="bytime"><?= _t('По дням')?></span>
            <span class="b-filter__switch-item text" data-filter-category="bysites"><?= _t('По сайтам')?></span>
            <span class="b-filter__switch-item text" data-filter-category="byzones"><?= _t('По зонам')?></span>
            <span class="b-filter__switch-item text" data-filter-category="bycountries"><?= _t('По странам')?></span>
        </div>
        <?php endif; ?>
        
        <table id="table-line" class="table table-striped admin">
            
            <thead class="metric">
            <?php foreach($variables as $metric => $categories): ?>
                <?php $current_style = ($this->metricType != $metric) ? 'style="display: none;"' : ''; ?>
                
                    <?php if($metric == 'minstat'): ?>
                        <tr data-metric="<?= $metric ?>" <?= $current_style ?>>
                            <th rowspan="2"><?= _t('Время')?></th>
                            <th rowspan="2"><b id="sspViewsCnt">Показы</b></th>
                            <th rowspan="2"><b id="sspClicksCnt">Клики</b></th>
                            <th rowspan="2"><b id="ctr">CTR</b></th>

                            <th colspan="3" class="minstat-common-th"><b id="sum">Сумма</b></th>
                            <th colspan="3" class="minstat-common-th"><b id="site">Сайт</b></th>
                            <th colspan="3" class="minstat-common-th"><b id="system">Система</b></th>
                            <th rowspan="2"><b id="ratio">Ratio</b></th>
                        </tr>
                        <tr data-metric="<?= $metric ?>" <?= $current_style ?>>
                            <th class="minstat-item-th" style="width: 100px;"><b id="sspMoney">Деньги</b></th>
                            <th class="minstat-item-th"><b id="cpm">CPM</b></th>
                            <th class="minstat-item-th"><b id="cpc">CPC</b></th>
                            
                            <th class="minstat-item-th" style="width: 100px;"><b id="sspSiteMoney">Деньги</b></th>
                            <th class="minstat-item-th"><b id="siteCpm">CPM</b></th>
                            <th class="minstat-item-th"><b id="siteCpc">CPC</b></th>
                            
                            <th class="minstat-item-th" style="width: 100px;"><b id="sspSystemMoney">Деньги</b></th>
                            <th class="minstat-item-th"><b id="systemCpm">CPM</b></th>
                            <th class="minstat-item-th"><b id="systemCpc">CPC</b></th>
                        </tr>
                    <?php else : ?>
                        <tr data-metric="<?= $metric ?>" <?= $current_style ?>>
                            <th><?= _t('Время')?></th>
                            <?php foreach($categories as $name => $title): ?>
                            <th>
                                <b id="<?= $name ?>">
                                    <?= _t($title)?>
                                    <b class="arrow asc">&and;</b>
                                    <b class="arrow desc">&or;</b>
                                </b>
                            </th>
                            <?php endforeach ?>
                        </tr>
                    <?php endif; ?>
                
                    <?php if(false): ?>
                    <tr data-metric="<?= $metric ?>" <?= $current_style ?>>
                        <th><?= _t('Время')?></th>
                        
                        <?php if($metric == 'minstat'): ?>
                            <th><b id="sspViewsCnt">Показы</b></th>
                            <th><b id="sspClicksCnt">Клики</b></th>
                            <th><b id="ctr">CTR</b></th>
                            <th><b id="money">Деньги</b></th>
                            <th><b id="cpm">CPM</b></th>
                            <th><b id="cpc">CPC</b></th>
                            <th><b id="ratio">Ratio</b></th>
                        <?php else : ?>
                            <?php foreach($categories as $name => $title): ?>
                            <th>
                                <b id="<?= $name ?>">
                                    <?= _t($title)?>
                                    <b class="arrow asc">&and;</b>
                                    <b class="arrow desc">&or;</b>
                                </b>
                            </th>
                            <?php endforeach ?>
                        <?php endif; ?>
                    </tr>
                    <?php endif; ?>
            <?php endforeach ?>
            </thead>
            <tbody>
            </tbody>
        </table>
    </div>
</section>
