Перенес скрипты, шаблоны из админки, правки в контроллерах

parent 5dad880d
...@@ -38,7 +38,10 @@ return [ ...@@ -38,7 +38,10 @@ return [
->allow(Roles::ROLE_USER, 'user.cabinet.viewid', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet.viewid', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.orderid', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet.orderid', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.amsystem', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet.amsystem', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.group', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.campaign', null, new \App\Acl\Assertion\UserActive()) ->allow(Roles::ROLE_USER, 'user.cabinet.campaign', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.groups.stat', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.campaigns.stat', 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')
......
...@@ -3012,7 +3012,6 @@ return [ ...@@ -3012,7 +3012,6 @@ return [
'codes' => 'codes' =>
array( array(
0 => 703883, 0 => 703883,
1 => 694422,
), ),
), ),
340 => 340 =>
...@@ -3216,6 +3215,22 @@ return [ ...@@ -3216,6 +3215,22 @@ return [
0 => 703447, 0 => 703447,
), ),
), ),
365 =>
array(
'name' => 'город Севастополь',
'codes' =>
array(
0 => 694422,
),
),
366 =>
array(
'name' => 'Моб. операторы',
'codes' =>
array(
0 => 'empty',
),
),
) )
] ]
]; ];
...@@ -385,7 +385,7 @@ return [ ...@@ -385,7 +385,7 @@ return [
], ],
[ [
'name' => 'user.cabinet.amsystem', 'name' => 'user.cabinet.amsystem',
'path' => '/[:lang/]campaigns/', 'path' => '/[:lang/]groups/',
'middleware' => App\Action\User\CabinetAmSystem::class, 'middleware' => App\Action\User\CabinetAmSystem::class,
'allowed_methods' => ['GET', 'POST'], 'allowed_methods' => ['GET', 'POST'],
'options' => [ 'options' => [
...@@ -394,13 +394,29 @@ return [ ...@@ -394,13 +394,29 @@ return [
], ],
'defaults' => [ 'defaults' => [
'lang' => \App\Model\Locales::DEFAULT_LANG, 'lang' => \App\Model\Locales::DEFAULT_LANG,
'action' => App\Action\User\CabinetAmSystem::ACTION_LIST, 'action' => App\Action\User\CabinetAmSystem::ACTION_GROUPS_LIST,
]
],
],
[
'name' => 'user.cabinet.group',
'path' => '/[:lang/]group/:id/',
'middleware' => App\Action\User\CabinetAmSystem::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\CabinetAmSystem::ACTION_GROUPS_ITEM,
] ]
], ],
], ],
[ [
'name' => 'user.cabinet.campaign', 'name' => 'user.cabinet.campaign',
'path' => '/[:lang/]campaign/:id', 'path' => '/[:lang/]campaign/:id/',
'middleware' => App\Action\User\CabinetAmSystem::class, 'middleware' => App\Action\User\CabinetAmSystem::class,
'allowed_methods' => ['GET', 'POST'], 'allowed_methods' => ['GET', 'POST'],
'options' => [ 'options' => [
...@@ -410,7 +426,35 @@ return [ ...@@ -410,7 +426,35 @@ return [
], ],
'defaults' => [ 'defaults' => [
'lang' => \App\Model\Locales::DEFAULT_LANG, 'lang' => \App\Model\Locales::DEFAULT_LANG,
'action' => App\Action\User\CabinetAmSystem::ACTION_ITEM, 'action' => App\Action\User\CabinetAmSystem::ACTION_CAMPAIGNS_ITEM,
]
],
],
[
'name' => 'user.cabinet.groups.stat',
'path' => '/groups/stat/:id/',
'middleware' => App\Action\User\CabinetAmSystem::class,
'allowed_methods' => ['POST'],
'options' => [
'constraints' => [
'id' => '\d+',
],
'defaults' => [
'action' => App\Action\User\CabinetAmSystem::ACTION_GROUPS_STAT,
]
],
],
[
'name' => 'user.cabinet.campaigns.stat',
'path' => '/campaigns/stat/:id/',
'middleware' => App\Action\User\CabinetAmSystem::class,
'allowed_methods' => ['POST'],
'options' => [
'constraints' => [
'id' => '\d+',
],
'defaults' => [
'action' => App\Action\User\CabinetAmSystem::ACTION_CAMPAIGNS_STAT,
] ]
], ],
], ],
......
...@@ -64,6 +64,10 @@ h1 { ...@@ -64,6 +64,10 @@ h1 {
color : #697075; color : #697075;
} }
.panel-heading h1 {
font-family: Arial, sans-serif;
}
h2 { h2 {
font-family: 'RalewayBold', sans-serif; font-family: 'RalewayBold', sans-serif;
font-size : 1rem; font-size : 1rem;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
;(function($){
var jqPluginName = 'filterAmsystemTable';
var filterPlugin = function(element, options) {
var self = this;
var config = $.extend(true, {}, $.fn[jqPluginName].defaults, options);
config.context = element;
config.$table = $(config.table, config.context);
config.$selectStatus = $(config.selectStatus, config.context);
config.currentFilter = ($.cookie(config.cookieName)) ? $.cookie(config.cookieName) : config.currentFilterDefault;
// Форматирование значений для таблицы
this.valueFormatTable = function(value, currentActiveLine)
{
var
localeFormatter = d3.locale(config.myLocale),
format;
switch(currentActiveLine) {
case 'money':
case 'order_money':
case 'cpc':
case 'cpm':
format = localeFormatter.numberFormat("$,.2f");
break;
case 'ctr':
format = function(d) { return d3.format(',.2f')(d) + "%"; };
break;
default:
format = localeFormatter.numberFormat(",.0f");
break;
}
return format(value);
}
this.setTableFilter = function(val) {
config.$selectStatus.val(val);
config.filters.forEach(function(item) {
config.$table.removeClass(item);
})
config.$table.addClass(val);
$.cookie(config.cookieName, val, { expires : 365 });
}
this.setTotalValue = function(val) {
var $totalTr = $('tr.total', config.$table);
if ($totalTr.length > 0) {
var
totalValue = [],
totalValueCat,
views, money, clicks;
config.sumCats.forEach(function(cat){
totalValueCat = 0;
$('tbody tr.banner-item', config.$table).each(function(){
var $this = $(this);
if (val == 'all' || $this.hasClass(val)) {
totalValueCat+= parseFloat($('td.'+ cat, $this).data('value'));
}
});
totalValue[cat] = totalValueCat;
});
views = totalValue['views'];
money = totalValue['money'];
clicks = totalValue['clicks'];
totalValue['ctr'] = (views != 0) ? ((clicks/views)*100).toFixed(2) : 0;
totalValue['cpm'] = (views != 0) ? ((money/views)*1000).toFixed(3) : 0;
totalValue['cpc'] = (clicks != 0) ? (money/clicks).toFixed(2) : 0;
config.cats.forEach(function(cat){
$('tr.total td.' + cat, config.$table).html(self.valueFormatTable(totalValue[cat], cat));
});
}
}
this.InitData = function() {
this.setTableFilter(config.currentFilter);
this.setTotalValue(config.currentFilter);
}
// Устанавливаем по-умолчанию фильтр для таблицы:
this.InitData();
config.$selectStatus.on('change', function(){
self.setTableFilter($(this).val());
self.setTotalValue($(this).val());
});
config.context.data(jqPluginName, this);
}
$.fn[jqPluginName] = function(options) {
return this.each(function() {
var _this = $(this);
if (!_this.data(jqPluginName))
{
new filterPlugin(_this, options);
}
});
}
$.fn[jqPluginName].defaults = {
context: null,
table: null,
$table: null,
selectStatus: null,
$selectStatus: null,
filters: ['all', 'active', 'not-active', 'archive', 'not-archive'],
cookieName: 'table_filter_status',
cats: ['views', 'clicks', 'ctr', 'cpm', 'cpc', 'money', 'order_cnt', 'order_money'],
sumCats: ['views', 'clicks', 'money', 'order_cnt', 'order_money'],
currentFilterDefault: 'all',
myLocale: {
"decimal": ",",
"thousands": "\xa0",
"grouping": [3],
"currency": ["", " ₴"],
"dateTime": "%A, %e %B %Y г. %X",
"date": "%d.%m.%Y",
"time": "%H:%M:%S",
"periods": ["AM", "PM"],
"days": ["воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота"],
"shortDays": ["вс", "пн", "вт", "ср", "чт", "пт", "сб"],
"months": ["января", "февраля", "марта", "апреля", "мая", "июня", "июля", "августа", "сентября", "октября", "ноября", "декабря"],
"shortMonths": ["янв", "фев", "мар", "апр", "май", "июн", "июл", "авг", "сен", "окт", "ноя", "дек"]
}
}
})(jQuery);
;(function($){
var jqPluginName = 'sortAmsystemTable';
var sortPlugin = function(element, options) {
var self = this;
var config = $.extend(true, {}, $.fn[jqPluginName].defaults, options);
config.context = element;
config.$columnItems = $(config.columnItems, config.context);
config.isParentStructure = $('tr[data-parent]', config.context).length>0;
this.addDataItems = function() {
config.dataItems = [];
config.$itemsRows = $(config.itemsRows, config.context);
var $itemRow;
config.$itemsRows.each(function(i, e){
$itemRow = $(e);
var itemData = {
tr: $itemRow, // строка в таблице
};
config.$columnItems.each(function(){
var
sortName = $.trim($(this).data('sort')),
sortValue = $('td[data-cat="' + sortName + '"]', $itemRow).data('value');
itemData[sortName] = sortValue;
});
config.dataItems.push(itemData);
});
}
this.filterItems = function(field) {
config.$columnItems.filter('[data-sort="' + field + '"]').click();
}
// Клик по названию колонки для сортировки:
config.$columnItems.click(function() {
// Сортировка в таблице
var
$columnItem = $(this),
sortField = $columnItem.data('sort'),
sortAsc = $columnItem.attr('data-sortasc');
config.$columnItems.removeClass('selected');
$columnItem.attr('data-sortasc', -sortAsc);
$columnItem.removeClass('asc').removeClass('desc').addClass('selected').addClass((-sortAsc > 0) ? 'asc' : 'desc');
config.dataItems.sort(function(a, b) {
if (sortAsc < 0) {
return (a[sortField] > b[sortField]) ? 1 : -1;
} else {
return (a[sortField] < b[sortField]) ? 1 : -1;
}
});
// Доп. сортровка данных для родительских структуры внутри таблицы:
if (config.isParentStructure) {
var dataItemsTemp = [],id;
config.dataItems.forEach(function(item, i){
if (item.tr.hasClass('group-item')) {
dataItemsTemp.push(item);
id = item.tr.data('id');
config.dataItems.forEach(function(item, i){
if (item.tr.data('parent') == id) {
dataItemsTemp.push(item);
}
});
}
});
config.dataItems = dataItemsTemp;
}
// Переписываем таблицу:
var
$table = $(config.context),
$tableBody = $('tbody', $table),
$tableContent = $('<tbody>');
for (var i = 0; i < config.dataItems.length; i++) {
(config.dataItems[i].tr).appendTo($tableContent);
}
$tableBody.html('').append($tableContent.children());
});
self.InitData = function() {
this.addDataItems();
}
this.addDataItems();
this.filterItems(config.defaultSortField);
config.context.data(jqPluginName, this);
}
$.fn[jqPluginName] = function(options) {
return this.each(function() {
var _this = $(this);
if (!_this.data(jqPluginName))
{
new sortPlugin(_this, options);
}
});
}
$.fn[jqPluginName].defaults = {
context: null,
dataItems: [],
itemsRows: 'tbody tr',
$itemsRows: null,
columnItems: '.sort[data-sort]',
$columnItems: null,
fieldsInt: ['id', 'views', 'clicks', 'orders', 'reach', 'order_cnt'],
fieldsFloat: ['cl', 'money', 'ctr', 'cpc', 'cpm', 'order_money'],
isParentStructure: false,
defaultSortField: 'views'
}
})(jQuery);
...@@ -2,7 +2,7 @@ $(document).ready(function () { ...@@ -2,7 +2,7 @@ $(document).ready(function () {
"use strict"; "use strict";
// Свернуть-развернуть дочерние ячейки в таблице: // Свернуть-развернуть дочерние ячейки в таблице:
$('.table.campaigns').on('click', 'span.group', function(e) { $('.table.groups').on('click', 'span.group', function(e) {
var var
$this = $(this), $this = $(this),
...@@ -12,6 +12,7 @@ $(document).ready(function () { ...@@ -12,6 +12,7 @@ $(document).ready(function () {
isOpen, isOpen,
$subcats = $('tr.campaign-item[data-parent="'+ id + '"]', $tableBody); $subcats = $('tr.campaign-item[data-parent="'+ id + '"]', $tableBody);
$this.toggleClass('open'); $this.toggleClass('open');
isOpen = $this.hasClass('open'); isOpen = $this.hasClass('open');
...@@ -24,32 +25,17 @@ $(document).ready(function () { ...@@ -24,32 +25,17 @@ $(document).ready(function () {
}); });
// Разворачиваем списки групп кампаний при старте: // Разворачиваем списки групп кампаний при старте:
$('.table.campaigns span.group').click(); $('.table.groups span.group').click();
// Фильтрация для таблицы:
var
$table = $('.table.campaigns'),
$selectStatus = $('.form-control.campaign-status'),
filters = ['all', 'active', 'not-active', 'archive', 'not-archive'],
cookieName = 'table_filter_status',
currentFilter = ($.cookie(cookieName)) ? $.cookie(cookieName) : 'not-archive';
function setTableFilter(val)
{
$selectStatus.val(val);
filters.forEach(function(item) {
$table.removeClass(item);
})
$table.addClass(val);
$.cookie(cookieName, val, { expires : 365 });
}
$selectStatus.on('change', function(){ // Фильтрация в таблице:
setTableFilter($(this).val()); $('.users-groups').filterAmsystemTable({
table: '.table.groups',
selectStatus: '.form-control.campaign-status',
currentFilterDefault: 'not-archive'
}); });
// Устанавливаем по-умолчанию фильтр для таблицы: // Сортировка в таблице групп-кампаний:
setTableFilter(currentFilter); $('.users-groups .table.groups').sortAmsystemTable();
}); });
This diff is collapsed.
...@@ -34,6 +34,7 @@ use App\Entity\Common; ...@@ -34,6 +34,7 @@ use App\Entity\Common;
*/ */
class Campaign extends Common class Campaign extends Common
{ {
/* group_id */ /* group_id */
public function getGroupId() public function getGroupId()
{ {
...@@ -78,25 +79,25 @@ class Campaign extends Common ...@@ -78,25 +79,25 @@ class Campaign extends Common
return $this; return $this;
} }
/* url */ /* checksum */
public function getUrl() public function getChecksum()
{ {
return $this->url; return $this->checksum;
} }
public function setUrl($url) public function setChecksum($checksum)
{ {
$this->url = $url; $this->checksum = $checksum;
return $this; return $this;
} }
/* checksum */ /* url */
public function getChecksum() public function getUrl()
{ {
return $this->checksum; return $this->url;
} }
public function setChecksum($checksum) public function setUrl($url)
{ {
$this->checksum = $checksum; $this->url = $url;
return $this; return $this;
} }
...@@ -155,6 +156,28 @@ class Campaign extends Common ...@@ -155,6 +156,28 @@ class Campaign extends Common
return $this; return $this;
} }
/* order_sum */
public function getOrderSum()
{
return $this->orderSum;
}
public function setOrderSum($orderSum)
{
$this->orderSum = $orderSum;
return $this;
}
/* tracking_action */
public function getTrackingAction()
{
return $this->trackingAction;
}
public function setTrackingAction($trackingAction)
{
$this->trackingAction = $trackingAction;
return $this;
}
/* max_speed */ /* max_speed */
public function getMaxSpeed() public function getMaxSpeed()
{ {
......
...@@ -45,6 +45,17 @@ class Group extends Common ...@@ -45,6 +45,17 @@ class Group extends Common
return $this; return $this;
} }
/* checksum */
public function getChecksum()
{
return $this->checksum;
}
public function setChecksum($checksum)
{
$this->checksum = $checksum;
return $this;
}
/* title */ /* title */
public function getTitle() public function getTitle()
{ {
...@@ -100,6 +111,28 @@ class Group extends Common ...@@ -100,6 +111,28 @@ class Group extends Common
return $this; return $this;
} }
/* order_sum */
public function getOrderSum()
{
return $this->orderSum;
}
public function setOrderSum($orderSum)
{
$this->orderSum = $orderSum;
return $this;
}
/* tracking_action */
public function getTrackingAction()
{
return $this->trackingAction;
}
public function setTrackingAction($trackingAction)
{
$this->trackingAction = $trackingAction;
return $this;
}
/* visitor_limit */ /* visitor_limit */
public function getVisitorLimit() public function getVisitorLimit()
{ {
......
...@@ -369,11 +369,48 @@ class Statistics ...@@ -369,11 +369,48 @@ class Statistics
$stats['money'] = round($stats['money'], 2); $stats['money'] = round($stats['money'], 2);
} }
// Данные для статистики по баннерам
public function getBannersStat($banners_id_list, $taget_action, $dates)
{
$dataRequest = array(
'method' => ($dates) ? 'banner_day' : 'banner_total',
'data' => array(
'ids' => $banners_id_list,
)
);
if ($dates) {
$dataRequest['data']['start_date'] = $dates[0];
$dataRequest['data']['end_date'] = $dates[1];
}
//return $dataRequest;
try {
$stats = $this->apiRequest($dataRequest);
} catch (\Exception $e) {
$stats['status'] = 'Error';
}
//return $stats;
if ($stats) {
$this->AddSpecialFields($stats);
$dataStats = $stats;
}
return $dataStats;
}
// Данные для статистики по кампании (баннеры) // Данные для статистики по кампании (баннеры)
public function getCampaignsStat($id_list, $taget_action, $dates, $by_days = false) public function getCampaignsStat($type, $id_list, $taget_action, $dates, $by_days = false)
{ {
if ($type == 'campaign') {
$method = ($dates) ? 'camp_day' : 'camp_total';
} else {
$method = ($dates) ? 'cgroup_day' : 'cgroup_total';
}
$dataRequest = array( $dataRequest = array(
'method' => ($dates) ? 'camp_day' : 'camp_total', 'method' => $method,
'data' => array( 'data' => array(
'ids' => $id_list, 'ids' => $id_list,
) )
...@@ -493,43 +530,17 @@ class Statistics ...@@ -493,43 +530,17 @@ class Statistics
return $dataStats; return $dataStats;
} }
// Данные для статистики по баннерам
public function getBannersStat($banners_id_list, $dates)
{
$dataRequest = array(
'method' => ($dates) ? 'banner_day' : 'banner_total',
'data' => array(
'ids' => $banners_id_list,
)
);
if ($dates) {
$dataRequest['data']['start_date'] = $dates[0];
$dataRequest['data']['end_date'] = $dates[1];
}
//return $dataRequest;
try {
$stats = $this->apiRequest($dataRequest);
} catch (\Exception $e) {
$stats['status'] = 'Error';
}
//return $stats;
if ($stats) {
$this->AddSpecialFields($stats);
$dataStats = $stats;
}
return $dataStats;
}
// Данные для статистики кампании по сайтам // Данные для статистики кампании по сайтам
public function getCampaignsSitesStat($id, $taget_action, $dates) public function getCampaignsSitesStat($type, $id, $taget_action, $dates)
{ {
if ($type == 'campaign') {
$method = 'camp_zone';
} else {
$method = 'cgroup_zone';
}
$dataRequest = array( $dataRequest = array(
'method' => 'camp_zone', 'method' => $method,
'data' => array( 'data' => array(
'id' => $id, 'id' => $id,
'start_date' => $dates[0], 'start_date' => $dates[0],
...@@ -564,10 +575,16 @@ class Statistics ...@@ -564,10 +575,16 @@ class Statistics
} }
// Данные для статистики кампании по регионам // Данные для статистики кампании по регионам
public function getCampaignsRegionsStat($id, $taget_action, $dates) public function getCampaignsRegionsStat($type, $id, $taget_action, $dates)
{ {
if ($type == 'campaign') {
$method = 'camp_geo';
} else {
$method = 'cgroup_geo';
}
$dataRequest = array( $dataRequest = array(
'method' => 'camp_geo', 'method' => $method,
'data' => array( 'data' => array(
'id' => $id, 'id' => $id,
'start_date' => $dates[0], 'start_date' => $dates[0],
...@@ -585,21 +602,15 @@ class Statistics ...@@ -585,21 +602,15 @@ class Statistics
//return $stats; //return $stats;
if ($stats) { if ($stats) {
// Убираем города у регионов Киев(703447) и empty:
foreach ([703447, 'empty'] as $region_code) {
unset($stats[$region_code]['sub']);
}
foreach ($stats as $region => $stat) { foreach ($stats as $region => $stat) {
$this->AddSpecialFields($stats[$region]); $this->AddSpecialFields($stats[$region]);
if ($stat['sub']) { if ($stat['sub']) {
foreach ($stat['sub'] as $sub => $stat) { foreach ($stat['sub'] as $sub => $stat) {
$this->AddSpecialFields($stats[$region]['sub'][$sub]); $this->AddSpecialFields($stats[$region]['sub'][$sub]);
} }
} }
} }
$dataStats = $stats; $dataStats = $stats;
} }
......
<?php
/*
Функции для форматирования
*/
function formatMoney($val)
{
return number_format((float)$val, 2, ',', ' ') . ' &#8372';
}
?>
<?php
/*
Функции для форматирования
*/
function formatMoney($val)
{
return number_format((float)$val, 2, ',', ' ') . ' &#8372';
}
function formatCPM($val)
{
return number_format((float)$val, 3, ',', ' ') . ' &#8372';
}
function formatCTR($val)
{
return number_format((float)$val, 2, ',', ' ') . '%';
}
function formatIntegerValue($val)
{
return number_format($val, 0, ',', ' ');
}
function formatField($value, $cat)
{
switch ($cat) {
case 'money':
case 'order_money':
case 'cpc':
case 'cpm':
$formatted_value = formatMoney($value);
break;
case 'ctr':
$formatted_value = formatCTR($value);
break;
default:
$formatted_value = formatIntegerValue($value);
}
return $formatted_value;
}
?>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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