Commit 08d25902322dd7ad117dcb5c85f2d141ab9a1559

Authored by Alexey Boroda
1 parent 06df1d06

-Send mail ready

backend/controllers/RequestController.php
@@ -16,18 +16,18 @@ @@ -16,18 +16,18 @@
16 'index' => [ 16 'index' => [
17 'class' => Index::class, 17 'class' => Index::class,
18 'columns' => [ 18 'columns' => [
19 - 'id' => [  
20 - 'type' => Index::NUMBER_COL,  
21 -  
22 - ],  
23 - 'name' => [ 19 + 'id' => [
  20 + 'type' => Index::NUMBER_COL,
  21 +
  22 + ],
  23 + 'name' => [
24 'type' => Index::ACTION_COL, 24 'type' => Index::ACTION_COL,
25 'columnConfig' => [ 25 'columnConfig' => [
26 #'buttonsTemplate' => '{edit}{delete}', 26 #'buttonsTemplate' => '{edit}{delete}',
27 'buttonsTemplate' => '{edit}', 27 'buttonsTemplate' => '{edit}',
28 ], 28 ],
29 ], 29 ],
30 - 30 +
31 'organization' => [ 31 'organization' => [
32 'type' => Index::STRING_COL, 32 'type' => Index::STRING_COL,
33 ], 33 ],
@@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
37 'enableMassDelete' => true, 37 'enableMassDelete' => true,
38 'modelPrimaryKey' => 'id', 38 'modelPrimaryKey' => 'id',
39 'create' => false, 39 'create' => false,
40 - 'defaultSort' => ['id' => SORT_DESC] 40 + 'defaultSort' => [ 'id' => SORT_DESC ],
41 ], 41 ],
42 ]; 42 ];
43 } 43 }
@@ -46,6 +46,23 @@ @@ -46,6 +46,23 @@
46 { 46 {
47 $model = $this->findModel($id); 47 $model = $this->findModel($id);
48 48
  49 + $model->scenario = Customer::ADMIN_SCENARIO;
  50 +
  51 + $request = \Yii::$app->request;
  52 +
  53 + $wasNew = (strval($model->status) === '2');
  54 +
  55 + if ($request->isPost) {
  56 + if ($model->load($request->post()) && $model->save()) {
  57 +
  58 + if ($wasNew && (strval($model->status) === '1' )) {
  59 + $this->mail($model->email);
  60 + }
  61 +
  62 + return $this->redirect([ 'index' ]);
  63 + }
  64 + }
  65 +
49 return $this->render( 66 return $this->render(
50 'update', 67 'update',
51 [ 68 [
@@ -96,4 +113,8 @@ @@ -96,4 +113,8 @@
96 return false; 113 return false;
97 } 114 }
98 } 115 }
  116 +
  117 + public function mail($email) {
  118 +
  119 + }
99 } 120 }
100 \ No newline at end of file 121 \ No newline at end of file
common/models/Customer.php
@@ -5,71 +5,63 @@ @@ -5,71 +5,63 @@
5 use Yii; 5 use Yii;
6 use yii\helpers\FileHelper; 6 use yii\helpers\FileHelper;
7 use yii\behaviors\TimestampBehavior; 7 use yii\behaviors\TimestampBehavior;
8 -  
9 - 8 +
10 /** 9 /**
11 * This is the model class for table "customer". 10 * This is the model class for table "customer".
12 * 11 *
13 - * @property int $id  
14 - * @property string $name  
15 - * @property string $secondname  
16 - * @property string $dignity  
17 - * @property int $gender  
18 - * @property string $birth  
19 - * @property string $citizenship  
20 - * @property string $passport  
21 - * @property string $email  
22 - * @property string $organization  
23 - * @property int $status  
24 - * @property int $language_id  
25 - * @property string $image  
26 - * @property bool $conference  
27 - * @property bool $geee  
28 - * @property bool $gere  
29 - *  
30 - * 12 + * @property int $id
  13 + * @property string $name
  14 + * @property string $secondname
  15 + * @property string $dignity
  16 + * @property int $gender
  17 + * @property string $birth
  18 + * @property string $citizenship
  19 + * @property string $passport
  20 + * @property string $email
  21 + * @property string $organization
  22 + * @property int $status
  23 + * @property int $language_id
  24 + * @property string $image
  25 + * @property bool $conference
  26 + * @property bool $geee
  27 + * @property bool $gere
31 * New properties 28 * New properties
32 - * @property string $phone_own  
33 - * @property string $phone_office  
34 - * @property string $phone_other  
35 - * @property string $fax 29 + * @property string $phone_own
  30 + * @property string $phone_office
  31 + * @property string $phone_other
  32 + * @property string $fax
36 * @property integer $passport_number 33 * @property integer $passport_number
37 * @property integer $passport_date 34 * @property integer $passport_date
38 - * @property string $passport_place 35 + * @property string $passport_place
39 * @property integer $passport_valid 36 * @property integer $passport_valid
40 * @property boolean $need_visa 37 * @property boolean $need_visa
41 - * @property string $special_meal  
42 - *  
43 - * @property boolean $working_language_ru  
44 - * @property boolean $working_language_en  
45 - * @property boolean $working_language_fr  
46 - * @property boolean $meal_halal  
47 - * @property boolean $meal_kashrut  
48 - * @property boolean $meal_vegan  
49 - *  
50 - * @property integer $working_lang  
51 - * @property string $post_address ==> ะพั„ะธั†ะธะฐะปัŒะฝั‹ะน ะฟะพั‡ั‚ะพะฒั‹ะน ะฐะดั€ะตั  
52 - *  
53 - * @property integer $created_at  
54 - * 38 + * @property string $special_meal
  39 + * @property boolean $working_language_ru
  40 + * @property boolean $working_language_en
  41 + * @property boolean $working_language_fr
  42 + * @property boolean $meal_halal
  43 + * @property boolean $meal_kashrut
  44 + * @property boolean $meal_vegan
  45 + * @property integer $working_lang
  46 + * @property string $post_address ==> ะพั„ะธั†ะธะฐะปัŒะฝั‹ะน ะฟะพั‡ั‚ะพะฒั‹ะน ะฐะดั€ะตั
  47 + * @property integer $created_at
55 */ 48 */
56 class Customer extends \yii\db\ActiveRecord 49 class Customer extends \yii\db\ActiveRecord
57 { 50 {
58 public $file; 51 public $file;
59 - 52 +
60 public $acceptance; 53 public $acceptance;
61 - 54 +
  55 + const ADMIN_SCENARIO = 'admin';
  56 +
62 const STATUS_NEW = 2; 57 const STATUS_NEW = 2;
63 const STATUS_ACTIVE = 1; 58 const STATUS_ACTIVE = 1;
64 const STATUS_NO = 0; 59 const STATUS_NO = 0;
65 - 60 +
66 const MEAL_1 = 'ะฅะฐะปัะปัŒ'; 61 const MEAL_1 = 'ะฅะฐะปัะปัŒ';
67 const MEAL_2 = 'ะšะฐัˆั€ัƒั‚'; 62 const MEAL_2 = 'ะšะฐัˆั€ัƒั‚';
68 const MEAL_3 = 'ะ’ะตะณะธั‚ะฐั€ะธะฐะฝะตั†ัŒ'; 63 const MEAL_3 = 'ะ’ะตะณะธั‚ะฐั€ะธะฐะฝะตั†ัŒ';
69 - const MEAL_NONE = 'ะะต ะฒั‹ะฑั€ะฐะฝะพ';  
70 -  
71 -  
72 - 64 + const MEAL_NONE = 'ะะต ะฒั‹ะฑั€ะฐะฝะพ';
73 65
74 const MALE = '1'; 66 const MALE = '1';
75 const FEMALE = '2'; 67 const FEMALE = '2';
@@ -80,21 +72,18 @@ @@ -80,21 +72,18 @@
80 { 72 {
81 return 'customer'; 73 return 'customer';
82 } 74 }
83 -  
84 -  
85 - 75 +
86 public function behaviors() 76 public function behaviors()
87 { 77 {
88 - return [  
89 - [  
90 - 'class' => TimestampBehavior::className(),  
91 - 'updatedAtAttribute' => false,  
92 - ],  
93 - ]; 78 + return [
  79 + [
  80 + 'class' => TimestampBehavior::className(),
  81 + 'updatedAtAttribute' => false,
  82 + ],
  83 + ];
94 } 84 }
95 -  
96 -  
97 - /** 85 +
  86 + /**
98 * {@inheritdoc} 87 * {@inheritdoc}
99 */ 88 */
100 public function rules() 89 public function rules()
@@ -114,8 +103,8 @@ @@ -114,8 +103,8 @@
114 'gender', 103 'gender',
115 'status', 104 'status',
116 'language_id', 105 'language_id',
117 - 'acceptance',  
118 - 'working_lang' 106 + 'acceptance',
  107 + 'working_lang',
119 ], 108 ],
120 'integer', 109 'integer',
121 ], 110 ],
@@ -128,18 +117,18 @@ @@ -128,18 +117,18 @@
128 'conference', 117 'conference',
129 'geee', 118 'geee',
130 'gere', 119 'gere',
131 - 'need_visa',  
132 - 'working_language_ru',  
133 - 'working_language_en',  
134 - 'working_language_fr',  
135 - 'meal_halal',  
136 - 'meal_kashrut',  
137 - 'meal_vegan',  
138 - 120 + 'need_visa',
  121 + 'working_language_ru',
  122 + 'working_language_en',
  123 + 'working_language_fr',
  124 + 'meal_halal',
  125 + 'meal_kashrut',
  126 + 'meal_vegan',
  127 +
