Ejemplo n.º 1
0
     $redirect_url = 'feedback.send?action=auto&redirect_url=' . urlencode(Registry::get('config.current_url'));
     return array(CONTROLLER_STATUS_REDIRECT, $redirect_url);
 }
 $time_periods = array(DateTimeHelper::PERIOD_TODAY, DateTimeHelper::PERIOD_YESTERDAY, DateTimeHelper::PERIOD_THIS_MONTH, DateTimeHelper::PERIOD_LAST_MONTH, DateTimeHelper::PERIOD_THIS_YEAR, DateTimeHelper::PERIOD_LAST_YEAR);
 $time_period = DateTimeHelper::getPeriod(DateTimeHelper::PERIOD_MONTH_AGO_TILL_NOW);
 // Predefined period selected
 if (isset($_REQUEST['time_period']) && in_array($_REQUEST['time_period'], $time_periods)) {
     $time_period = DateTimeHelper::getPeriod($_REQUEST['time_period']);
     fn_set_session_data('dashboard_selected_period', serialize(array('period' => $_REQUEST['time_period'])));
 } elseif (isset($_REQUEST['time_from'], $_REQUEST['time_to'])) {
     $time_period = DateTimeHelper::createCustomPeriod('@' . $_REQUEST['time_from'], '@' . $_REQUEST['time_to']);
     fn_set_session_data('dashboard_selected_period', serialize(array('from' => $time_period['from']->format(DateTime::ISO8601), 'to' => $time_period['to']->format(DateTime::ISO8601))));
 } elseif ($timeframe = fn_get_session_data('dashboard_selected_period')) {
     $timeframe = unserialize($timeframe);
     if (isset($timeframe['period']) && in_array($timeframe['period'], $time_periods)) {
         $time_period = DateTimeHelper::getPeriod($timeframe['period']);
     } elseif (isset($timeframe['from'], $timeframe['to'])) {
         $time_period = DateTimeHelper::createCustomPeriod($timeframe['from'], $timeframe['to']);
     }
 }
 $timestamp_from = $time_period['from']->getTimestamp();
 $timestamp_to = $time_period['to']->getTimestamp();
 $time_difference = $timestamp_to - $timestamp_from;
 $is_day = $timestamp_to - $timestamp_from <= SECONDS_IN_DAY ? true : false;
 $stats = '';
 if (!defined('HTTPS')) {
     $stats .= base64_decode('PGltZyBzcmM9Imh0dHA6Ly93d3cuY3MtY2FydC5jb20vaW1hZ2VzL2JhY2tncm91bmQuZ2lmIiBoZWlnaHQ9IjEiIHdpZHRoPSIxIiBhbHQ9IiIgLz4=');
 }
 $general_stats = array();
 /* Products */
 if (fn_check_view_permissions('products.manage', 'GET')) {
Ejemplo n.º 2
0
function fn_create_periods($params)
{
    $period_name = empty($params['period']) ? null : $params['period'];
    $available_periods = array(DateTimeHelper::PERIOD_TODAY, DateTimeHelper::PERIOD_YESTERDAY, DateTimeHelper::PERIOD_THIS_WEEK, DateTimeHelper::PERIOD_LAST_WEEK, DateTimeHelper::PERIOD_THIS_MONTH, DateTimeHelper::PERIOD_LAST_MONTH, DateTimeHelper::PERIOD_THIS_YEAR, DateTimeHelper::PERIOD_LAST_YEAR, DateTimeHelper::PERIOD_DAY_AGO_TILL_NOW, DateTimeHelper::PERIOD_WEEK_AGO_TILL_NOW, DateTimeHelper::PERIOD_MONTH_AGO_TILL_NOW);
    if (in_array($period_name, $available_periods)) {
        $period = DateTimeHelper::getPeriod($period_name);
        $time_from = $period['from']->getTimestamp();
        $time_to = $period['to']->getTimestamp();
    } elseif ($period_name == 'HC' && isset($params['last_days'])) {
        $period = DateTimeHelper::createCustomPeriod("-{$params['last_days']} day", 'now');
        $time_from = $period['from']->getTimestamp();
        $time_to = $period['to']->getTimestamp();
    } else {
        $time_from = empty($params['time_from']) ? 0 : fn_parse_date($params['time_from']);
        $time_to = empty($params['time_to']) ? TIME : fn_parse_date($params['time_to'], true);
    }
    Tygh::$app['view']->assign('time_from', $time_from);
    Tygh::$app['view']->assign('time_to', $time_to);
    return array($time_from, $time_to);
}