From b32c8ed844196232e9c303f476e517aafa8dbece Mon Sep 17 00:00:00 2001 From: captainbeer Date: Thu, 30 Aug 2018 18:14:51 +0300 Subject: [PATCH] -Testing email --- backend/controllers/RequestController.php | 6 +++--- common/mail/request.php | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ frontend/controllers/SiteController.php | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 134 insertions(+), 16 deletions(-) create mode 100644 common/mail/request.php diff --git a/backend/controllers/RequestController.php b/backend/controllers/RequestController.php index 639bf34..7d33aba 100644 --- a/backend/controllers/RequestController.php +++ b/backend/controllers/RequestController.php @@ -17,10 +17,10 @@ 'class' => Index::class, 'columns' => [ 'name' => [ - 'type' => Index::ACTION_COL, + 'type' => Index::ACTION_COL, 'columnConfig' => [ - 'buttonsTemplate' => '{edit}{delete}' - ] + 'buttonsTemplate' => '{edit}{delete}', + ], ], 'secondname' => [ 'type' => Index::STRING_COL, diff --git a/common/mail/request.php b/common/mail/request.php new file mode 100644 index 0000000..1daf4e0 --- /dev/null +++ b/common/mail/request.php @@ -0,0 +1,71 @@ +formatter; + +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Фамилия :asText($model->secondname) ?>
Имя :asText($model->name) ?>
Титул :asText($model->dignity) ?>
Пол :gender === Customer::MALE) { + echo 'Мужской'; + } elseif ($model->gender === Customer::FEMALE) { + echo 'Женский'; + } else { + echo 'Не задано'; + } + ?>
Дата рождения :asText($model->birth) ?>
Гражданство :asText($model->citizenship) ?>
Паспорт :asText($model->passport) ?>
Email :asText($model->email) ?>
Должность :asText($model->organization) ?>
Министерская конференция :asBoolean($model->conference) ?>
GEEE :asBoolean($model->geee) ?>
GERE :asBoolean($model->gere) ?>
diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 2f6e456..fe2528c 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -1,4 +1,5 @@ with(['language', 'image'])->where(['status' => true])->orderBy('sort')->all(); - return $this->render('index', [ - 'speakers' => $speakers - ]); + $speakers = Speaker::find() + ->with( + [ + 'language', + 'image', + ] + ) + ->where([ 'status' => true ]) + ->orderBy('sort') + ->all(); + return $this->render( + 'index', + [ + 'speakers' => $speakers, + ] + ); } /** @@ -154,15 +167,49 @@ public function actionRegister() { $model = new Customer(); - if ($model->load(\Yii::$app->request->post())){ - $model->file = UploadedFile::getInstance($model, 'file'); - if ($model->upload() and $model->save()){ - \Yii::$app->session->setFlash('success', \Yii::t('app', 'Дякуемо за реєстрацію. Підтвердження участі буде відправлено на вказаний email')); - return $this->redirect(['site/index']); + if ($model->load(\Yii::$app->request->post())) { + $model->file = UploadedFile::getInstance($model, 'file'); + if ($model->upload() and $model->save()) { + \Yii::$app->session->setFlash( + 'success', + \Yii::t( + 'app', + 'Дякуемо за реєстрацію. Підтвердження участі буде відправлено на вказаний email' + ) + ); + + $this->mail($model); + + return $this->redirect([ 'site/index' ]); } } - return $this->render('signup', [ - 'model' => $model - ]); + return $this->render( + 'signup', + [ + 'model' => $model, + ] + ); + } + + /** + * @param $model Customer + */ + public function mail($model) + { + \Yii::$app->mailer->compose( + 'request', + [ + 'model' => $model, + ] + ) + ->setFrom( + [ + 'artboxcore@gmail.com' => 'Artbox Core', + ] + ) + ->setTo('kennen.md@gmail.com') + ->setSubject('U have request!') + ->attach(\Yii::getAlias('@' . trim($model->image, '/'))) + ->send(); } } -- libgit2 0.21.4