Exemple #1
0
<?php

define('SQL_INC', 1);
define('CURR_MENU', 'tariffs');
define('CURR_SUBMENU', 'tariffs_routes');
require 'inc/common.inc.php';
check_permissions(CURR_SUBMENU, 1);
$id_tariff = intval($_POST['id_tariff']) ? intval($_POST['id_tariff']) : intval($_GET['id_tariff']);
$id_group = intval($_POST['id_group']) ? intval($_POST['id_group']) : intval($_GET['id_group']);
$id_timer = intval($_POST['id_timer']) ? intval($_POST['id_timer']) : intval($_GET['id_timer']);
$groups = get_routes_groups(false, $id_tariff);
$tpl->assign('groups', $groups);
$tpl->assign('id_group', $id_group);
$tpl->assign('id_tariff', $id_tariff);
if ($_POST['modify'] || $id_timer) {
    check_permissions(CURR_SUBMENU, 2);
    if (!$_POST['confirm'] && $id_timer) {
        $db->sql_query("select id_group, time_from, time_to, cost_in, cost_out, prepaid, speed from timers where id='{$id_timer}'");
        $result = $db->sql_fetchrow();
        $range = $result['time_from'] . '-' . $result['time_to'];
    }
    $id_group = isset($_POST['id_group']) ? intval($_POST['id_group']) : $result['id_group'];
    $range = isset($_POST['range']) ? $_POST['range'] : $range;
    $cost_in = $_POST['confirm'] ? $_POST['cost_in'] : $result['cost_in'];
    $cost_out = $_POST['confirm'] ? $_POST['cost_out'] : $result['cost_out'];
    $prepaid = $_POST['confirm'] ? intval($_POST['prepaid']) : $result['prepaid'];
    $speed = $_POST['confirm'] ? $_POST['speed'] : $result['speed'];
    if (!$range) {
        $errors[] = $lang['errors_range_empty'];
    } elseif (preg_match('/^([01]?[0-9]|2[0-3])-([01]?[0-9]|2[0-3])$/', $range)) {
        list($time_from, $time_to) = split('-', $range);
Exemple #2
0
            $level = 1;
            $db->sql_query("select users.login, users.id as \"id_user\", sum(data_old.incoming) as \"incoming\", sum(data_old.outgoing) as \"outgoing\", sum(data_old.cost) as \"cost\" from data_old, users where data_old.id_user=users.id and (data_old.log_time between '{$time_from}' and '{$time_to}') {$sql_where2} group by data_old.id_user order by data_old.id_user");
            while ($stats2[] = $db->sql_fetchrow()) {
            }
            $db->sql_query("select users.login, users.id as \"id_user\", sum(data.incoming) as \"incoming\", sum(data.outgoing) as \"outgoing\", sum(data.cost) as \"cost\" from data, users where data.id_user=users.id and (data.log_time between '{$time_from}' and '{$time_to}') {$sql_where} group by data.id_user order by data.id_user");
    }
} else {
    $db->sql_query("select {$sql_cols2}, sum(data_old.incoming) as \"incoming\", sum(data_old.outgoing) as \"outgoing\", sum(data_old.cost) as \"cost\", min(data_old.log_time) as \"log_time\" from data_old where (data_old.log_time between '{$time_from}' and '{$time_to}') {$sql_where2} {$sql_group_by} order by \"Y\", \"n\", \"j\", \"G\", \"i\"");
    while ($stats2[] = $db->sql_fetchrow()) {
    }
    $db->sql_query("select {$sql_cols}, sum(data.incoming) as \"incoming\", sum(data.outgoing) as \"outgoing\", sum(data.cost) as \"cost\", min(data.log_time) as \"log_time\" from data where (data.log_time between '{$time_from}' and '{$time_to}') {$sql_where} {$sql_group_by} order by \"Y\", \"n\", \"j\", \"G\", \"i\"");
}
unset($stats2[count($stats2) - 1]);
$stats = $stats2;
while ($stats[] = $db->sql_fetchrow()) {
}
unset($stats[count($stats) - 1]);
$groups = get_routes_groups(true);
$users = get_users(true);
$tpl->assign('date1', $date1);
$tpl->assign('date2', $date2);
$tpl->assign('type', $type);
$tpl->assign('types', $types);
$tpl->assign('level', $level);
$tpl->assign('groups', $groups);
$tpl->assign('users', $users);
$tpl->assign('cost', $cost);
$tpl->assign('id_group', $id_group);
$tpl->assign('id_user', $id_user);
$tpl->assign('stats', $stats);
$tpl->display('stats.tpl');