<?php
$t = 'Статистика биллинга';
require_once '../../wcore/core.php';
require_once '../../wcore/head.php';
iank(3);
$info = [
    'clients'               =>  _mc('users'),
    'clients_online'        =>  _mc('users',"WHERE `time_online` > '".(time()-300)."'"),
    'clients_today'         =>  _mc('users',"WHERE `time_online` > '".(time()-86400)."'"),
    'clients_week'          =>  _mc('users',"WHERE `time_online` > '".(time()-604800)."'"),
    'clients_month'         =>  _mc('users',"WHERE `time_online` > '".(time()-2419200)."'"),
    'clients_reg'           =>  mysqli_fetch_object(mysqli_query($mysqli,"SELECT * FROM `users` ORDER BY `id` DESC LIMIT 1")),
    'order_active'          =>  _mc('orders',"WHERE `status` = 2"),
    'order_stop'            =>  _mc('orders',"WHERE `status` != 2"),
    'order_wait'            =>  _mc('orders',"WHERE `status` = 1 || `status` = 0 "),
    'pay_count'             =>  _mc('bill_pays'),
    'pay_count_f'           =>  _mc('bill_pays',"WHERE `time_pay` = 0"),
    'pay_count_t'           =>  _mc('bill_pays',"WHERE `time_pay` != 0"),
    'pay_count_today'       =>  _mc('bill_pays',"WHERE `time` > '".(time()-86400)."'"),
    'pay_bits_today'        =>  _mc('bill_pays',"WHERE `time` > '".(time()-86400)."'",'amount'),
    'pay_bits_today_t'      =>  _mc('bill_pays',"WHERE `time` > '".(time()-86400)."' AND `time_pay` != 0",'amount'),
    'pay_count_week'        =>  _mc('bill_pays',"WHERE `time` > '".(time()-604800)."'"),
    'pay_bits_week'         =>  _mc('bill_pays',"WHERE `time` > '".(time()-604800)."'",'amount'),
    'pay_bits_week_t'       =>  _mc('bill_pays',"WHERE `time` > '".(time()-604800)."' AND `time_pay` != 0",'amount'),
    'pay_count_month'       =>  _mc('bill_pays',"WHERE `time` > '".(time()-2419200)."'"),
    'pay_bits_month'        =>  _mc('bill_pays',"WHERE `time` > '".(time()-2419200)."'",'amount'),
    'pay_bits_month_t'      =>  _mc('bill_pays',"WHERE `time` > '".(time()-2419200)."' AND `time_pay` != 0",'amount'),
    'pay_count_year'        =>  _mc('bill_pays',"WHERE `time` > '".(time()-29030400)."'"),
    'pay_bits_year'         =>  _mc('bill_pays',"WHERE `time` > '".(time()-29030400)."'",'amount'),
    'pay_bits_year_t'       =>  _mc('bill_pays',"WHERE `time` > '".(time()-29030400)."' AND `time_pay` != 0",'amount'),
    'pay_bits_all'          =>  _mc('bill_pays',NULL,'amount'),
    'pay_bits_all_t'        =>  _mc('bill_pays',"WHERE `time_pay` != 0",'amount'),
    'pay_bits_all_f'        =>  _mc('bill_pays',"WHERE `time_pay` = 0",'amount'),
    'top_payment_sys'       =>  mysqli_fetch_object(mysqli_query($mysqli,"SELECT payment,COUNT(*) AS total FROM bill_pays WHERE `time_pay` != 0 GROUP BY payment ORDER BY id ASC LIMIT 1")),
    'order_count'           =>  _mc("orders"),
    'order_count_1'         =>  _mc("servers`,`orders","WHERE `servers`.`id`=`orders`.`l_s` AND `servers`.`type` = '1'"),
    'order_count_2'         =>  _mc("servers`,`orders","WHERE `servers`.`id`=`orders`.`l_s` AND `servers`.`type` = '2'"),
    'order_count_3'         =>  _mc("servers`,`orders","WHERE `servers`.`id`=`orders`.`l_s` AND `servers`.`type` = '3'"),
    'order_count_4'         =>  _mc("servers`,`orders","WHERE `servers`.`id`=`orders`.`l_s` AND `servers`.`type` = '4'"),
    'order_count_5'         =>  _mc("servers`,`orders","WHERE `servers`.`id`=`orders`.`l_s` AND `servers`.`type` = '5'"),
];
echo $twig->render('admin_statistic.tpl', array('lang' =>$lang,'info'=>$info));
require_once '../../wcore/foot.php';