diff --git a/common/models/BlogSearch.php b/common/models/BlogSearch.php index 7437d09..15f26c1 100644 --- a/common/models/BlogSearch.php +++ b/common/models/BlogSearch.php @@ -47,17 +47,19 @@ ], [ [ - 'date_add_from', + 'date_add_to', ], - 'default', - 'value' => date('Y-m-d', 0), + 'compare', + 'compareAttribute' => 'date_add_from', + 'operator' => '>=', ], [ [ - 'date_add_to', + 'date_add_from', ], - 'default', - 'value' => date('Y-m-d'), + 'compare', + 'compareValue' => date('Y-m-d'), + 'operator' => '<=', ], ]; } @@ -101,17 +103,30 @@ // grid filtering conditions $query->andFilterWhere([ 'blog_id' => $this->blog_id, - 'date_add' => $this->date_add, 'user_add_id' => $this->user_add_id, 'view_count' => $this->view_count, ]); - $query->andFilterWhere([ - 'between', - 'date_add', - $this->date_add_from, - (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d') - ]); + if(!empty($this->date_add_from) && !empty($this->date_add_to)) { + $query->andWhere([ + 'between', + 'date_add', + $this->date_add_from, + (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d'), + ]); + } elseif(!empty($this->date_add_from)) { + $query->andWhere([ + '>=', + 'date_add', + $this->date_add_from, + ]); + } elseif(!empty($this->date_add_to)) { + $query->andWhere([ + '<=', + 'date_add', + (new \DateTime($this->date_add_to))->modify('+1 day')->format('Y-m-d'), + ]); + } $query->andFilterWhere([ 'like', diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index d40a8ca..63629f9 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -272,6 +272,10 @@ class SiteController extends Controller $user_info->load(Yii::$app->request->post(),'SignupForm'); + if(empty($user_info->city) && !empty(\Yii::$app->request->post()['SignupForm']['city_custom'])) { + $user_info->city = \Yii::$app->request->post()['SignupForm']['city_custom']; + } + $user_info->user_id = $user->id; $user_info->save(); diff --git a/frontend/models/SignupForm.php b/frontend/models/SignupForm.php index 9b71ea7..7638a01 100755 --- a/frontend/models/SignupForm.php +++ b/frontend/models/SignupForm.php @@ -23,7 +23,7 @@ class SignupForm extends Model public $is_freelancer; public $city; public $name; - + public $city_custom; const SCENARIO_USER = 'user'; @@ -40,7 +40,7 @@ class SignupForm extends Model ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], ['username', 'string', 'min' => 2, 'max' => 255], - ['city', 'string', 'min' => 2, 'max' => 255], + [['city', 'city_custom'], 'string', 'min' => 2, 'max' => 255], ['email', 'filter', 'filter' => 'trim'], ['email', 'required'], @@ -95,7 +95,6 @@ class SignupForm extends Model $user->generateAuthKey(); if ($user->save()) { -// $user->link('userInfo', new UserInfo(['city' => $this->city])); return $user; } } diff --git a/frontend/views/accounts/blog.php b/frontend/views/accounts/blog.php index 221c318..81a5763 100644 --- a/frontend/views/accounts/blog.php +++ b/frontend/views/accounts/blog.php @@ -59,7 +59,9 @@ 'changeMonth' => true, ], ]) - ." + ."" + .(($searchModel->hasErrors('date_add_from'))?'Дата начала не может быть больше сегодняшнего дня':'') + .(($searchModel->hasErrors('date_add_to'))?'Дата окончания должна быть больше даты начала':'')." ", 'format' => 'html', ], diff --git a/frontend/views/site/registration.php b/frontend/views/site/registration.php index a21d3f3..daf9553 100644 --- a/frontend/views/site/registration.php +++ b/frontend/views/site/registration.php @@ -1,11 +1,11 @@ -
-
- field($model, 'username')->textInput(['class'=>'custom-input-2'])?> -
-
-
Логин должен содержать не менее 3-х символов, начинаться с английской буквы и заканчиваться буквой или цифрой. Допускаются английские буквы, цифры и знаки 'тире', 'подчеркивание', 'точка'
-
+
+
+ field($model, 'username') + ->textInput([ 'class' => 'custom-input-2' ]) ?> +
+
+
Логин должен содержать не менее 3-х символов, начинаться с английской буквы и заканчиваться буквой или цифрой. Допускаются английские буквы, цифры и знаки 'тире', 'подчеркивание', 'точка'
+
-
-
+
+
- field($model, 'password')->passwordInput(['class'=>'custom-input-2'])?> + field($model, 'password') + ->passwordInput([ 'class' => 'custom-input-2' ]) ?> -
-
-
Пароль должен содержать не менее 6-ти символов.
-
+
+
Пароль должен содержать не менее 6-ти символов.
+
+
-
-
- field($model, 'email')->textInput(['class'=>'custom-input-2'])?> -
-
-
На этот адрес электронной почты будет отправлено уведомление о регистрации.
-
+
+
+ field($model, 'email') + ->textInput([ 'class' => 'custom-input-2' ]) ?> +
+
+
На этот адрес электронной почты будет отправлено уведомление о регистрации.
+
-
-
Кто Вы
-
-
+
+
Кто Вы
+
+
-
- + type = '1'; - echo $form->field ($model, 'type',['options'=> ['class'=>'check-radio-wr']]) - ->label (false) - ->radioList ( - [1 => 'Частное лицо', 2 => 'Компания'], - [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ] - ); - ?> -
+ echo $form->field($model, 'type', [ 'options' => [ 'class' => 'check-radio-wr' ] ]) + ->label(false) + ->radioList([ + 1 => 'Частное лицо', + 2 => 'Компания', + ], [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + }, + ]); + ?> +
-
- field($model, 'is_freelancer', [ 'template' => "{input}\n{label}\n{error}" , 'options'=>['class'=>'custom-form-buttons'] ]) - ->label('Я - Фрилансер') - ->checkbox([ - 'class' => 'custom-check', - ], false); ?> - - field($model, 'is_customer', [ 'template' => "{input}\n{label}\n{error}", 'options'=>['class'=>'custom-form-buttons'] ]) - ->label('Я - Заказчик') - ->checkbox([ - 'class' => 'custom-check', - ], false); ?> -
+
+ field($model, 'is_freelancer', [ + 'template' => "{input}\n{label}\n{error}", + 'options' => [ 'class' => 'custom-form-buttons' ], + ]) + ->label('Я - Фрилансер') + ->checkbox([ + 'class' => 'custom-check', + ], false); ?> + + field($model, 'is_customer', [ + 'template' => "{input}\n{label}\n{error}", + 'options' => [ 'class' => 'custom-form-buttons' ], + ]) + ->label('Я - Заказчик') + ->checkbox([ + 'class' => 'custom-check', + ], false); ?> +
-
-
-
- field($model, 'name')->textInput(['class'=>'custom-input-2'])?> -
+
+
+
+ field($model, 'name') + ->textInput([ 'class' => 'custom-input-2' ]) ?>
+
-
-
- field($model, 'firstname')->textInput(['class'=>'custom-input-2'])?> -
+
+
+ field($model, 'firstname') + ->textInput([ 'class' => 'custom-input-2' ]) ?>
-
-
- field($model, 'lastname')->textInput(['class'=>'custom-input-2'])?> -
+
+
+
+ field($model, 'lastname') + ->textInput([ 'class' => 'custom-input-2' ]) ?>
-
-
- field($model, 'city')->widget(Select2::classname(), [ - 'options' => ['placeholder' => 'Выбор города ...'], - 'pluginOptions' => [ - 'allowClear' => true, - 'minimumInputLength' => 3, - 'ajax' => [ - 'url' => \yii\helpers\Url::to(['site/city']), - 'dataType' => 'json', - 'data' => new JsExpression('function(params) { return {q:params.term}; }') - ], - 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), - 'templateResult' => new JsExpression('function(city) { return city.text; }'), - 'templateSelection' => new JsExpression('function (city) { return city.text; }'), - ], - ]); - ?> -
+
+
+
+ field($model, 'city') + ->widget(Select2::classname(), [ + 'options' => [ 'placeholder' => 'Выбор города ...' ], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'ajax' => [ + 'url' => \yii\helpers\Url::to([ 'site/city' ]), + 'dataType' => 'json', + 'data' => new JsExpression('function(params) { return {q:params.term}; }'), + ], + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), + 'templateResult' => new JsExpression('function(city) { return city.text; }'), + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), + ], + ]); ?>
- - - +
-
-
- - -
-
Если вашего города нет в списке, введите его.
-
-
- field($model, 'verifyCode')->widget(Captcha::className(), [ - 'options' => ['class' => 'custom-input-2'], - 'template' => ' +
+ field($model, 'city_custom', [ 'options' => [ 'class' => 'input-blocks' ] ]) + ->label('Город не в списке') + ->textInput([ 'class' => 'custom-input-2' ]) ?> +
Если вашего города нет в списке, введите его.
+
+
+ field($model, 'verifyCode') + ->widget(Captcha::className(), [ + 'options' => [ 'class' => 'custom-input-2' ], + 'template' => '
{image} @@ -152,16 +160,17 @@ use yii\widgets\ActiveForm;
', - ])->label(false) ?> -
-
- -
+ ]) + ->label(false) ?> +
+
+
+
- +
@@ -169,7 +178,7 @@ use yii\widgets\ActiveForm;
registerJS($js ); + $this->registerJS($js); ?> -- libgit2 0.21.4