public function loadTranslation() { if (!$this->validate()) { Alert::addError('Translation has not been loaded', $this->errors); return false; } $xlsImport = new xlsImport(Yii::$app->controller, Yii::$app->request->referrer, SourceMessage::className(), KReader::className(), $this, 'file', $this->isUpdate); $xlsImport->run(); return true; }
public function actionDelete($id, $language) { $model = $this->findModel(Message::className(), ['id' => $id, 'language' => $language]); if ($model->delete()) { Alert::addSuccess(Yii::t('messages', 'Translation has been successfully deleted')); } else { Alert::addError(Yii::t('messages', 'Translation has not been deleted')); } return $this->redirect(Yii::$app->request->referrer); }
public function createMessage() { if (!$this->validate()) { Alert::addError(Yii::t('messages', 'Translation has not been saved'), $this->errors); return false; } $sourceMessage = new SourceMessage(); $sourceMessage->language = $this->language; $sourceMessage->category = $this->category; $sourceMessage->message = $this->source_message; $sourceMessage->messageTranslation = $this->translation; if (!$sourceMessage->save()) { Alert::addError(Yii::t('messages', 'Translation has not been saved'), $sourceMessage->errors); } return false; }
public function afterSave($insert) { $this->activeAttributes(); if ($insert) { $message = new Message(); } else { $message = Message::findOne(['id' => $this->id, 'language' => $this->language]); if (!$message instanceof Message) { $message = new Message(); } } $message->id = $this->id; $message->language = $this->language; $message->translation = $this->messageTranslation; if ($message->save()) { Alert::addSuccess(Yii::t('messages', 'Translation has been saved')); self::commitLocalTransaction(); return true; } Alert::addError(Yii::t('messages', 'Translation has not been saved'), $message->errors); self::rollbackLocalTransaction(); throw new BadRequestHttpException(Alert::popError()); }
public function actionMassDelete() { $url = Yii::$app->request->getQueryParam('url'); if (isset($_POST['keys'])) { foreach ($_POST['keys'] as $key) { try { $model = $this->findModel(ClientBeacons::className(), $key); if ($model) { if ($model->delete()) { Alert::addSuccess("Items has been successfully deleted"); } } } catch (Exception $e) { Alert::addError('Item has not been deleted', $e->getMessage()); } } } return $this->redirect($url); }
public function actionMassDelete() { if (isset($_POST['keys'])) { foreach ($_POST['keys'] as $key) { try { $model = $this->findModel(ClientUsers::className(), $key); if ($model) { if ($model->delete()) { Alert::addSuccess("Items has been successfully deleted"); } } } catch (Exception $e) { Alert::addError('Item has not been deleted', $e->getMessage()); } } } return $this->redirect(['list']); }
public function actionPasswordChange($token) { try { $model = new PasswordChangeForm($token); } catch (InvalidParamException $e) { throw new BadRequestHttpException('Wrong password reset token.'); } if ($model->load(Yii::$app->request->post())) { if ($model->validate() && $model->changePassword()) { Alert::addSuccess('New password was saved.'); return $this->goHome(); } else { Alert::addError('Password hasn\'t been saved.'); return $this->goHome(); } } return $this->render('password-change', ['model' => $model]); }
public function run() { if (!self::prepareFile()) { return false; } self::setIsUpdate(); $this->transaction = Yii::$app->getDb()->beginTransaction(); $this->xlsRowToDb(); if (count($this->errors) || $this->error) { $this->transaction->rollback(); $error_array = array(); if (count($this->errors)) { $error_array[] = $this->errors; } if (count($this->error)) { $error_array[] = $this->error; } Alert::addError(Yii::t('messages', 'Your request ends with errors'), $error_array); return $this->controller->redirect(Url::to([$this->base_url])); } else { $this->transaction->commit(); if (count($this->warnings)) { Alert::addWarning(Yii::t('messages', 'Your request ends with warnings'), $this->warnings); } return $this->controller->redirect(Url::to([$this->base_url])); } }
/** * */ public function actionSaveMap() { $model = new BeaconMapLoad(); $model->load(Yii::$app->request->post()); if ($model->saveMap()) { Alert::addSuccess(Yii::t('messages', ':map_load')); } else { Alert::addError(Yii::t('messages', ':map_not_load')); } return $this->redirect(['map']); }