From 1bd8578320c94e1d23bcb45a7450246577eea963 Mon Sep 17 00:00:00 2001 From: "Gustavo G. Andrade" Date: Sun, 26 Apr 2015 18:46:54 -0300 Subject: [PATCH] Added: setFlash messages --- controllers/CashbookController.php | 5 ++++- controllers/CategoryController.php | 3 +++ messages/pt/app.php | 6 ++++++ views/cashbook/index.php | 7 +++++++ views/cashbook/view.php | 6 ++++++ views/category/index.php | 7 +++++++ 6 files changed, 33 insertions(+), 1 deletion(-) diff --git a/controllers/CashbookController.php b/controllers/CashbookController.php index 927cd73..9b55311 100644 --- a/controllers/CashbookController.php +++ b/controllers/CashbookController.php @@ -89,7 +89,8 @@ public function actionCreate() $path = $model->getImageFile(); $file->saveAs($path); } - return $this->redirect(['view', 'id'=>$model->id]); + Yii::$app->session->setFlash("Entry-success", Yii::t("app", "Entry successfully included")); + return $this->redirect(['index']); } else { // error in saving model } @@ -129,6 +130,7 @@ public function actionUpdate($id) $path = $model->getImageFile(); $file->saveAs($path); } + Yii::$app->session->setFlash("Entry-success", Yii::t("app", "Entry updated")); return $this->redirect(['view', 'id'=>$model->id]); } else { // error in saving model @@ -156,6 +158,7 @@ public function actionDelete($id) Yii::$app->session->setFlash('error', 'Error deleting image'); } } + Yii::$app->session->setFlash("Entry-success", Yii::t("app", "Entry successfully deleted")); return $this->redirect(['index']); } diff --git a/controllers/CategoryController.php b/controllers/CategoryController.php index 6a3525f..a8ebc43 100644 --- a/controllers/CategoryController.php +++ b/controllers/CategoryController.php @@ -84,6 +84,7 @@ public function actionCreate() $model->user_id = Yii::$app->user->identity->id; if ($model->load(Yii::$app->request->post()) && $model->save()) { + Yii::$app->session->setFlash("Category-success", Yii::t("app", "Category successfully included")); return $this->redirect(['index']); } else { return $this->render('create', [ @@ -103,6 +104,7 @@ public function actionUpdate($id) $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { + Yii::$app->session->setFlash("Category-success", Yii::t("app", "Category updated")); return $this->redirect(['index']); } else { return $this->render('update', [ @@ -120,6 +122,7 @@ public function actionUpdate($id) public function actionDelete($id) { $this->findModel($id)->delete(); + Yii::$app->session->setFlash("Category-success", Yii::t("app", "Category successfully deleted")); return $this->redirect(['index']); } diff --git a/messages/pt/app.php b/messages/pt/app.php index 22f62db..f07f77b 100644 --- a/messages/pt/app.php +++ b/messages/pt/app.php @@ -53,8 +53,14 @@ 'No entries found!' => 'Nenhum lançamento encontrado!', 'Basic Information' => 'Informações Básicas', 'Additional' => 'Complementares', + 'Entry successfully included' => 'Lançamento incluído com sucesso', + 'Entry updated' => 'Lançamento atualizado', + 'Entry successfully deleted' => 'Lançamento excluído com sucesso', // category model 'Hex Color' => 'Hex Cor', + 'Category successfully included' => 'Categoria incluída com sucesso', + 'Category updated' => 'Categoria atualizada', + 'Category successfully deleted' => 'Categoria excluído com sucesso', // view / site 'Overview' => 'Visão Geral', 'Monthly Summary' => 'Resumo Mensal', diff --git a/views/cashbook/index.php b/views/cashbook/index.php index 4382c25..c1c5182 100644 --- a/views/cashbook/index.php +++ b/views/cashbook/index.php @@ -29,6 +29,13 @@ '.Yii::t('app', 'Entry').'', ['/cashbook/create'], ['class'=>'btn btn-primary grid-button btn-sm pull-right']) ?>
+ session->getFlash("Entry-success")): ?> + +
+

+
+ + $dataProvider, 'tableOptions' => ['class'=>'table table-striped table-hover'], diff --git a/views/cashbook/view.php b/views/cashbook/view.php index 41e24e6..deded8e 100644 --- a/views/cashbook/view.php +++ b/views/cashbook/view.php @@ -31,7 +31,13 @@
+ session->getFlash("Entry-success")): ?> +
+

+
+ + $model, 'attributes' => [ diff --git a/views/category/index.php b/views/category/index.php index 0717445..84371b2 100644 --- a/views/category/index.php +++ b/views/category/index.php @@ -16,6 +16,13 @@ '.Yii::t('app', 'Category').'', ['/category/create'], ['class'=>'btn btn-primary grid-button btn-sm pull-right']) ?>
+ session->getFlash("Category-success")): ?> + +
+

+
+ + $dataProvider, //'filterModel' => $searchModel,