<h3>Блокировки на счете</h3> <?php $currency_id = !empty($_GET['currency_id']) ? (int) $_GET['currency_id'] : 0; $wallets = App::$cur->money->getUserWallets(); if ($currency_id && empty($wallets[$currency_id])) { Msg::add('У вас нет такого кошелька'); Msg::show(); return; } if ($currency_id) { $ids = $wallets[$currency_id]->id; } else { $ids = []; foreach ($wallets as $wallet) { $ids[] = $wallet->id; } $ids = implode(',', $ids); } $table = new \Ui\Table(); $table->setCols(['№', 'Кошелек', 'Сумма', 'Комментарий', 'Дата']); //items pages $pages = new \Ui\Pages($_GET, ['count' => \Money\Wallet\Block::getCount(['where' => ['wallet_id', $ids, 'IN']]), 'limit' => 20]); $histories = \Money\Wallet\Block::getList(['where' => ['wallet_id', $ids, 'IN'], 'order' => [['date_create', 'DESC'], ['id', 'DESC']], 'start' => $pages->params['start'], 'limit' => $pages->params['limit']]); foreach ($histories as $history) { $amount = $history->amount; $table->addRow([$history->id, $history->wallet->currency->name(), '<span class = "' . ($amount > 0 ? "text-success" : 'text-danger') . '">' . $amount . '</span>', $history->comment, $history->date_create]); } $table->draw(); $pages->draw();
public function getUserBlocks($userId = null) { $userId = $userId ? $userId : \Users\User::$cur->id; $blocked = \Money\Wallet\Block::getList(['where' => [['wallet:user_id', $userId], [['date_expired', '0000-00-00 00:00:00'], ['date_expired', date('Y-m-d H:i:s'), '>', 'OR']]]]); $blocks = []; foreach ($blocked as $block) { if (empty($blocks[$block->wallet->currency_id])) { $blocks[$block->wallet->currency_id] = $block->amount; } else { $blocks[$block->wallet->currency_id] += $block->amount; } } return $blocks; }