public function actionEditAccount() { $user = User::model()->findByPk(Yii::app()->user->id); $model = new AccountForm(); $model->user = $user; if (isset($_POST['AccountForm']) && isset($_POST['User'])) { $model->user->attributes = $_POST['User']; $model->attributes = $_POST['AccountForm']; if ($model->validate() && $model->save()) { $model->user->setState(Yii::app()->user, true); Yii::app()->user->setFlash('success', Yii::t('app', 'msg.success.update_account_info')); $this->refresh(true); } } $this->render('application.modules.account.views.common.profile.editAccount', array('model' => $model)); }
/** * @inheritDoc */ public function init() { parent::init(); $user = $this->_user; $this->lastName = $user->lastName; $this->firstName = $user->firstName; $this->middleName = $user->middleName; $this->division = $user->division; $this->post = $user->post; $this->phone = $user->phone; $this->mobile = $user->mobile; }
public function editAction($id) { $account = Account::findFirst(array("conditions" => "idAccount = ?1", "bind" => array(1 => $id))); if (!$account) { $this->flashSession->warning('La cuenta que desea editar no existe, por favor valide la información'); return $this->response->redirect('account'); } $form = new AccountForm($account); if ($this->request->isPost()) { $form->bind($this->request->getPost(), $account); $status = $form->getValue('status2'); $account->status = empty($status) || !$status ? 0 : 1; $account->updated = time(); if ($form->isValid() && $account->save()) { $this->flashSession->success("Se ha editado la cuenta exitosamente"); return $this->response->redirect("account"); } foreach ($account->getMessages() as $msg) { $this->flashSession->error($msg); } } $this->view->AccountForm = $form; $this->view->setVar("account", $account); }
public function updateAction($id) { $account = Account::findFirst(array('conditions' => "idAccount = ?0", 'bind' => array($id))); $this->validateModel($account, "No existe una cuenta con el id: {$id}", "account"); $accountForm = new AccountForm($account); $this->view->accountForm = $accountForm; $this->view->setVar("account", $account); if ($this->request->isPost()) { try { $accountForm->bind($this->request->getPost(), $account); $status = $accountForm->getValue('st'); $account->status = empty($status) ? 0 : 1; if ($this->saveModel($currency, "Se ha editado cuenta <em><strong>{$account->name}</strong></em> exitosamente")) { return $this->response->redirect("account"); } } catch (InvalidArgumentException $ex) { $this->flashSession->error($ex->getMessage()); } catch (Exception $ex) { $this->flashSession->error("Ha ocurrido un error, por favor contacta al administrador"); $this->logger->log($ex->getMessage()); $this->logger->log("Exception while creating currency: " . $ex->getTraceAsString()); } } }
public function signupAction() { $account = new Account(); $accountForm = new AccountForm($account); $this->view->accountForm = $accountForm; $user = new User(); $userForm = new UserForm($user); $this->view->userForm = $userForm; $this->view->setVar("tab", 0); if ($this->request->isPost()) { try { $this->db->begin(); $accountForm->bind($this->request->getPost(), $account); $userForm->bind($this->request->getPost(), $user); $idAccountplan = $accountForm->getValue('idAccountplan'); $idAccounttype = $accountForm->getValue('idAccounttype'); $city = $accountForm->getValue('city'); $pass1 = $userForm->getValue('pass1'); $pass2 = $userForm->getValue('pass2'); $email = $this->request->getPost('email'); $this->validateEqualsPassword($pass1, $pass2); $this->validateFields(array($idAccounttype, $idAccountplan, $city), array("Debes seleccionar un tipo de cuenta", "Debes seleccionar un plan de pago, recuerda que tenemos algunos gratuitos", "Debes seleccionar una ciudad")); if ($this->saveAccount($account, $accountForm, $userForm)) { if ($this->saveUser($user, $account)) { $file = $_FILES['avatar']; $ext = explode("/", $file['type']); $file['newName'] = "{$user->idUser}.{$ext[1]}"; $dir = $this->uploader->user_avatar_dir . "/" . $user->idUser . "/images/avatar/"; $uploader = new \Sayvot\Misc\Uploader(); $uploader->setExtensionsAllowed(array("png", "jpg", "jpeg")); $uploader->setFile($file); $uploader->setMaxSizeSupported($this->uploader->images_max_size); $uploader->setDir($dir); $uploader->validate(); $uploader->upload(); if ($this->saveCredential($user, $email, $pass1)) { $this->db->commit(); $pe = new \Sayvot\Misc\ParametersEncoder(); $link = $pe->encodeLink("account/verify", array($account->idAccount, $user->idUser)); $this->flashSession->warning($link); return $this->response->redirect("session/login"); } } } } catch (InvalidArgumentException $ex) { $this->flashSession->error($ex->getMessage()); $this->db->rollback(); } catch (Exception $ex) { $this->db->rollback(); $this->flashSession->error("Ha ocurrido un error, por favor contacta al administrador"); $this->logger->log("Exception while creating account: " . $ex->getMessage()); $this->logger->log($ex->getTraceAsString()); } } }
/** * @inheritDoc */ public function init() { parent::init(); $this->email = $this->_user->email; }
public function put_update() { $account = Account::find(Input::get('id')); if (!$account) { return Redirect::to_action('accounts@index'); } # Set id to ignore on unique rules AccountForm::set('current_id', $account->id); if (!AccountForm::is_valid()) { return Redirect::back()->with_input()->with_errors(AccountForm::$validation); } $account->name = Input::get('name'); $account->account_number = Input::get('account_number'); $account->account_type = Input::get('account_type'); $account->secretary = Input::get('secretary'); $account->treasurer = Input::get('treasurer'); $account->announcement = Input::get('announcement'); $account->save(); return Redirect::to_action('accounts@index'); }
/** * @inheritDoc */ public function attributeLabels() { return array_merge(parent::attributeLabels(), ['password' => 'Новый пароль', 'password_repeat' => 'Новый пароль повторно']); }
public function editAction($idAccount) { $editAccount = Account::findFirst(array("conditions" => "idAccount = ?1", "bind" => array(1 => $idAccount))); if (!$editAccount) { $this->flashSession->error('La cuenta a la que intenta acceder no existe, por favor valide la información.'); return $this->response->redirect('account/index'); } $this->view->setVar('account_value', $editAccount); $editAccount->city = $editAccount->city; $editAccount->state = $editAccount->state; $accountForm = new AccountForm($editAccount); if ($this->request->isPost()) { $accountForm->bind($this->request->getPost(), $editAccount); try { $editAccount->updated = time(); if (!$this->request->getPost('status')) { $editAccount->status = 0; } if (!$editAccount->save()) { $this->trace("fail", "Error al editar una cuenta con ID: " . $editAccount->idAccount); foreach ($editAccount->getMessages() as $msg) { throw new Exception($msg); } } } catch (Exception $ex) { $this->flashSession->error($ex->getMessage()); $this->trace("fail", "Ha ocurrido un error: " . $ex->getMessage()); throw new Exception('Ha ocurrido un error'); } $this->trace("success", "Se edito la cuenta con ID: " . $editAccount->idAccount); $this->flashSession->success('Se ha editado exitosamente la cuenta <strong>' . $editAccount->name . '</strong>'); return $this->response->redirect('account/index'); } $this->view->accountForm = $accountForm; }