МЕтод для получения данных по клику

parent 80de9341
...@@ -82,11 +82,21 @@ class ViewId extends Common ...@@ -82,11 +82,21 @@ class ViewId extends Common
try { try {
$view_id = $request->getAttribute('id'); /** @var UserService $auth */
//return new JsonResponse($view_id); $auth = $this->container->get(UserService::class);
$userId = $auth->getIdentity()->getId();
$data['error'] = _t('Извините, история визитов по клику: '. $view_id .' временно не работает');
/** @var \App\Model\Feeds $feedsModel */
$feedsModel = $this->container->get(Feeds::class);
$feed_id_list = $feedsModel->getIdListByUser($userId);
$view_id = $request->getAttribute('id');
// Статистика по клику:
$viewIdStats = $stats->getViewIdStatData($feed_id_list, $view_id);
$data['viewIdStats'] = $viewIdStats;
} catch(\Exception $e) { } catch(\Exception $e) {
$data['error'] = _t('Извините, история визитов по клику временно не работает'); $data['error'] = _t('Извините, история визитов по клику временно не работает');
} }
......
...@@ -59,4 +59,22 @@ class Feeds extends Common ...@@ -59,4 +59,22 @@ class Feeds extends Common
return $id; return $id;
} }
public function getIdListByUser($userId)
{
$feeds = $this->findAll(['clientid' => $userId])->toArray();
if ($feeds) {
$feed_id_list = [];
foreach($feeds as $feed_item) {
$feed_id = $feed_item['id'];
if (!in_array($feed_id, $feed_id_list)) {
$feed_id_list[] = $feed_id;
}
}
}
return $feed_id_list;
}
} }
\ No newline at end of file
...@@ -250,6 +250,30 @@ class Statistics ...@@ -250,6 +250,30 @@ class Statistics
return $stats; return $stats;
} }
// Данные по статистике по клику
public function getViewIdStatData($feed_id_list, $view_id)
{
$dataRequest = array(
'method' => "viewid",
'data' => array(
'filters' => array(
'FeedID' => array('values' => $feed_id_list),
'ViewID' => $view_id,
),
)
);
return $dataRequest;
//$stats = $this->apiRequest($dataRequest);
try {
$stats = $this->apiRequest($dataRequest);
} catch (\Exception $e) {
$stats['status'] = 'Error';
}
//return $stats;
$stats = [$feed_id_list, $view_id];
return $stats;
}
......
...@@ -59,21 +59,13 @@ $error = $this->error; ...@@ -59,21 +59,13 @@ $error = $this->error;
if (!$error) { if (!$error) {
$periodStats = $this->periodStats; $periodStats = $this->periodStats;
//$campaignStats = $this->campaignStats;
$current_period = $this->current_period; $current_period = $this->current_period;
$dates = $this->dates; $dates = $this->dates;
$current_report = $this->current_report;
$report_conf = $this->report_conf;
$report_title = $report_conf['title'];
$report_main_cat = $report_conf['main_cat'];
$report_cats = $report_conf['cats'];
$reports_list = $this->reports_list;
$periods_list = $this->periods_list; $periods_list = $this->periods_list;
$colors_active_lines = $this->colors_active_lines;
$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $current_report]);
$system_link = $this->url('adm.system.actions');
//$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $current_report]);
} }
?> ?>
...@@ -88,36 +80,15 @@ if (!$error) { ...@@ -88,36 +80,15 @@ if (!$error) {
<?php else: ?> <?php else: ?>
<textarea id="period-stats"><?= ($periodStats ? json_encode($periodStats, JSON_UNESCAPED_UNICODE) : '')?></textarea> <textarea id="period-stats"><?= ($viewIdStats ? json_encode($viewIdStats, JSON_UNESCAPED_UNICODE) : '')?></textarea>
<textarea id="report-cats"><?= ($report_cats ? json_encode($report_cats, JSON_UNESCAPED_UNICODE) : '')?></textarea>
<?php /* ?>
<textarea id="campaign-stats"><?= ($campaignStats ? json_encode($campaignStats) : '')?></textarea>
<?php */ ?>
<section class="b-content__work"> <section class="b-content__work">
<div class="wrapp" style="position: relative;"> <div class="wrapp" style="position: relative;">
<div class="b-feeds-stat_data-loading"></div> <div class="b-feeds-stat_data-loading"></div>
<?php /* ?>
<a class="btn btn-primary service-action feed-test-data" href="<?= $system_link ?>">Сформировать тестовые данные</a>
<?php */ ?>
<div class="b-feeds-stat_controls form-group"> <div class="b-feeds-stat_controls form-group">
<?php /* Переключатель отчетов */ ?>
<div class="b-feeds-stat_controls-report">
<div class="dropdown" style="display:inline-block;">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<?= _t($report_title) ?>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu">
<?php foreach($reports_list as $report_name => $report_title): ?>
<li><a href="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $report_name]) ?>" <?php if($current_report == $report_name): ?>class="current"<?php endif; ?> report="<?= $report_name ?>"><?= _t($report_title) ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php /* Выбор дат */ ?> <?php /* Выбор дат */ ?>
<span class="b-feeds-stat_controls-period"> <span class="b-feeds-stat_controls-period">
...@@ -135,7 +106,10 @@ if (!$error) { ...@@ -135,7 +106,10 @@ if (!$error) {
</span> </span>
</div> </div>
<?php print_r($viewIdStats) ?>
<div class="chart-graph-stat-info"> <div class="chart-graph-stat-info">
<h2>По заданным параметрам статистика отсутствует</h2> <h2>По заданным параметрам статистика отсутствует</h2>
</div> </div>
...@@ -144,47 +118,6 @@ if (!$error) { ...@@ -144,47 +118,6 @@ if (!$error) {
<div class="message"></div> <div class="message"></div>
</div> </div>
<?php /* График */ ?>
<?php if ($current_report == 'common'): ?>
<div id="chart-graph-stat" style="height: 370px;" data-colors=<?= ($colors_active_lines ? json_encode($colors_active_lines) : '')?>></div>
<?php endif ?>
<?php /* Таблица */ ?>
<div id="table-stat" class="b-table_wrapp">
<div class="b-content__loading"></div>
<table id="table-line" class="table table-striped admin <?= $current_report ?>">
<thead class="metric sortable">
<tr>
<th class="period" data-id="period">
<?php foreach($report_main_cat as $main_cat): ?>
<b class="main-cat selected <?php if(!$main_cat['isSorted']): ?>not-sorted<?php endif; ?>" data-cat="<?= $main_cat['name'] ?>"><?= _t($main_cat['title'])?></b>
<?php endforeach; ?>
</th>
<?php foreach($report_cats as $name => $title): ?>
<th class="<?= $name ?>" data-id="<?= $name ?>">
<?php if($current_report == 'common'): ?>
<span style="border-color: <?= $colors_active_lines[$name] ?>;">
<input type="checkbox" data-field="<?= $name ?>" checked />
</span>
<b class="cat" id="<?= $name ?>"><?= _t($title)?></b>
<?php endif; ?>
<?php if($current_report == 'transaction'): ?>
<?php if ($name == 'Basket'): ?>
<b class="cat not-sorted" id="<?= $name ?>"><?= _t($title)?></b><br />
<b class="basket-link not-sorted">Товар</b> <b class="quantity not-sorted">Кол-во</b> <b class="price not-sorted">Цена</b>
<?php else: ?>
<b class="cat" id="<?= $name ?>"><?= _t($title)?><b class="arrow asc">&#9650;</b><b class="arrow desc">&#9660;</b></b>
<?php endif; ?>
<?php endif; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div> </div>
</section> </section>
......
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