Обработка иключения отсутствия фидов у пользователя

parent 766c66d5
...@@ -81,10 +81,6 @@ return [ ...@@ -81,10 +81,6 @@ return [
->allow(Roles::ROLE_SUPPORT, 'logout') ->allow(Roles::ROLE_SUPPORT, 'logout')
->allow(Roles::ROLE_SUPPORT, 'adm.profile') ->allow(Roles::ROLE_SUPPORT, 'adm.profile')
// Manager Feed
->allow(Roles::ROLE_MANAGER_FEED, 'adm.feeds')
; ;
......
...@@ -88,89 +88,76 @@ class Cabinet extends Common ...@@ -88,89 +88,76 @@ class Cabinet extends Common
/** @var \App\Model\Feeds $feedsModel */ /** @var \App\Model\Feeds $feedsModel */
$feedsModel = $this->container->get(Feeds::class); $feedsModel = $this->container->get(Feeds::class);
$feeds = $feedsModel->findAll(['clientid' => $userId])->toArray(); $feeds = $feedsModel->findAll(['clientid' => $userId])->toArray();
// Фиды пользователя: if ($feeds) {
$feed_id_list = [];
foreach($feeds as $feed_item) { // Фиды пользователя:
$feed_id = $feed_item['id']; $feed_id_list = [];
if (!in_array($feed_id, $feed_id_list)) { foreach($feeds as $feed_item) {
$feed_id_list[] = $feed_id; $feed_id = $feed_item['id'];
if (!in_array($feed_id, $feed_id_list)) {
$feed_id_list[] = $feed_id;
}
} }
}
$report_type = $request->getAttribute('report');
// Текущий месяц: $report_type = $request->getAttribute('report');
$current_period = 'current_month';
$dates = [date('Y-m-01'), date('Y-m-d')]; // Текущий месяц:
$current_period = 'current_month';
switch ($report_type) { $dates = [date('Y-m-01'), date('Y-m-d')];
case 'common':
$periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates); switch ($report_type) {
case 'common':
$cats = [ $periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates);
'Views' => 'Показы', //$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
'Clicks' => 'Клики',
'Orders' => 'Заказы', $cats = [
'OrderSum' => 'Заказы на сумму', 'Views' => 'Показы',
'AdMoney' => 'Комиссия AddCPM' 'Clicks' => 'Клики',
]; 'Orders' => 'Заказы',
'OrderSum' => 'Заказы на сумму',
/* 'AdMoney' => 'Комиссия AddCPM'
$cats = [ ];
'shows' => 'Показы',
'clicks' => 'Клики', break;
'transactions' => 'Транзакции', case 'transaction':
'salemoney' => 'salemoney', $periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates);
'admoney' => 'admoney'
]; /*
$cats = [
'localmoney' => 'localmoney',
'usdollarmoney' => 'usdollarmoney'
];
*/
$cats = [
'Views' => 'Показы',
'Clicks' => 'Клики',
'Orders' => 'Заказы',
'OrderSum' => 'Заказы на сумму',
'AdMoney' => 'Комиссия AddCPM'
];
break;
default:
$data['error'] = _t('Извините, тип отчета "'. $report_type .'" недоступен');
break;
}
$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates); $data['feeds'] = $feeds;
*/ $data['report'] = $report_type;
$data['current_period'] = $current_period;
break; $data['dates'] = $dates;
case 'transaction': $data['periodStats'] = $periodStats;
$periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates); //$data['campaignStats'] = $campaignStats;
$data['cats'] = $cats;
/* $data['periods_list'] = $this->container->get('config')['feed_conf']['periods_list'];
$cats = [ $data['colors_active_lines'] = $this->container->get('config')['feed_conf']['colors_active_lines'];
'localmoney' => 'localmoney',
'usdollarmoney' => 'usdollarmoney' } else {
]; $data['error'] = _t('Извините, у пользователя нет фидов');
*/
$cats = [
'Views' => 'Показы',
'Clicks' => 'Клики',
'Orders' => 'Заказы',
'OrderSum' => 'Заказы на сумму',
'AdMoney' => 'Комиссия AddCPM'
];
break;
default:
$data['error'] = _t('Извините, тип отчета "'. $report_type .'" недоступен');
break;
} }
/*
$periodStats['type'] = 'interval';
$periodStats['report'] = $report_type;
$campaignStats['type'] = 'interval';
$campaignStats['report'] = $report_type;
$data['campaignStats'] = $campaignStats;
*/
$data['feeds'] = $feeds;
$data['report'] = $report_type;
$data['current_period'] = $current_period;
$data['dates'] = $dates;
$data['periodStats'] = $periodStats;
$data['cats'] = $cats;
$data['periods_list'] = $this->container->get('config')['feed_conf']['periods_list'];
$data['colors_active_lines'] = $this->container->get('config')['feed_conf']['colors_active_lines'];
} catch(\Exception $e) { } catch(\Exception $e) {
$data['error'] = _t('Извините, статистика временно не работает'); $data['error'] = _t('Извините, статистика временно не работает');
} }
...@@ -214,9 +201,7 @@ class Cabinet extends Common ...@@ -214,9 +201,7 @@ class Cabinet extends Common
switch ($report_type) { switch ($report_type) {
case 'common': case 'common':
$periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates); $periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates);
/* //$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
*/
break; break;
case 'transaction': case 'transaction':
$periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates); $periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates);
...@@ -232,12 +217,6 @@ class Cabinet extends Common ...@@ -232,12 +217,6 @@ class Cabinet extends Common
} }
/* /*
$periodStats['type'] = 'interval';
$periodStats['report'] = $report_type;
$campaignStats['type'] = 'interval';
$campaignStats['report'] = $report_type;
if ($periodStats || $companyStats) { if ($periodStats || $companyStats) {
$data = array( $data = array(
'period' => $periodStats, 'period' => $periodStats,
......
...@@ -54,17 +54,22 @@ $sxml = new SimpleXMLElement(substr($gravatar, 0, -1) . '/>'); ...@@ -54,17 +54,22 @@ $sxml = new SimpleXMLElement(substr($gravatar, 0, -1) . '/>');
$src = $sxml['src']; $src = $sxml['src'];
$error = $this->error; $error = $this->error;
$periodStats = $this->periodStats;
//$campaignStats = $this->campaignStats; if (!$error) {
$current_period = $this->current_period;
$dates = $this->dates; $periodStats = $this->periodStats;
$cats = $this->cats; //$campaignStats = $this->campaignStats;
$report = $this->report; $current_period = $this->current_period;
$periods_list = $this->periods_list; $dates = $this->dates;
$colors_active_lines = $this->colors_active_lines; $cats = $this->cats;
$report = $this->report;
$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $report]); $periods_list = $this->periods_list;
$system_link = $this->url('adm.system.actions'); $colors_active_lines = $this->colors_active_lines;
$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $report]);
$system_link = $this->url('adm.system.actions');
}
?> ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment