Страница кабинета списка кампаний, статистика, модели данных

parent 8e8e11e5
......@@ -37,7 +37,7 @@ return [
->allow(Roles::ROLE_USER, 'user.cabinet.profile', 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.campaigns', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'user.cabinet.amsystem', 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')
......
......@@ -61,6 +61,8 @@ return [
$hpm->setService(\App\Entity\Feeds\StatsDay::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\Transaction::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\OrderStatus::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\AmSystem\Campaign::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Contacts::class, new \Zend\Hydrator\ClassMethods());
......@@ -224,6 +226,18 @@ return [
$container->get(\Monolog\Logger::class)
);
},
\App\Model\AmSystem\Campaigns::class => function (ContainerInterface $container) {
return new \App\Model\AmSystem\Campaigns(
new Zend\Db\TableGateway\TableGateway(
'am_campaigns',
$container->get(Zend\Db\Adapter\Adapter::class),
new \Zend\Db\TableGateway\Feature\MetadataFeature(),
new \Zend\Db\ResultSet\HydratingResultSet($container->get(\Zend\Hydrator\DelegatingHydrator::class), new \App\Entity\AmSystem\Campaign())
),
$container->get(\Zend\Hydrator\DelegatingHydrator::class),
$container->get(\Monolog\Logger::class)
);
},
\App\Model\FAQ\Categories::class => function (ContainerInterface $container) {
return new \App\Model\FAQ\Categories(
new Zend\Db\TableGateway\TableGateway(
......
......@@ -65,8 +65,8 @@ return [
$container
);
},
App\Action\User\Campaigns::class => function(ContainerInterface $container) {
return new App\Action\User\Campaigns(
App\Action\User\CabinetAmSystem::class => function(ContainerInterface $container) {
return new App\Action\User\CabinetAmSystem(
$container->get(\Zend\Expressive\Router\RouterInterface::class),
$container->get(\Zend\Expressive\Template\TemplateRendererInterface::class),
$container
......@@ -384,9 +384,9 @@ return [
],
],
[
'name' => 'user.campaigns',
'name' => 'user.cabinet.amsystem',
'path' => '/[:lang/]campaigns/',
'middleware' => App\Action\User\Campaigns::class,
'middleware' => App\Action\User\CabinetAmSystem::class,
'allowed_methods' => ['GET', 'POST'],
'options' => [
'constraints' => [
......@@ -394,7 +394,7 @@ return [
],
'defaults' => [
'lang' => \App\Model\Locales::DEFAULT_LANG,
'action' => App\Action\User\Campaigns::ACTION_LIST,
'action' => App\Action\User\CabinetAmSystem::ACTION_LIST,
]
],
],
......
/* Таблица стилей к странице рекламных кампаний */
.b-content__work
{
margin: 0 auto;
padding-top: 75px;
max-width: 1240px;
}
.b-content__work.error .wrapp
{
margin: 100px auto;
min-height: 300px;
text-align: center;
}
input[type="checkbox"],
input[type="radio"]
{
vertical-align: -2px;
}
.edited {
min-width: 100px;
min-height: 20px;
/*border-bottom: 1px dotted #ccc;*/
cursor: pointer;
}
input.editing {
display: none;
background-color: transparent;
border: 1px solid #ccc;
}
.b-left
{
float: left;
padding-right: 5px;
width: 50%;
}
.b-right
{
float: right;
padding-left: 5px;
width: 50%;
}
table.campaigns tbody tr td.stat {
font-family: monospace;
white-space: nowrap;
text-align: right;
}
table.campaigns tbody tr td.stat.load-target {
font-style: italic;
}
.form-group.title
{
font-size: 16px;
}
input.campaign-title {
padding: 0 12px;
line-height: 34px;
color: #697075;
}
.campaign-title.edited {
display: inline-block;
padding: 0 13px;
min-width: 600px;
height: 36px;
line-height: 36px;
color: #337ab7;
font-weight: bold;
}
.campaign-title.editing {
margin-left: 4px;
width: 600px;
}
.form-control.user-id
{
display: inline-block;
width: 250px;
}
.user-new
{
display: none;
margin-left: 10px;
}
.user-new input
{
display: inline;
width: 300px;
}
.form-group.url .value-show,
.form-group.tracking_pixels .value-show div.url
{
padding: 5px;
line-height: 15px;
font-family: monospace;
border: 1px solid #CCCCCC;
border-radius: 4px;
word-wrap: break-word;
}
.form-group.tracking_pixels .value-show div.url
{
line-height: 15px;
margin-bottom: 4px;
}
.form-group label.select-item.disabled
{
color: #BCBCBC;
}
.btn.btn-primary.save-item,
.btn.btn-primary.cancel-item
{
float: none;
margin: 0;
}
.form-group .value-edit,
.form-group .save-item,
.form-group .cancel-item
{
display: none;
}
.form-group .value-show span
{
font-size: 13px;
color: #000000;
}
.form-group .value-show b
{
color: #23527c;
}
.form-group.state-edit .value-show,
.form-group.state-edit .edit-item
{
display: none;
}
.form-group.state-edit .value-edit
{
display: block;
}
.form-group.state-edit .save-item,
.form-group.state-edit .cancel-item
{
display: inline-block;
}
.panel-heading h1
{
display: inline-block;
}
.panel-heading__controls
{
float: right;
}
.form-control.date-value,
.form-control.price,
.form-control.money-limit-total,
.form-control.limit
{
display: inline;
}
.form-control.date-value
{
width: 110px;
}
.form-control.price,
.form-control.money-limit-total
{
width: 100px;
}
.form-control.limit
{
width: 70px;
margin-bottom: 4px;
}
.form-group.campaign-money-limit .form-control.limit
{
width: 100px;
}
.form-group label:first-child
{
margin-right: 10px;
}
.form-group label.select-item
{
font-weight: normal;
}
.form-group .campaign-visitor-limit
{
float: left;
width: 240px;
}
.form-group .tracking_pixels_item label
{
font-weight: normal;
}
.form-group .tracking_pixels_item .add-row
{
display: inline;
}
.form-group .tracking_pixels_urls .url-item
{
margin-bottom: 4px;
padding-right: 20px;
height: 34px;
}
.form-group .tracking_pixels_urls input
{
float: left;
width: 100%;
}
.form-group .tracking_pixels_urls .delete-item {
float: right;
margin-right: -20px;
height: 32px;
width: 15px;
font-size: 27px;
line-height: 32px;
vertical-align: -4px;
color: #383838;
cursor: pointer;
}
.form-control#targeting_geo_country
{
display: inline-block;
width: 200px;
margin-bottom: 6px;
margin-right: 4px;
}
.geo_country .b-exclude label
{
font-weight: normal;
font-size: 13px;
}
.geo_region,
.geo_city
{
float: left;
padding: 4px 6px 0;
margin-bottom: 5px;
width: 100%;
border: 1px solid #CCC;
border-radius: 4px;
}
.geo_region .b-exclude,
.geo_city .b-exclude
{
float: right;
}
.geo_region-city .filters-select
{
float: left;
padding-right: 3px;
width: 50%;
height: 200px;
}
.geo_region-city .filters-values {
float: right;
padding-left: 3px;
width: 50%;
height: 200px;
}
.geo_region-city .region-val-geo {
line-height: 32px;
}
.geo_region #region-filter {
display: inline-block;
float: none;
margin-right: 0;
}
.geo_region-city .filters-select .filter {
margin-bottom: 8px;
}
.geo_region-city .filters-select .list-filters-wrap {
display: inline-block;
width: 100%;
border: 1px solid #CCCCCC;
border-radius: 4px;
}
.geo_region-city .list-filter {
padding-left: 4px;
height: 150px;
overflow-x: hidden;
overflow-y: scroll;
}
.geo_region-city .list-filter label,
.geo_region-city .values-string-list label
{
font-weight: normal;
}
.geo_region-city .values-string-list {
padding: 2px 6px;
height: 194px;
min-height: 34px;
border: 1px solid #CCCCCC;
border-radius: 4px;
overflow-y: scroll;
}
table.campaigns tbody tr.disabled
{
opacity: 0.5;
}
table.campaign-banners thead tr th {
text-align: right;
}
table.campaign-banners tbody tr td {
font-size: 12px;
font-family: monospace;
white-space: nowrap;
text-align: right;
}
table.campaign-banners tbody tr td.stat.load-target {
font-style: italic;
}
table.campaign-banners tbody tr td span.banner-preview
{
display: inline-block;
width: 48px;
height: 48px;
cursor: pointer;
background-size: contain;
background-repeat: no-repeat;
background-position: center;
}
.b-popup__window.preview {
width: auto;
min-width: 380px;
overflow: hidden;
}
.b-popup-message
{
display: none;
position: absolute;
top: 140px;
left: 25px;
width: 330px;
color: #D93025;
text-align: center;
border-radius: 4px;
font-weight: bold;
}
.b-popup-content {
min-height: 300px;
max-height: 800px;
padding: 10px;
}
.b-popup-content h2
{
color: #000000;
}
.b-popup-content b
{
color: #39B54A;
}
.b-popup-content span
{
font-family: 'RalewayRegular', sans-serif;
}
.b-popup__window.preview .form-group {
margin-bottom: 0;
}
.b-popup__window.preview .banner-img {
text-align: center;
}
.b-popup__window.preview .form-group .controls {
display: none;
}
.form-group.banners .form-pattern,
.form-group.banners input#img
{
display: none;
}
.form-group .image-controls,
.form-group .image-wrap
{
margin-bottom: 5px;
}
.form-group .image-wrap
{
display: none;
padding: 10px 0;
text-align: center;
}
.form-group .form-control.banner-size
{
display: inline-block;
width: 170px;
}
.form-group .btn.select-image
{
float: right;
}
\ No newline at end of file
......@@ -56,7 +56,7 @@ class Index extends Common
$route = 'user.cabinet';
}
if ($user_type == 'advertiser') {
$route = 'user.campaigns';
$route = 'user.cabinet.amsystem';
}
return new RedirectResponse($this->router->generateUri($route));
}
......
......@@ -28,6 +28,9 @@ namespace App\Action\User;
use App\Action\Common;
use App\Authentication\UserService;
use App\Model\Users;
//use App\Model\AmSystem\Campaigns;
//use App\Entity\AmSystem\Campaign;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\HtmlResponse;
......@@ -35,12 +38,19 @@ use Zend\Diactoros\Response\JsonResponse;
use Zend\Diactoros\Response\RedirectResponse;
use Zend\Hydrator\DelegatingHydrator;
/*
use App\Entity\User;
use App\Entity\AmSystem\Banner;
use App\Model\Statistics;
*/
/**
* Class Campaigns
* Class CabinetAmSystem
* @package App\Action\User
*/
class Campaigns extends Common
class CabinetAmSystem extends Common
{
const ACTION_LIST = 'list';
......@@ -60,9 +70,6 @@ class Campaigns extends Common
case self::ACTION_STAT:
$response = $this->getStatData($request);
break;
case self::ACTION_CATS:
$response = $this->editCatsData($request);
break;
default:
}
} catch(\Exception $e) {
......@@ -77,103 +84,54 @@ class Campaigns extends Common
}
elseif($request->getAttribute('action') == self::ACTION_LIST)
{
return new HtmlResponse('Campaigns LIST');
try {
/** @var UserService $auth */
$auth = $this->container->get(UserService::class);
$userId = $auth->getIdentity()->getId();
/** @var \App\Model\Feeds\Shops $shopsModel */
$shopsModel = $this->container->get(\App\Model\Feeds\Shops::class);
$shop = $shopsModel->findOne(['users_id' => $userId]);
if($shop) {
$shop_title = $shop->getTitle();
}
/** @var \App\Model\Feeds $feedsModel */
$feedsModel = $this->container->get(Feeds::class);
$feeds = $feedsModel->findAll(['clientid' => $userId])->toArray();
/** @var \App\Model\AmSystem\Campaigns $campaignsModel */
$campaignsModel = $this->container->get(\App\Model\AmSystem\Campaigns::class);
$campaigns = $campaignsModel->findAll(['user_id' => $userId])->toArray();
if ($feeds) {
if ($campaigns) {
// Фиды пользователя:
$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;
/** @var \App\Model\Statistics $stats */
$stats = $this->container->get(\App\Model\Statistics::class);
$campaigns_stat = [];
foreach ($campaigns as $campaign_item) {
$campaign_id = $campaign_item['id'];
$campaigns_stat[$campaign_id] = $stats->getCampaignsStat([$campaign_id], null);
if ($campaign_item['target_action'] == 'load') {
$campaigns_stat[$campaign_id]['views'] = $campaigns_stat[$campaign_id]['loads'];
$campaigns_stat[$campaign_id]['reach'] = $campaigns_stat[$campaign_id]['reach_load'];
} else {
$campaigns_stat[$campaign_id]['reach'] = $campaigns_stat[$campaign_id]['reach_view'];
}
}
$report_type = $request->getAttribute('report');
$views = $campaigns_stat[$campaign_id]['views'];
$money = $campaigns_stat[$campaign_id]['money'];
$clicks = $campaigns_stat[$campaign_id]['clicks'];
// Текущий месяц:
$current_period = 'current_month';
$dates = [date('Y-m-01'), date('Y-m-d')];
$campaigns_stat[$campaign_id]['ctr'] = ($views != 0) ? round(($clicks/$views)*100, 2) : 0;
$campaigns_stat[$campaign_id]['cpm'] = ($views != 0) ? round(($money/$views)*1000, 3) : 0;
$campaigns_stat[$campaign_id]['cpc'] = ($clicks != 0) ? round(($money/$clicks)*100, 1) : 0;
$reports_conf = $this->container->get('config')['feed_conf']['reports'];
$report_conf = $reports_conf[$report_type];
// Список отчетов:
$reports_list = [];
foreach($reports_conf as $report_name => $report_value) {
$reports_list[$report_name] = $report_value['title'];
}
switch ($report_type) {
case 'common':
$periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates, $report_conf);
break;
case 'transactions':
$periodStats = $stats->getFeedStatData($report_type, $feed_id_list, $dates, $report_conf);
break;
default:
$data['error'] = _t('Извините, тип отчета "'. $report_type .'" недоступен');
break;
}
// Добавляем спец. категории для сводного отчета по магазину:
if ($report_type == 'common') {
$periodStats = $this->addStatsSpecialCats($periodStats);
$campaigns_stat[$campaign_id]['money'] = round($campaigns_stat[$campaign_id]['money'], 2);
}
// Добавляем данные о статусах заказов:
if ($report_type == 'transactions') {
if ($periodStats) {
/** @var \App\Model\Feeds $ordersStatusModel */
$ordersStatusModel = $this->container->get(OrdersStatus::class);
$ordersStatus = $ordersStatusModel->findAll(['feed_id' => $feed_id_list])->toArray();
$statuses = [];
foreach($ordersStatus as $order_item) {
$statuses[$order_item['feed_id']][$order_item['order_id']] = array(
'confirmed' => $order_item['confirmed'] ? 1 : 0,
'approved' => $order_item['approved'] ? 1 : 0
);
}
$periodStats['ordersStatus'] = $statuses;
}
}
$data['shop_title'] = $shop_title;
$data['feeds'] = $feeds;
$data['current_report'] = $report_type;
$data['current_period'] = $current_period;
$data['dates'] = $dates;
$data['periodStats'] = $periodStats;
$data['report_conf'] = $report_conf;
$data['reports_list'] = $reports_list;
$data['periods_list'] = $this->container->get('config')['feed_conf']['periods_list'];
$data['colors_active_lines'] = $this->container->get('config')['feed_conf']['colors_active_lines'];
$data['campaigns'] = $campaigns;
$data['stats'] = $campaigns_stat;
} else {
$data['error'] = _t('Извините, у пользователя нет фидов');
$data['error'] = _t('Отсутствуют доступные кампании');
}
} catch(\Exception $e) {
$data['error'] = _t('Извините, статистика временно не работает');
$data['error'] = _t('Извините, данные по кампаниям временно недоступны');
}
$data = array_merge($data, [
......@@ -181,7 +139,7 @@ class Campaigns extends Common
'layoutInfo' => $request->getAttribute('layoutInfo'),
]);
return new HtmlResponse($this->template->render('app::user/cabinet-feed', $data));
return new HtmlResponse($this->template->render('app::user/campaigns_list', $data));
}
}
......
<?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\Entity\AmSystem;
use App\Entity\Common;
/**
* Class Banner
* @package App\Entity
*/
class Banner extends Common
{
/* active */
public function getActive()
{
return $this->active;
}
public function setActive($active)
{
$this->active = $active;
return $this;
}
/* width */
public function getWidth()
{
return $this->width;
}
public function setWidth($width)
{
$this->width = $width;
return $this;
}
/* height */
public function getHeight()
{
return $this->height;
}
public function setHeight($height)
{
$this->height = $height;
return $this;
}
/* img */
public function getImg()
{
return $this->img;
}
public function setImg($img)
{
$this->img = $img;
return $this;
}
}
\ No newline at end of file
<?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\Entity\AmSystem;
use App\Entity\Common;
/**
* Class Campaign
* @package App\Entity
*/
class Campaign extends Common
{
/* title */
public function getTitle()
{
return $this->title;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/* active */
public function getActive()
{
return $this->active;
}
public function setActive($active)
{
$this->active = $active;
return $this;
}
/* user_id */
public function getUserId()
{
return $this->userId;
}
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/* url */
public function getUrl()
{
return $this->url;
}
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/* date_begin */
public function getDateBegin()
{
return $this->dateBegin;
}
public function setDateBegin($dateBegin)
{
$this->dateBegin = $dateBegin;
return $this;
}
/* date_end */
public function getDateEnd()
{
return $this->dateEnd;
}
public function setDateEnd($dateEnd)
{
$this->dateEnd = $dateEnd;
return $this;
}
/* buy_type */
public function getBuyType()
{
return $this->buyType;
}
public function setBuyType($buyType)
{
$this->buyType = $buyType;
return $this;
}
/* target_action */
public function getTargetAction()
{
return $this->targetAction;
}
public function setTargetAction($targetAction)
{
$this->targetAction = $targetAction;
return $this;
}
/* price */
public function getPrice()
{
return $this->price;
}
public function setPrice($price)
{
$this->price = $price;
return $this;
}
/* max_speed */
public function getMaxSpeed()
{
return $this->maxSpeed;
}
public function setMaxSpeed($maxSpeed)
{
$this->maxSpeed = $maxSpeed;
return $this;
}
/* money_limit */
public function getMoneyLimit()
{
return $this->moneyLimit;
}
public function setMoneyLimit($moneyLimit)
{
$this->moneyLimit = $moneyLimit;
return $this;
}
/* visitor_limit */
public function getVisitorLimit()
{
return $this->visitorLimit;
}
public function setVisitorLimit($visitorLimit)
{
$this->visitorLimit = $visitorLimit;
return $this;
}
/* tracking_pixels */
public function getTrackingPixels()
{
return $this->trackingPixels;
}
public function setTrackingPixels($trackingPixels)
{
$this->trackingPixels = $trackingPixels;
return $this;
}
/* targeting */
public function getTargeting()
{
return $this->targeting;
}
public function setTargeting($targeting)
{
$this->targeting = $targeting;
return $this;
}
/* banners */
public function getBanners()
{
return $this->banners;
}
public function setBanners($banners)
{
$this->banners = $banners;
return $this;
}
}
\ No newline at end of file
<?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\Model\AmSystem;
use App\Model\Common;
/**
* Class Banners
* @package App\Model
*/
class Banners extends Common
{
}
\ No newline at end of file
<?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\Model\AmSystem;
use App\Model\Common;
/**
* Class Campaigns
* @package App\Model
*/
class Campaigns extends Common
{
}
\ No newline at end of file
......@@ -345,6 +345,56 @@ class Statistics
return $stats;
}
// Данные по статистике для кампании (баннеры)
public function getCampaignsStat($campaigns_id_list, $dates)
{
$dataRequest = array(
'method' => ($dates) ? 'camp_day' : 'camp_total',
'data' => array(
'ids' => $campaigns_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;
}
// Данные по статистике для баннеров
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;
}
// Запрос к API:
private function apiRequest($data)
{
......
<?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/adm/amsystem.js')
;
$this->headLink()
->appendStylesheet('/css/styles-amsystem.css')
;
$lang = $this->lang;
$campaigns = $this->campaigns;
?>
<?php if($error): ?>
<section class="b-content__work error">
<div class="wrapp">
<h1><?= $error?></h1>
</div>
</section>
<?php else: ?>
<section class="b-content__work">
<div class="panel panel-info">
<div class="panel-heading">
<h1><?= _t('Список кампаний') ?></h1>
</div>
<div class="panel-body all">
<table class="table table-striped campaigns" data-content="campaigns" data-action="/amsystem/campaigns/id/edit/">
<thead>
<tr>
<th width="1px"></th>
<th width="1px">#ID</th>
<th>Название кампании</th>
<th width="1px">Показы</th>
<th width="1px">Клики</th>
<th width="1px">CTR</th>
<th width="1px">Расход</th>
<th width="1px">Охват</th>
<th width="1px">eCPM</th>
<th width="1px">eCPC</th>
</tr>
</thead>
<tbody>
<?php foreach ($campaigns as $campaign) : ?>
<tr <?php if (!$campaign['active']): ?>class="disabled"<?php endif; ?>>
<?php
$campaign_id = $campaign['id'];
$stat = $stats[$campaign_id];
$target_class = ($campaign['target_action'] == 'load') ? 'load-target' : '';
?>
<td>
<input class="is-active" type="checkbox" data-id="<?= $campaign_id ?>" <?php if ($campaign['active']): ?>checked<?php endif; ?>>
</td>
<td>
<span class="item-id"><?= $campaign_id ?></span>
</td>
<td>
<?php
/*
$btn_link = $this->url('adm.amsystem.campaigns.edit', [
'lang' => $this->lang,
'id' => $campaign_id,
]);*/
?>
<span class="item-title"><a href="<?= $btn_link?>"><?= $campaign['title'] ?></a></span>
</td>
<td class="stat <?= $target_class ?>"><?= $stat['views'] ?></td>
<td class="stat"><?= $stat['clicks'] ?></td>
<td class="stat"><?= $stat['ctr'] ?></td>
<td class="stat"><?= $stat['money'] ?></td>
<td class="stat <?= $target_class ?>"><?= $stat['reach'] ?></td>
<td class="stat"><?= $stat['cpm'] ?></td>
<td class="stat"><?= $stat['cpc'] ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<div class="panel-footer">
</div>
</div>
</section>
<?php endif; ?>
\ No newline at end of file
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