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
						<th>examinations</th>
						<th>extra</th>
					</tr>';
        }
        $all_ex = get_all_ex($sample_array['sample_id']);
        echo '<tr>
					<td>' . $sample_array['section'] . '</td>
					<td>' . $sample_array['request_id'] . '</td>
					<td>' . $sample_array['sample_id'] . '</td>
					<td>' . $sample_array['patient_name'] . '</td>
					<td>' . $sample_array['patient_id'] . '</td>
					<td>' . $sample_array['clinician'] . '/' . $sample_array['unit'] . '/' . $sample_array['location'] . '</td>
					<td>' . $all_ex[0] . '</td>
					<td><pre>' . $sample_array['extra'] . '</pre>
					<td><pre>' . $all_ex[1] . '</pre>					
					</td>
				</tr>';
        $prev_section = $section;
    }
    echo '</table>';
}
if (!login_varify()) {
    exit;
}
if (!isset($_POST['from']) || !isset($_POST['to'])) {
    main_menu();
    read_from_to();
} else {
    //echo 'preparing to print requests from '.$_POST['from'].' to '.$_POST['to'];
    prepare_report($_POST['from'], $_POST['to']);
}
Example #3
0
<?php

include_once 'k-inc.php';
$logfile = $tmp_dir . "/ks-callback.log";
// check deleteSchema
file_put_contents($logfile, date(DATE_ATOM) . "hit" . print_r($_REQUEST, true) . " \n", FILE_APPEND);
if (FALSE !== strpos($_GET["type"], "updateschema")) {
    // update dataset
    $key = (int) $_GET["obj_key"];
    $report_fname = prepare_report($key);
    //$client_dir=$tmp_dir;
    //$report_fname=$client_dir."report.zip";
    $secret = sha1($capsidea_client_secret . $capsidea_permanent_access_token);
    $host_reply = askhost($server_url . "&schemakey=" . $key . $schemajson, array('file_contents' => '@' . $report_fname), "", "", "", 1800000, array("appid: {$capsidea_appid}", "sig: {$secret}"), true);
    // defined in askhost.php
    //echo " time ".$time3=((get_timer()-$stime)/1)." sec "; // $stime=get_timer();
    $result = $host_reply["data"];
    $error_log = "cube: {$key}" . "secret: " . $secret . "<br>response:<pre>" . $host_reply["data"] . "</pre>" . "<br>connection debug:<pre>" . $host_reply["d"] . "</pre>";
    if (500 == $host_reply["httpcode"]) {
        echo "ERR: {$error_log}\n" . $host_reply["httpcode"];
        log_fatal("error 500 from cps: \n {$error_log}");
    }
    // if 500
    if (401 == $host_reply["httpcode"]) {
        echo "ERR: unauthorized {$error_log}\n" . $host_reply["httpcode"];
        log_fatal("error 401 from cps \n {$error_log}");
    }
    // if 500
    if (200 == $host_reply["httpcode"]) {
        echo "unlinking " . $report_fname . "\n";
        unlink($report_fname);
Example #4
0
<?php

// callback file, requested by capsidea.com when user needs new data
include 'cb-inc.php';
$logfile = $tmp_dir . "/crunchbase-callback.log";
file_put_contents($logfile, date(DATE_ATOM) . "hit" . print_r($_REQUEST, true) . " \n", FILE_APPEND);
if (FALSE !== strpos($_GET["type"], "updateschema")) {
    // update dataset
    $key = (int) $_GET["obj_key"];
    $m = new MongoClient();
    $db = $m->crunchbase;
    $report_fname = prepare_report($db);
    $secret = sha1($capsidea_client_secret . $capsidea_permanent_access_token);
    $host_reply = askhost($server_url . "&schemakey=" . $key . $schemajson, array('file_contents' => '@' . $report_fname), "", "", "", 1800000, array("appid: {$capsidea_appid}", "sig: {$secret}"), true);
    // defined in askhost.php
    //echo " time ".$time3=((get_timer()-$stime)/1)." sec "; // $stime=get_timer();
    $result = $host_reply["data"];
    $error_log = "cube: {$key}" . "secret: " . $secret . "<br>response:<pre>" . $host_reply["data"] . "</pre>" . "<br>connection debug:<pre>" . $host_reply["d"] . "</pre>";
    if (500 == $host_reply["httpcode"]) {
        echo "ERR: {$error_log}\n" . $host_reply["httpcode"];
        log_fatal("error 500 from cps: \n {$error_log}");
    }
    // if 500
    if (401 == $host_reply["httpcode"]) {
        echo "ERR: unauthorized {$error_log}\n" . $host_reply["httpcode"];
        log_fatal("error 401 from cps \n {$error_log}");
    }
    // if 500
    if (200 == $host_reply["httpcode"]) {
        echo "unlinking " . $report_fname . "\n";
        unlink($report_fname);
Example #5
0
<?php

if (!$include_flag) {
    exit;
}
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')));
foreach ($arr_report_data['report_params'] as $cur) {
    if ($cur['name'] == 'currency_id') {
        $selected_currency = $arr_currencies_list[$cur['value']];
        break;
    }
}
echo $mTemplate->render('report-page', $arr_report_data + array('currencies' => array_values($arr_currencies_list), 'selected_currency_symbol' => $selected_currency['symbol']));
?>
<script>
    function refresh_report(param_name, param_value)
    {
        if (param_name=='custom_range')
        {
            var obj=$(param_value).parent();
            var date_start=$('input[name="start"]', $(obj)).val();
            date_start=date_start.split('.');
            date_start=date_start[2] + '-' + date_start[1] + '-' + date_start[0];

            var date_end=$('input[name="end"]', $(obj)).val();
            date_end=date_end.split('.');
Example #6
0
 // Default account currency id: 16; RUB
 $main_currency_id = 16;
 $IN = $_REQUEST;
 if ($IN['filter_by'] != '') {
     $IN['filter_by'] = explode('||', $IN['filter_by']);
 } else {
     unset($IN['filter_by']);
 }
 if ($IN['filter_value'] != '') {
     $IN['filter_value'] = explode('||', $IN['filter_value']);
 } else {
     unset($IN['filter_value']);
 }
 $arr_currencies_list = get_active_currencies();
 $selected_currency = current($arr_currencies_list);
 $arr_sql = prepare_report('main-report', $IN + array('report_params' => array('act' => 'reports')), true);
 $arr_sql['select'] = 'tclicks.id';
 unset($arr_sql['group']);
 unset($arr_sql['limit']);
 unset($arr_sql['order']);
 switch ($IN['main_column']) {
     case 'campaign_ads':
         $arr_campaign_ads = explode('-', $IN['value']);
         $sql = "SELECT " . $arr_sql['select'] . " FROM " . $arr_sql['from'] . " " . $arr_sql['join'] . " WHERE\n                            campaign_name='" . _str($arr_campaign_ads[0]) . "' AND\n                            ads_name='" . _str($arr_campaign_ads[1]) . "' AND\n                        " . $arr_sql['where'];
         break;
     default:
         $sql = "SELECT " . $arr_sql['select'] . " FROM " . $arr_sql['from'] . " " . $arr_sql['join'] . " WHERE `" . _str($IN['main_column']) . "`='" . _str($IN['value']) . "' AND " . $arr_sql['where'];
         break;
 }
 if ($IN['currency'] == $main_currency_id) {
     if ($IN['clicks_count'] > 0) {
Example #7
0
<?php

// kickstarter data connector for capsidea
include 'k-inc.php';
$cdata = get_capsidea_data2($capsidea_client_secret);
$secret = $cdata["t"];
$schemakey = "";
// if (isset($cdata["k"])) { // check, if this is reinitialisation
// 	$cps_key=$cdata["k"];
// 	$schemakey="&schemakey=$cps_key";
// }
$report_fname = prepare_report();
echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\"><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n<script type=\"text/javascript\" src=\"http://beta.capsidea.com/api.js\"></script>";
echo "<script>function doit(key) {CI.updateSource(key);CI.openSource(key);CI.closeApp();}</script>";
//echo "<script>CI.closeApp();</script>";
echo "<title>Success</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"view.css\" media=\"all\"></head>\n<body id=\"main_body\"> ";
echo "please standby while Capsidea.com processing report<br>NB: This can take a while, so be patient<br>";
flush();
ob_flush();
flush();
ob_flush();
flush();
ob_flush();
flush();
ob_flush();
$name = date("YMdHi");
$host_reply = askhost($server_url . "&name={$name}" . $schemakey . $schemajson, array('file_contents' => '@' . $report_fname), "", "", "", 1800000, array("appid: {$capsidea_appid}", "sig: {$secret}"), true);
// defined in askhost.php
//echo " time ".$time3=((get_timer()-$stime)/1)." sec "; // $stime=get_timer();
$result = $host_reply["data"];
$error_log = "cube: {$schemakey}" . "secret: " . $secret . "<br>response:<pre>" . $host_reply["data"] . "</pre>" . "<br>connection debug:<pre>" . $host_reply["d"] . "</pre>";
$IN = array();
// Set default values
$allowed_report_in_params = array('hourly_report' => array('main_column' => 'source_name'), 'flow_report' => array('date' => get_current_day(), 'filter_by' => 'none', 'filter_value' => ''));
// Set allowed values from $_REQUEST for each report
foreach ($allowed_report_in_params as $report => $data) {
    foreach (array_keys($allowed_report_in_params[$report]) as $cur) {
        if (isset($_REQUEST[$cur]) && $_REQUEST[$cur] != '') {
            $IN[$report][$cur] = $_REQUEST[$cur];
        } else {
            // 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)