89 lines
3.4 KiB
PHP
89 lines
3.4 KiB
PHP
<?php
|
|
|
|
use KupShop\KupShopBundle\Context\DomainContext;
|
|
use KupShop\KupShopBundle\Util\Contexts;
|
|
use KupShop\OrderingBundle\Util\Order\OrderInfo;
|
|
use Query\Operator;
|
|
|
|
$main_class = 'IndexBoard';
|
|
|
|
class IndexBoard extends Frame
|
|
{
|
|
protected $template = 'board/index.tpl';
|
|
|
|
public function get_vars()
|
|
{
|
|
$vars = parent::get_vars();
|
|
|
|
$stats = [];
|
|
|
|
$today = new DateTime('today');
|
|
$todayRange = new \Range($today->format('Y-m-d 00:00:00'), $today->format('Y-m-d 23:59:59'));
|
|
|
|
$orders = sqlQueryBuilder()->select('COUNT(id)')
|
|
->from('orders')
|
|
->andWhere('status_storno=0')
|
|
->andWhere(Operator::between('date_created', $todayRange))
|
|
->andWhere(Operator::not(Operator::equals(['source' => OrderInfo::ORDER_SOURCE_RETURNS])));
|
|
$stats['today_orders'] = $orders->execute()->fetchOne();
|
|
|
|
$total_price = (findModule(Modules::CURRENCIES) ? 'total_price * currency_rate' : 'total_price');
|
|
$orders->select("SUM({$total_price})");
|
|
$stats['today_price'] = $orders->execute()->fetchOne();
|
|
|
|
$stats['unfinished_orders'] = returnSQLResult("SELECT COUNT(*) FROM orders WHERE status='0' AND status_storno='0'");
|
|
|
|
$stats['total_products'] = returnSQLResult('SELECT COUNT(*) FROM products');
|
|
|
|
$yesterday = (new DateTime('yesterday'))->format('Y-m-d H:i:s');
|
|
|
|
$stats['errors_critical'] = sqlQueryBuilder()->select('COUNT(*)')
|
|
->from('report_activities')
|
|
->where('date > :date')
|
|
->andWhere(Operator::equals(['severity' => 'error']))
|
|
->andWhere(Operator::not(Operator::equals(['type' => 'sync'])))
|
|
->setParameter('date', getAdminUser()['date_check_error'] ?? $yesterday)
|
|
->execute()->fetchColumn();
|
|
|
|
$stats['errors_sync'] = sqlQueryBuilder()->select('COUNT(*)')
|
|
->from('report_activities')
|
|
->where('date > :date')
|
|
->andWhere(Operator::equals(['severity' => 'error']))
|
|
->andWhere(Operator::equals(['type' => 'sync']))
|
|
->setParameter('date', getAdminUser()['date_check_error'] ?? $yesterday)
|
|
->execute()->fetchColumn();
|
|
|
|
$stats['errors_recommendation'] = sqlQueryBuilder()->select('COUNT(*)')
|
|
->from('report_activities')
|
|
->where('date > :date')
|
|
->andWhere(Operator::equals(['severity' => 'recommendation']))
|
|
->setParameter('date', $yesterday)
|
|
->execute()->fetchColumn();
|
|
|
|
$links = [];
|
|
|
|
$mainDomain = Contexts::get(DomainContext::class)->getSupported()[0];
|
|
$domain = join('.', array_slice(explode('.', $mainDomain), -2));
|
|
|
|
if (strpos($domain, 'kupshop.cz') !== false || strpos($domain, 'wpj.biz') !== false || strpos($domain, 'wpj.cloud') !== false || strpos($domain, 'wpjshop.cz') !== false) {
|
|
$domain = join('.', array_slice(explode('.', $mainDomain), -3));
|
|
}
|
|
|
|
$hash = md5(date('Y-m-d').'wpj_wpj');
|
|
$hash = base64_encode(json_encode(['url' => 'https://'.$domain, 'hash' => $hash]));
|
|
|
|
$links['klient'] = "https://klient.wpj.cz/list/{$hash}";
|
|
|
|
$vars['stats'] = $stats;
|
|
$vars['links'] = $links;
|
|
|
|
if (isAutoDeploy()) {
|
|
$vars['deploy_time'] = filemtime(__FILE__);
|
|
}
|
|
|
|
$vars['changelog_time'] = getAdminUser()['date_check_changelog'] ?? (new DateTime('yesterday'))->format('c');
|
|
|
|
return $vars;
|
|
}
|
|
}
|