Commit 143979c5d8451dd44f3af9e4855fc0c968841e1e
1 parent
db659e19
test
Showing
5 changed files
with
163 additions
and
134 deletions
Show diff stats
common/models/BlogSearch.php
@@ -47,17 +47,19 @@ | @@ -47,17 +47,19 @@ | ||
47 | ], | 47 | ], |
48 | [ | 48 | [ |
49 | [ | 49 | [ |
50 | - 'date_add_from', | 50 | + 'date_add_to', |
51 | ], | 51 | ], |
52 | - 'default', | ||
53 | - 'value' => date('Y-m-d', 0), | 52 | + 'compare', |
53 | + 'compareAttribute' => 'date_add_from', | ||
54 | + 'operator' => '>=', | ||
54 | ], | 55 | ], |
55 | [ | 56 | [ |
56 | [ | 57 | [ |
57 | - 'date_add_to', | 58 | + 'date_add_from', |
58 | ], | 59 | ], |
59 | - 'default', | ||
60 | - 'value' => date('Y-m-d'), | 60 | + 'compare', |
61 | + 'compareValue' => date('Y-m-d'), | ||
62 | + 'operator' => '<=', | ||
61 | ], | 63 | ], |
62 | ]; | 64 | ]; |
63 | } | 65 | } |
@@ -101,17 +103,30 @@ | @@ -101,17 +103,30 @@ | ||
101 | // grid filtering conditions | 103 | // grid filtering conditions |
102 | $query->andFilterWhere([ | 104 | $query->andFilterWhere([ |
103 | 'blog_id' => $this->blog_id, | 105 | 'blog_id' => $this->blog_id, |
104 | - 'date_add' => $this->date_add, | ||
105 | 'user_add_id' => $this->user_add_id, | 106 | 'user_add_id' => $this->user_add_id, |
106 | 'view_count' => $this->view_count, | 107 | 'view_count' => $this->view_count, |
107 | ]); | 108 | ]); |
108 | 109 | ||
109 | - $query->andFilterWhere([ | ||
110 | - 'between', | ||
111 | - 'date_add', | ||
112 | - $this->date_add_from, | ||
113 | - (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d') | ||
114 | - ]); | 110 | + if(!empty($this->date_add_from) && !empty($this->date_add_to)) { |
111 | + $query->andWhere([ | ||
112 | + 'between', | ||
113 | + 'date_add', | ||
114 | + $this->date_add_from, | ||
115 | + (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d'), | ||
116 | + ]); | ||
117 | + } elseif(!empty($this->date_add_from)) { | ||
118 | + $query->andWhere([ | ||
119 | + '>=', | ||
120 | + 'date_add', | ||
121 | + $this->date_add_from, | ||
122 | + ]); | ||
123 | + } elseif(!empty($this->date_add_to)) { | ||
124 | + $query->andWhere([ | ||
125 | + '<=', | ||
126 | + 'date_add', | ||
127 | + (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d'), | ||
128 | + ]); | ||
129 | + } | ||
115 | 130 | ||
116 | $query->andFilterWhere([ | 131 | $query->andFilterWhere([ |
117 | 'like', | 132 | 'like', |
frontend/controllers/SiteController.php
@@ -272,6 +272,10 @@ class SiteController extends Controller | @@ -272,6 +272,10 @@ class SiteController extends Controller | ||
272 | 272 | ||
273 | $user_info->load(Yii::$app->request->post(),'SignupForm'); | 273 | $user_info->load(Yii::$app->request->post(),'SignupForm'); |
274 | 274 | ||
275 | + if(empty($user_info->city) && !empty(\Yii::$app->request->post()['SignupForm']['city_custom'])) { | ||
276 | + $user_info->city = \Yii::$app->request->post()['SignupForm']['city_custom']; | ||
277 | + } | ||
278 | + | ||
275 | $user_info->user_id = $user->id; | 279 | $user_info->user_id = $user->id; |
276 | 280 | ||
277 | $user_info->save(); | 281 | $user_info->save(); |
frontend/models/SignupForm.php
@@ -23,7 +23,7 @@ class SignupForm extends Model | @@ -23,7 +23,7 @@ class SignupForm extends Model | ||
23 | public $is_freelancer; | 23 | public $is_freelancer; |
24 | public $city; | 24 | public $city; |
25 | public $name; | 25 | public $name; |
26 | - | 26 | + public $city_custom; |
27 | 27 | ||
28 | 28 | ||
29 | const SCENARIO_USER = 'user'; | 29 | const SCENARIO_USER = 'user'; |
@@ -40,7 +40,7 @@ class SignupForm extends Model | @@ -40,7 +40,7 @@ class SignupForm extends Model | ||
40 | ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], | 40 | ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], |
41 | ['username', 'string', 'min' => 2, 'max' => 255], | 41 | ['username', 'string', 'min' => 2, 'max' => 255], |
42 | 42 | ||
43 | - ['city', 'string', 'min' => 2, 'max' => 255], | 43 | + [['city', 'city_custom'], 'string', 'min' => 2, 'max' => 255], |
44 | 44 | ||
45 | ['email', 'filter', 'filter' => 'trim'], | 45 | ['email', 'filter', 'filter' => 'trim'], |
46 | ['email', 'required'], | 46 | ['email', 'required'], |
@@ -95,7 +95,6 @@ class SignupForm extends Model | @@ -95,7 +95,6 @@ class SignupForm extends Model | ||
95 | $user->generateAuthKey(); | 95 | $user->generateAuthKey(); |
96 | 96 | ||
97 | if ($user->save()) { | 97 | if ($user->save()) { |
98 | -// $user->link('userInfo', new UserInfo(['city' => $this->city])); | ||
99 | return $user; | 98 | return $user; |
100 | } | 99 | } |
101 | } | 100 | } |
frontend/views/accounts/blog.php
@@ -59,7 +59,9 @@ | @@ -59,7 +59,9 @@ | ||
59 | 'changeMonth' => true, | 59 | 'changeMonth' => true, |
60 | ], | 60 | ], |
61 | ]) | 61 | ]) |
62 | - ."</span> | 62 | + ."</span>" |
63 | + .(($searchModel->hasErrors('date_add_from'))?'Дата начала не может быть больше сегодняшнего дня':'') | ||
64 | + .(($searchModel->hasErrors('date_add_to'))?'Дата окончания должна быть больше даты начала':'')." | ||
63 | </div>", | 65 | </div>", |
64 | 'format' => 'html', | 66 | 'format' => 'html', |
65 | ], | 67 | ], |
frontend/views/site/registration.php
1 | <?php | 1 | <?php |
2 | -/** | ||
3 | - * @var $user common\models\User | ||
4 | - * @var $user_info common\models\UserInfo | ||
5 | - */ | 2 | + /** |
3 | + * @var $user common\models\User | ||
4 | + * @var $user_info common\models\UserInfo | ||
5 | + */ | ||
6 | use yii\captcha\Captcha; | 6 | use yii\captcha\Captcha; |
7 | -use yii\web\View; | ||
8 | -use yii\widgets\ActiveForm; | 7 | + use yii\web\View; |
8 | + use yii\widgets\ActiveForm; | ||
9 | use kartik\select2\Select2; | 9 | use kartik\select2\Select2; |
10 | use yii\web\JsExpression; | 10 | use yii\web\JsExpression; |
11 | 11 | ||
@@ -18,128 +18,136 @@ use yii\widgets\ActiveForm; | @@ -18,128 +18,136 @@ use yii\widgets\ActiveForm; | ||
18 | <div class="registration-form style"> | 18 | <div class="registration-form style"> |
19 | <?php $form = ActiveForm::begin(); ?> | 19 | <?php $form = ActiveForm::begin(); ?> |
20 | 20 | ||
21 | - <div class="input-blocks-wrapper"> | ||
22 | - <div class="input-blocks"> | ||
23 | - <?= $form->field($model, 'username')->textInput(['class'=>'custom-input-2'])?> | ||
24 | - </div> | ||
25 | - <div class="input-blocks-help-wr"> | ||
26 | - <div class="input-blocks-help">Логин должен содержать не менее 3-х символов, начинаться с английской буквы и заканчиваться буквой или цифрой. Допускаются английские буквы, цифры и знаки 'тире', 'подчеркивание', 'точка'</div> | ||
27 | - </div> | 21 | + <div class="input-blocks-wrapper"> |
22 | + <div class="input-blocks"> | ||
23 | + <?= $form->field($model, 'username') | ||
24 | + ->textInput([ 'class' => 'custom-input-2' ]) ?> | ||
25 | + </div> | ||
26 | + <div class="input-blocks-help-wr"> | ||
27 | + <div class="input-blocks-help">Логин должен содержать не менее 3-х символов, начинаться с английской буквы и заканчиваться буквой или цифрой. Допускаются английские буквы, цифры и знаки 'тире', 'подчеркивание', 'точка'</div> | ||
28 | </div> | 28 | </div> |
29 | + </div> | ||
29 | 30 | ||
30 | - <div class="input-blocks-wrapper"> | ||
31 | - <div class="input-blocks"> | 31 | + <div class="input-blocks-wrapper"> |
32 | + <div class="input-blocks"> | ||
32 | 33 | ||
33 | - <?= $form->field($model, 'password')->passwordInput(['class'=>'custom-input-2'])?> | 34 | + <?= $form->field($model, 'password') |
35 | + ->passwordInput([ 'class' => 'custom-input-2' ]) ?> | ||
34 | 36 | ||
35 | - </div> | ||
36 | - <div class="input-blocks-help-wr"> | ||
37 | - <div class="input-blocks-help">Пароль должен содержать не менее 6-ти символов.</div> | ||
38 | - </div> | ||
39 | </div> | 37 | </div> |
38 | + <div class="input-blocks-help-wr"> | ||
39 | + <div class="input-blocks-help">Пароль должен содержать не менее 6-ти символов.</div> | ||
40 | + </div> | ||
41 | + </div> | ||
40 | 42 | ||
41 | - <div class="input-blocks-wrapper"> | ||
42 | - <div class="input-blocks"> | ||
43 | - <?= $form->field($model, 'email')->textInput(['class'=>'custom-input-2'])?> | ||
44 | - </div> | ||
45 | - <div class="input-blocks-help-wr"> | ||
46 | - <div class="input-blocks-help">На этот адрес электронной почты будет отправлено уведомление о регистрации.</div> | ||
47 | - </div> | 43 | + <div class="input-blocks-wrapper"> |
44 | + <div class="input-blocks"> | ||
45 | + <?= $form->field($model, 'email') | ||
46 | + ->textInput([ 'class' => 'custom-input-2' ]) ?> | ||
47 | + </div> | ||
48 | + <div class="input-blocks-help-wr"> | ||
49 | + <div class="input-blocks-help">На этот адрес электронной почты будет отправлено уведомление о регистрации.</div> | ||
48 | </div> | 50 | </div> |
51 | + </div> | ||
49 | 52 | ||
50 | - <div class="who-you-are style"> | ||
51 | - <div class="who-you-are-title style">Кто Вы</div> | ||
52 | - <div class="who-you-are-form-wr style"> | ||
53 | - <div class="who-you-are-form"> | 53 | + <div class="who-you-are style"> |
54 | + <div class="who-you-are-title style">Кто Вы</div> | ||
55 | + <div class="who-you-are-form-wr style"> | ||
56 | + <div class="who-you-are-form"> | ||
54 | 57 | ||
55 | - <div class="register-val-company"> | ||
56 | - <?php | 58 | + <div class="register-val-company"> |
59 | + <?php | ||
57 | $model->type = '1'; | 60 | $model->type = '1'; |
58 | - echo $form->field ($model, 'type',['options'=> ['class'=>'check-radio-wr']]) | ||
59 | - ->label (false) | ||
60 | - ->radioList ( | ||
61 | - [1 => 'Частное лицо', 2 => 'Компания'], | ||
62 | - [ | ||
63 | - 'item' => function($index, $label, $name, $checked, $value) { | ||
64 | - $return = '<div class="custom-form-buttons">'; | ||
65 | - $return .= '<input class="custom-radio" id="custom-radio-'.$value.'" '.($checked ? "checked" : "" ).' type="radio" name="' . $name . '" value="' . $value . '" >'; | ||
66 | - $return .= '<label for="custom-radio-'.$value.'" ><span></span>' . $label .'</label>'; | ||
67 | - $return .= '</div>'; | ||
68 | - return $return; | ||
69 | - } | ||
70 | - ] | ||
71 | - ); | ||
72 | - ?> | ||
73 | - </div> | 61 | + echo $form->field($model, 'type', [ 'options' => [ 'class' => 'check-radio-wr' ] ]) |
62 | + ->label(false) | ||
63 | + ->radioList([ | ||
64 | + 1 => 'Частное лицо', | ||
65 | + 2 => 'Компания', | ||
66 | + ], [ | ||
67 | + 'item' => function($index, $label, $name, $checked, $value) { | ||
68 | + $return = '<div class="custom-form-buttons">'; | ||
69 | + $return .= '<input class="custom-radio" id="custom-radio-' . $value . '" ' . ( $checked ? "checked" : "" ) . ' type="radio" name="' . $name . '" value="' . $value . '" >'; | ||
70 | + $return .= '<label for="custom-radio-' . $value . '" ><span></span>' . $label . '</label>'; | ||
71 | + $return .= '</div>'; | ||
72 | + return $return; | ||
73 | + }, | ||
74 | + ]); | ||
75 | + ?> | ||
76 | + </div> | ||
74 | 77 | ||
75 | - <div class="check-radio-wr"> | ||
76 | - <?= $form->field($model, 'is_freelancer', [ 'template' => "{input}\n{label}\n{error}" , 'options'=>['class'=>'custom-form-buttons'] ]) | ||
77 | - ->label('<span></span>Я - Фрилансер') | ||
78 | - ->checkbox([ | ||
79 | - 'class' => 'custom-check', | ||
80 | - ], false); ?> | ||
81 | - | ||
82 | - <?= $form->field($model, 'is_customer', [ 'template' => "{input}\n{label}\n{error}", 'options'=>['class'=>'custom-form-buttons'] ]) | ||
83 | - ->label('<span></span>Я - Заказчик') | ||
84 | - ->checkbox([ | ||
85 | - 'class' => 'custom-check', | ||
86 | - ], false); ?> | ||
87 | - </div> | 78 | + <div class="check-radio-wr"> |
79 | + <?= $form->field($model, 'is_freelancer', [ | ||
80 | + 'template' => "{input}\n{label}\n{error}", | ||
81 | + 'options' => [ 'class' => 'custom-form-buttons' ], | ||
82 | + ]) | ||
83 | + ->label('<span></span>Я - Фрилансер') | ||
84 | + ->checkbox([ | ||
85 | + 'class' => 'custom-check', | ||
86 | + ], false); ?> | ||
87 | + | ||
88 | + <?= $form->field($model, 'is_customer', [ | ||
89 | + 'template' => "{input}\n{label}\n{error}", | ||
90 | + 'options' => [ 'class' => 'custom-form-buttons' ], | ||
91 | + ]) | ||
92 | + ->label('<span></span>Я - Заказчик') | ||
93 | + ->checkbox([ | ||
94 | + 'class' => 'custom-check', | ||
95 | + ], false); ?> | ||
96 | + </div> | ||
88 | 97 | ||
89 | - <div id="register-company-block-target"></div> | ||
90 | - <div class="input-blocks-wrapper register-company-block"> | ||
91 | - <div class="input-blocks"> | ||
92 | - <?= $form->field($model, 'name')->textInput(['class'=>'custom-input-2'])?> | ||
93 | - </div> | 98 | + <div id="register-company-block-target"></div> |
99 | + <div class="input-blocks-wrapper register-company-block"> | ||
100 | + <div class="input-blocks"> | ||
101 | + <?= $form->field($model, 'name') | ||
102 | + ->textInput([ 'class' => 'custom-input-2' ]) ?> | ||
94 | </div> | 103 | </div> |
104 | + </div> | ||
95 | 105 | ||
96 | - <div class="input-blocks-wrapper"> | ||
97 | - <div class="input-blocks"> | ||
98 | - <?= $form->field($model, 'firstname')->textInput(['class'=>'custom-input-2'])?> | ||
99 | - </div> | 106 | + <div class="input-blocks-wrapper"> |
107 | + <div class="input-blocks"> | ||
108 | + <?= $form->field($model, 'firstname') | ||
109 | + ->textInput([ 'class' => 'custom-input-2' ]) ?> | ||
100 | </div> | 110 | </div> |
101 | - <div class="input-blocks-wrapper"> | ||
102 | - <div class="input-blocks"> | ||
103 | - <?= $form->field($model, 'lastname')->textInput(['class'=>'custom-input-2'])?> | ||
104 | - </div> | 111 | + </div> |
112 | + <div class="input-blocks-wrapper"> | ||
113 | + <div class="input-blocks"> | ||
114 | + <?= $form->field($model, 'lastname') | ||
115 | + ->textInput([ 'class' => 'custom-input-2' ]) ?> | ||
105 | </div> | 116 | </div> |
106 | - <div class="input-blocks-wrapper"> | ||
107 | - <div class="input-blocks"> | ||
108 | - <?= | ||
109 | - $form->field($model, 'city')->widget(Select2::classname(), [ | ||
110 | - 'options' => ['placeholder' => 'Выбор города ...'], | ||
111 | - 'pluginOptions' => [ | ||
112 | - 'allowClear' => true, | ||
113 | - 'minimumInputLength' => 3, | ||
114 | - 'ajax' => [ | ||
115 | - 'url' => \yii\helpers\Url::to(['site/city']), | ||
116 | - 'dataType' => 'json', | ||
117 | - 'data' => new JsExpression('function(params) { return {q:params.term}; }') | ||
118 | - ], | ||
119 | - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | ||
120 | - 'templateResult' => new JsExpression('function(city) { return city.text; }'), | ||
121 | - 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | ||
122 | - ], | ||
123 | - ]); | ||
124 | - ?> | ||
125 | - </div> | 117 | + </div> |
118 | + <div class="input-blocks-wrapper"> | ||
119 | + <div class="input-blocks"> | ||
120 | + <?= $form->field($model, 'city') | ||
121 | + ->widget(Select2::classname(), [ | ||
122 | + 'options' => [ 'placeholder' => 'Выбор города ...' ], | ||
123 | + 'pluginOptions' => [ | ||
124 | + 'allowClear' => true, | ||
125 | + 'minimumInputLength' => 3, | ||
126 | + 'ajax' => [ | ||
127 | + 'url' => \yii\helpers\Url::to([ 'site/city' ]), | ||
128 | + 'dataType' => 'json', | ||
129 | + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), | ||
130 | + ], | ||
131 | + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), | ||
132 | + 'templateResult' => new JsExpression('function(city) { return city.text; }'), | ||
133 | + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), | ||
134 | + ], | ||
135 | + ]); ?> | ||
126 | </div> | 136 | </div> |
127 | - | ||
128 | - | ||
129 | - | 137 | + </div> |
130 | 138 | ||
131 | 139 | ||
132 | - <div class="input-blocks-wrapper city-two"> | ||
133 | - <div class="input-blocks"> | ||
134 | - <label for="input-txt-7">Город не в списке</label> | ||
135 | - <input class="custom-input-2" id="input-txt-7" type="text"> | ||
136 | - </div> | ||
137 | - <div class="form-help-two">Если вашего города нет в списке, введите его. </div> | ||
138 | - </div> | ||
139 | - <div class="input-blocks-wrapper captcha-wr"> | ||
140 | - <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ | ||
141 | - 'options' => ['class' => 'custom-input-2'], | ||
142 | - 'template' => ' | 140 | + <div class="input-blocks-wrapper city-two"> |
141 | + <?= $form->field($model, 'city_custom', [ 'options' => [ 'class' => 'input-blocks' ] ]) | ||
142 | + ->label('Город не в списке') | ||
143 | + ->textInput([ 'class' => 'custom-input-2' ]) ?> | ||
144 | + <div class="form-help-two">Если вашего города нет в списке, введите его.</div> | ||
145 | + </div> | ||
146 | + <div class="input-blocks-wrapper captcha-wr"> | ||
147 | + <?= $form->field($model, 'verifyCode') | ||
148 | + ->widget(Captcha::className(), [ | ||
149 | + 'options' => [ 'class' => 'custom-input-2' ], | ||
150 | + 'template' => ' | ||
143 | <div class="input-blocks-wrapper captcha"> | 151 | <div class="input-blocks-wrapper captcha"> |
144 | <div class="input-blocks-captcha"> | 152 | <div class="input-blocks-captcha"> |
145 | {image} | 153 | {image} |
@@ -152,16 +160,17 @@ use yii\widgets\ActiveForm; | @@ -152,16 +160,17 @@ use yii\widgets\ActiveForm; | ||
152 | </div> | 160 | </div> |
153 | </div> | 161 | </div> |
154 | ', | 162 | ', |
155 | - ])->label(false) ?> | ||
156 | - </div> | ||
157 | - <div class="input-blocks-wrapper button"> | ||
158 | - <button type="submit" value="Submit">Зарегистрироваться</button> | ||
159 | - </div> | 163 | + ]) |
164 | + ->label(false) ?> | ||
165 | + </div> | ||
166 | + <div class="input-blocks-wrapper button"> | ||
167 | + <button type="submit" value="Submit">Зарегистрироваться</button> | ||
160 | </div> | 168 | </div> |
161 | </div> | 169 | </div> |
162 | </div> | 170 | </div> |
171 | + </div> | ||
163 | 172 | ||
164 | - <?php ActiveForm::end()?> | 173 | + <?php ActiveForm::end() ?> |
165 | </div> | 174 | </div> |
166 | </div> | 175 | </div> |
167 | </div> | 176 | </div> |
@@ -169,7 +178,7 @@ use yii\widgets\ActiveForm; | @@ -169,7 +178,7 @@ use yii\widgets\ActiveForm; | ||
169 | 178 | ||
170 | </div> | 179 | </div> |
171 | <?php | 180 | <?php |
172 | - $js = " | 181 | + $js = " |
173 | var labelName= $('.field-signupform-firstname label').text() | 182 | var labelName= $('.field-signupform-firstname label').text() |
174 | var labelLastName= $('.field-signupform-lastname label').text() | 183 | var labelLastName= $('.field-signupform-lastname label').text() |
175 | var newLabelName= 'представителя' | 184 | var newLabelName= 'представителя' |
@@ -212,6 +221,6 @@ use yii\widgets\ActiveForm; | @@ -212,6 +221,6 @@ use yii\widgets\ActiveForm; | ||
212 | }) | 221 | }) |
213 | "; | 222 | "; |
214 | 223 | ||
215 | -$this->registerJS($js ); | 224 | + $this->registerJS($js); |
216 | ?> | 225 | ?> |
217 | 226 |