<?php
defined('COT_CODE') or die('Wrong URL');
$return['success'] = false;
if(cot_plugin_active('marketorders')) {
$type = cot_import('period', 'G', 'INT');
if(empty($type) && $type != 0) {
$type = 1;
} elseif($type == -1) {
$type = 0;
}
if(!in_array($type, array(0, 1, 3, 6, 12))) $type = 1;
if($usr['id'] > 0) {
$anlt_arr = cot_mk_update_analytics(array($usr['profile']), $type, true);
$anlt = $anlt_arr[$usr['id']]['anlt'];
$ruserupd = $anlt_arr[$usr['id']]['ruserupd'];
$line_charts = array(
'base-sales' => $anlt['base-sales'],
'extra-sales' => $anlt['extra-sales'],
);
unset($anlt['base-sales']);
unset($anlt['extra-sales']);
if($ruserupd['user_mk_cache_upd'] > 0) $usr['profile']['user_mk_cache_upd'] = $ruserupd['user_mk_cache_upd'];
$anlt['anltlastupdate'] = ($anlt['anlt_cache_upd'] > 0 ? cot_build_timeago(($sys['now'] - ($sys['now'] - $anlt['anlt_cache_upd'])), 5) : 'Только что');
$return = array(
'success' => true,
'statistic' => $anlt,
'total_sum' => $anlt['total_summ_all_orders']['value'],
'line-charts' => $line_charts
);
if(count($ruserupd) > 0) $db->update($db_users, $ruserupd, 'user_id='.$usr['id']);
}
}
?>