Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
addcpm-json
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Александр Чаплыгин
addcpm-json
Commits
80de9341
Commit
80de9341
authored
Feb 28, 2019
by
Александр Чаплыгин
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Страницы статистики по клику, роутинг, action
parent
b55070ec
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
383 additions
and
0 deletions
+383
-0
acl.global.php
src/config/autoload/acl.global.php
+1
-0
routes.global.php
src/config/autoload/routes.global.php
+23
-0
ViewId.php
src/src/App/Action/User/ViewId.php
+167
-0
view-id.phtml
src/templates/app/user/view-id.phtml
+192
-0
No files found.
src/config/autoload/acl.global.php
View file @
80de9341
...
...
@@ -34,6 +34,7 @@ return [
->
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.profile'
,
null
,
new
\App\Acl\Assertion\UserActive
())
->
allow
(
Roles
::
ROLE_USER
,
'user.viewid'
,
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_GUEST
,
'email.counter'
)
...
...
src/config/autoload/routes.global.php
View file @
80de9341
...
...
@@ -58,6 +58,13 @@ return [
$container
);
},
App\Action\User\ViewId
::
class
=>
function
(
ContainerInterface
$container
)
{
return
new
App\Action\User\ViewId
(
$container
->
get
(
\Zend\Expressive\Router\RouterInterface
::
class
),
$container
->
get
(
\Zend\Expressive\Template\TemplateRendererInterface
::
class
),
$container
);
},
App\Action\User\Profile
::
class
=>
function
(
ContainerInterface
$container
)
{
return
new
App\Action\User\Profile
(
$container
->
get
(
\Zend\Expressive\Router\RouterInterface
::
class
),
...
...
@@ -306,6 +313,22 @@ return [
]
],
],
[
'name'
=>
'user.viewid'
,
'path'
=>
'/[:lang/]cabinet/viewid/:id'
,
'middleware'
=>
App\Action\User\ViewId
::
class
,
'allowed_methods'
=>
[
'GET'
,
'POST'
],
'options'
=>
[
'constraints'
=>
[
'lang'
=>
'[a-z]{2,3}'
,
'id'
=>
'\w+'
,
],
'defaults'
=>
[
'lang'
=>
\App\Model\Locales
::
DEFAULT_LANG
,
'action'
=>
App\Action\User\ViewId
::
ACTION_STAT
,
]
],
],
[
'name'
=>
'user.cabinet.profile'
,
'path'
=>
'/[:lang/]cabinet/profile/'
,
...
...
src/src/App/Action/User/ViewId.php
0 → 100644
View file @
80de9341
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
namespace
App\Action\User
;
use
App\Action\Common
;
use
App\Authentication\UserService
;
use
App\Model\Users
;
use
App\Model\Statistics
;
use
App\Model\Providers
;
use
App\Model\Feeds\Feeds
;
use
Psr\Http\Message\ResponseInterface
;
use
Psr\Http\Message\ServerRequestInterface
;
use
Zend\Diactoros\Response\HtmlResponse
;
use
Zend\Diactoros\Response\JsonResponse
;
use
Zend\Diactoros\Response\RedirectResponse
;
/**
* Class ViewId
* @package App\Action\User
*/
class
ViewId
extends
Common
{
const
ACTION_STAT
=
'stat'
;
/**
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable|null $next
* @return HtmlResponse
*/
function
__invoke
(
ServerRequestInterface
$request
,
ResponseInterface
$response
,
callable
$next
=
null
)
{
/** @var \App\Model\Statistics $stats */
$stats
=
$this
->
container
->
get
(
Statistics
::
class
);
if
(
$request
->
getMethod
()
==
'POST'
)
{
try
{
switch
(
$request
->
getAttribute
(
'action'
))
{
case
self
::
ACTION_STAT
:
$response
=
$this
->
getStatData
(
$request
);
break
;
default
:
}
}
catch
(
\Exception
$e
)
{
$data
=
[
'result'
=>
false
,
'msg'
=>
$e
->
getMessage
(),
];
$response
=
new
JsonResponse
(
$data
);
}
return
$response
;
}
else
{
try
{
$view_id
=
$request
->
getAttribute
(
'id'
);
//return new JsonResponse($view_id);
$data
[
'error'
]
=
_t
(
'Извините, история визитов по клику: '
.
$view_id
.
' временно не работает'
);
}
catch
(
\Exception
$e
)
{
$data
[
'error'
]
=
_t
(
'Извините, история визитов по клику временно не работает'
);
}
$data
=
array_merge
(
$data
,
[
'lang'
=>
$request
->
getAttribute
(
'layoutInfo'
)
->
getLang
(),
'layoutInfo'
=>
$request
->
getAttribute
(
'layoutInfo'
),
]);
return
new
HtmlResponse
(
$this
->
template
->
render
(
'app::user/view-id'
,
$data
));
}
}
private
function
getStatData
(
ServerRequestInterface
$request
)
{
/** @var UserService $auth */
$auth
=
$this
->
container
->
get
(
UserService
::
class
);
$userId
=
$auth
->
getIdentity
()
->
getId
();
/** @var \App\Model\Statistics $stats */
$stats
=
$this
->
container
->
get
(
Statistics
::
class
);
// Выводим стр. по фидам, если за пользователем закреплен фид:
/** @var \App\Model\Feeds $feedsModel */
$feedsModel
=
$this
->
container
->
get
(
Feeds
::
class
);
$feeds
=
$feedsModel
->
findAll
([
'clientid'
=>
$userId
])
->
toArray
();
// Фиды пользователя:
$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
;
}
}
$report_type
=
$request
->
getAttribute
(
'report'
);
$data_request
=
$request
->
getParsedBody
();
$dates
=
$data_request
[
'period'
];
$report_conf
=
$this
->
container
->
get
(
'config'
)[
'feed_conf'
][
'reports'
][
$report_type
];
switch
(
$report_type
)
{
case
'common'
:
$periodStats
=
$stats
->
getFeedStatData
(
$report_type
,
$feed_id_list
,
$dates
,
$report_conf
);
//$campaignStats = $statsDaysModel->getStatsByFeeds($feed_id_list, $dates);
break
;
case
'transaction'
:
$periodStats
=
$stats
->
getFeedStatData
(
$report_type
,
$feed_id_list
,
$dates
,
$report_conf
);
break
;
default
:
$periodStats
=
null
;
$campaignStats
=
null
;
break
;
}
if
(
!
$periodStats
)
{
return
new
JsonResponse
(
null
);
}
/*
if ($periodStats || $companyStats) {
$data = array(
'period' => $periodStats,
'campaign' => $campaignStats,
);
} else {
$data = null;
}
*/
$data
=
$periodStats
;
return
new
JsonResponse
(
$data
);
}
}
\ No newline at end of file
src/templates/app/user/view-id.phtml
0 → 100644
View file @
80de9341
<?php
/**
* Copyright (c) 2016 Serhii Borodai <clarifying@gmail.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*
*/
/** @var $this \Zend\View\Renderer\PhpRenderer */
$this
->
headScript
()
->
appendFile
(
'/js/underscore-min.js'
)
->
appendFile
(
'/js/jquery.cookie.js'
)
->
appendFile
(
'/js/bootstrap.min.js'
)
->
appendFile
(
'/js/c3.min.js'
)
->
appendFile
(
'/js/d3.min.js'
)
->
appendFile
(
'/js/datepicker.min.js'
)
//->appendFile('/js/script-feeds-stat-charts.js')
//->appendFile('/js/script-feeds-stat-table.js')
//->appendFile('/js/script-feeds-stat.js')
//->appendFile('/js/adm/service-actions.js')
;
$this
->
headLink
()
->
appendStylesheet
(
'/css/c3.css'
)
->
appendStylesheet
(
'/css/datepicker.min.css'
)
->
appendStylesheet
(
'/css/styles-feeds-stat.css'
)
;
/** @var \App\Entity\IdentityInterface $identity */
$identity
=
$this
->
identity
();
$gravatar
=
$this
->
gravatar
(
$identity
->
getEmail
());
$gravatar
->
setDefaultImg
(
\Zend\View\Helper\Gravatar
::
DEFAULT_IDENTICON
);
$sxml
=
new
SimpleXMLElement
(
substr
(
$gravatar
,
0
,
-
1
)
.
'/>'
);
$src
=
$sxml
[
'src'
];
$error
=
$this
->
error
;
if
(
!
$error
)
{
$periodStats
=
$this
->
periodStats
;
//$campaignStats = $this->campaignStats;
$current_period
=
$this
->
current_period
;
$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
;
$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'
);
}
?>
<?php
if
(
$error
)
:
?>
<section
class=
"b-content__work"
>
<div
class=
"wrapp"
style=
"margin: 100px auto; text-align: center;"
>
<h1>
<?=
$error
?>
</h1>
</div>
</section>
<?php
else
:
?>
<textarea
id=
"period-stats"
>
<?=
(
$periodStats
?
json_encode
(
$periodStats
,
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"
>
<div
class=
"wrapp"
style=
"position: relative;"
>
<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"
>
<?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
/* Выбор дат */
?>
<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
]
?>
"
/>
–
<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>
<div
class=
"chart-graph-stat-info"
>
<h2>
По заданным параметрам статистика отсутствует
</h2>
</div>
<div
class=
"chart-graph-stat-error"
>
<h2>
Ошибка в статистике
</h2>
<div
class=
"message"
></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"
>
▲
</b><b
class=
"arrow desc"
>
▼
</b></b>
<?php
endif
;
?>
<?php
endif
;
?>
</th>
<?php
endforeach
;
?>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</section>
<?php
endif
?>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment