mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
update multi creation with more comfort
This commit is contained in:
parent
217fed5c8a
commit
7da24267d0
@ -252,6 +252,8 @@ class TransactionCreationsController extends AppController
|
||||
|
||||
if ($this->request->is('post')) {
|
||||
$requestData = $this->request->getData();
|
||||
//var_dump($requestData);
|
||||
//die("miau");
|
||||
// memo
|
||||
// amount
|
||||
$memo = $requestData['memo'];
|
||||
@ -263,19 +265,34 @@ class TransactionCreationsController extends AppController
|
||||
$this->Flash->error(__('no user choosen'));
|
||||
} else {
|
||||
$users = $requestData['user'];
|
||||
if(isset($requestData['user_pending'])) {
|
||||
$pendings = $requestData['user_pending'];
|
||||
} else {
|
||||
$pendings = [];
|
||||
}
|
||||
//var_dump(array_keys($users));
|
||||
$receiverUsers = $stateUserTable
|
||||
->find('all')
|
||||
->where(['id IN' => array_keys($users)])
|
||||
->select(['public_key', 'email'])
|
||||
->select(['public_key', 'email', 'id'])
|
||||
->contain(false);
|
||||
$transactions = [];
|
||||
//var_dump($receiverUsers);
|
||||
foreach($receiverUsers as $receiverUser) {
|
||||
$localAmountCent = $amountCent;
|
||||
$id = $receiverUser->id;
|
||||
if($requestData['user_amount'][$id] != '') {
|
||||
$localAmountCent = $this->GradidoNumber->parseInputNumberToCentNumber($requestData['user_amount'][$id]);
|
||||
}
|
||||
if(isset($pendings[$id])) {
|
||||
$pendings[$id] += $localAmountCent;
|
||||
} else {
|
||||
$pendings[$id] = $localAmountCent;
|
||||
}
|
||||
$pubKeyHex = bin2hex(stream_get_contents($receiverUser->public_key));
|
||||
$identHash = TransactionCreation::DRMakeStringHash($receiverUser->email);
|
||||
$builderResult = TransactionCreation::build(
|
||||
$amountCent,
|
||||
$localAmountCent,
|
||||
$memo,
|
||||
$pubKeyHex,
|
||||
$identHash
|
||||
@ -284,6 +301,16 @@ class TransactionCreationsController extends AppController
|
||||
array_push($transactions, base64_encode($builderResult['transactionBody']->serializeToString()));
|
||||
}
|
||||
}
|
||||
/*echo "pendings: ";
|
||||
var_dump($pendings);
|
||||
echo "<br>";*/
|
||||
foreach($possibleReceiver as $i => $_possibleReceiver) {
|
||||
$id = $_possibleReceiver['id'];
|
||||
if(isset($pendings[$id])) {
|
||||
$possibleReceiver[$i]['pending'] = $pendings[$id];
|
||||
}
|
||||
}
|
||||
$this->set('possibleReceiver', $possibleReceiver);
|
||||
$creationTransactionCount = count($transactions);
|
||||
if($creationTransactionCount > 0) {
|
||||
$user_balance = 0;
|
||||
|
||||
@ -22,17 +22,36 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
}
|
||||
|
||||
.grd_big_checkbox {
|
||||
border:1px dotted grey;
|
||||
border:1px dotted black;
|
||||
padding:4px;
|
||||
margin-bottom:5px;
|
||||
}
|
||||
|
||||
.grd_margin-bottom_50 {
|
||||
margin-bottom:50px;
|
||||
}
|
||||
|
||||
.grd_smaller {
|
||||
font-size:smaller;
|
||||
color:blue;
|
||||
}
|
||||
|
||||
.color-orange {
|
||||
color:#6400d9;
|
||||
}
|
||||
|
||||
.flowing-bottom {
|
||||
position:fixed;
|
||||
bottom:0px;
|
||||
padding-left:20px;
|
||||
padding-right:20px;
|
||||
padding-top:10px;
|
||||
padding-bottom:10px;
|
||||
background-color:rgba(255,255,255,0.5);
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="grd_container_small">
|
||||
<div class="grd_container_small grd_margin-bottom_50">
|
||||
|
||||
<button type="button" onclick="checkAll()" >Alle auswählen</button>
|
||||
<button type="button" onclick="uncheckAll()">Alle abwählen</button>
|
||||
@ -43,25 +62,38 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
<?= $this->Form->control('memo'); ?>
|
||||
<?= $this->Form->control('amount'); ?>
|
||||
<?php foreach($possibleReceiver as $possibleReceiver) :
|
||||
$disable = '';
|
||||
$disable = null;
|
||||
if($activeUser['id'] == $possibleReceiver['id'] || $possibleReceiver['amount'] > 10000000) {
|
||||
$disable = 'disabled';
|
||||
}
|
||||
?>
|
||||
<div class="grd_big_checkbox">
|
||||
<?php if(isset($possibleReceiver['pending'])) : ?>
|
||||
<?= $this->Form->hidden('user_pending[' . $possibleReceiver['id'] . ']', ['value' => $possibleReceiver['pending']] ) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->Form->checkbox('user[' .$possibleReceiver['id'] . ']', ['value' => $possibleReceiver['id'], 'hiddenField' => false, $disable]); ?>
|
||||
<?php if($disable != '') : ?>
|
||||
<?php if($disable != null) : ?>
|
||||
<span style="color:grey" title="Du kannst leider nicht für dich selbst schöpfen.">
|
||||
<?php endif; ?>
|
||||
<?= $possibleReceiver['name'] ?>
|
||||
<?php if($possibleReceiver['email'] != '') : ?>
|
||||
<<?= $possibleReceiver['email'] ?>>
|
||||
<?php endif; ?><br>
|
||||
<div class="input number grd-padding-top-bottom-5">
|
||||
<?= $this->Form->text('user_amount[' . $possibleReceiver['id'] . ']', ['placeholder' => __('Für benutzerdefinierten Betrag'), 'type' => 'number', 'step' => '0.01', $disable]); ?> GDD
|
||||
</div>
|
||||
<?php if(isset($possibleReceiver['pending'])) : ?>
|
||||
<span class="grd_smaller color-orange">
|
||||
Bereits als Transaktion angelegt: <?= $this->element('printGradido', ['number' => $possibleReceiver['pending']]);?>
|
||||
</span>
|
||||
<br>
|
||||
<?php endif; ?>
|
||||
<?php if($possibleReceiver['amount'] != 0) : ?>
|
||||
<span class="grd_smaller">
|
||||
In diesem Monat bereits geschöpft: <?= $this->element('printGradido', ['number' => $possibleReceiver['amount']]);?></span>
|
||||
In diesem Monat bereits geschöpft: <?= $this->element('printGradido', ['number' => $possibleReceiver['amount']]);?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<?php if($disable != '') : ?>
|
||||
<?php if($disable != null) : ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
<br>
|
||||
@ -69,8 +101,10 @@ $this->assign('title', __('Schöpfungstransaktion'));
|
||||
<?php endforeach; ?>
|
||||
<!--<?= $this->Form->control('receiver_pubkey_hex', []) ?>-->
|
||||
</fieldset>
|
||||
<?= $this->Form->button(__('Transaktion(n) abschließen'), ['name' => 'next', 'class' => 'grd-form-bn grd-form-bn-succeed grd_clickable grd-width-200']) ?>
|
||||
<?= $this->Form->button(__('Weitere Transaktion erstellen'), ['name' => 'add', 'class' => 'grd-form-bn grd_clickable grd-width-200']) ?>
|
||||
<div class="flowing-bottom">
|
||||
<?= $this->Form->button(__('Transaktion(n) abschließen'), ['name' => 'next', 'class' => 'grd-form-bn grd-form-bn-succeed grd_clickable grd-width-200']) ?>
|
||||
<?= $this->Form->button(__('Weitere Transaktion erstellen'), ['name' => 'add', 'class' => 'grd-form-bn grd_clickable grd-width-200']) ?>
|
||||
</div>
|
||||
<?= $this->Form->end() ?>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user