Ejemplo n.º 1
0
 public function formPopUpAction()
 {
     if (strpos($_GET['item'], ':')) {
         $raw = explode(':', $_GET['item']);
         $modelName = $raw[0];
         $id = $raw[1];
         $model = $modelName::get($id, $modelName::index(), !empty($_GET['params']['dataManagerParams']) ? $_GET['params']['dataManagerParams'] : []);
     } else {
         $modelName = $_GET['item'];
         $model = new $modelName();
     }
     $params = [];
     if (!empty($_GET['params'])) {
         $params = $_GET['params'];
         if (!empty($params['preset'])) {
             $model->setParams($params['preset']);
         }
     }
     if (!empty($_GET['params']['dataManagerParams']['appType'])) {
         $params['appType'] = $_GET['params']['dataManagerParams']['appType'];
     }
     $formName = !empty($_GET['formName']) ? $_GET['formName'] : (!empty($_GET['params']['formName']) ? $_GET['params']['formName'] : 'manager');
     $form = new Ui\ActiveForm($model, $formName);
     if (!empty($_GET['_']) || !empty($_POST['_'])) {
         $return = new Server\Result();
         ob_start();
         $form->checkRequest($params, true);
         $_GET['item'] = get_class($form->model) . ($model->pk() ? ':' . $model->pk() : '');
         $get = $_GET;
         if (isset($get['notSave'])) {
             unset($get['notSave']);
         }
         $form->action = (App::$cur->system ? '/' . App::$cur->name : '') . '/ui/formPopUp/?' . http_build_query($get);
         $form->draw($params, true);
         $return->content = ob_get_contents();
         ob_end_clean();
         $return->send();
     } else {
         $form->checkRequest($params);
         $_GET['item'] = get_class($form->model) . ($model->pk() ? ':' . $model->pk() : '');
         $get = $_GET;
         if (isset($get['notSave'])) {
             unset($get['notSave']);
         }
         $form->action = (App::$cur->system ? '/' . App::$cur->name : '') . '/ui/formPopUp/?' . http_build_query($get);
         $this->view->setTitle(($model && $model->pk() ? 'Изменить ' : 'Создать ') . $form->header);
         $this->view->page(['content' => 'form', 'data' => compact('form', 'params')]);
     }
 }
Ejemplo n.º 2
0
 public function transferAction()
 {
     $transfer = new Money\Transfer();
     $form = new Ui\ActiveForm($transfer, 'transfer');
     $transferId = $form->checkRequest();
     if ($transferId) {
         $transfer = Money\Transfer::get($transferId);
         $transfer->user_id = \Users\User::$cur->id;
         $transfer->code = Tools::randomString();
         $transfer->save();
         $wallets = $this->money->getUserWallets();
         $text = 'Перевод средств для ' . $transfer->toUser->name();
         $wallets[$transfer->currency_id]->diff(-$transfer->amount, $text);
         \App::$cur->users->AddUserActivity($transfer->user_id, 4, $text . '<br />' . (double) $transfer->amount . ' ' . $wallets[$transfer->currency_id]->currency->acronym());
         $block = new Money\Wallet\Block();
         $block->wallet_id = $wallets[$transfer->currency_id]->id;
         $block->amount = $transfer->amount;
         $block->comment = 'Заблокированно на перевод средств для ' . $transfer->toUser->name();
         $block->data = 'Money\\Transfer:' . $transfer->id;
         $block->save();
         $from = 'noreply@' . INJI_DOMAIN_NAME;
         $to = \Users\User::$cur->mail;
         $subject = 'Подтверждение перевода';
         $text = 'Чтобы подтвержить перевод №' . $transfer->id . ' введите код <b>' . $transfer->code . '</b> на <a href = "http://' . INJI_DOMAIN_NAME . '/money/confirmTransfer/' . $transfer->id . '?code=' . $transfer->code . '">странице</a> перевода';
         Tools::sendMail($from, $to, $subject, $text);
         Tools::redirect('/money/confirmTransfer/' . $transfer->id);
     }
     $this->view->setTitle('Перевод средств');
     $this->view->page(['data' => compact('form')]);
 }
Ejemplo n.º 3
0
<h3>Мой профиль</h3>
<?php 
$form = new Ui\ActiveForm(Users\User::$cur, 'profile');
$form->header = '';
$form->checkRequest([], true);
$form->draw();