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

parent 0f95a915
......@@ -69,6 +69,7 @@ return [
$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\Transaction::class, new \Zend\Hydrator\ClassMethods());
$hpm->setService(\App\Entity\Contacts::class, new \Zend\Hydrator\ClassMethods());
......@@ -283,6 +284,18 @@ return [
$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) {
return new \App\Model\FAQ\Categories(
......
......@@ -319,15 +319,17 @@ return [
[
'name' => 'user.cabinet',
'path' => '/[:lang/]cabinet/',
'path' => '/[:lang/]cabinet/[:report]',
'middleware' => App\Action\User\Cabinet::class,
'allowed_methods' => ['GET'],
'options' => [
'constraints' => [
'lang' => '[a-z]{2,3}',
'report' => '\w+',
],
'defaults' => [
'lang' => \App\Model\Locales::DEFAULT_LANG,
'report' => 'common',
]
],
],
......
......@@ -114,10 +114,15 @@ $(document).ready(function(){
Render: function(dataLineChartStat) {
// Формируем список переключателей (категорий) 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 activeLines: ', activeLines);
//console.log('AAA activeLines: ', activeLines);
dataTable = {};
activeLines.forEach(function(item){
......
......@@ -39,6 +39,7 @@ $(document).ready(function(){
if ($('#period-stats').val()) {
dataLineChartStat = JSON.parse($('#period-stats').val());
}
//console.log('AAA dataLineChartStat = ', dataLineChartStat);
// Отрисовка графика и таблицы по стартовым данным:
renderLineChart();
......@@ -54,8 +55,6 @@ $(document).ready(function(){
// Клик на checkbox в названии поля таблицы:
$('#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();
});
......@@ -63,12 +62,14 @@ $(document).ready(function(){
// Отрисовка графика Stat
function renderLineChart()
{
if(dataLineChartStat) {
if(dataLineChartStat && $chartStat.length>0) {
$.ChartStat.DateStat(dataLineChartStat);
return false;
}
}
$chartTable.show();
// Отрисовка почасовой таблицы
function renderHourTable()
{
......
......@@ -33,6 +33,7 @@ use App\Model\Statistics;
use App\Model\Providers;
use App\Model\Feeds\Feeds;
use App\Model\Feeds\StatsDays;
use App\Model\Feeds\Transactions;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Zend\Diactoros\Response\HtmlResponse;
......@@ -85,34 +86,71 @@ class Cabinet extends Common
}
}
/** @var \App\Model\Feeds $statDaysModel */
$statsDaysModel = $this->container->get(StatsDays::class);
$stats = $statsDaysModel->findAll(['FeedID' => $feed_id_list])->toArray();
$periodStats = array(
'period' => [],
'shows' => $stat_item['shows'],
'clicks' => $stat_item['clicks'],
'transactions' => $stat_item['transactions'],
'salemoney' => $stat_item['salemoney'],
'admoney' => $stat_item['admoney'],
'type' => 'interval'
);
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'];
$report_type = $request->getAttribute('report');
$dates = ['2018-10-09', '2018-11-09'];
if ($report_type == 'common') {
/** @var \App\Model\Feeds $statDaysModel */
$statsDaysModel = $this->container->get(StatsDays::class);
$stats = $statsDaysModel->findAll(['FeedID' => $feed_id_list])->toArray();
$periodStats = array(
'period' => [],
'shows' => [],
'clicks' => [],
'transactions' => [],
'salemoney' => [],
'admoney' => [],
'type' => 'interval',
'report' => $report_type
);
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['periodStats'] = $periodStats;
//$data['periodStats'] = $stats;
$data['report'] = $report_type;
$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', [
......@@ -178,7 +216,6 @@ class Cabinet extends Common
'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));
}
}
\ 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'];
$error = $this->error;
$periodStats = $this->periodStats;
$dates = $this->dates;
$cats = $this->cats;
$report = $this->report;
$colors_active_lines = array(
'shows' => '#2CA02C',
'clicks' => '#D62728',
'transactions' => '#1F77B4',
'salemoney' => '#FF7F0E',
'admoney' => '#9467BD'
'admoney' => '#9467BD',
//'usdollarmoney' => '#2CA02C',
//'localmoney' => '#D62728',
);
......@@ -86,7 +92,9 @@ $colors_active_lines = array(
<?php if($error): ?>
<section class="b-content__work">
<h1><?= $error?></h1>
<div class="wrapp" style="margin: 100px auto; text-align: center;">
<h1><?= $error?></h1>
</div>
</section>
<?php else: ?>
......@@ -101,14 +109,16 @@ $colors_active_lines = array(
<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">
<?= _t('Сводный отчет') ?>
<?php if($report == 'common'): ?>
<?= _t('Сводный отчет') ?>
<?php else: ?>
<?= _t('Транзакции') ?>
<?php endif; ?>
<span class="caret"></span>
</button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu">
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Сводный отчет') ?></a></li>
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Отчет 1') ?></a></li>
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Отчет 2') ?></a></li>
<li><a href="#" class="current" report="<?= $report ?>"><?= _t('Отчет 3') ?></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="<?= $this->url('user.cabinet', ['lang' => $this->lang, 'report' => 'transaction']) ?>" <?php if($report == 'transaction'): ?>class="current"<?php endif; ?> report="transaction"><?= _t('Транзакции') ?></a></li>
</ul>
</div>
</div>
......@@ -140,33 +150,36 @@ $colors_active_lines = array(
<h2>Ошибка в статистике</h2>
<div class="message"></div>
</div>
<?php /* График */ ?>
<?php if ($report == 'common'): ?>
<div id="chart-graph-stat" style="height: 370px;"></div>
<div class="chart-graph-stat-loading"></div>
<?php endif ?>
<?php /* Таблица */ ?>
<div id="table-stat" class="b-table_wrapp">
<div class="b-content__loading"></div>
<table id="table-line" class="table table-striped admin">
<thead class="metric sortable">
<tr data-metric="<?= $metric ?>">
<th><?= _t('Дата/Компания')?></th>
<?php foreach(['shows', 'clicks', 'transactions', 'salemoney', 'admoney'] as $name): ?>
<th>
<b>
<?= _t('Дата/Компания')?>
</b>
</th>
<?php foreach($cats as $name): ?>
<th>
<?php if ($report == 'common'): ?>
<span style="border-color: <?= $colors_active_lines[$name] ?>;">
<input type="checkbox" data-field="<?= $name ?>" />
</span>
<?php endif; ?>
<b id="<?= $name ?>">
<?= _t($name)?>
<!--
<b class="arrow asc">&and;</b>
<b class="arrow desc">&or;</b>
-->
<?= _t($name)?><!--<b class="arrow asc">&and;</b><b class="arrow desc">&or;</b>-->
</b>
</th>
<?php endforeach ?>
<?php endforeach; ?>
</tr>
</thead>
<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