Статистика по клику

parent 046cd179
...@@ -34,7 +34,7 @@ return [ ...@@ -34,7 +34,7 @@ return [
->allow(Roles::ROLE_GUEST, 'user.mail.sent.password') ->allow(Roles::ROLE_GUEST, 'user.mail.sent.password')
->allow(Roles::ROLE_USER, 'user.cabinet', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.profile', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet.profile', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.viewid', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet.viewid', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'install.counter', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'install.counter', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'download.counter', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'download.counter', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_GUEST, 'email.counter') ->allow(Roles::ROLE_GUEST, 'email.counter')
......
...@@ -53,6 +53,7 @@ return [ ...@@ -53,6 +53,7 @@ return [
'cats' => [ 'cats' => [
'Timestamp' => 'Время<br />Дата', 'Timestamp' => 'Время<br />Дата',
'Basket' => 'Состав корзины', 'Basket' => 'Состав корзины',
'ViewID' => 'ViewID',
'OrderSum' => 'Сумма', 'OrderSum' => 'Сумма',
] ]
/* /*
......
...@@ -314,13 +314,14 @@ return [ ...@@ -314,13 +314,14 @@ return [
], ],
], ],
[ [
'name' => 'user.viewid', 'name' => 'user.cabinet.viewid',
'path' => '/[:lang/]cabinet/viewid/:id', 'path' => '/[:lang/]cabinet/viewid/:feedid/:id',
'middleware' => App\Action\User\ViewId::class, 'middleware' => App\Action\User\ViewId::class,
'allowed_methods' => ['GET', 'POST'], 'allowed_methods' => ['GET', 'POST'],
'options' => [ 'options' => [
'constraints' => [ 'constraints' => [
'lang' => '[a-z]{2,3}', 'lang' => '[a-z]{2,3}',
'feedid' => '\w+',
'id' => '\w+', 'id' => '\w+',
], ],
'defaults' => [ 'defaults' => [
......
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
#period-stats, #period-stats,
#campaign-stats, #campaign-stats,
#report-cats #report-cats,
#viewid-stats
{ {
display: none; display: none;
} }
...@@ -158,7 +159,7 @@ input[type="checkbox"] ...@@ -158,7 +159,7 @@ input[type="checkbox"]
text-align: center; text-align: center;
} }
.b-table_wrapp .b-table_wrapp.report
{ {
display: none; display: none;
margin-top: 30px; margin-top: 30px;
...@@ -225,6 +226,17 @@ input[type="checkbox"] ...@@ -225,6 +226,17 @@ input[type="checkbox"]
line-height: 14px; line-height: 14px;
} }
.table.table-striped.admin thead tr th.StartTime,
.table.table-striped.admin thead tr th.EndTime
{
width: auto;
}
.table.table-striped.admin thead tr th.URL
{
width: 500px;
}
.table.table-striped.admin tbody td.Timestamp .table.table-striped.admin tbody td.Timestamp
{ {
line-height: 13px; line-height: 13px;
...@@ -248,7 +260,15 @@ input[type="checkbox"] ...@@ -248,7 +260,15 @@ input[type="checkbox"]
width: 530px; width: 530px;
} }
.table.table-striped.admin thead tr th.Basket .quantity .table.table-striped.admin.viewid thead tr th.Basket .basket-link
{
width: 500px;
}
.table.table-striped.admin thead tr th.Basket .quantity,
.table.table-striped.admin thead tr th.Basket .viewid
{ {
text-align: center; text-align: center;
width: 55px; width: 55px;
...@@ -307,6 +327,22 @@ input[type="checkbox"] ...@@ -307,6 +327,22 @@ input[type="checkbox"]
width: 540px; width: 540px;
} }
table.viewid .b-basket-content .basket-link
{
display: inline-block;
width: 510px;
font-size: 11px;
font-weight: bold;
}
.b-basket-content .view-id-url
{
display: inline-block;
width: 595px;
margin-bottom: 4px;
}
.b-basket-content .quantity .b-basket-content .quantity
{ {
display: inline-block; display: inline-block;
...@@ -321,6 +357,11 @@ input[type="checkbox"] ...@@ -321,6 +357,11 @@ input[type="checkbox"]
text-align: left; text-align: left;
} }
table.viewid .b-basket-content .price
{
width: 40px;
}
......
...@@ -7,7 +7,7 @@ $(document).ready(function(){ ...@@ -7,7 +7,7 @@ $(document).ready(function(){
activeLines = [], activeLines = [],
currentActiveLine, currentActiveLine,
currencyFields = ['admoney', 'salemoney', 'usdollarmoney', 'localmoney', 'AdMoney', 'OrderSum', 'Price'], currencyFields = ['admoney', 'salemoney', 'usdollarmoney', 'localmoney', 'AdMoney', 'OrderSum', 'Price'],
notFormatFields = ['Timestamp', 'Basket'], notFormatFields = ['Timestamp', 'Basket', 'ViewID'],
dateTimeFields = ['Timestamp', 'period']; dateTimeFields = ['Timestamp', 'period'];
// Шаблон содержимого ячейки Basket // Шаблон содержимого ячейки Basket
...@@ -33,6 +33,12 @@ $(document).ready(function(){ ...@@ -33,6 +33,12 @@ $(document).ready(function(){
' <span><%=data.date %></span><br /> \n' + ' <span><%=data.date %></span><br /> \n' +
''); '');
// Шаблон ячейки ViewID
var templateViewIDContent = _.template('\n'+
' <a class="viewid-link" href="viewid/<%=data.feedId %>/<%=data.viewId %>" target="_blank"><%=data.viewId %></a> \n' +
'');
function valueFormat(value) function valueFormat(value)
{ {
...@@ -126,7 +132,7 @@ $(document).ready(function(){ ...@@ -126,7 +132,7 @@ $(document).ready(function(){
return (isDesc) ? b[sortField]-a[sortField] : a[sortField]-b[sortField]; return (isDesc) ? b[sortField]-a[sortField] : a[sortField]-b[sortField];
} }
}); });
//console.log('AAA dataTableForSort = ', dataTableForSort); console.log('AAA dataTableForSort = ', dataTableForSort);
// Отрисовка таблицы: // Отрисовка таблицы:
dataTableForSort.forEach(function(item){ dataTableForSort.forEach(function(item){
...@@ -141,7 +147,10 @@ $(document).ready(function(){ ...@@ -141,7 +147,10 @@ $(document).ready(function(){
$row.append($('<td class="'+ line +'">').append(templateTimestampContent({ $row.append($('<td class="'+ line +'">').append(templateTimestampContent({
data: {date: getDateValue(item[line]), time: getHourMinValue(item[line])} data: {date: getDateValue(item[line]), time: getHourMinValue(item[line])}
}))); })));
} else if (line == 'ViewID') {
$row.append($('<td class="'+ line +'">').append(templateViewIDContent({
data: {feedId: item[line][0], viewId: item[line][1]}
})));
} else { } else {
currentActiveLine = line; currentActiveLine = line;
$row.append($('<td class="'+ line +'">').html(valueFormat(item[line]))); $row.append($('<td class="'+ line +'">').html(valueFormat(item[line])));
......
...@@ -73,8 +73,7 @@ $(document).ready(function(){ ...@@ -73,8 +73,7 @@ $(document).ready(function(){
//console.log('AAA dataLineChartStat = ', dataLineChartStat); //console.log('AAA dataLineChartStat = ', dataLineChartStat);
if (!dataLineChartStat) { if (!dataLineChartStat) {
ShowInfo(); ShowInfo();
} } else {
// Отрисовка графика и таблицы по стартовым данным: // Отрисовка графика и таблицы по стартовым данным:
if (dataLineChartStat.status == 'Error') { if (dataLineChartStat.status == 'Error') {
ShowError(); ShowError();
...@@ -82,6 +81,7 @@ $(document).ready(function(){ ...@@ -82,6 +81,7 @@ $(document).ready(function(){
renderLineChart(); renderLineChart();
renderHourTable(); renderHourTable();
} }
}
// Смена периода: // Смена периода:
......
...@@ -88,6 +88,7 @@ class Cabinet extends Common ...@@ -88,6 +88,7 @@ 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();
//$feed_id_list = $feedsModel->getIdListByUser($userId);
if ($feeds) { if ($feeds) {
......
...@@ -79,24 +79,42 @@ class ViewId extends Common ...@@ -79,24 +79,42 @@ class ViewId extends Common
} else { } else {
/*
$feed_id = $request->getAttribute('feedid');
$view_id = $request->getAttribute('id');
$viewIdStats = $stats->getViewIdStatData($feed_id, $view_id);
return new JsonResponse($viewIdStats);
*/
try { try {
$feed_id = $request->getAttribute('feedid');
$view_id = $request->getAttribute('id');
/** @var UserService $auth */ /** @var UserService $auth */
$auth = $this->container->get(UserService::class); $auth = $this->container->get(UserService::class);
$userId = $auth->getIdentity()->getId(); $userId = $auth->getIdentity()->getId();
/** @var \App\Model\Feeds $feedsModel */ /** @var \App\Model\Feeds $feedsModel */
$feedsModel = $this->container->get(Feeds::class); $feedsModel = $this->container->get(Feeds::class);
$feed_id_list = $feedsModel->getIdListByUser($userId); $feed_item = $feedsModel->findById($feed_id);
$view_id = $request->getAttribute('id'); if ($feed_item) {
if ($feed_item->getClientid() == $userId){
// Статистика по клику: // Статистика по клику:
$viewIdStats = $stats->getViewIdStatData($feed_id_list, $view_id); $viewIdStats = $stats->getViewIdStatData($feed_id, $view_id);
$data['viewIdStats'] = $viewIdStats; $data['viewIdStats'] = $viewIdStats;
} else {
$data['error'] = _t('Извините, данный фид закреплен за другим пользователем');
}
} else {
$data['error'] = _t('Извините, фид не найден');
}
} catch(\Exception $e) { } catch(\Exception $e) {
$data['error'] = _t('Извините, история визитов по клику временно не работает'); $data['error'] = _t('Извините, история визитов по клику временно не работает');
} }
...@@ -106,7 +124,7 @@ class ViewId extends Common ...@@ -106,7 +124,7 @@ class ViewId extends Common
'layoutInfo' => $request->getAttribute('layoutInfo'), 'layoutInfo' => $request->getAttribute('layoutInfo'),
]); ]);
return new HtmlResponse($this->template->render('app::user/view-id', $data)); return new HtmlResponse($this->template->render('app::user/cabinet-feed-click-history', $data));
} }
} }
......
...@@ -58,7 +58,7 @@ class Feed extends Common ...@@ -58,7 +58,7 @@ class Feed extends Common
/** /**
* @return mixed * @return mixed
*/ */
public function getClientid() public function getClientid(): int
{ {
return $this->clientid; return $this->clientid;
} }
......
...@@ -67,6 +67,7 @@ class Statistics ...@@ -67,6 +67,7 @@ class Statistics
//return $dataRequest; //return $dataRequest;
//$stats = $this->apiRequest($dataRequest); //$stats = $this->apiRequest($dataRequest);
//return $stats;
try { try {
$stats = $this->apiRequest($dataRequest); $stats = $this->apiRequest($dataRequest);
} catch (\Exception $e) { } catch (\Exception $e) {
...@@ -240,6 +241,7 @@ class Statistics ...@@ -240,6 +241,7 @@ class Statistics
if ($report_type == 'transaction') { if ($report_type == 'transaction') {
foreach ($stats['data'] as $item) { foreach ($stats['data'] as $item) {
$dataStats['period'][] = $item['ForeignID']; $dataStats['period'][] = $item['ForeignID'];
$dataStats['ViewID'][] = [$item['FeedID'], $item['ViewID']];
$dataStats['Timestamp'][] = $item['Timestamp']; $dataStats['Timestamp'][] = $item['Timestamp'];
$dataStats['OrderSum'][] = $item['OrderSum']; $dataStats['OrderSum'][] = $item['OrderSum'];
$dataStats['Basket'][] = $item['Basket']; $dataStats['Basket'][] = $item['Basket'];
...@@ -251,27 +253,39 @@ class Statistics ...@@ -251,27 +253,39 @@ class Statistics
} }
// Данные по статистике по клику // Данные по статистике по клику
public function getViewIdStatData($feed_id_list, $view_id) public function getViewIdStatData($feed_id, $view_id)
{ {
$dataRequest = array( $dataRequest = array(
'method' => "viewid", 'method' => 'feed_click_history',
'data' => array( 'data' => array(
'filters' => array( 'feed_id' => (int) $feed_id,
'FeedID' => array('values' => $feed_id_list), 'view_id' => $view_id
'ViewID' => $view_id, //'feed_id' => 10004,
), //'view_id' => '94ed3f578fa785d3'
) )
); );
return $dataRequest;
//$stats = $this->apiRequest($dataRequest); //return $dataRequest;
$stats = $this->apiRequest($dataRequest);
//return $stats;
try { try {
$stats = $this->apiRequest($dataRequest); $stats = $this->apiRequest($dataRequest);
} catch (\Exception $e) { } catch (\Exception $e) {
$stats['status'] = 'Error'; $stats['status'] = 'Error';
} }
//return $stats;
$stats = [$feed_id_list, $view_id]; // В запросе ошибка или отсутствуют данные для статистики:
if ($stats['status'] == 'Error') {
return $stats;
}
if ($stats['data'] == []) {
return null;
}
$stats = $stats['data'];
return $stats; return $stats;
} }
......
...@@ -58,12 +58,18 @@ $error = $this->error; ...@@ -58,12 +58,18 @@ $error = $this->error;
if (!$error) { if (!$error) {
$periodStats = $this->periodStats; $viewIdStats = $this->viewIdStats;
$current_period = $this->current_period; $cats = array(
$dates = $this->dates; 'StartTime' => 'StartTime',
$periods_list = $this->periods_list; 'EndTime' => 'EndTime',
'IP' => 'IP',
'Basket' => 'Basket',
'Pages' => 'Pages',
//'TransactionID' => 'TransactionID',
'ForeignID' => 'ForeignID',
'OrderSum' => 'OrderSum',
);
//$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $current_report]); //$data_request_link = $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $current_report]);
} }
...@@ -80,35 +86,16 @@ if (!$error) { ...@@ -80,35 +86,16 @@ if (!$error) {
<?php else: ?> <?php else: ?>
<textarea id="period-stats"><?= ($viewIdStats ? json_encode($viewIdStats, JSON_UNESCAPED_UNICODE) : '')?></textarea> <?php /* ?>
<textarea id="viewid-stats"><?= ($viewIdStats ? json_encode($viewIdStats, JSON_UNESCAPED_UNICODE) : '')?></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>
<div class="b-feeds-stat_controls form-group"> <?php //print_r($viewIdStats) ?>
<?php /* Выбор дат */ ?>
<span class="b-feeds-stat_controls-period">
<div style="display:inline-block;">Дата: </div>
<input type='text' id="date-value-1" class="btn btn-default date-value" value="<?=$dates[0] ?>"/> &ndash;
<input type='text' id="date-value-2" class="btn btn-default date-value" value="<?=$dates[1] ?>"/>
<span>период: </span>
<select class="form-control stat-period" name="period" data-link="<?=$data_request_link ?>">
<option value="" disabled>--</option>
<?php foreach($periods_list as $period => $title): ?>
<option value="<?=$period ?>" <?php if ($period == $current_period): ?>selected<?php endif; ?>><?=$title ?></option>
<?php endforeach; ?>
</select>
</span>
</div>
<?php print_r($viewIdStats) ?>
<div class="chart-graph-stat-info"> <div class="chart-graph-stat-info">
<h2>По заданным параметрам статистика отсутствует</h2> <h2>По заданным параметрам статистика отсутствует</h2>
...@@ -118,6 +105,68 @@ if (!$error) { ...@@ -118,6 +105,68 @@ if (!$error) {
<div class="message"></div> <div class="message"></div>
</div> </div>
<?php /* Таблица */ ?>
<div id="table-stat" class="b-table_wrapp">
<div class="b-content__loading"></div>
<table id="table-line" class="table table-striped admin transaction viewid">
<thead class="metric sortable">
<tr>
<?php foreach($cats as $name => $title): ?>
<th class="<?= $name ?>" data-id="<?= $name ?>">
<?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>
<?php endif; ?>
</th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php foreach($viewIdStats as $view_id): ?>
<tr>
<?php foreach($cats as $name => $title): ?>
<td class="<?= $name ?>" data-id="<?= $name ?>">
<?php if($name == 'StartTime' || $name == 'EndTime'): ?>
<?php
$date_time = explode(" ", $view_id[$name]);
?>
<span style="white-space: nowrap;">
<b><?= $date_time[1] ?></b>
<span><?= $date_time[0] ?></span>
</span>
<?php elseif($name == 'Basket'): ?>
<div class="b-basket-content">
<a class="view-id-url" href="<?=$view_id['URL'] ?>" target="_blank"><?= $view_id['URL'] ?></a>
<?php if(count($view_id[$name])>0): ?>
<table>
<tbody>
<?php foreach($view_id[$name] as $item): ?>
<tr>
<td><a class="basket-link" href="<?=$item['URL'] ?>" target="_blank"><?=$item['Title'] ?></a></td>
<td><span class="quantity"><?=$item['Quantity'] ?></span></td>
<td><span class="price"><?=$item['Price'] ?></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<?php else: ?>
<span class="cat"><?= $view_id[$name] ?></span>
<?php endif; ?>
</td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div> </div>
</section> </section>
......
...@@ -166,7 +166,7 @@ if (!$error) { ...@@ -166,7 +166,7 @@ if (!$error) {
<?php endif ?> <?php endif ?>
<?php /* Таблица */ ?> <?php /* Таблица */ ?>
<div id="table-stat" class="b-table_wrapp"> <div id="table-stat" class="b-table_wrapp report">
<div class="b-content__loading"></div> <div class="b-content__loading"></div>
<table id="table-line" class="table table-striped admin <?= $current_report ?>"> <table id="table-line" class="table table-striped admin <?= $current_report ?>">
<thead class="metric sortable"> <thead class="metric sortable">
......
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