Подключил таблицу transactions, завел стр.статистики для неё

parent 0f95a915
...@@ -69,6 +69,7 @@ return [ ...@@ -69,6 +69,7 @@ return [
$hpm->setService(\App\Entity\Feeds\Feed::class, new \Zend\Hydrator\ClassMethods()); $hpm->setService(\App\Entity\Feeds\Feed::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Feeds\StatsDay::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\Contacts::class, new \Zend\Hydrator\ClassMethods()); $hpm->setService(\App\Entity\Contacts::class, new \Zend\Hydrator\ClassMethods());
...@@ -283,6 +284,18 @@ return [ ...@@ -283,6 +284,18 @@ return [
$container->get(\Monolog\Logger::class) $container->get(\Monolog\Logger::class)
); );
}, },
\App\Model\Feeds\Transactions::class => function (ContainerInterface $container) {
return new \App\Model\Feeds\Transactions(
new Zend\Db\TableGateway\TableGateway(
'transactions',
$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\Transaction())
),
$container->get(\Zend\Hydrator\DelegatingHydrator::class),
$container->get(\Monolog\Logger::class)
);
},
\App\Model\FAQ\Categories::class => function (ContainerInterface $container) { \App\Model\FAQ\Categories::class => function (ContainerInterface $container) {
return new \App\Model\FAQ\Categories( return new \App\Model\FAQ\Categories(
......
...@@ -319,15 +319,17 @@ return [ ...@@ -319,15 +319,17 @@ return [
[ [
'name' => 'user.cabinet', 'name' => 'user.cabinet',
'path' => '/[:lang/]cabinet/', 'path' => '/[:lang/]cabinet/[:report]',
'middleware' => App\Action\User\Cabinet::class, 'middleware' => App\Action\User\Cabinet::class,
'allowed_methods' => ['GET'], 'allowed_methods' => ['GET'],
'options' => [ 'options' => [
'constraints' => [ 'constraints' => [
'lang' => '[a-z]{2,3}', 'lang' => '[a-z]{2,3}',
'report' => '\w+',
], ],
'defaults' => [ 'defaults' => [
'lang' => \App\Model\Locales::DEFAULT_LANG, 'lang' => \App\Model\Locales::DEFAULT_LANG,
'report' => 'common',
] ]
], ],
], ],
......
...@@ -114,10 +114,15 @@ $(document).ready(function(){ ...@@ -114,10 +114,15 @@ $(document).ready(function(){
Render: function(dataLineChartStat) { Render: function(dataLineChartStat) {
// Формируем список переключателей (категорий) activeLines: // Формируем список переключателей (категорий) activeLines:
activeLines = ['shows', 'clicks', 'transactions', 'salemoney', 'admoney']; if (dataLineChartStat.report == 'common') {
activeLines = ['shows', 'clicks', 'transactions', 'salemoney', 'admoney'];
}
if (dataLineChartStat.report == 'transaction') {
activeLines = ['usdollarmoney', 'localmoney'];
}
//console.log('AAA TableStat render: ', dataLineChartStat); //console.log('AAA TableStat render: ', dataLineChartStat);
console.log('AAA activeLines: ', activeLines); //console.log('AAA activeLines: ', activeLines);
dataTable = {}; dataTable = {};
activeLines.forEach(function(item){ activeLines.forEach(function(item){
......
...@@ -39,6 +39,7 @@ $(document).ready(function(){ ...@@ -39,6 +39,7 @@ $(document).ready(function(){
if ($('#period-stats').val()) { if ($('#period-stats').val()) {
dataLineChartStat = JSON.parse($('#period-stats').val()); dataLineChartStat = JSON.parse($('#period-stats').val());
} }
//console.log('AAA dataLineChartStat = ', dataLineChartStat);
// Отрисовка графика и таблицы по стартовым данным: // Отрисовка графика и таблицы по стартовым данным:
renderLineChart(); renderLineChart();
...@@ -54,8 +55,6 @@ $(document).ready(function(){ ...@@ -54,8 +55,6 @@ $(document).ready(function(){
// Клик на checkbox в названии поля таблицы: // Клик на checkbox в названии поля таблицы:
$('#table-line').on('change', 'thead.metric.sortable th input[type="checkbox"]', function(){ $('#table-line').on('change', 'thead.metric.sortable th input[type="checkbox"]', function(){
//var $this = $(this);
//console.log('AAA check ', $this.data('field'), ' ', $this.prop('checked'));
renderLineChart(); renderLineChart();
}); });
...@@ -63,12 +62,14 @@ $(document).ready(function(){ ...@@ -63,12 +62,14 @@ $(document).ready(function(){
// Отрисовка графика Stat // Отрисовка графика Stat
function renderLineChart() function renderLineChart()
{ {
if(dataLineChartStat) { if(dataLineChartStat && $chartStat.length>0) {
$.ChartStat.DateStat(dataLineChartStat); $.ChartStat.DateStat(dataLineChartStat);
return false; return false;
} }
} }
$chartTable.show();
// Отрисовка почасовой таблицы // Отрисовка почасовой таблицы
function renderHourTable() function renderHourTable()
{ {
......
...@@ -33,6 +33,7 @@ use App\Model\Statistics; ...@@ -33,6 +33,7 @@ use App\Model\Statistics;
use App\Model\Providers; use App\Model\Providers;
use App\Model\Feeds\Feeds; use App\Model\Feeds\Feeds;
use App\Model\Feeds\StatsDays; use App\Model\Feeds\StatsDays;
use App\Model\Feeds\Transactions;
use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\HtmlResponse; use Zend\Diactoros\Response\HtmlResponse;
...@@ -85,34 +86,71 @@ class Cabinet extends Common ...@@ -85,34 +86,71 @@ class Cabinet extends Common
} }
} }
/** @var \App\Model\Feeds $statDaysModel */ $report_type = $request->getAttribute('report');
$statsDaysModel = $this->container->get(StatsDays::class); $dates = ['2018-10-09', '2018-11-09'];
$stats = $statsDaysModel->findAll(['FeedID' => $feed_id_list])->toArray();
if ($report_type == 'common') {
$periodStats = array( /** @var \App\Model\Feeds $statDaysModel */
'period' => [], $statsDaysModel = $this->container->get(StatsDays::class);
'shows' => $stat_item['shows'], $stats = $statsDaysModel->findAll(['FeedID' => $feed_id_list])->toArray();
'clicks' => $stat_item['clicks'],
'transactions' => $stat_item['transactions'], $periodStats = array(
'salemoney' => $stat_item['salemoney'], 'period' => [],
'admoney' => $stat_item['admoney'], 'shows' => [],
'type' => 'interval' 'clicks' => [],
); 'transactions' => [],
foreach($stats as $stat_item) { 'salemoney' => [],
$periodStats['period'][] = $stat_item['eventdate']; 'admoney' => [],
$periodStats['shows'][] = $stat_item['shows']; 'type' => 'interval',
$periodStats['clicks'][] = $stat_item['clicks']; 'report' => $report_type
$periodStats['transactions'][] = $stat_item['transactions']; );
$periodStats['salemoney'][] = $stat_item['salemoney'];
$periodStats['admoney'][] = $stat_item['admoney']; foreach($stats as $stat_item) {
$periodStats['period'][] = $stat_item['eventdate'];
$periodStats['shows'][] = $stat_item['shows'];
$periodStats['clicks'][] = $stat_item['clicks'];
$periodStats['transactions'][] = $stat_item['transactions'];
$periodStats['salemoney'][] = $stat_item['salemoney'];
$periodStats['admoney'][] = $stat_item['admoney'];
}
$cats = ['shows','clicks','transactions','salemoney','admoney'];
} }
$dates = ['2018-10-09', '2018-11-09']; else if ($report_type == 'transaction') {
/** @var \App\Model\Feeds $transactionsModel */
$transactionsModel = $this->container->get(Transactions::class);
$stats = $transactionsModel->findAll(['FeedID' => $feed_id_list])->toArray();
$periodStats = array(
'period' => [],
'localmoney' => [],
'usdollarmoney' => [],
'type' => 'interval',
'report' => $report_type
);
foreach($stats as $stat_item) {
$periodStats['period'][] = $stat_item['eventdate'];
$periodStats['localmoney'][] = $stat_item['localmoney'];
$periodStats['usdollarmoney'][] = $stat_item['usdollarmoney'];
}
$cats = ['localmoney','usdollarmoney'];
} else {
$data['error'] = _t('Извините, тип отчета "'. $report_type .'" недоступен');
}
$data['feeds'] = $feeds; $data['feeds'] = $feeds;
$data['periodStats'] = $periodStats; $data['report'] = $report_type;
//$data['periodStats'] = $stats;
$data['dates'] = $dates; $data['dates'] = $dates;
$data['periodStats'] = $periodStats;
$data['cats'] = $cats;
//return new HtmlResponse('123132data: '.var_dump($stats));
/* /*
$response = new HtmlResponse($this->template->render('app::user/feeds', [ $response = new HtmlResponse($this->template->render('app::user/feeds', [
...@@ -178,7 +216,6 @@ class Cabinet extends Common ...@@ -178,7 +216,6 @@ class Cabinet extends Common
'layoutInfo' => $request->getAttribute('layoutInfo'), 'layoutInfo' => $request->getAttribute('layoutInfo'),
]); ]);
//return new HtmlResponse($this->template->render('app::user/cabinet', $data));
return new HtmlResponse($this->template->render('app::user/cabinet-feed', $data)); return new HtmlResponse($this->template->render('app::user/cabinet-feed', $data));
} }
} }
\ 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 StatsDay
* @package App\Entity
*/
class Transaction extends Common
{
// FeedID
public function getFeedid()
{
return $this->feedid;
}
public function setFeedid($feedid)
{
$this->feedid = $feedid;
return $this;
}
// EventDate
public function getEventdate()
{
return $this->eventdate;
}
public function setEventdate($eventdate)
{
$this->eventdate = $eventdate;
return $this;
}
// Transactionid
public function getTransactionid()
{
return $this->transactionid;
}
public function setTransactionid($transactionid)
{
$this->transactionid = $transactionid;
return $this;
}
// Foreignid
public function getForeignid()
{
return $this->foreignid;
}
public function setForeignid($foreignid)
{
$this->foreignid = $foreignid;
return $this;
}
// Currency
public function getCurrency()
{
return $this->currency;
}
public function setCurrency($currency)
{
$this->currency = $currency;
return $this;
}
// Localmoney
public function getLocalmoney(): float
{
return $this->localmoney;
}
public function setLocalmoney($localmoney)
{
$this->localmoney = $localmoney;
return $this;
}
// Usdollarmoney
public function getUsdollarmoney(): float
{
return $this->usdollarmoney;
}
public function setUsdollarmoney($usdollarmoney)
{
$this->usdollarmoney = $usdollarmoney;
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 Transactions
* @package App\Model
*/
class Transactions extends Common
{
}
\ No newline at end of file
...@@ -57,13 +57,19 @@ $src = $sxml['src']; ...@@ -57,13 +57,19 @@ $src = $sxml['src'];
$error = $this->error; $error = $this->error;
$periodStats = $this->periodStats; $periodStats = $this->periodStats;
$dates = $this->dates; $dates = $this->dates;
$cats = $this->cats;
$report = $this->report;
$colors_active_lines = array( $colors_active_lines = array(
'shows' => '#2CA02C', 'shows' => '#2CA02C',
'clicks' => '#D62728', 'clicks' => '#D62728',
'transactions' => '#1F77B4', 'transactions' => '#1F77B4',
'salemoney' => '#FF7F0E', 'salemoney' => '#FF7F0E',
'admoney' => '#9467BD' 'admoney' => '#9467BD',
//'usdollarmoney' => '#2CA02C',
//'localmoney' => '#D62728',
); );
...@@ -86,7 +92,9 @@ $colors_active_lines = array( ...@@ -86,7 +92,9 @@ $colors_active_lines = array(
<?php if($error): ?> <?php if($error): ?>
<section class="b-content__work"> <section class="b-content__work">
<h1><?= $error?></h1> <div class="wrapp" style="margin: 100px auto; text-align: center;">
<h1><?= $error?></h1>
</div>
</section> </section>
<?php else: ?> <?php else: ?>
...@@ -101,14 +109,16 @@ $colors_active_lines = array( ...@@ -101,14 +109,16 @@ $colors_active_lines = array(
<div class="b-feeds-stat_controls-report"> <div class="b-feeds-stat_controls-report">
<div class="dropdown" style="display:inline-block;"> <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"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
<?= _t('Сводный отчет') ?> <?php if($report == 'common'): ?>
<?= _t('Сводный отчет') ?>
<?php else: ?>
<?= _t('Транзакции') ?>
<?php endif; ?>
<span class="caret"></span> <span class="caret"></span>
</button> </button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu"> <ul class="dropdown-menu" aria-labelledby="dropdownMenu">
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Сводный отчет') ?></a></li> <li><a href="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => 'common']) ?>" <?php if($report == 'common'): ?>class="current"<?php endif; ?> report="common"><?= _t('Сводный отчет') ?></a></li>
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Отчет 1') ?></a></li> <li><a href="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => 'transaction']) ?>" <?php if($report == 'transaction'): ?>class="current"<?php endif; ?> report="transaction"><?= _t('Транзакции') ?></a></li>
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Отчет 2') ?></a></li>
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Отчет 3') ?></a></li>
</ul> </ul>
</div> </div>
</div> </div>
...@@ -140,33 +150,36 @@ $colors_active_lines = array( ...@@ -140,33 +150,36 @@ $colors_active_lines = array(
<h2>Ошибка в статистике</h2> <h2>Ошибка в статистике</h2>
<div class="message"></div> <div class="message"></div>
</div> </div>
<?php /* График */ ?> <?php /* График */ ?>
<?php if ($report == 'common'): ?>
<div id="chart-graph-stat" style="height: 370px;"></div> <div id="chart-graph-stat" style="height: 370px;"></div>
<div class="chart-graph-stat-loading"></div> <div class="chart-graph-stat-loading"></div>
<?php endif ?>
<?php /* Таблица */ ?> <?php /* Таблица */ ?>
<div id="table-stat" class="b-table_wrapp"> <div id="table-stat" class="b-table_wrapp">
<div class="b-content__loading"></div> <div class="b-content__loading"></div>
<table id="table-line" class="table table-striped admin"> <table id="table-line" class="table table-striped admin">
<thead class="metric sortable"> <thead class="metric sortable">
<tr data-metric="<?= $metric ?>"> <tr data-metric="<?= $metric ?>">
<th><?= _t('Дата/Компания')?></th>
<?php foreach(['shows', 'clicks', 'transactions', 'salemoney', 'admoney'] as $name): ?>
<th> <th>
<b>
<?= _t('Дата/Компания')?>
</b>
</th>
<?php foreach($cats as $name): ?>
<th>
<?php if ($report == 'common'): ?>
<span style="border-color: <?= $colors_active_lines[$name] ?>;"> <span style="border-color: <?= $colors_active_lines[$name] ?>;">
<input type="checkbox" data-field="<?= $name ?>" /> <input type="checkbox" data-field="<?= $name ?>" />
</span> </span>
<?php endif; ?>
<b id="<?= $name ?>"> <b id="<?= $name ?>">
<?= _t($name)?> <?= _t($name)?><!--<b class="arrow asc">&and;</b><b class="arrow desc">&or;</b>-->
<!--
<b class="arrow asc">&and;</b>
<b class="arrow desc">&or;</b>
-->
</b> </b>
</th> </th>
<?php endforeach ?> <?php endforeach; ?>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
......
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