139 ], 128 ],
140 'boolean', 129 'boolean',
141 ], 130 ],
142 - 131 +
143 [ 132 [
144 [ 133 [
145 'name', 134 'name',
@@ -150,27 +139,27 @@ @@ -150,27 +139,27 @@
150 'passport', 139 'passport',
151 'email', 140 'email',
152 'image', 141 'image',
153 - 'passport_place',  
154 - 'special_meal',  
155 - 'passport_number',  
156 - 'passport_date',  
157 - 'passport_valid',  
158 - 'post_address' 142 + 'passport_place',
  143 + 'special_meal',
  144 + 'passport_number',
  145 + 'passport_date',
  146 + 'passport_valid',
  147 + 'post_address',
159 ], 148 ],
160 'string', 149 'string',
161 'max' => 255, 150 'max' => 255,
162 ], 151 ],
163 - [  
164 - [  
165 - 'phone_own',  
166 - 'phone_office',  
167 - 'phone_other',  
168 - 'fax'  
169 - ],  
170 - 'string',  
171 - 'max' => 30,  
172 - ],  
173 - 152 + [
  153 + [
  154 + 'phone_own',
  155 + 'phone_office',
  156 + 'phone_other',
  157 + 'fax',
  158 + ],
  159 + 'string',
  160 + 'max' => 30,
  161 + ],
  162 +
