Example #1
0
function display_date_selector($p_year = null, $p_month = null, $p_day = null)
{
    $cur_year = get_current_year();
    $cur_month = get_current_month();
    $cur_day = get_current_day();
    $sel_year = $p_year == null ? $cur_year : $p_year;
    $sel_month = $p_month == null ? $cur_month : $p_month;
    $sel_day = $p_day == null ? $cur_day : $p_day;
    echo "<select name=\"fm_year\">\n";
    for ($year = $cur_year; $year <= $cur_year + 10; $year++) {
        $selected = $year == $sel_year ? "selected" : "";
        echo "<option value=\"{$year}\" {$selected}>{$year}</option>\n";
    }
    echo "</select>\n";
    echo "<select name=\"fm_month\">\n";
    for ($month = 1; $month <= 12; $month++) {
        $selected = $month == $sel_month ? "selected" : "";
        $month = sprintf("%02d", $month);
        echo "<option value=\"{$month}\" {$selected}>{$month}</option>\n";
    }
    echo "</select>\n";
    echo "<select name=\"fm_day\">\n";
    for ($day = 1; $day <= 31; $day++) {
        $selected = $day == $sel_day ? "selected" : "";
        $day = sprintf("%02d", $day);
        echo "<option value=\"{$day}\" {$selected}>{$day}</option>\n";
    }
    echo "</select>\n";
}
Example #2
0
         $assign['arr_report_data'] = $report_lp['data'];
         if (!empty($report_lp['data'])) {
             echo '<div class="col-sm-9"><h3>Целевые страницы</h3></div>';
             // Таблица отчета
             echo tpx('report_table', $assign);
         }
         // Возвращаем режим на место, иначе кнопки внизу будут вести на этот тип отчёта
         $params['mode'] = $assign['report_params']['mode'] = '';
         //}
     }
     break;
 case 'all_stats':
     if ($from == '') {
         if ($to == '') {
             $from = get_current_day('-6 days');
             $to = get_current_day();
         } else {
             $from = date('d.m.Y', strtotime('-6 days', strtotime($to)));
         }
     } else {
         if ($to == '') {
             $to = date('d.m.Y', strtotime('+6 days', strtotime($from)));
         } else {
             // Will use existing values
         }
     }
     $fromF = date('d.m.Y', strtotime($from));
     $toF = date('d.m.Y', strtotime($to));
     $value_date_range = "{$fromF} - {$toF}";
     echo '<form method="post"  name="datachangeform" id="range_form">
             <div class="pull-left"><h3>' . $report_name . '</h3></div>
function type_subpanel2($params, $type, $mode = '')
{
    // Кнопки типов статистики
    $type_buttons = array('all' => 'Все', 'day' => 'По дням', 'month' => 'По месяцам');
    $out = '';
    foreach ($type_buttons as $k => $v) {
        $add_params = array('part' => $k, 'type' => $type, 'mode' => $mode);
        // Дефолтные параметры для переключения на дни и месяцы
        if ($k == 'month') {
            $add_params['from'] = date('Y-m-01', strtotime(get_current_day('-6 months')));
            $add_params['to'] = date('Y-m-t', strtotime(get_current_day()));
        } elseif ($k == 'day' and $params['part'] == 'month') {
            $add_params['from'] = get_current_day('-6 days');
            $add_params['to'] = get_current_day();
        }
        echo '<li class="' . ($params['part'] == $k ? 'active' : '') . '"><a href="' . report_lnk($params, $add_params) . '">' . $v . '</a></li>';
    }
    return $out;
}
<?php

