Добавил модель для статусов заказов, стартовый рендер по признаку статуса

parent 4109bae4
......@@ -60,6 +60,7 @@ return [
$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());
$hpm->setService(\App\Entity\Feeds\OrderStatus::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Contacts::class, new \Zend\Hydrator\ClassMethods());
......@@ -211,6 +212,18 @@ return [
$container->get(\Monolog\Logger::class)
);
},
\App\Model\Feeds\OrdersStatus::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\OrdersStatus(
new Zend\Db\TableGateway\TableGateway(
'orders_status',
$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\OrderStatus())
),
$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(
......
......@@ -233,6 +233,12 @@ input[type="checkbox"]
width: 550px;
}
.table.table-striped.admin.transactions tbody tr td span.order-id
{
white-space: nowrap;
}
/* .b-basket-content */
.table.table-striped.admin.transactions thead tr th.period
{
......
......@@ -35,7 +35,10 @@ $(document).ready(function(){
// Шаблон ячейки OrderID
var templateOrderIDContent = _.template('\n'+
' <span class="order-id"> \n' +
' <input type="checkbox" name="order-id" id="<%=data.orderId %>" data-feed-id="<%=data.feedId %>" <%=data.confirmed %> <%=data.approved %>> \n' +
' <a class="orderid-link" href="orderid/<%=data.feedId %>/<%=data.orderId %>" target="_blank"><%=data.orderId %></a> \n' +
' </span> \n' +
'');
// Шаблон ячейки ViewID
......@@ -89,13 +92,6 @@ $(document).ready(function(){
sortField = false,
isDesc = true;
/*
dataTable = {};
for (var key in dataLineChartStat) {
dataTable[key] = dataLineChartStat[key];
}
*/
// Определение поля для сортировки строк в таблице:
if ($selectedField.length > 0) {
sortField = $selectedField.attr('id');
......@@ -119,6 +115,11 @@ $(document).ready(function(){
}
//console.log('AAA sortField = ', sortField, ' isDesc = ', isDesc);
if (dataLineChartStat.report == 'transactions') {
console.log('AAA dataLineChartStat = ', dataLineChartStat.ordersStatus);
}
// Подготовка данных для сортировки:
dataPeriod.forEach(function(dataTableItem, ind){
var dataTableSortItem = {};
......@@ -147,8 +148,19 @@ $(document).ready(function(){
$row = $('<tr>');
if (dataLineChartStat.report == 'transactions') {
var
feedId = item['ViewID'][0],
orderId = item['period'],
orderStatus = dataLineChartStat.ordersStatus[feedId][orderId];
$row.append($('<td>').append(templateOrderIDContent({
data: {feedId: item['ViewID'][0], orderId: item['period']}
data: {
feedId: item['ViewID'][0],
orderId: item['period'],
confirmed: (orderStatus && !orderStatus.confirmed) ? '' : 'checked',
approved: (orderStatus && orderStatus.approved) ? 'disabled' : '',
}
})));
} else {
$row.append($('<td>').html(item['period']));
......
......@@ -32,6 +32,7 @@ use App\Model\Users;
use App\Model\Statistics;
use App\Model\Providers;
use App\Model\Feeds\Feeds;
use App\Model\Feeds\OrdersStatus;
use App\Entity\Feeds\CategoryFee;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
......@@ -138,6 +139,21 @@ class Cabinet extends Common
break;
}
// Добавляем данные о статусах заказов:
if ($report_type == 'transactions') {
/** @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['feeds'] = $feeds;
$data['current_report'] = $report_type;
$data['current_period'] = $current_period;
......
<?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 OrderStatus
* @package App\Entity
*/
class OrderStatus extends Common
{
/**
* @return int
*/
public function getFeedId(): int
{
return $this->feedId;
}
/**
* @param int $feed_id
* @return OrderStatus
*/
public function setFeedId($feed_id)
{
$this->feedId = $feed_id;
return $this;
}
/**
* @return int
*/
public function getOrderId(): int
{
return $this->orderId;
}
/**
* @param int $order_id
* @return OrderStatus
*/
public function setOrderId($order_id)
{
$this->orderId = $order_id;
return $this;
}
/**
* @return int
*/
public function getConfirmed(): bool
{
return $this->confirmed;
}
/**
* @param int $confirmed
* @return OrderStatus
*/
public function setConfirmed($confirmed)
{
$this->confirmed = $confirmed;
return $this;
}
/**
* @return int
*/
public function getApproved(): bool
{
return $this->approved;
}
/**
* @param int $approved
* @return OrderStatus
*/
public function setApproved($approved)
{
$this->approved = $approved;
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 OrdersStatus
* @package App\Model
*/
class OrdersStatus extends Common
{
}
\ 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