174 [ 163 [
175 [ 'gender' ], 164 [ 'gender' ],
176 'in', 165 'in',
@@ -189,29 +178,55 @@ @@ -189,29 +178,55 @@
189 'citizenship', 178 'citizenship',
190 #'passport', 179 #'passport',
191 'email', 180 'email',
192 - 'post_address',  
193 - 'passport_number',  
194 - 'passport_date',  
195 - 'passport_place',  
196 - 'passport_valid',  
197 - 'need_visa',  
198 - 'acceptance',  
199 - 'phone_office',  
200 - 'phone_other',  
201 - 'need_visa' 181 + 'post_address',
  182 + 'passport_number',
  183 + 'passport_date',
  184 + 'passport_place',
  185 + 'passport_valid',
  186 + 'need_visa',
  187 + 'phone_office',
  188 + 'phone_other',
  189 + 'need_visa',
202 ], 190 ],
203 'required', 191 'required',
204 ], 192 ],
205 - [['phone_office',  
206 - 'phone_other'  
207 - ],'match','pattern'=>'#^[\d\s]+$#'],  
208 - [  
209 - ['acceptance'],  
210 - 'compare',  
211 - 'compareValue' => 1  
212 - ],  
213 - ['email', 'email'],  
214 - ['file', 'file', 'skipOnEmpty' => false, 'checkExtensionByMimeType'=>false,'extensions' => ['png', 'jpg', 'gif'], 'maxSize' => 1024*1024*1024*2] 193 + [
  194 + [
  195 + 'acceptance',
  196 + ],
  197 + 'required',
  198 + 'except' => self::ADMIN_SCENARIO,
  199 + ],
  200 + [
  201 + [
  202 + 'phone_office',
  203 + 'phone_other',
  204 + ],
  205 + 'match',
  206 + 'pattern' => '#^[\d\s]+$#',
  207 + ],
  208 + [
  209 + [ 'acceptance' ],
  210 + 'compare',
  211 + 'compareValue' => 1,
  212 + ],
  213 + [
  214 + 'email',
  215 + 'email',
  216 + ],
  217 + [
  218 + 'file',
  219 + 'file',
  220 + 'skipOnEmpty' => false,
  221 + 'checkExtensionByMimeType' => false,
  222 + 'extensions' => [
  223 + 'png',
  224 + 'jpg',
  225 + 'gif',
  226 + ],
  227 + 'maxSize' => 1024 * 1024 * 1024 * 2,
  228 + 'except' => self::ADMIN_SCENARIO,
  229 + ],
