public function content($params = []) { $this->paramsParse($params); if (empty($this->template->config['noSysMsgAutoShow'])) { Msg::show(); } if (!file_exists($this->template->contentPath)) { echo 'Content not found'; } else { extract($this->contentData); include $this->template->contentPath; } }
<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 checkRequest($params = [], $ajax = false) { if (!$this->checkAccess()) { $this->drawError('you not have access to "' . $this->modelName . '" manager with name: "' . $this->formName . '"'); return []; } $successId = 0; if (!empty($_POST[$this->requestFormName][$this->modelName])) { $request = $_POST[$this->requestFormName][$this->modelName]; if ($this->model) { $presets = !empty($this->form['preset']) ? $this->form['preset'] : []; if (!empty($this->form['userGroupPreset'][\Users\User::$cur->group_id])) { $presets = array_merge($presets, $this->form['userGroupPreset'][\Users\User::$cur->group_id]); } $afterSave = []; $error = false; foreach ($this->inputs as $col => $param) { if (!empty($presets[$col])) { continue; } if (is_object($param)) { $afterSave[] = $param; continue; } if (!empty($this->form['userGroupReadonly'][\Users\User::$cur->group_id]) && in_array($col, $this->form['userGroupReadonly'][\Users\User::$cur->group_id])) { continue; } $inputClassName = '\\Ui\\ActiveForm\\Input\\' . ucfirst($param['type']); $input = new $inputClassName(); $input->activeForm = $this; $input->activeFormParams = $params; $input->modelName = $this->modelName; $input->colName = $col; $input->colParams = $param; try { $input->validate($request); $input->parseRequest($request); } catch (\Exception $exc) { \Msg::add($exc->getMessage(), 'danger'); $error = true; } } if (!$error && empty($_GET['notSave'])) { foreach ($presets as $col => $preset) { if (!empty($preset['value'])) { $this->model->{$col} = $preset['value']; } elseif (!empty($preset['userCol'])) { if (strpos($preset['userCol'], ':')) { $rel = substr($preset['userCol'], 0, strpos($preset['userCol'], ':')); $param = substr($preset['userCol'], strpos($preset['userCol'], ':') + 1); $this->model->{$col} = \Users\User::$cur->{$rel}->{$param}; } else { $this->model->{$col} = \Users\User::$cur->{$preset['userCol']}; } } } if (!$this->parent) { if (!empty($this->form['successText'])) { $text = $this->form['successText']; } else { $text = $this->model->pk() ? 'Изменения были успешно сохранены' : 'Новый элемент был успешно добавлен'; } \Msg::add($text, 'success'); } $this->model->save(!empty($params['dataManagerParams']) ? $params['dataManagerParams'] : []); foreach ($afterSave as $form) { $form->checkRequest(); } if ($ajax) { \Msg::show(); } elseif (!empty($_GET['redirectUrl'])) { \Tools::redirect($_GET['redirectUrl'] . (!empty($_GET['dataManagerHash']) ? '#' . $_GET['dataManagerHash'] : '')); } $successId = $this->model->pk(); } } if (!is_array($params) && is_callable($params)) { $params($request); } } return $successId; }