Commit 808969ba52f6672335527cb692bbb18c3ded7168
1 parent
2d107e9e
01.03.16
Showing
4 changed files
with
43 additions
and
15 deletions
Show diff stats
common/models/UserInfo.php
frontend/controllers/ChatController.php
| @@ -39,9 +39,18 @@ class ChatController extends Controller | @@ -39,9 +39,18 @@ class ChatController extends Controller | ||
| 39 | 39 | ||
| 40 | public function actionList() | 40 | public function actionList() |
| 41 | { | 41 | { |
| 42 | + $user = \Yii::$app->user->identity; | ||
| 43 | + $chat = Chat::find() | ||
| 44 | + ->where([ | ||
| 45 | + 'or', | ||
| 46 | + ['from_user' => $user->id,], | ||
| 47 | + ['to_user' => $user->id,], | ||
| 48 | + ]) | ||
| 49 | + | ||
| 50 | + ->with('messages.user'); | ||
| 42 | 51 | ||
| 43 | $chat = new ActiveDataProvider([ | 52 | $chat = new ActiveDataProvider([ |
| 44 | - 'query' => Chat::find(), | 53 | + 'query' => $chat, |
| 45 | 'pagination' => [ | 54 | 'pagination' => [ |
| 46 | 'pageSize' => 5, | 55 | 'pageSize' => 5, |
| 47 | ], | 56 | ], |
frontend/controllers/SiteController.php
| @@ -286,10 +286,12 @@ class SiteController extends Controller | @@ -286,10 +286,12 @@ class SiteController extends Controller | ||
| 286 | } | 286 | } |
| 287 | 287 | ||
| 288 | if (Yii::$app->getUser()->login($user)) { | 288 | if (Yii::$app->getUser()->login($user)) { |
| 289 | + | ||
| 289 | return $this->redirect('/accounts'); | 290 | return $this->redirect('/accounts'); |
| 290 | } | 291 | } |
| 291 | } | 292 | } |
| 292 | } | 293 | } |
| 294 | + | ||
| 293 | $model = new SignupForm(); | 295 | $model = new SignupForm(); |
| 294 | return $this->render('registration', [ | 296 | return $this->render('registration', [ |
| 295 | 'model' => $model, | 297 | 'model' => $model, |
frontend/views/site/registration.php
| @@ -4,7 +4,8 @@ | @@ -4,7 +4,8 @@ | ||
| 4 | * @var $user_info common\models\UserInfo | 4 | * @var $user_info common\models\UserInfo |
| 5 | */ | 5 | */ |
| 6 | use yii\captcha\Captcha; | 6 | use yii\captcha\Captcha; |
| 7 | - use yii\widgets\ActiveForm; | 7 | +use yii\web\View; |
| 8 | +use yii\widgets\ActiveForm; | ||
| 8 | use kartik\select2\Select2; | 9 | use kartik\select2\Select2; |
| 9 | use yii\web\JsExpression; | 10 | use yii\web\JsExpression; |
| 10 | 11 | ||
| @@ -167,33 +168,50 @@ | @@ -167,33 +168,50 @@ | ||
| 167 | </div> | 168 | </div> |
| 168 | 169 | ||
| 169 | </div> | 170 | </div> |
| 170 | -<script> | ||
| 171 | - var labelName= $('.field-signupform-firstname label').text() | ||
| 172 | - var labelLastName= $('.field-signupform-lastname label').text() | ||
| 173 | - var newLabelName= 'представителя' | ||
| 174 | - | ||
| 175 | - var registerValCompany = $('.register-val-company .custom-radio:checked').attr('value'); | ||
| 176 | - var regHideBlock = $('.register-company-block .form-group') | ||
| 177 | - if(registerValCompany==1) { | 171 | +<?php |
| 172 | + $js = " | ||
| 173 | + var labelName= $('.field-signupform-firstname label').text() | ||
| 174 | + var labelLastName= $('.field-signupform-lastname label').text() | ||
| 175 | + var newLabelName= 'представителя' | ||
| 176 | + | ||
| 177 | + var registerValCompany = $('.register-val-company .custom-radio:checked').attr('value'); | ||
| 178 | + var regHideBlock = $('.register-company-block .form-group'); | ||
| 179 | + if(registerValCompany==1) { | ||
| 178 | $('.field-signupform-firstname label').html(labelName) | 180 | $('.field-signupform-firstname label').html(labelName) |
| 179 | $('.field-signupform-lastname label').html(labelLastName) | 181 | $('.field-signupform-lastname label').html(labelLastName) |
| 180 | $('.register-company-block').css('display', 'none'); | 182 | $('.register-company-block').css('display', 'none'); |
| 181 | - } | ||
| 182 | - $('.register-val-company .custom-radio').change(function(){ | 183 | + $('#w0').yiiActiveForm('remove','signupform-name'); |
| 184 | + } | ||
| 185 | + $('.register-val-company .custom-radio').change(function(){ | ||
| 183 | var newRegisterValCompany = +$(this).attr('value'); | 186 | var newRegisterValCompany = +$(this).attr('value'); |
| 184 | if(newRegisterValCompany==1){ | 187 | if(newRegisterValCompany==1){ |
| 185 | //human | 188 | //human |
| 186 | $('.field-signupform-firstname label').html(labelName) | 189 | $('.field-signupform-firstname label').html(labelName) |
| 187 | $('.field-signupform-lastname label').html(labelLastName) | 190 | $('.field-signupform-lastname label').html(labelLastName) |
| 188 | $('.register-company-block').css('display', 'none'); | 191 | $('.register-company-block').css('display', 'none'); |
| 192 | + $('#w0').yiiActiveForm('remove','signupform-name'); | ||
| 193 | + | ||
| 194 | + | ||
| 189 | 195 | ||
| 190 | } else { | 196 | } else { |
| 191 | //company | 197 | //company |
| 192 | $('.field-signupform-firstname label').html(labelName+' '+newLabelName) | 198 | $('.field-signupform-firstname label').html(labelName+' '+newLabelName) |
| 193 | $('.field-signupform-lastname label').html(labelLastName+' '+newLabelName) | 199 | $('.field-signupform-lastname label').html(labelLastName+' '+newLabelName) |
| 194 | $('.register-company-block').css('display', 'block'); | 200 | $('.register-company-block').css('display', 'block'); |
| 201 | + $('#w0').yiiActiveForm('add', { | ||
| 202 | + 'container': '.field-signupform-name', | ||
| 203 | + 'error': '.help-block', | ||
| 204 | + 'id': 'signupform-name', | ||
| 205 | + 'input': '#signupform-name', | ||
| 206 | + 'name': 'name', | ||
| 207 | + validate: function (attribute, value, messages, deferred, \$form) {yii.validation.required(value, messages, {'message':'Необходимо заполнить «Название компании».'});} | ||
| 208 | + | ||
| 209 | + }); | ||
| 195 | } | 210 | } |
| 196 | 211 | ||
| 197 | - }) | 212 | + }) |
| 213 | +"; | ||
| 214 | + | ||
| 215 | +$this->registerJS($js ); | ||
| 216 | +?> | ||
| 198 | 217 | ||
| 199 | -</script> | ||
| 200 | \ No newline at end of file | 218 | \ No newline at end of file |