Compare View
Commits (3)
Showing
4 changed files
Show diff stats
backend/controllers/RequestController.php
... | ... | @@ -17,10 +17,10 @@ |
17 | 17 | 'class' => Index::class, |
18 | 18 | 'columns' => [ |
19 | 19 | 'name' => [ |
20 | - 'type' => Index::ACTION_COL, | |
20 | + 'type' => Index::ACTION_COL, | |
21 | 21 | 'columnConfig' => [ |
22 | - 'buttonsTemplate' => '{edit}{delete}' | |
23 | - ] | |
22 | + 'buttonsTemplate' => '{edit}{delete}', | |
23 | + ], | |
24 | 24 | ], |
25 | 25 | 'secondname' => [ |
26 | 26 | 'type' => Index::STRING_COL, | ... | ... |
1 | +<?php | |
2 | + | |
3 | + /** | |
4 | + * @var \yii\web\View $this | |
5 | + * @var \common\models\Customer $model | |
6 | + */ | |
7 | + | |
8 | + use common\models\Customer; | |
9 | + | |
10 | + $formatter = \Yii::$app->formatter; | |
11 | + | |
12 | +?> | |
13 | + | |
14 | +<table> | |
15 | + <tr> | |
16 | + <td><b>Фамилия</b> :</td> | |
17 | + <td><?= $formatter->asText($model->secondname) ?></td> | |
18 | + </tr> | |
19 | + <tr> | |
20 | + <td><b>Имя</b> :</td> | |
21 | + <td><?= $formatter->asText($model->name) ?></td> | |
22 | + </tr> | |
23 | + <tr> | |
24 | + <td><b>Титул</b> :</td> | |
25 | + <td><?= $formatter->asText($model->dignity) ?></td> | |
26 | + </tr> | |
27 | + <tr> | |
28 | + <td><b>Пол</b> :</td> | |
29 | + <td><?php | |
30 | + if ($model->gender === Customer::MALE) { | |
31 | + echo 'Мужской'; | |
32 | + } elseif ($model->gender === Customer::FEMALE) { | |
33 | + echo 'Женский'; | |
34 | + } else { | |
35 | + echo 'Не задано'; | |
36 | + } | |
37 | + ?></td> | |
38 | + </tr> | |
39 | + <tr> | |
40 | + <td><b>Дата рождения</b> :</td> | |
41 | + <td><?= $formatter->asText($model->birth) ?></td> | |
42 | + </tr> | |
43 | + <tr> | |
44 | + <td><b>Гражданство</b> :</td> | |
45 | + <td><?= $formatter->asText($model->citizenship) ?></td> | |
46 | + </tr> | |
47 | + <tr> | |
48 | + <td><b>Паспорт</b> :</td> | |
49 | + <td><?= $formatter->asText($model->passport) ?></td> | |
50 | + </tr> | |
51 | + <tr> | |
52 | + <td><b>Email</b> :</td> | |
53 | + <td><?= $formatter->asText($model->email) ?></td> | |
54 | + </tr> | |
55 | + <tr> | |
56 | + <td><b>Должность</b> :</td> | |
57 | + <td><?= $formatter->asText($model->organization) ?></td> | |
58 | + </tr> | |
59 | + <tr> | |
60 | + <td><b>Министерская конференция</b> :</td> | |
61 | + <td><?= $formatter->asBoolean($model->conference) ?></td> | |
62 | + </tr> | |
63 | + <tr> | |
64 | + <td><b>GEEE</b> :</td> | |
65 | + <td><?= $formatter->asBoolean($model->geee) ?></td> | |
66 | + </tr> | |
67 | + <tr> | |
68 | + <td><b>GERE</b> :</td> | |
69 | + <td><?= $formatter->asBoolean($model->gere) ?></td> | |
70 | + </tr> | |
71 | +</table> | ... | ... |
common/models/Customer.php
frontend/controllers/SiteController.php
1 | 1 | <?php |
2 | + | |
2 | 3 | namespace frontend\controllers; |
3 | 4 | |
4 | 5 | use artbox\core\models\Feedback; |
... | ... | @@ -12,7 +13,7 @@ |
12 | 13 | use yii\web\Controller; |
13 | 14 | use yii\web\Response; |
14 | 15 | use yii\web\UploadedFile; |
15 | - | |
16 | + | |
16 | 17 | /** |
17 | 18 | * Site controller |
18 | 19 | */ |
... | ... | @@ -52,10 +53,22 @@ |
52 | 53 | */ |
53 | 54 | public function actionIndex() |
54 | 55 | { |
55 | - $speakers = Speaker::find()->with(['language', 'image'])->where(['status' => true])->orderBy('sort')->all(); | |
56 | - return $this->render('index', [ | |
57 | - 'speakers' => $speakers | |
58 | - ]); | |
56 | + $speakers = Speaker::find() | |
57 | + ->with( | |
58 | + [ | |
59 | + 'language', | |
60 | + 'image', | |
61 | + ] | |
62 | + ) | |
63 | + ->where([ 'status' => true ]) | |
64 | + ->orderBy('sort') | |
65 | + ->all(); | |
66 | + return $this->render( | |
67 | + 'index', | |
68 | + [ | |
69 | + 'speakers' => $speakers, | |
70 | + ] | |
71 | + ); | |
59 | 72 | } |
60 | 73 | |
61 | 74 | /** |
... | ... | @@ -154,15 +167,64 @@ |
154 | 167 | public function actionRegister() |
155 | 168 | { |
156 | 169 | $model = new Customer(); |
157 | - if ($model->load(\Yii::$app->request->post())){ | |
158 | - $model->file = UploadedFile::getInstance($model, 'file'); | |
159 | - if ($model->upload() and $model->save()){ | |
160 | - \Yii::$app->session->setFlash('success', \Yii::t('app', 'Дякуемо за реєстрацію. Підтвердження участі буде відправлено на вказаний email')); | |
161 | - return $this->redirect(['site/index']); | |
170 | + if ($model->load(\Yii::$app->request->post())) { | |
171 | + $model->file = UploadedFile::getInstance($model, 'file'); | |
172 | + if ($model->upload() and $model->save()) { | |
173 | + \Yii::$app->session->setFlash( | |
174 | + 'success', | |
175 | + \Yii::t( | |
176 | + 'app', | |
177 | + 'Дякуемо за реєстрацію. Підтвердження участі буде відправлено на вказаний email' | |
178 | + ) | |
179 | + ); | |
180 | + | |
181 | + try { | |
182 | + $this->mail($model); | |
183 | + } catch (\Exception $exception) { | |
184 | + \Yii::error($exception->getMessage() . '. On request: ' . $model->id); | |
185 | + | |
186 | + return $this->redirect([ 'site/index' ]); | |
187 | + } catch (\Throwable $throwable) { | |
188 | + \Yii::error($throwable->getMessage() . '. On request: ' . $model->id); | |
189 | + | |
190 | + return $this->redirect([ 'site/index' ]); | |
191 | + } | |
192 | + | |
193 | + return $this->redirect([ 'site/index' ]); | |
162 | 194 | } |
163 | 195 | } |
164 | - return $this->render('signup', [ | |
165 | - 'model' => $model | |
166 | - ]); | |
196 | + return $this->render( | |
197 | + 'signup', | |
198 | + [ | |
199 | + 'model' => $model, | |
200 | + ] | |
201 | + ); | |
202 | + } | |
203 | + | |
204 | + /** | |
205 | + * @param $model Customer | |
206 | + */ | |
207 | + public function mail($model) | |
208 | + { | |
209 | + \Yii::$app->mailer->compose( | |
210 | + 'request', | |
211 | + [ | |
212 | + 'model' => $model, | |
213 | + ] | |
214 | + ) | |
215 | + ->setFrom( | |
216 | + [ | |
217 | + 'artboxcore@gmail.com' => 'Artbox Core', | |
218 | + ] | |
219 | + ) | |
220 | + ->setTo( | |
221 | + [ | |
222 | + 'kennen.md@gmail.com', | |
223 | + 'kazimirova.artweb@gmail.com', | |
224 | + ] | |
225 | + ) | |
226 | + ->setSubject('U have request!') | |
227 | + ->attach(\Yii::getAlias('@' . trim($model->image, '/'))) | |
228 | + ->send(); | |
167 | 229 | } |
168 | 230 | } | ... | ... |