Перенес структуру групп кампаний, правка общего списка кампаний пользователя

parent 42f6c1b9
...@@ -62,6 +62,7 @@ return [ ...@@ -62,6 +62,7 @@ return [
$hpm->setService(\App\Entity\Feeds\Transaction::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\Feeds\OrderStatus::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\AmSystem\Group::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\AmSystem\Campaign::class, new \Zend\Hydrator\ClassMethods()); $hpm->setService(\App\Entity\AmSystem\Campaign::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\AmSystem\Banner::class, new \Zend\Hydrator\ClassMethods()); $hpm->setService(\App\Entity\AmSystem\Banner::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Zone::class, new \Zend\Hydrator\ClassMethods()); $hpm->setService(\App\Entity\Zone::class, new \Zend\Hydrator\ClassMethods());
...@@ -228,6 +229,18 @@ return [ ...@@ -228,6 +229,18 @@ return [
$container->get(\Monolog\Logger::class) $container->get(\Monolog\Logger::class)
); );
}, },
\App\Model\AmSystem\Groups::class => function (ContainerInterface $container) {
return new \App\Model\AmSystem\Groups(
new Zend\Db\TableGateway\TableGateway(
'am_groups',
$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\Group())
),
$container->get(\Zend\Hydrator\DelegatingHydrator::class),
$container->get(\Monolog\Logger::class)
);
},
\App\Model\AmSystem\Campaigns::class => function (ContainerInterface $container) { \App\Model\AmSystem\Campaigns::class => function (ContainerInterface $container) {
return new \App\Model\AmSystem\Campaigns( return new \App\Model\AmSystem\Campaigns(
new Zend\Db\TableGateway\TableGateway( new Zend\Db\TableGateway\TableGateway(
......
...@@ -97,10 +97,51 @@ table.campaigns tbody tr td.stat { ...@@ -97,10 +97,51 @@ table.campaigns tbody tr td.stat {
text-align: right; text-align: right;
} }
table.campaigns tbody tr.group-item {
font-weight: bold;
background-color: #f9f9f9;
}
table.campaigns tbody tr.campaign-item {
display: none;
}
table.campaigns tbody tr.campaign-item.open {
display: table-row;
}
table.campaigns tbody td.campaign-item-title {
padding-left: 40px;
}
table.campaigns tbody tr td.stat.load-target { table.campaigns tbody tr td.stat.load-target {
font-style: italic; font-style: italic;
} }
.table.campaigns span.group
{
display: inline-block;
min-width: 12px;
color: #697075;
cursor: pointer;
}
.table.campaigns span.group b.open
{
display: none;
}
.table.campaigns span.group.open b.closed
{
display: none;
}
.table.campaigns span.group.open b.open
{
display: inline;
}
.form-group.active span .form-group.active span
{ {
color: #D93025; color: #D93025;
......
$(document).ready(function () {
"use strict";
// Свернуть-развернуть дочерние ячейки в таблице:
$('.table.campaigns').on('click', 'span.group', function(e) {
var
$this = $(this),
$tableBody = $('tbody', $this.parents('table')),
$wrap = $this.parents('tr').eq(0),
id = $wrap.data('id'),
isOpen,
$subcats = $('tr.campaign-item[data-parent="'+ id + '"]', $tableBody);
$this.toggleClass('open');
isOpen = $this.hasClass('open');
if (isOpen) {
$subcats.addClass('open');
} else {
$subcats.removeClass('open');
}
});
// Разворачиваем списки групп кампаний при старте:
$('.table.campaigns span.group').click();
});
...@@ -93,11 +93,20 @@ class CabinetAmSystem extends Common ...@@ -93,11 +93,20 @@ class CabinetAmSystem extends Common
$auth = $this->container->get(UserService::class); $auth = $this->container->get(UserService::class);
$userId = $auth->getIdentity()->getId(); $userId = $auth->getIdentity()->getId();
/** @var \App\Model\AmSystem\Groups $groupsModel */
$groupsModel = $this->container->get(\App\Model\AmSystem\Groups::class);
$groups = $groupsModel->findAll(['user_id' => $userId])->toArray();
if ($groups) {
/** @var \App\Model\AmSystem\Campaigns $campaignsModel */ /** @var \App\Model\AmSystem\Campaigns $campaignsModel */
$campaignsModel = $this->container->get(\App\Model\AmSystem\Campaigns::class); $campaignsModel = $this->container->get(\App\Model\AmSystem\Campaigns::class);
$campaigns = $campaignsModel->findAll(['user_id' => $userId])->toArray();
if ($campaigns) { $groups_campaigns = [];
foreach($groups as $group) {
$campaigns = $campaignsModel->findAll(['group_id' => $group['id']])->toArray();
$groups_campaigns[$group['id']] = $campaigns;
}
/** @var \App\Model\Statistics $stats */ /** @var \App\Model\Statistics $stats */
$stats = $this->container->get(\App\Model\Statistics::class); $stats = $this->container->get(\App\Model\Statistics::class);
...@@ -108,7 +117,9 @@ class CabinetAmSystem extends Common ...@@ -108,7 +117,9 @@ class CabinetAmSystem extends Common
$campaigns_stat[$campaign_id] = $stats->getCampaignsStat([$campaign_id], $campaign_item['target_action'], null, false); $campaigns_stat[$campaign_id] = $stats->getCampaignsStat([$campaign_id], $campaign_item['target_action'], null, false);
} }
$data['groups'] = $groups;
$data['campaigns'] = $campaigns; $data['campaigns'] = $campaigns;
$data['groups_campaigns'] = $groups_campaigns;
$data['stats'] = $campaigns_stat; $data['stats'] = $campaigns_stat;
} else { } else {
...@@ -135,13 +146,19 @@ class CabinetAmSystem extends Common ...@@ -135,13 +146,19 @@ class CabinetAmSystem extends Common
$auth = $this->container->get(UserService::class); $auth = $this->container->get(UserService::class);
$userId = $auth->getIdentity()->getId(); $userId = $auth->getIdentity()->getId();
/** @var \App\Model\AmSystem\Groups $groupsModel */
$groupsModel = $this->container->get(\App\Model\AmSystem\Groups::class);
/** @var \App\Model\AmSystem\Campaigns $campaignsModel */ /** @var \App\Model\AmSystem\Campaigns $campaignsModel */
$campaignsModel = $this->container->get(\App\Model\AmSystem\Campaigns::class); $campaignsModel = $this->container->get(\App\Model\AmSystem\Campaigns::class);
$campaign_item = $campaignsModel->findById($campaign_id); $campaign_item = $campaignsModel->findById($campaign_id);
if ($campaign_item) { if ($campaign_item) {
if ($campaign_item->getUserId() == $userId){ $group_id = $campaign_item->getGroupId();
$group = $groupsModel->findOne(['id' => $group_id]);
if ($group->getUserId() == $userId){
$countries = $this->container->get('config')['amsystem_conf']['country']; $countries = $this->container->get('config')['amsystem_conf']['country'];
$regions = $this->container->get('config')['amsystem_conf']['region']; $regions = $this->container->get('config')['amsystem_conf']['region'];
......
...@@ -34,6 +34,27 @@ use App\Entity\Common; ...@@ -34,6 +34,27 @@ use App\Entity\Common;
*/ */
class Campaign extends Common class Campaign extends Common
{ {
/* user_id */
public function getUserId()
{
return $this->userId;
}
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/* group_id */
public function getGroupId()
{
return $this->groupId;
}
public function setGroupId($groupId)
{
$this->groupId = $groupId;
return $this;
}
/* title */ /* title */
public function getTitle() public function getTitle()
...@@ -57,17 +78,6 @@ class Campaign extends Common ...@@ -57,17 +78,6 @@ class Campaign extends Common
return $this; return $this;
} }
/* user_id */
public function getUserId()
{
return $this->userId;
}
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/* url */ /* url */
public function getUrl() public function getUrl()
{ {
......
<?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 Group
* @package App\Entity
*/
class Group extends Common
{
/* active */
public function getActive()
{
return $this->active;
}
public function setActive($active)
{
$this->active = $active;
return $this;
}
/* title */
public function getTitle()
{
return $this->title;
}
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/* user_id */
public function getUserId()
{
return $this->userId;
}
public function setUserId($userId)
{
$this->userId = $userId;
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;
}
/* visitor_limit */
public function getVisitorLimit()
{
return $this->visitorLimit;
}
public function setVisitorLimit($visitorLimit)
{
$this->visitorLimit = $visitorLimit;
return $this;
}
/* money_limit */
public function getMoneyLimit()
{
return $this->moneyLimit;
}
public function setMoneyLimit($moneyLimit)
{
$this->moneyLimit = $moneyLimit;
return $this;
}
/* max_speed */
public function getMaxSpeed()
{
return $this->maxSpeed;
}
public function setMaxSpeed($maxSpeed)
{
$this->maxSpeed = $maxSpeed;
return $this;
}
/* targeting */
public function getTargeting()
{
return $this->targeting;
}
public function setTargeting($targeting)
{
$this->targeting = $targeting;
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 Groups
* @package App\Model
*/
class Groups extends Common
{
}
\ No newline at end of file
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
/** @var $this \Zend\View\Renderer\PhpRenderer */ /** @var $this \Zend\View\Renderer\PhpRenderer */
$this->headScript() $this->headScript()
//->appendFile('/js/adm/amsystem.js') ->appendFile('/js/adm/amsystem.js')
; ;
$this->headLink() $this->headLink()
...@@ -36,7 +36,9 @@ $this->headLink() ...@@ -36,7 +36,9 @@ $this->headLink()
; ;
$lang = $this->lang; $lang = $this->lang;
$groups = $this->groups;
$campaigns = $this->campaigns; $campaigns = $this->campaigns;
$groups_campaigns = $this->groups_campaigns;
$error = $this->error; $error = $this->error;
?> ?>
...@@ -59,11 +61,9 @@ $error = $this->error; ...@@ -59,11 +61,9 @@ $error = $this->error;
<div class="panel-body all"> <div class="panel-body all">
<table class="table table-striped campaigns" data-content="campaigns" data-action="/amsystem/campaigns/id/edit/"> <table class="table campaigns" data-content="campaigns" data-action="/amsystem/campaigns/id/edit/">
<thead> <thead>
<tr> <tr>
<th width="1px"></th>
<th width="1px">#ID</th>
<th>Название кампании</th> <th>Название кампании</th>
<th width="1px">Показы</th> <th width="1px">Показы</th>
<th width="1px">Клики</th> <th width="1px">Клики</th>
...@@ -76,26 +76,51 @@ $error = $this->error; ...@@ -76,26 +76,51 @@ $error = $this->error;
</thead> </thead>
<tbody> <tbody>
<?php foreach ($campaigns as $campaign) : ?> <?php foreach ($groups as $group) : ?>
<tr <?php if (!$campaign['active']): ?>class="disabled"<?php endif; ?>> <?php
$group_id = $group['id'];
$stat = null;
$target_class = ($group['target_action'] == 'load') ? 'load-target' : '';
?>
<tr class="group-item <?php if (!$group['active']): ?>disabled<?php endif; ?>" data-id="<?= $group_id ?>">
<td>
<?php
/*
$btn_link = $this->url('user.cabinet.campaign', [
'lang' => $this->lang,
'id' => $campaign_id,
]);*/
?>
<span class="group"><b class="closed">+</b><b class="open">&ndash;</b></span>
<input class="is-active" type="checkbox" data-id="<?= $group_id ?>" <?php if ($group['active']): ?>checked<?php endif; ?> disabled>
<span class="item-title"><?= $group['title'] ?></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 if ($groups_campaigns[$group_id]): ?>
<?php foreach ($groups_campaigns[$group_id] as $campaign) : ?>
<tr class="campaign-item <?php if (!$campaign['active']): ?>disabled<?php endif; ?>" data-parent="<?= $group_id ?>">
<?php <?php
$campaign_id = $campaign['id']; $campaign_id = $campaign['id'];
$stat = $stats[$campaign_id]; $stat = $stats[$campaign_id];
$target_class = ($campaign['target_action'] == 'load') ? 'load-target' : ''; $target_class = ($campaign['target_action'] == 'load') ? 'load-target' : '';
?> ?>
<td> <td class="campaign-item-title">
<input class="is-active" type="checkbox" data-id="<?= $campaign_id ?>" <?php if ($campaign['active']): ?>checked<?php endif; ?> disabled>
</td>
<td>
<span class="item-id"><?= $campaign_id ?></span>
</td>
<td>
<?php <?php
$btn_link = $this->url('user.cabinet.campaign', [ $btn_link = $this->url('user.cabinet.campaign', [
'lang' => $this->lang, 'lang' => $this->lang,
'id' => $campaign_id, 'id' => $campaign_id,
]); ]);
?> ?>
<input class="is-active" type="checkbox" data-id="<?= $campaign_id ?>" <?php if ($campaign['active']): ?>checked<?php endif; ?> disabled>
<span class="item-title"><a href="<?= $btn_link?>"><?= $campaign['title'] ?></a></span> <span class="item-title"><a href="<?= $btn_link?>"><?= $campaign['title'] ?></a></span>
</td> </td>
<td class="stat <?= $target_class ?>"><?= $stat['views'] ?></td> <td class="stat <?= $target_class ?>"><?= $stat['views'] ?></td>
...@@ -108,6 +133,9 @@ $error = $this->error; ...@@ -108,6 +133,9 @@ $error = $this->error;
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?>
<?php endforeach; ?>
</tbody> </tbody>
</table> </table>
......
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