Стр. категорий магазина, роутинг, модели, переключатель

parent 15918c4c
......@@ -33,6 +33,7 @@ return [
->allow(Roles::ROLE_USER, 'user.mail.request.activate.protection')
->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.cats', 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.viewid', null, new \App\Acl\Assertion\UserActive())
->allow(Roles::ROLE_USER, 'install.counter', null, new \App\Acl\Assertion\UserActive())
......
......@@ -53,8 +53,11 @@ return [
//TODO: Delete this?
$hpm->setService(\App\Entity\Feeds\Shop::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\Feed::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\ShopFeed::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\Category::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\CategoryFee::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\StatsDay::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\Transaction::class, new \Zend\Hydrator\ClassMethods());
......@@ -148,6 +151,30 @@ return [
$container->get(\Monolog\Logger::class)
);
},
\App\Model\Feeds\Shops::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\Shops(
new Zend\Db\TableGateway\TableGateway(
'shops',
$container->get(Zend\Db\Adapter\AdapterRetarg::class),
new \Zend\Db\TableGateway\Feature\MetadataFeature(),
new \Zend\Db\ResultSet\HydratingResultSet($container->get(\Zend\Hydrator\DelegatingHydrator::class), new \App\Entity\Feeds\Shop())
),
$container->get(\Zend\Hydrator\DelegatingHydrator::class),
$container->get(\Monolog\Logger::class)
);
},
\App\Model\Feeds\ShopFeeds::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\ShopFeeds(
new Zend\Db\TableGateway\TableGateway(
'shop_feeds',
$container->get(Zend\Db\Adapter\AdapterRetarg::class),
new \Zend\Db\TableGateway\Feature\MetadataFeature(),
new \Zend\Db\ResultSet\HydratingResultSet($container->get(\Zend\Hydrator\DelegatingHydrator::class), new \App\Entity\Feeds\ShopFeed())
),
$container->get(\Zend\Hydrator\DelegatingHydrator::class),
$container->get(\Monolog\Logger::class)
);
},
\App\Model\Feeds\Feeds::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\Feeds(
new Zend\Db\TableGateway\TableGateway(
......@@ -160,6 +187,30 @@ return [
$container->get(\Monolog\Logger::class)
);
},
\App\Model\Feeds\Categories::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\Categories(
new Zend\Db\TableGateway\TableGateway(
'categories',
$container->get(Zend\Db\Adapter\AdapterRetarg::class),
new \Zend\Db\TableGateway\Feature\MetadataFeature(),
new \Zend\Db\ResultSet\HydratingResultSet($container->get(\Zend\Hydrator\DelegatingHydrator::class), new \App\Entity\Feeds\Category())
),
$container->get(\Zend\Hydrator\DelegatingHydrator::class),
$container->get(\Monolog\Logger::class)
);
},
\App\Model\Feeds\CategoryFees::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\CategoryFees(
new Zend\Db\TableGateway\TableGateway(
'category_fees',
$container->get(Zend\Db\Adapter\AdapterRetarg::class),
new \Zend\Db\TableGateway\Feature\MetadataFeature(),
new \Zend\Db\ResultSet\HydratingResultSet($container->get(\Zend\Hydrator\DelegatingHydrator::class), new \App\Entity\Feeds\CategoryFee())
),
$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(
......
......@@ -313,6 +313,21 @@ return [
]
],
],
[
'name' => 'user.cabinet.cats',
'path' => '/[:lang/]cabinet/cats',
'middleware' => App\Action\User\Cabinet::class,
'allowed_methods' => ['GET', 'POST'],
'options' => [
'constraints' => [
'lang' => '[a-z]{2,3}',
],
'defaults' => [
'lang' => \App\Model\Locales::DEFAULT_LANG,
'action' => App\Action\User\Cabinet::ACTION_CATS,
]
],
],
[
'name' => 'user.cabinet.viewid',
'path' => '/[:lang/]cabinet/viewid/:feedid/:id',
......
......@@ -123,10 +123,10 @@ input[type="checkbox"]
float: left;
}
.b-feeds-stat_controls-period
{
float: right;
margin-top: 2px;
}
.b-feeds-stat_controls input.date-value
......@@ -406,8 +406,8 @@ input[type="checkbox"]
.b-filter__switch {
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
display: -webkit-inline-flex;
display: inline-flex;
}
.display.b-filter__switch {
......@@ -443,4 +443,14 @@ input[type="checkbox"]
}
.m-filter__switch-item_active.b-filter__switch-item {
background-color: #E6E6E6;
}
\ No newline at end of file
}
.b-filter__switch-item a
{
color: #383838;
}
.b-filter__switch-item a:hover
{
text-decoration: none;
}
\ No newline at end of file
......@@ -46,6 +46,7 @@ use Zend\Diactoros\Response\RedirectResponse;
class Cabinet extends Common
{
const ACTION_STAT = 'stat';
const ACTION_CATS = 'cats';
/**
* @param ServerRequestInterface $request
......@@ -77,8 +78,11 @@ class Cabinet extends Common
}
return $response;
} else {
//} else {
}
elseif($request->getAttribute('action') == self::ACTION_STAT)
{
try {
/** @var UserService $auth */
......@@ -156,6 +160,137 @@ class Cabinet extends Common
return new HtmlResponse($this->template->render('app::user/cabinet-feed', $data));
}
elseif($request->getAttribute('action') == self::ACTION_CATS)
{
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_id = $shop->getId();
// Определяем список фидов магазина:
/** @var \App\Model\Feeds\Feeds $shopFeedsModel */
$shopFeedsModel = $this->container->get(\App\Model\Feeds\ShopFeeds::class);
$shopFeeds = $shopFeedsModel->findAll(['shop_id' => $shop_id]) -> toArray();
if (count($shopFeeds) > 0) {
/** @var \App\Model\ShopFeeds $shopFeedsModel */
$feedsModel = $this->container->get(\App\Model\Feeds\Feeds::class);
/** @var \App\Model\Feeds\Categories $categoriesModel */
$categoriesModel = $this->container->get(\App\Model\Feeds\Categories::class);
/** @var \App\Model\Feeds\CategoryFees $categoryFeesModel */
$categoryFeesModel = $this->container->get(\App\Model\Feeds\CategoryFees::class);
// Формируем древовидную структуру категорий:
function get_sub_cats($id, $cats, $parent_cat_percent, $fees) {
$sub_cats=[];
foreach ($cats as $cat) {
if ($cat['parentid'] == $id) {
$cat_percent = $cat['orderpercent'];
$is_own = 1;
if ($cat_percent < 0) {
if ($fees[$cat['id']]) {
$cat_percent = $fees[$cat['id']];
} else {
$cat_percent = $parent_cat_percent;
$is_own = 0;
}
}
$cat['own'] = $is_own;
$cat['percent'] = $cat_percent/10;
$cat['sub_cats'] = get_sub_cats($cat['id'], $cats, $cat_percent, $fees);
$sub_cats[] = $cat;
}
}
return $sub_cats;
}
// Определяем список категорий у фидов магазина:
$feeds_cats = [];
foreach ($shopFeeds as $shopFeed) {
$feed_id = $shopFeed['feed_id'];
$feed = $feedsModel->findOne(['id' => $feed_id]);
$feed_title = $feed->getTitle();
$feed_percent = $feed->getOrderpercent();
// fees категорий фида:
$feed_category_fees = $categoryFeesModel->findAll(['FeedID' => $feed_id]) -> toArray();
$fees = [];
foreach ($feed_category_fees as $feed_category_fee) {
$fees[$feed_category_fee['catid']] = $feed_category_fee['orderpercent'];
}
// Определяем список категорий фида:
$cats_list = $categoriesModel->findAll(['FeedID' => $feed_id], 'Title ASC') -> toArray();
$feed_cats = [];
foreach ($cats_list as $cat) {
if ($cat['parentid'] == 0) {
$cat_percent = $cat['orderpercent'];
$is_own = 1;
if ($cat_percent < 0) {
if ($fees[$cat['id']]) {
$cat_percent = $fees[$cat['id']];
} else {
$cat_percent = $feed_percent;
$is_own = 0;
}
}
$cat['own'] = $is_own;
$cat['percent'] = $cat_percent/10;
$cat['sub_cats'] = get_sub_cats($cat['id'], $cats_list, $cat_percent, $fees);
$feed_cats[] = $cat;
}
}
$feeds_cats[] = array(
'id' => $feed_id,
'title' => $feed_title,
'percent' => $feed_percent/10,
'cats' => $feed_cats,
);
}
$data['lang'] = $request->getAttribute('layoutInfo')->getLang();
$data['feeds_cats'] = $feeds_cats;
} else {
$data['error'] = _t('Извините, у магазинов пользователя нет фидов ');
}
} else {
$data['error'] = _t('Извините, у пользователя нет магазина');
}
} 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/cabinet-cats', $data));
}
}
private function getStatData(ServerRequestInterface $request)
......
<?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\Feeds;
use App\Entity\Common;
/**
* Class Category
* @package App\Entity
*/
class Category extends Common
{
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
* @return Category
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return mixed
*/
public function getParentid(): int
{
return $this->parentid;
}
/**
* @param mixed $parent_id
* @return Category
*/
public function setParentid($parent_id)
{
$this->parentid = $parent_id;
return $this;
}
/**
* @return mixed
*/
public function getForeignid(): int
{
return $this->foreignid;
}
/**
* @param mixed $foreign_id
* @return Category
*/
public function setForeignid($foreign_id)
{
$this->foreignid = $foreign_id;
return $this;
}
/**
* @return mixed
*/
public function getOrderpercent(): int
{
return $this->orderpercent;
}
/**
* @param mixed $order_percent
* @return Category
*/
public function setOrderpercent($order_percent)
{
$this->orderpercent = $order_percent;
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\Feeds;
use App\Entity\Common;
/**
* Class CategoryFee
* @package App\Entity
*/
class CategoryFee extends Common
{
/**
* @return mixed
*/
public function getFeedid(): int
{
return $this->feedid;
}
/**
* @param mixed $feed_id
* @return CategoryFee
*/
public function setFeedid($feed_id)
{
$this->feedid = $feed_id;
return $this;
}
/**
* @return mixed
*/
public function getCatid(): int
{
return $this->catid;
}
/**
* @param mixed $cat_id
* @return CategoryFee
*/
public function setCatid($cat_id)
{
$this->catid = $cat_id;
return $this;
}
/**
* @return mixed
*/
public function getForeigncatid(): int
{
return $this->foreigncatid;
}
/**
* @param mixed $foreign_cat_id
* @return CategoryFee
*/
public function setForeigncatid($foreign_cat_id)
{
$this->foreigncatid = $foreign_cat_id;
return $this;
}
/**
* @return mixed
*/
public function getOrderpercent(): int
{
return $this->orderpercent;
}
/**
* @param mixed $order_percent
* @return CategoryFee
*/
public function setOrderpercent($order_percent)
{
$this->orderpercent = $order_percent;
return $this;
}
}
\ No newline at end of file
......@@ -203,6 +203,25 @@ class Feed extends Common
}
/**
* @return mixed
*/
public function getOrderpercent(): int
{
return $this->orderpercent;
}
/**
* @param mixed $order_percent
* @return Feed
*/
public function setOrderpercent($order_percent)
{
$this->orderpercent = $order_percent;
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\Feeds;
use App\Entity\Common;
/**
* Class Shop
* @package App\Entity
*/
class Shop extends Common
{
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
* @return Shop
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return int
*/
public function getUsersId()
{
return $this->usersId;
}
/**
* @param int $usersId
* @return Shop
*/
public function setUsersId($usersId)
{
$this->usersId = $usersId;
return $this;
}
/**
* @return int
*/
public function getEditEnable()
{
return $this->editEnable;
}
/**
* @param int $edit_enable
* @return Shop
*/
public function setEditEnable($edit_enable)
{
$this->editEnable = $edit_enable;
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\Feeds;
use App\Entity\Common;
/**
* Class ShopFeed
* @package App\Entity
*/
class ShopFeed extends Common
{
/**
* @return mixed
*/
public function getShopId()
{
return $this->shopId;
}
/**
* @param mixed $shop_id
* @return ShopFeed
*/
public function setShopId($shop_id)
{
$this->shopId = $shop_id;
return $this;
}
/**
* @return int
*/
public function getFeedId()
{
return $this->feedId;
}
/**
* @param int $feed_id
* @return ShopFeed
*/
public function setFeedId($feed_id)
{
$this->feedId = $feed_id;
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\Feeds;
use App\Model\Common;
/**
* Class Categories
* @package App\Model
*/
class Categories 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\Feeds;
use App\Model\Common;
/**
* Class CategoryFees
* @package App\Model
*/
class CategoryFees extends Common
{
public function saveRetargCatFee($entity, $action)
{
$data_entity = $this->delegatingHydrator->extract($entity);
$table_fields = $this->tableGateway->getColumns();
$data = [];
foreach ($table_fields as $field) {
if (isset($data_entity[mb_strtolower($field)])) {
$data[$field] = $data_entity[mb_strtolower($field)];
}
}
if ($action == 'insert') {
$query = function($data) {
$this->tableGateway->insert($data);
return $data['CatID'];
};
}
if ($action == 'update') {
$query = function($data) {
$id = $data['CatID'];
unset($data['CatID']);
$this->tableGateway->update($data, ['CatID' => $id]);
return $id;
};
}
try {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->beginTransaction();
$id = $query($data);
$this->tableGateway->getAdapter()->getDriver()->getConnection()->commit();
} catch (\Exception $e) {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->rollback();
throw $e;
}
return $id;
}
public function deleteRetargCatFee($entity)
{
$result = false;
$cat_id = $entity->getCatid();
if ($entity) {
$result = $this->tableGateway->delete(['CatID' => $cat_id]);
} else {
throw new \Exception("Record not found ID:" . $cat_id);
}
return $result;
}
}
\ No newline at end of file
......@@ -34,30 +34,6 @@ use App\Model\Common;
*/
class Feeds extends Common
{
public function createListItem($entity)
{
$data = $this->delegatingHydrator->extract($entity);
// accept data columns only available at table
$data = array_intersect_key($data, array_fill_keys($this->tableGateway->getColumns(), 1));
$query = function($data) {
$this->tableGateway->insert($data);
$insertId = $this->tableGateway->lastInsertValue;
return $insertId;
};
try {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->beginTransaction();
$id = $query($data);
$this->tableGateway->getAdapter()->getDriver()->getConnection()->commit();
} catch (\Exception $e) {
$this->tableGateway->getAdapter()->getDriver()->getConnection()->rollback();
throw $e;
}
return $id;
}
public function getIdListByUser($userId)
{
......
<?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\Feeds;
use App\Model\Common;
/**
* Class ShopFeeds
* @package App\Model
*/
class ShopFeeds 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\Feeds;
use App\Model\Common;
/**
* Class Shops
* @package App\Model
*/
class Shops 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.
*
*
*/
/** @var $this \Zend\View\Renderer\PhpRenderer */
$this->headScript()
->appendFile('/js/jquery.cookie.js')
->appendFile('/js/bootstrap.min.js')
;
$this->headLink()
->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) {
/*
$current_report = $this->current_report;
$report_conf = $this->report_conf;
$reports_list = $this->reports_list;
$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: ?>
<section class="b-content__work">
<div class="wrapp" style="position: relative;">
<div class="b-feeds-stat_controls form-group">
<?php /* Переключатель страниц */ ?>
<div class="b-filter__switch display">
<span class="b-filter__switch-item text"><a href="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => 'common']) ?>"><?= _t('Сводный отчет') ?></a></span>
<span class="b-filter__switch-item text"><a href="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => 'transaction']) ?>"><?= _t('Транзакции') ?></a></span>
<span class="b-filter__switch-item text m-filter__switch-item_active"><a href="<?= $this->url('user.cabinet.cats', ['lang' => $this->lang]) ?>"><?= _t('Категории') ?></a></span>
</div>
</div>
</div>
</section>
<?php endif ?>
\ No newline at end of file
......@@ -120,7 +120,8 @@ if (!$error) {
<?php */ ?>
<div class="b-feeds-stat_controls form-group">
<?php /* Переключатель отчетов */ ?>
<?php /* Переключатель страниц */ ?>
<?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">
......@@ -134,14 +135,13 @@ if (!$error) {
</ul>
</div>
</div>
<?php */ ?>
<div class="b-filter__switch display">
<?php foreach($reports_list as $report_name => $report_title): ?>
<?php /* ?>
<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>
<?php */ ?>
<span class="b-filter__switch-item text <?php if($current_report == $report_name): ?>m-filter__switch-item_active<?php endif; ?>"><?= _t($report_title) ?></span>
<span class="b-filter__switch-item text <?php if($current_report == $report_name): ?>m-filter__switch-item_active<?php endif; ?>"><a href="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => $report_name]) ?>"><?= _t($report_title) ?></a></span>
<?php endforeach; ?>
<span class="b-filter__switch-item text"><a href="<?= $this->url('user.cabinet.cats', ['lang' => $this->lang]) ?>"><?= _t('Категории') ?></a></span>
</div>
<?php /* Выбор дат */ ?>
......
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