Example #1
0
<?php

if (!$include_flag) {
    exit;
}
echo '<script src="' . _HTML_LIB_PATH . '/chartjs/Chart.js"></script>';
echo '<script src="' . _HTML_LIB_PATH . '/mustache/mustache.js"></script>';
include _TRACK_SHOW_COMMON_PATH . '/lib/mustache/Autoloader.php';
Mustache_Autoloader::register(_TRACK_SHOW_COMMON_PATH . '/lib/mustache');
$mTemplate = new Mustache_Engine(array('loader' => new Mustache_Loader_FilesystemLoader(_TRACK_SHOW_COMMON_PATH . '/templates/views')));
$arr_currencies_list = get_active_currencies();
$selected_currency = current($arr_currencies_list);
$arr_report_data = prepare_report('main-report', $_REQUEST + array('report_params' => array('act' => 'reports'), 'type' => 'sales', 'main_column' => 'source_name'));
list($more, $arr_flow_data, $s, $s1) = get_sales_flow_data($_REQUEST, 'flow_report');
$arr_report_data['flow_rows'] = $arr_flow_data;
$arr_report_data['show_more'] = $more;
// Fill sales table header names
$arr_report_data['flow-table-header']['values'] = array('short_date' => array('caption' => 'Дата'), 'offer_name' => array('caption' => 'Оффер'), 'network' => array('caption' => 'Сеть'), 'source_name' => array('caption' => 'Источник'), 'campaign_name' => array('caption' => 'Кампания'), 'placement' => array('caption' => 'Площадка'), 'profit' => array('caption' => 'Сумма'), 'status' => array('caption' => 'Статус'));
// ********************************************************************************
// Prepare data for sales chart
$i = 0;
$arr_sales_chart_data = array();
foreach ($arr_report_data['table-columns'] as $cur) {
    if ($i++ == 0) {
        continue;
    }
    $arr_sales_chart_data['captions'][] = "'" . $cur['caption'] . "'";
}
$i = 0;
$total_sales = 0;
foreach ($arr_report_data['table-total']['values'] as $cur) {
Example #2
0
if ($_REQUEST['ajax_act'] == 'a_load_sales_flow') {
    // 20 - first request limit, 100 - second and next request limit
    $offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] + 100 : 20;
    if ($_REQUEST['filter_by'] == 'subid') {
        $offset = 0;
    }
    if ($_REQUEST['limit'] != '') {
        $limit = $_REQUEST['limit'];
    } else {
        $limit = 100;
    }
    $IN = $_REQUEST;
    if (isset($IN['date_start'])) {
        $IN['report_period'] = 'custom';
    }
    list($more, $arr_data, $offset) = get_sales_flow_data($IN, 'flow_report', $limit, $offset);
    $out = array('more' => $more, 'data' => $arr_data, 'offset' => $offset);
    echo json_encode($out);
    exit;
}
if ($_REQUEST['ajax_act'] == 'copy_link') {
    $old_id = rq('link_id', 2);
    // Создаём новый линк в базе
    $ins = array('link_name' => 'lnk_' . mt_rand(11111, 99999), 'date_add' => date('Y-m-d H:i:s'));
    $q = insertsql($ins, 'tbl_rules');
    db_query($q);
    $new_id = mysql_insert_id();
    // Корректируем имя линка
    $link_name = 'lnk_' . $new_id;
    $upd = array('link_name' => $link_name, 'id' => $new_id);
    $q = updatesql($upd, 'tbl_rules', 'id');