From 5b3bcbbae8acfa42d94c6d9fe374def017a584a2 Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Thu, 7 May 2020 14:04:27 +0000 Subject: [PATCH] update create multi, simple paging --- .../TransactionCreationsController.php | 15 ++++++++++-- .../TransactionCreations/create_multi.ctp | 23 ++++++++++++++++++- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/Controller/TransactionCreationsController.php b/src/Controller/TransactionCreationsController.php index e1c8c521a..745b63ef0 100644 --- a/src/Controller/TransactionCreationsController.php +++ b/src/Controller/TransactionCreationsController.php @@ -182,12 +182,13 @@ class TransactionCreationsController extends AppController } } - public function createMulti() + public function createMulti($page = 0) { $startTime = microtime(true); $this->viewBuilder()->setLayout('frontend'); $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); + $limit = 200; if($result !== true) { return $result; } @@ -229,6 +230,7 @@ class TransactionCreationsController extends AppController $stateUsers = $stateUserTable ->find('all') ->select(['id', 'first_name', 'last_name', 'email']) + ->order(['id']) ->contain(['TransactionCreations' => [ 'fields' => [ 'TransactionCreations.amount', @@ -239,7 +241,12 @@ class TransactionCreationsController extends AppController //var_dump($stateUsers->toArray()); $possibleReceiver = []; - foreach($stateUsers as $stateUser) { + $countUsers = 0; + foreach($stateUsers as $i => $stateUser) { + $countUsers++; + if($i < $page * $limit || $i >= ($page + 1) * $limit) { + continue; + } $sumAmount = 0; $sumAmount2 = 0; if(isset($transactionsLastMonthTargetDateSortedByStateUserId[$stateUser->id])) { @@ -279,10 +286,14 @@ class TransactionCreationsController extends AppController $this->set('creationForm', $creationForm); $this->set('transactionExecutingCount', $session->read('Transaction.executing')); $this->set('timeUsed', microtime(true) - $startTime); + $this->set('countUsers', $countUsers); + $this->set('limit', $limit); + $this->set('page', $page); if ($this->request->is('post')) { $requestData = $this->request->getData(); //var_dump($requestData); + //var_dump($this->request->getData('user')); //die("miau"); // memo // amount diff --git a/src/Template/TransactionCreations/create_multi.ctp b/src/Template/TransactionCreations/create_multi.ctp index 76a57319e..93531abf1 100644 --- a/src/Template/TransactionCreations/create_multi.ctp +++ b/src/Template/TransactionCreations/create_multi.ctp @@ -34,6 +34,14 @@ use Cake\I18n\FrozenTime; margin-bottom:50px; } + .grd_margin-bottom_100 { + margin-bottom:100px; + } + + .grd_margin-bottom_120 { + margin-bottom:120px; + } + .grd_smaller { font-size:smaller; color:blue; @@ -54,7 +62,7 @@ use Cake\I18n\FrozenTime; } -
+
@@ -121,6 +129,19 @@ use Cake\I18n\FrozenTime;
+ $limit) : + ?>

Benutzer insgesamt

+

Seiten: + 0) echo ', '; + if($i != $page) { + echo $this->Html->link($i, ['action' => 'create_multi', $i]); + } else { + echo $i; + } + } + ?> +

Form->button(__('Transaktion(en) abschließen'), ['name' => 'next', 'class' => 'grd-form-bn grd-form-bn-succeed grd_clickable grd-width-200']) ?> Form->button(__('Weitere Transaktion erstellen'), ['name' => 'add', 'class' => 'grd-form-bn grd_clickable grd-width-200']) ?>