mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
adding new elements
This commit is contained in:
parent
38fd36775e
commit
fc7a7a9d8b
@ -18,7 +18,7 @@ class StateBalancesController extends AppController
|
||||
{
|
||||
parent::initialize();
|
||||
//$this->Auth->allow(['add', 'edit']);
|
||||
$this->Auth->allow(['overview']);
|
||||
$this->Auth->allow(['overview', 'overviewGdt']);
|
||||
$this->loadComponent('JsonRequestClient');
|
||||
}
|
||||
/**
|
||||
@ -49,8 +49,17 @@ class StateBalancesController extends AppController
|
||||
// sendRequestGDT
|
||||
// listPerEmailApi
|
||||
|
||||
//$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
|
||||
//var_dump($user);
|
||||
$gdtSum = 0;
|
||||
if('admin' === $user['role']) {
|
||||
$gdtEntries = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'sumPerEmailApi');
|
||||
//var_dump($gdtEntries);
|
||||
if('success' == $gdtEntries['state'] && 'success' == $gdtEntries['data']['state']) {
|
||||
$gdtSum = intval($gdtEntries['data']['sum']);
|
||||
}
|
||||
}
|
||||
//
|
||||
//
|
||||
|
||||
$creationsTable = TableRegistry::getTableLocator()->get('TransactionCreations');
|
||||
$creationTransactions = $creationsTable
|
||||
@ -141,6 +150,39 @@ class StateBalancesController extends AppController
|
||||
$this->set('transactionExecutingCount', $session->read('Transaction.executing'));
|
||||
$this->set('balance', $session->read('StateUser.balance'));
|
||||
$this->set('timeUsed', microtime(true) - $startTime);
|
||||
$this->set('gdtSum', $gdtSum);
|
||||
}
|
||||
|
||||
public function overviewGdt()
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
$this->viewBuilder()->setLayout('frontend_ripple');
|
||||
$session = $this->getRequest()->getSession();
|
||||
$result = $this->requestLogin();
|
||||
if($result !== true) {
|
||||
return $result;
|
||||
}
|
||||
$user = $session->read('StateUser');
|
||||
$requestResult = $this->JsonRequestClient->sendRequestGDT(['email' => $user['email']], 'GdtEntries' . DS . 'listPerEmailApi');
|
||||
if('success' === $requestResult['state'] && 'success' === $requestResult['data']['state']) {
|
||||
var_dump(array_keys($requestResult['data']));
|
||||
$ownEntries = $requestResult['data']['ownEntries'];
|
||||
//$gdtEntries = $requestResult['data']['entries'];
|
||||
|
||||
$gdtSum = 0;
|
||||
foreach($ownEntries as $i => $gdtEntry) {
|
||||
$gdtSum += $gdtEntry['gdt'];
|
||||
echo "index: $i<br>";
|
||||
var_dump($gdtEntry);
|
||||
|
||||
}
|
||||
//echo "gdtSum: $gdtSum<br>";
|
||||
$this->set('gdtSum', $gdtSum);
|
||||
$this->set('ownEntries', $ownEntries);
|
||||
} else {
|
||||
$this->Flash->error(__('Fehler beim GDT Server, bitte abwarten oder den Admin benachrichtigen!'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function sortTransactions($a, $b) {
|
||||
|
||||
8
src/Template/Element/printEuro.ctp
Normal file
8
src/Template/Element/printEuro.ctp
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
24
src/Template/Element/printGDT.ctp
Normal file
24
src/Template/Element/printGDT.ctp
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
//$class = 'grd-negative-currency';
|
||||
$class = 'gdt-text-color';
|
||||
//$title = '' . $number;
|
||||
/*if($number == 0) $class = "grd-default-currency";
|
||||
else if($number > 0) $class = "grd-positive-currency";*/
|
||||
if($number < 0) {
|
||||
$class = 'grd-negative-currency';
|
||||
}
|
||||
|
||||
?><?php if(isset($raw) && true == $raw): ?>
|
||||
<?= $this->Number->format(intval($number) / 100.0, ['precision' => 2]) . ' GDT';?>
|
||||
<?php else : ?>
|
||||
<span class="<?php echo $class;?>">
|
||||
<?= $this->Number->format(intval($number) / 100.0, ['precision' => 2]) . ' GDT';?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
@ -14,6 +14,9 @@ $this->assign('title', __('Kontoübersicht'));
|
||||
<div class="grid-body py-3">
|
||||
<h3><?= __('Aktueller Kontostand: ') ?></h3>
|
||||
<h2><?= $this->element('printGradido', ['number' => $balance]) ?></h2>
|
||||
<?php if($gdtSum > 0) : ?>
|
||||
<h2><?= $this->Html->link($this->element('printGDT', ['number' => $gdtSum]), ['action' => 'overview_gdt'], ['escape' => false]) ?></h2>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -106,6 +109,7 @@ $this->assign('title', __('Kontoübersicht'));
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?= $this->Html->css(['gdt.css']) ?>
|
||||
<?php if($transactionExecutingCount > 0) : ?>
|
||||
<script type="text/javascript">
|
||||
//function getJson(basisUrl, method, successFunction, errorFunction, timeoutFunction)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user