215 230
216 ]; 231 ];
217 } 232 }
@@ -222,57 +237,58 @@ @@ -222,57 +237,58 @@
222 public function attributeLabels() 237 public function attributeLabels()
223 { 238 {
224 return [ 239 return [
225 - 'id' => Yii::t('app', 'ID'),  
226 - 'name' => Yii::t('app', 'Name'),  
227 - 'secondname' => Yii::t('app', 'Secondname'),  
228 - 'dignity' => Yii::t('app', 'Dignity'),  
229 - 'gender' => Yii::t('app', 'Gender'),  
230 - 'birth' => Yii::t('app', 'Birth'),  
231 - 'citizenship' => Yii::t('app', 'Citizenship'),  
232 - 'passport' => Yii::t('app', 'Passport'),  
233 - 'email' => Yii::t('app', 'Email'),  
234 - 'organization' => Yii::t('app', 'Organization'),  
235 - 'status' => Yii::t('app', 'Status'),  
236 - 'language_id' => Yii::t('app', 'Language ID'),  
237 - 'image' => Yii::t('app', 'Image'),  
238 - 'conference' => Yii::t('app', 'Conference'),  
239 - 'geee' => Yii::t('app', 'Geee'),  
240 - 'gere' => Yii::t('app', 'Gere'),  
241 - 'need_visa' => Yii::t('app', 'Need visa'),  
242 - 'passport_number' => Yii::t('app', 'Passport number'),  
243 - 'passport_date' => Yii::t('app', 'Passport date'),  
244 - 'passport_place' => Yii::t('app', 'Passport place'),  
245 - 'passport_valid' => Yii::t('app', 'Passport valid'),  
246 - 'phone_own' => Yii::t('app', 'Phone own'),  
247 - 'phone_office' => Yii::t('app', 'Phone office'),  
248 - 'phone_other' => Yii::t('app', 'Phone other'),  
249 - 'fax' => Yii::t('app', 'fax'),  
250 - 'acceptance' => Yii::t('app', 'acceptance'),  
251 - 'working_lang' => Yii::t('app', 'Working language'),  
252 - 'special_meal' => Yii::t('app', 'Special meal'),  
253 - 'post_address' => Yii::t('app', 'Post address'),  
254 - 240 + 'id' => Yii::t('app', 'ID'),
  241 + 'name' => Yii::t('app', 'Name'),
  242 + 'secondname' => Yii::t('app', 'Secondname'),
  243 + 'dignity' => Yii::t('app', 'Dignity'),
  244 + 'gender' => Yii::t('app', 'Gender'),
  245 + 'birth' => Yii::t('app', 'Birth'),
  246 + 'citizenship' => Yii::t('app', 'Citizenship'),
  247 + 'passport' => Yii::t('app', 'Passport'),
  248 + 'email' => Yii::t('app', 'Email'),
  249 + 'organization' => Yii::t('app', 'Organization'),
  250 + 'status' => Yii::t('app', 'Status'),
  251 + 'language_id' => Yii::t('app', 'Language ID'),
  252 + 'image' => Yii::t('app', 'Image'),
  253 + 'conference' => Yii::t('app', 'Conference'),
  254 + 'geee' => Yii::t('app', 'Geee'),
  255 + 'gere' => Yii::t('app', 'Gere'),
  256 + 'need_visa' => Yii::t('app', 'Need visa'),
  257 + 'passport_number' => Yii::t('app', 'Passport number'),
  258 + 'passport_date' => Yii::t('app', 'Passport date'),
  259 + 'passport_place' => Yii::t('app', 'Passport place'),
  260 + 'passport_valid' => Yii::t('app', 'Passport valid'),
  261 + 'phone_own' => Yii::t('app', 'Phone own'),
  262 + 'phone_office' => Yii::t('app', 'Phone office'),
  263 + 'phone_other' => Yii::t('app', 'Phone other'),
  264 + 'fax' => Yii::t('app', 'fax'),
  265 + 'acceptance' => Yii::t('app', 'acceptance'),
  266 + 'working_lang' => Yii::t('app', 'Working language'),
  267 + 'special_meal' => Yii::t('app', 'Special meal'),
  268 + 'post_address' => Yii::t('app', 'Post address'),
  269 +
255 ]; 270 ];
256 } 271 }
257 272
258 -  
259 public function upload() 273 public function upload()
260 { 274 {
261 /** 275 /**
262 - * @var \yii\web\UploadedFile $file; 276 + * @var \yii\web\UploadedFile $file ;
263 */ 277 */
264 if (!empty($this->file) and $this->validate()) { 278 if (!empty($this->file) and $this->validate()) {
265 if (!file_exists(\Yii::getAlias('@storage/customers/'))) { 279 if (!file_exists(\Yii::getAlias('@storage/customers/'))) {
266 FileHelper::createDirectory(\Yii::getAlias('@storage/customers/')); 280 FileHelper::createDirectory(\Yii::getAlias('@storage/customers/'));
267 } 281 }
268 - $filename = $this->file->baseName.'_'.Yii::$app->security->generateRandomString(5).'.'.$this->file->extension;  
269 - if ($this->file->saveAs(\Yii::getAlias('@storage/customers/') . $filename)) {  
270 - $this->image = '/storage/customers/'.$filename; 282 + $filename = $this->file->baseName . '_' . Yii::$app->security->generateRandomString(
  283 + 5
  284 + ) . '.' . $this->file->extension;
  285 + if ($this->file->saveAs(\Yii::getAlias('@storage/customers/') . $filename)) {
  286 + $this->image = '/storage/customers/' . $filename;
271 $this->file->name = $filename; 287 $this->file->name = $filename;
272 return true; 288 return true;
273 } 289 }
274 return false; 290 return false;
275 - 291 +
276 } 292 }
277 return true; 293 return true;
278 } 294 }
frontend/controllers/SiteController.php
@@ -241,7 +241,7 @@ @@ -241,7 +241,7 @@
241 ) 241 )
242 ->setTo( 242 ->setTo(
243 [ 243 [
244 - 'kennen.md@gmail.com', 244 +// 'kennen.md@gmail.com',
245 'energyforum@euromediacompany.com', 245 'energyforum@euromediacompany.com',
246 ] 246 ]
247 ) 247 )