diff --git a/config/ripple_control_group_form.php b/config/ripple_control_group_form.php index 913dac7a7..b5bc5604d 100644 --- a/config/ripple_control_group_form.php +++ b/config/ripple_control_group_form.php @@ -1,6 +1,6 @@ '
' . '' . '
', - 'error' => '
' . '{{content}}' . '
', - + // Container for error items. //'errorList' => '', 'errorList' => '{{content}}', - + // Error item wrapper. //'errorItem' => '
  • {{text}}
  • ', 'errorItem' => '
    {{text}}
    ' diff --git a/src/Controller/StateUsersController.php b/src/Controller/StateUsersController.php index b24e1e7bb..5ab8ccfac 100644 --- a/src/Controller/StateUsersController.php +++ b/src/Controller/StateUsersController.php @@ -10,6 +10,9 @@ use App\Controller\AppController; use App\Form\UserSearchForm; use App\Model\Validation\GenericValidation; +use Model\Navigation\NaviHierarchy; +use Model\Navigation\NaviHierarchyEntry; + use Model\Transactions\TransactionCreation; // for translating @@ -31,20 +34,24 @@ __('no keys'); */ class StateUsersController extends AppController { - + public function initialize() { parent::initialize(); $this->loadComponent('GradidoNumber'); $this->loadComponent('JsonRequestClient'); $this->Auth->allow([ - 'search', 'ajaxCopyLoginToCommunity', 'ajaxCopyCommunityToLogin', + 'search', 'ajaxCopyLoginToCommunity', 'ajaxCopyCommunityToLogin', 'ajaxDelete', 'ajaxCountTransactions', 'ajaxVerificationEmailResend', 'ajaxGetUserEmailVerificationCode' ]); - + $this->set( + 'naviHierarchy', + (new NaviHierarchy())-> + add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', false))->add(new NaviHierarchyEntry(__('Benutzer suchen'), 'StateUsers', 'search', true)) + ); } - + /** * Index method * @@ -59,7 +66,7 @@ class StateUsersController extends AppController $this->set(compact('stateUsers')); } - + public function listIdentHashes() { $stateUsers = $this->StateUsers->find('all')->toArray(); @@ -68,7 +75,7 @@ class StateUsersController extends AppController } $this->set('stateUsers', $stateUsers); } - + public function search() { $startTime = microtime(true); @@ -81,19 +88,19 @@ class StateUsersController extends AppController } $user = $session->read('StateUser'); if($user['role'] != 'admin') { - return $this->redirect(['controller' => 'dashboard', 'action' => 'index']); + return $this->redirect(['controller' => 'dashboard', 'action' => 'index']); } - + $searchForm = new UserSearchForm(); - + $timeUsed = microtime(true) - $startTime; //$this->set('timeUsed', $timeUsed); $csfr_token = $this->request->getParam('_csrfToken'); $this->set(compact('timeUsed', 'searchForm', 'csfr_token')); - + if ($this->request->is('post')) { $requestData = $this->request->getData(); - + if($searchForm->validate($requestData)) { //var_dump($requestData); $searchString = $requestData['search']; @@ -134,13 +141,13 @@ class StateUsersController extends AppController $communityUsers = $this->StateUsers ->find('all') ->contain(['StateBalances' => ['fields' => ['amount', 'state_user_id']]]); - + $communityUsers->where(['OR' => [ 'first_name LIKE' => $globalSearch, 'last_name LIKE' => $globalSearch, 'email LIKE' => $globalSearch ]]); - + //var_dump($communityUsers->toArray()); foreach($communityUsers as $u) { $pubkey_hex = bin2hex(stream_get_contents($u->public_key)); @@ -159,14 +166,14 @@ class StateUsersController extends AppController $finalUser['balance'] = 0; $finalUser['pubkeyhex'] = $pubhex; $finalUser['created'] = null; - + if(count($user['community']) == 1) { - if(isset($user['community'][0]->state_balances) && + if(isset($user['community'][0]->state_balances) && isset($user['community'][0]->state_balances[0]['amount'])) { $finalUser['balance'] = $user['community'][0]->state_balances[0]->amount; } } - + if(count($user['login']) == 0) { $state = 'account not on login-server'; $color = 'danger'; @@ -191,9 +198,9 @@ class StateUsersController extends AppController $state = 'account copied to community'; $color = 'success'; //var_dump($user['community'][0]->state_balances[0]['amount']); - + } - + } else { $state = 'email not activated'; $color = 'warning'; @@ -205,7 +212,7 @@ class StateUsersController extends AppController $finalUser['indicator'] = ['name' => $state, 'color' => $color]; array_push($finalUserEntrys, $finalUser); } - + foreach($emptyPubkeys as $user) { $finalUser = []; $state = 'account not on community server'; @@ -231,14 +238,14 @@ class StateUsersController extends AppController } else { $this->Flash->error(__('Something was invalid, please try again!')); } - + $this->set('finalUserEntrys', $finalUserEntrys); } $timeUsed = microtime(true) - $startTime; $this->set('timeUsed', $timeUsed); } - - public function ajaxCopyCommunityToLogin() + + public function ajaxCopyCommunityToLogin() { $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); @@ -254,8 +261,8 @@ class StateUsersController extends AppController } return $this->returnJson(['state' => 'error', 'msg' => 'no post request']); } - - public function ajaxCopyLoginToCommunity() + + public function ajaxCopyLoginToCommunity() { $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); @@ -266,26 +273,26 @@ class StateUsersController extends AppController if($user['role'] != 'admin') { return $this->returnJson(['state' => 'error', 'msg' => 'not an admin']); } - + if($this->request->is('post')) { $jsonData = $this->request->input('json_decode', true); //$user = $jsonData['user']; //var_dump($jsonData); - + $newStateUser = $this->StateUsers->newEntity(); $this->StateUsers->patchEntity($newStateUser, $jsonData); $newStateUser->public_key = hex2bin($jsonData['pubkeyhex']); - + if(!$this->StateUsers->save($newStateUser)) { return $this->returnJson(['state' => 'error', 'msg' => 'error by saving', 'details' => json_encode($newStateUser->errors())]); } - + return $this->returnJson(['state' => 'success']); } return $this->returnJson(['state' => 'error', 'msg' => 'no post request']); } - - public function ajaxVerificationEmailResend() + + public function ajaxVerificationEmailResend() { $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); @@ -300,7 +307,7 @@ class StateUsersController extends AppController $jsonData = $this->request->input('json_decode', true); $email = $jsonData['email']; $session_id = $session->read('session_id'); - + return $this->returnJson($this->JsonRequestClient->sendRequest(json_encode([ 'session_id' => $session_id, 'email' => $email @@ -312,7 +319,7 @@ class StateUsersController extends AppController } return $this->returnJson(['state' => 'error', 'msg' => 'no post request']); } - + public function ajaxGetUserEmailVerificationCode() { $session = $this->getRequest()->getSession(); @@ -328,7 +335,7 @@ class StateUsersController extends AppController $jsonData = $this->request->input('json_decode', true); $email = $jsonData['email']; $session_id = $session->read('session_id'); - + return $this->returnJson($this->JsonRequestClient->sendRequest(json_encode([ 'session_id' => $session_id, 'email' => $email, @@ -337,9 +344,9 @@ class StateUsersController extends AppController } return $this->returnJson(['state' => 'error', 'msg' => 'no post request']); } - - - public function ajaxDelete() + + + public function ajaxDelete() { $session = $this->getRequest()->getSession(); $result = $this->requestLogin(); @@ -350,7 +357,7 @@ class StateUsersController extends AppController if($user['role'] != 'admin') { return $this->returnJson(['state' => 'error', 'msg' => 'not an admin']); } - + if($this->request->is('post')) { $jsonData = $this->request->input('json_decode', true); //$user = $jsonData['user']; @@ -360,7 +367,7 @@ class StateUsersController extends AppController if($stateUsers->count() != 1) { return $this->returnJson(['state' => 'error', 'msg' => 'invalid result count']); } - + if ($this->StateUsers->delete($stateUsers->first())) { return $this->returnJson(['state' => 'success']); } else { @@ -369,7 +376,7 @@ class StateUsersController extends AppController } return $this->returnJson(['state' => 'error', 'msg' => 'no post request']); } - + public function ajaxCountTransactions() { $session = $this->getRequest()->getSession(); @@ -381,7 +388,7 @@ class StateUsersController extends AppController if($user['role'] != 'admin') { return $this->returnJson(['state' => 'error', 'msg' => 'not an admin']); } - + if($this->request->is('post')) { $jsonData = $this->request->input('json_decode', true); //$user = $jsonData['user']; @@ -419,17 +426,17 @@ class StateUsersController extends AppController } } return $this->returnJson(['state' => 'success', 'counts' => $counts]); - + } return $this->returnJson(['state' => 'error', 'msg' => 'no post request']); - + } /* - + getField(vnode, 'receive'), - + getField(vnode, 'sended'), - + getField(vnode, 'creation'), */ @@ -444,8 +451,8 @@ class StateUsersController extends AppController { $stateUser = $this->StateUsers->get($id, [ 'contain' => [ - 'StateBalances', - 'TransactionCreations' => ['Transactions'], + 'StateBalances', + 'TransactionCreations' => ['Transactions'], 'TransactionSendCoins' => ['Transactions', 'ReceiverUsers'], 'TransactionReceivedCoins' => ['Transactions', 'StateUsers']] ]); diff --git a/src/Controller/TransactionCreationsController.php b/src/Controller/TransactionCreationsController.php index 745b63ef0..c90ce1bd3 100644 --- a/src/Controller/TransactionCreationsController.php +++ b/src/Controller/TransactionCreationsController.php @@ -10,6 +10,9 @@ use Cake\Core\Configure; use Cake\I18n\FrozenDate; use Cake\Datasource\ConnectionManager; +use Model\Navigation\NaviHierarchy; +use Model\Navigation\NaviHierarchyEntry; + use App\Form\CreationForm; // protobuf transactions //use Model\Messages\Gradido\TransactionCreation; @@ -24,7 +27,7 @@ use Model\Transactions\TransactionCreation; */ class TransactionCreationsController extends AppController { - + public function initialize() { parent::initialize(); @@ -32,6 +35,11 @@ class TransactionCreationsController extends AppController $this->loadComponent('JsonRequestClient'); //$this->Auth->allow(['add', 'edit']); //$this->Auth->allow('create'); + $this->set( + 'naviHierarchy', + (new NaviHierarchy())-> + add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', false))->add(new NaviHierarchyEntry(__('Gradido schöpfen'), 'TransactionCreations', 'create-multi', true)) + ); } /** * Index method @@ -68,7 +76,7 @@ class TransactionCreationsController extends AppController $this->set('transactionCreation', $transactionCreation); } - + public function create() { $startTime = microtime(true); @@ -87,8 +95,8 @@ class TransactionCreationsController extends AppController $creationForm = new CreationForm(); $transactionCreation = $this->TransactionCreations->newEntity(); $transactionCreation->state_user_id = $user['id']; - - // adding possible addresses + input field for copy + + // adding possible addresses + input field for copy $stateUserTable = TableRegistry::getTableLocator()->get('StateUsers'); $stateUsers = $stateUserTable->find('all')->contain(false); $receiverProposal = []; @@ -103,13 +111,13 @@ class TransactionCreationsController extends AppController } $timeUsed = microtime(true) - $startTime; $this->set(compact('transactionCreation', 'timeUsed', 'receiverProposal', 'creationForm')); - + if ($this->request->is('post')) { $requestData = $this->request->getData(); $mode = 'next'; if(isset($requestData['add'])) {$mode = 'add'; } if($creationForm->validate($requestData)) { - + $pubKeyHex = ''; $identHash = ''; $amountCent = $this->GradidoNumber->parseInputNumberToCentNumber($requestData['amount']); @@ -121,14 +129,14 @@ class TransactionCreationsController extends AppController //echo "identHash: $identHash for " . $receiverProposal[$receiverIndex]['email']; } $builderResult = TransactionCreation::build( - $amountCent, - $requestData['memo'], + $amountCent, + $requestData['memo'], $pubKeyHex, $identHash ); // echo "builder result state: " . $builderResult['state'] . '
    '; if($builderResult['state'] == 'success') { - + $user_balance = 0; if(isset($user['balance'])) { $user_balance = $user['balance']; @@ -181,7 +189,7 @@ class TransactionCreationsController extends AppController } } } - + public function createMulti($page = 0) { $startTime = microtime(true); @@ -193,9 +201,9 @@ class TransactionCreationsController extends AppController return $result; } $user = $session->read('StateUser'); - + $stateUserTable = TableRegistry::getTableLocator()->get('StateUsers'); - + $connection = ConnectionManager::get('default'); $transactionActiveMonth = $connection->execute( 'SELECT id, received FROM transactions ' @@ -209,7 +217,7 @@ class TransactionCreationsController extends AppController foreach($transactionActiveMonth as $t) { $transactionActiveMonthSortedById[$t['id']] = $t['received']; } - $firstDayLastMonth = new FrozenDate(); + $firstDayLastMonth = new FrozenDate(); $firstDayLastMonth = $firstDayLastMonth->day(1)->subMonth(1); $transactionsLastMonthTargeDate = $this->TransactionCreations ->find('all') @@ -218,15 +226,15 @@ class TransactionCreationsController extends AppController ->group(['state_user_id']) ->contain([]); $transactionsLastMonthTargeDate->select([ - 'state_user_id', + 'state_user_id', 'sum_amount' => $transactionsLastMonthTargeDate->func()->sum('amount') ]); - + $transactionsLastMonthTargetDateSortedByStateUserId = []; foreach($transactionsLastMonthTargeDate as $transactionCreation) { $transactionsLastMonthTargetDateSortedByStateUserId[$transactionCreation->state_user_id] = $transactionCreation->sum_amount; } - + $stateUsers = $stateUserTable ->find('all') ->select(['id', 'first_name', 'last_name', 'email']) @@ -238,7 +246,7 @@ class TransactionCreationsController extends AppController 'TransactionCreations.state_user_id' ] ]]); - + //var_dump($stateUsers->toArray()); $possibleReceiver = []; $countUsers = 0; @@ -257,9 +265,9 @@ class TransactionCreationsController extends AppController if(isset($transactionActiveMonthSortedById[$transactionCreation->transaction_id])) { $sumAmount += $transactionCreation->amount; } - + } - + //if($sumAmount < 20000000) { array_push($possibleReceiver, [ 'name' => $stateUser->first_name . ' ' . $stateUser->last_name, @@ -277,10 +285,10 @@ class TransactionCreationsController extends AppController }); //var_dump($possibleReceiver); $creationForm = new CreationForm(); - + $timeUsed = microtime(true) - $startTime; $this->set(compact('timeUsed', 'stateUsers', 'creationForm', 'possibleReceiver')); - + $this->set('firstDayLastMonth', $firstDayLastMonth); $this->set('activeUser', $user); $this->set('creationForm', $creationForm); @@ -289,7 +297,7 @@ class TransactionCreationsController extends AppController $this->set('countUsers', $countUsers); $this->set('limit', $limit); $this->set('page', $page); - + if ($this->request->is('post')) { $requestData = $this->request->getData(); //var_dump($requestData); @@ -302,7 +310,7 @@ class TransactionCreationsController extends AppController $targetDate = $requestData['target_date']; $mode = 'next'; if(isset($requestData['add'])) {$mode = 'add'; } - + if(!isset($requestData['user']) || count($requestData['user']) == 0) { $this->Flash->error(__('no user choosen')); } else { @@ -348,8 +356,8 @@ class TransactionCreationsController extends AppController //echo "output: "; var_dump($localTargetDateFrozen); //die('a'); $builderResult = TransactionCreation::build( - $localAmountCent, - $memo, + $localAmountCent, + $memo, $pubKeyHex, $identHash, $localTargetDateFrozen @@ -413,7 +421,7 @@ class TransactionCreationsController extends AppController } } } - } + } } } } @@ -425,7 +433,7 @@ class TransactionCreationsController extends AppController */ public function add() { - + $transactionCreation = $this->TransactionCreations->newEntity(); if ($this->request->is('post')) { $transactionCreation = $this->TransactionCreations->patchEntity($transactionCreation, $this->request->getData()); diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index 2bc1ffeb9..f6b0472d3 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -5,6 +5,9 @@ use App\Controller\AppController; use Cake\Datasource\ConnectionManager; use Cake\I18n\Time; +use Model\Navigation\NaviHierarchy; +use Model\Navigation\NaviHierarchyEntry; + /** * Users Controller * @@ -14,6 +17,16 @@ use Cake\I18n\Time; */ class UsersController extends AppController { + public function initialize() + { + parent::initialize(); + $this->set( + 'naviHierarchy', + (new NaviHierarchy())-> + add(new NaviHierarchyEntry(__('Startseite'), 'Dashboard', 'index', false))->add(new NaviHierarchyEntry(__('Benutzerstatistiken'), 'Users', 'statistics', true)) + ); + } + /** * Index method * @@ -25,13 +38,13 @@ class UsersController extends AppController $this->set(compact('users')); } - + public function statistics() { $startTime = microtime(true); $this->viewBuilder()->setLayout('frontend'); $users = $this->Users->find('all')->select(['id']); - + //$newUsersThisMonth $now = new Time(); $sortDate = $this->getStartEndForMonth($now->month, $now->year); @@ -44,11 +57,11 @@ class UsersController extends AppController $newUsersLastMonth = $this->Users->find('all') ->select(['id']) ->where(['created >=' => $prevSortDate[0], 'created <' => $prevSortDate[1]]); - + // new user sorted after date $connection = ConnectionManager::get('loginServer'); $newAccountsPerDay = $connection->execute('SELECT count(id) as count, created FROM users GROUP BY CAST(created as DATE) ORDER BY created DESC ')->fetchAll('assoc'); - + $newAccountsTree = []; foreach($newAccountsPerDay as $entry) { $created = new Time($entry['created']); @@ -61,12 +74,12 @@ class UsersController extends AppController array_push($newAccountsTree[$created->year][$created->month]['days'], $entry); $newAccountsTree[$created->year][$created->month]['count'] += intval($entry['count']); } - + // last 5 new users $lastUsers = $this->Users->find('all')->order(['created DESC'])->limit(5); - + $timeUsed = microtime(true) - $startTime; - + $this->set(compact( 'users', 'newUsersThisMonth', 'newUsersLastMonth', 'timeUsed', 'newAccountsTree', 'lastUsers')); diff --git a/src/Template/StateBalances/overview.ctp b/src/Template/StateBalances/overview.ctp index 26e533f08..85abfd90c 100644 --- a/src/Template/StateBalances/overview.ctp +++ b/src/Template/StateBalances/overview.ctp @@ -26,7 +26,7 @@ $this->assign('header', $header);

    Überweisungen

    -
    +
    diff --git a/src/Template/StateUsers/search.ctp b/src/Template/StateUsers/search.ctp index 5d4c139a8..ebb95a63c 100644 --- a/src/Template/StateUsers/search.ctp +++ b/src/Template/StateUsers/search.ctp @@ -1,6 +1,6 @@ assign('title', __('Benutzer suchen')); // In a View class $this->loadHelper('Form', [ - 'templates' => 'ripple_control_group_form', -]);//*/ + 'templates' => 'horizontal_form', +]); ?> +Html->css(['loginServer/style.css']) ?> -
    -
    -
    -

    Benutzer suchen

    -
    -
    -
    -
    - Form->create($searchForm, ['class' => 't-header-search-box']) ?> - Form->control('search', ['label' => false, 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname oder Nachname oder E-Mail')]) ?> - Form->button(' ' . __('Datenbank durchsuchen'), ['class' => 'btn btn-sm btn-primary']) ?> - Form->hidden('order_row', ['id' => 'input-order-row']) ?> -
    -
    -
    -
    -
    +
    +

    Benutzer suchen

    +
    + Form->create($searchForm, []) ?> + Form->control('search', ['label' => __('Suchbegriff'), 'class' => 'form-control', 'id' => 'inlineFormInputGroup', 'placeholder' => __('Vorname/Nachname/E-Mail')]) ?> + Form->button('search ' . __('Suchen'), ['class' => 'form-button']) ?> + Form->hidden('order_row', ['id' => 'input-order-row']) ?>
    -
    -
    -
    - -
    -
    +
    +
    -Html->script('userSearch') ?> \ No newline at end of file +Html->script('userSearch') ?> diff --git a/src/Template/TransactionCreations/create_multi.ctp b/src/Template/TransactionCreations/create_multi.ctp index 93531abf1..dab996318 100644 --- a/src/Template/TransactionCreations/create_multi.ctp +++ b/src/Template/TransactionCreations/create_multi.ctp @@ -1,6 +1,6 @@
    -
    @@ -74,8 +73,8 @@ use Cake\I18n\FrozenTime;
    Form->control('memo'); ?> Form->control('amount', ['required' => false]); ?> - day(1)->subMonth(1); ?> Form->control('target_date', ['value' => $firstDayLastMonth]); ?> @@ -94,7 +93,7 @@ use Cake\I18n\FrozenTime; - + <>
    @@ -129,17 +128,17 @@ use Cake\I18n\FrozenTime;
    - $limit) : + $limit) : ?>

    Benutzer insgesamt

    -

    Seiten: +

    Seiten: 0) echo ', '; + if($i > 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']) ?> @@ -154,21 +153,21 @@ use Cake\I18n\FrozenTime; var inputs = document.getElementsByTagName("input"); for(var i = 0; i < inputs.length; i++) { if(inputs[i].type == "checkbox") { - inputs[i].checked = true; - } - } + inputs[i].checked = true; + } + } } - + function uncheckAll() { var inputs = document.getElementsByTagName("input"); for(var i = 0; i < inputs.length; i++) { if(inputs[i].type == "checkbox") { - inputs[i].checked = false; - } + inputs[i].checked = false; + } } } - + (function(document, window, domIsReady, undefined) { domIsReady(function() { var userAmountInputs = document.getElementsByClassName("user_amount"); @@ -188,15 +187,15 @@ use Cake\I18n\FrozenTime; }); })(document, window, domIsReady); - // - + // + 0) : ?>