if (!$include_flag) {
    exit;
}
$params = $var['report_params'];
// Кнопки типов статистики
$type_buttons = array('all' => 'Все', 'day' => 'По дням', 'month' => 'По месяцам');
echo '<div class="btn-group">';
foreach ($type_buttons as $k => $v) {
    $add_params = array('part' => $k);
    // Дефолтные параметры для переключения на дни и месяцы
    if ($k == 'month') {
        $add_params['from'] = date('Y-m-01', strtotime(get_current_day('-6 months')));
        $add_params['to'] = date('Y-m-t', strtotime(get_current_day()));
    } elseif ($k == 'day' and $params['part'] == 'month') {
        $add_params['from'] = get_current_day('-6 days');
        $add_params['to'] = get_current_day();
    }
    echo '<a href="' . report_lnk($params, $add_params) . '" type="button" class="btn btn-default ' . ($params['part'] == $k ? 'active' : '') . '">' . $v . '</a>';
}
echo '</div>';
function report_options()
{
    global $group_types;
    // Дешифруем фильтры
    $tmp_filters = rq('filter');
    $filter = array(0 => array(), 1 => array());
    $filter_str = array();
    if (!empty($tmp_filters)) {
        $tmp_filters = explode(';', $tmp_filters);
        foreach ($tmp_filters as $tmp_filter) {
            list($k, $v, $type) = explode(':', $tmp_filter);
            $type = intval($type);
            if (array_key_exists($k, $group_types)) {
                $filter[$type][$k] = $v;
                $filter_str[$k] = $v . ':' . $type;
            }
        }
    }
    $part = rq('part', 0, 'day');
    // Устанавливаем даты по умолчанию
    switch ($part) {
        case 'month':
            $from = date('Y-m-01', strtotime(get_current_day('-6 months')));
            $to = date('Y-m-t', strtotime(get_current_day()));
            break;
        default:
            $from = get_current_day('-6 days');
            $to = get_current_day();
            break;
    }
    $group_by = rq('group_by', 0, 'out_id');
    $subgroup_by = rq('subgroup_by', 0, $group_by);
    $conv = rq('conv', 0, 'all');
    $mode = rq('mode', 0, '');
    $col = rq('col', 0, 'act');
    // Если эта группировка уже затронута фильтром - выбираем следующую по приоритету
    // Примечание: в отчёте по целевым можно не выбирать
    if ($mode != 'lp') {
        $i = 0;
        $group_types_keys = array_keys($group_types);
        while (!empty($filter) and array_key_exists($group_by, $filter)) {
            $group_by = $group_types_keys[$i];
            $i++;
        }
    }
    /*
          for($i = 0; empty($filter) or array_key_exists($group_by, $filter); $i++) {
          $group_by = $group_types_keys[$i];
          } */
    // Готовим параметры для отдачи
    $v = array('type' => rq('type', 0, 'basic'), 'part' => rq('part', 0, 'all'), 'filter' => $filter, 'filter_str' => $filter_str, 'group_by' => $group_by, 'subgroup_by' => $subgroup_by, 'conv' => $conv, 'mode' => $mode, 'col' => $col, 'from' => rq('from', 4, $from), 'to' => rq('to', 4, $to), 'no_other' => rq('no_other', 2));
    return $v;
}
function template_calendar_month(&$args)
{
    global $mod_strings;
    ?>

<table width="100%" id="daily_cal_table" border="0" cellspacing="1" cellpadding="0" >
  <?php 
    // need to change these values after we find out what activities
    // occur outside of these values
    /*
      $start_slice_idx = $args['calendar']->get_start_slice_idx();
      $end_slice_idx = $args['calendar']->get_end_slice_idx();
      $cur_slice_idx = 1;
    */
    $count = 0;
    if ($args['calendar']->slice_hash[$args['calendar']->slices_arr[35]]->start_time->month != $args['calendar']->date_time->month) {
        $rows = 5;
    } else {
        $rows = 6;
    }
    ?>
<tr>
<?php 
    if ($args['calendar']->show_week_on_month_view) {
        ?>
<th width="1%"  class="monthCalBodyTHWeek" scope='col'><?php 
        echo $mod_strings['LBL_WEEK'];
        ?>
</th>
<?php 
    }
    for ($i = 0; $i < 7; $i++) {
        $first_row_slice = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$i]];
        ?>
<th width="14%"  class="monthCalBodyTHDay" scope='col' ><?php 
        echo $first_row_slice->start_time->get_day_of_week_short();
        ?>
</th>
<?php 
    }
    ?>
</tr>
<?php 
    if (isset($_REQUEST['view']) && $_REQUEST['view'] == 'month') {
        $height_class = "monthViewDayHeight";
    } else {
        if (isset($args['size']) && $args['size'] == 'small') {
            $height_class = "";
        } else {
            $height_class = "yearViewDayHeight";
        }
    }
    for ($i = 0; $i < $rows; $i++) {
        ?>
<tr class="<?php 
        echo $height_class;
        ?>
">
<?php 
        if ($args['calendar']->show_week_on_month_view) {
            ?>
<td valign=middle align=center class="monthCalBodyWeek" scope='row'><a href="index.php?module=Calendar&action=index&view=week&<?php 
            echo $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]]->start_time->get_date_str();
            ?>
" class="monthCalBodyWeekLink"><?php 
            echo $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count + 1]]->start_time->week;
            ?>
</a></td>
<?php 
        }
        for ($j = 0; $j < 7; $j++) {
            $args['slice'] = $args['calendar']->slice_hash[$args['calendar']->slices_arr[$count]];
            ?>

<td  valign=top <?php 
            if ($j == 0) {
                echo "scope='row' ";
            }
            ?>
 class="<?php 
            if ($j == 0 || $j == 6) {
                ?>
monthCalBody<?php 
                if (get_current_day($args) == true) {
                    echo "Today";
                }
                ?>
WeekEnd<?php 
            } else {
                ?>
monthCalBody<?php 
                if (get_current_day($args) == true) {
                    echo "Today";
                }
                ?>
WeekDay<?php 
            }
            ?>
"><?php 
            template_cal_day_slice($args);
            ?>
</td>

<?php 
            $count++;
        }
        ?>
</tr>
<?php 
    }
    ?>
</table>
<?php 
}
            // Set default value
            $IN[$report][$cur] = $allowed_report_in_params[$report][$cur];
        }
    }
}
// Get hourly report data
$arr_report_data = prepare_report('main-report', $IN['hourly_report'] + array('report_type' => 'stats_flow', 'range_type' => 'hourly', 'date_start' => $IN['flow_report']['date'], 'date_end' => $IN['flow_report']['date']));
// Don't use parameters from hourly report
unset($arr_report_data['report_params']);
// Get clicks flow data
list($more, $arr_flow_data, $s, $s1) = get_visitors_flow_data($IN, 'flow_report');
// Fill variables for stats-flow report
$arr_flow_data['show_more'] = $more;
$date_prev = date('Y-m-d', strtotime('-1 days', strtotime($IN['flow_report']['date'])));
$date_next = date('Y-m-d', strtotime('+1 days', strtotime($IN['flow_report']['date'])));
$arr_template_data = array('hide-table-footer' => true, 'date_current' => $IN['flow_report']['date'], 'date_prev_caption' => mysqldate2string($date_prev), 'date_current_caption' => mysqldate2string($IN['flow_report']['date']), 'date_next_caption' => mysqldate2string($date_next), 'hide_next_day' => $IN['flow_report']['date'] == get_current_day(), 'date_prev' => $date_prev, 'date_next' => $date_next, 'csrf' => CSRF_KEY);
// Render template
echo $mTemplate->render('stats-flow-page', $arr_report_data + $arr_template_data + $arr_flow_data);
?>

<script type="text/javascript">
    function refresh_report(param_name, param_value)
    {
        switch (param_name)
        {
            default:
                var param_found=false;
                $('#report_params input[type="hidden"]').each(function() {
                    if ($(this).attr('name')==param_name)
                    {
                        param_found=true;
$group_actions = array('act' => array('cnt_act', 'conversion_a', 'roi', 'epc', 'profit'), 'sale' => array('cnt_sale', 'conversion', 'roi', 'epc', 'profit'), 'lead' => array('cnt_lead', 'conversion_l', 'cpl'));
$main_type = rq('report_type', 0, 'source_name');
$limited_to = '';
$params = array('type' => 'basic', 'part' => 'hour', 'filter' => array(), 'group_by' => $main_type, 'subgroup_by' => $main_type, 'conv' => 'all', 'mode' => '', 'col' => 'sale_lead', 'from' => $date, 'to' => $date);
$arr_report_data = get_clicks_report_grouped2($params);
/********/
$arr_hourly = array();
foreach ($arr_report_data['data'] as $row_name => $row_data) {
    foreach ($row_data as $cur_hour => $data) {
        $arr_hourly[$row_name][$cur_hour] = get_clicks_report_element2($data, true, false, $group_actions);
    }
}
echo "<div class='row'>";
echo "<div class='col-md-12'>";
echo "<p align=center>";
if ($date != get_current_day()) {
    echo "<a style='float:right;' href='?date={$next_date}&report_type={$main_type}'>" . mysqldate2string($next_date) . " &rarr;</a>";
} else {
    echo "<a style='float:right; visibility:hidden;' href='?date={$next_date}&report_type={$main_type}'>" . mysqldate2string($next_date) . " &rarr;</a>";
}
echo "<b>" . mysqldate2string($date) . "</b>";
echo "<a style='float:left;' href='?date={$prev_date}&report_type={$main_type}'>&larr; " . mysqldate2string($prev_date) . "</a></p>";
echo "<table class='table table-striped table-bordered table-condensed'>";
echo "<tbody>";
echo "<tr>";
echo "<td>";
echo "<div class='btn-group'>";
switch ($main_type) {
    case 'out_id':
        echo "<button class='btn btn-link dropdown-toggle' data-toggle='dropdown' style='padding:0; color:black; font-weight: bold;'>Оффер <span class='caret'></span></button>\n\t\t\t\t\t\t\t  <ul class='dropdown-menu'>\n\t\t\t\t\t\t\t    <li><a href='?date={$date}&report_type=source_name'>Источник</a></li>\n\t\t\t\t\t\t\t  </ul>";
        break;