Commit 377b29c784a9282d124eea88b84d85ec4520a4b9
1 parent
31c230f6
Yarik comment
Showing
24 changed files
with
637 additions
and
95 deletions
Show diff stats
.gitignore
common/config/main.php
common/modules/comment/Controller.php
| @@ -93,4 +93,5 @@ | @@ -93,4 +93,5 @@ | ||
| 93 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | 93 | \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; |
| 94 | \Yii::$app->response->send(); | 94 | \Yii::$app->response->send(); |
| 95 | } | 95 | } |
| 96 | + | ||
| 96 | } | 97 | } |
| 97 | \ No newline at end of file | 98 | \ No newline at end of file |
common/modules/comment/assets/CommentAsset.php
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | 3 | ||
| 4 | class CommentAsset extends \yii\web\AssetBundle | 4 | class CommentAsset extends \yii\web\AssetBundle |
| 5 | { | 5 | { |
| 6 | + | ||
| 6 | public $sourcePath = '@common/modules/comment/resources'; | 7 | public $sourcePath = '@common/modules/comment/resources'; |
| 7 | 8 | ||
| 8 | public $css = [ | 9 | public $css = [ |
| @@ -18,4 +19,8 @@ | @@ -18,4 +19,8 @@ | ||
| 18 | '\yii\web\JqueryAsset', | 19 | '\yii\web\JqueryAsset', |
| 19 | ]; | 20 | ]; |
| 20 | 21 | ||
| 22 | + public $jsOptions = [ | ||
| 23 | + 'position' => \yii\web\View::POS_READY, | ||
| 24 | + ]; | ||
| 25 | + | ||
| 21 | } | 26 | } |
| 22 | \ No newline at end of file | 27 | \ No newline at end of file |
common/modules/comment/models/Comment.php
| 1 | <?php | 1 | <?php |
| 2 | namespace common\modules\comment\models; | 2 | namespace common\modules\comment\models; |
| 3 | 3 | ||
| 4 | + use common\models\User; | ||
| 4 | use yii\db\ActiveQuery; | 5 | use yii\db\ActiveQuery; |
| 5 | 6 | ||
| 6 | /** | 7 | /** |
| @@ -18,6 +19,8 @@ | @@ -18,6 +19,8 @@ | ||
| 18 | * @property string $date_delete | 19 | * @property string $date_delete |
| 19 | * @property string $model | 20 | * @property string $model |
| 20 | * @property int $model_id | 21 | * @property int $model_id |
| 22 | + * @property Rating $rating | ||
| 23 | + * @property User $user | ||
| 21 | * @package common\modules\comment\models | 24 | * @package common\modules\comment\models |
| 22 | */ | 25 | */ |
| 23 | class Comment extends \yii\db\ActiveRecord | 26 | class Comment extends \yii\db\ActiveRecord |
| @@ -117,6 +120,22 @@ | @@ -117,6 +120,22 @@ | ||
| 117 | ]; | 120 | ]; |
| 118 | } | 121 | } |
| 119 | 122 | ||
| 123 | + public function afterSave($insert, $changedAttributes) | ||
| 124 | + { | ||
| 125 | + if($this->model == User::className()) { | ||
| 126 | + if($user = User::findOne($this->model_id)) { | ||
| 127 | + /** | ||
| 128 | + * @var User $user | ||
| 129 | + */ | ||
| 130 | + $user->updateRating(); | ||
| 131 | + } | ||
| 132 | + } | ||
| 133 | + parent::afterSave($insert, $changedAttributes); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * @inheritdoc | ||
| 138 | + */ | ||
| 120 | public static function tableName() | 139 | public static function tableName() |
| 121 | { | 140 | { |
| 122 | return '{{%comment}}'; | 141 | return '{{%comment}}'; |
| @@ -157,7 +176,7 @@ | @@ -157,7 +176,7 @@ | ||
| 157 | 'comment.model' => $model, | 176 | 'comment.model' => $model, |
| 158 | 'comment.model_id' => $model_id, | 177 | 'comment.model_id' => $model_id, |
| 159 | 'comment.status' => 1, | 178 | 'comment.status' => 1, |
| 160 | - ]); | 179 | + ])->with('rating'); |
| 161 | } | 180 | } |
| 162 | 181 | ||
| 163 | public function postComment() | 182 | public function postComment() |
| @@ -294,7 +313,7 @@ | @@ -294,7 +313,7 @@ | ||
| 294 | 'model' => $this->className(), | 313 | 'model' => $this->className(), |
| 295 | ]) | 314 | ]) |
| 296 | ->one(); | 315 | ->one(); |
| 297 | - if(!$rating instanceof \common\modules\comment\models\Rating) { | 316 | + if(!$rating instanceof \common\modules\comment\models\Rating && !empty($this->primaryKey)) { |
| 298 | $rating = new \common\modules\comment\models\Rating([ | 317 | $rating = new \common\modules\comment\models\Rating([ |
| 299 | 'model' => $this->className(), | 318 | 'model' => $this->className(), |
| 300 | 'model_id' => $this->comment_id, | 319 | 'model_id' => $this->comment_id, |
| @@ -331,4 +350,9 @@ | @@ -331,4 +350,9 @@ | ||
| 331 | } | 350 | } |
| 332 | } | 351 | } |
| 333 | 352 | ||
| 353 | + public function getUser() | ||
| 354 | + { | ||
| 355 | + return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); | ||
| 356 | + } | ||
| 357 | + | ||
| 334 | } | 358 | } |
common/modules/comment/models/CommentProject.php
| @@ -3,26 +3,32 @@ | @@ -3,26 +3,32 @@ | ||
| 3 | 3 | ||
| 4 | use common\models\Currency; | 4 | use common\models\Currency; |
| 5 | use common\models\File; | 5 | use common\models\File; |
| 6 | + use common\models\Project; | ||
| 7 | + use common\models\User; | ||
| 6 | use yii\db\ActiveQuery; | 8 | use yii\db\ActiveQuery; |
| 9 | + use yii\db\ActiveRecord; | ||
| 7 | use yii\web\UploadedFile; | 10 | use yii\web\UploadedFile; |
| 8 | 11 | ||
| 9 | /** | 12 | /** |
| 10 | * Class Comment | 13 | * Class Comment |
| 11 | - * @property bool $guestComment | ||
| 12 | - * @property integer $comment_id | ||
| 13 | - * @property string $text | ||
| 14 | - * @property int $user_id | ||
| 15 | - * @property int $status | ||
| 16 | - * @property string $date_add | ||
| 17 | - * @property string $date_update | ||
| 18 | - * @property string $date_delete | ||
| 19 | - * @property string $model | ||
| 20 | - * @property int $model_id | ||
| 21 | - * @property string $files | ||
| 22 | - * @property float $budget_from | ||
| 23 | - * @property float $budget_to | ||
| 24 | - * @property int $term_from | ||
| 25 | - * @property int $term_to | 14 | + * @property bool $guestComment |
| 15 | + * @property integer $comment_id | ||
| 16 | + * @property string $text | ||
| 17 | + * @property int $user_id | ||
| 18 | + * @property int $status | ||
| 19 | + * @property string $date_add | ||
| 20 | + * @property string $date_update | ||
| 21 | + * @property string $date_delete | ||
| 22 | + * @property string $model | ||
| 23 | + * @property int $model_id | ||
| 24 | + * @property string $files | ||
| 25 | + * @property float $budget_from | ||
| 26 | + * @property float $budget_to | ||
| 27 | + * @property int $term_from | ||
| 28 | + * @property int $term_to | ||
| 29 | + * @property int $state | ||
| 30 | + * @property Currency $currency | ||
| 31 | + * @property Project $project | ||
| 26 | * @package common\modules\comment\models | 32 | * @package common\modules\comment\models |
| 27 | */ | 33 | */ |
| 28 | class CommentProject extends \yii\db\ActiveRecord | 34 | class CommentProject extends \yii\db\ActiveRecord |
| @@ -35,13 +41,22 @@ | @@ -35,13 +41,22 @@ | ||
| 35 | const STATUS_PERSONAL = 3; | 41 | const STATUS_PERSONAL = 3; |
| 36 | const STATUS_ANONYMOUS = 4; | 42 | const STATUS_ANONYMOUS = 4; |
| 37 | 43 | ||
| 44 | + const STATE_NEW = 1; | ||
| 45 | + const STATE_CANDIDATE = 2; | ||
| 46 | + const STATE_PERFORMER = 3; | ||
| 47 | + const STATE_DENY = 4; | ||
| 48 | + const STATE_TRASH = 5; | ||
| 49 | + | ||
| 38 | const SCENARIO_USER = 'user'; | 50 | const SCENARIO_USER = 'user'; |
| 39 | const SCENARIO_GUEST = 'guest'; | 51 | const SCENARIO_GUEST = 'guest'; |
| 52 | + const SCENARIO_STATE = 'state'; | ||
| 53 | + const SCENARIO_OWNER = 'owner'; | ||
| 40 | 54 | ||
| 41 | /** | 55 | /** |
| 42 | * @var bool | 56 | * @var bool |
| 43 | */ | 57 | */ |
| 44 | public $guestComment = false; | 58 | public $guestComment = false; |
| 59 | + | ||
| 45 | public $file; | 60 | public $file; |
| 46 | 61 | ||
| 47 | public function rules() | 62 | public function rules() |
| @@ -84,7 +99,7 @@ | @@ -84,7 +99,7 @@ | ||
| 84 | [ | 99 | [ |
| 85 | [ 'budget_currency' ], | 100 | [ 'budget_currency' ], |
| 86 | 'exist', | 101 | 'exist', |
| 87 | - 'targetClass' => Currency::className(), | 102 | + 'targetClass' => Currency::className(), |
| 88 | 'targetAttribute' => 'currency_id', | 103 | 'targetAttribute' => 'currency_id', |
| 89 | ], | 104 | ], |
| 90 | [ | 105 | [ |
| @@ -104,6 +119,32 @@ | @@ -104,6 +119,32 @@ | ||
| 104 | 'default', | 119 | 'default', |
| 105 | 'value' => 1, | 120 | 'value' => 1, |
| 106 | ], | 121 | ], |
| 122 | + [ | ||
| 123 | + [ 'state' ], | ||
| 124 | + 'integer', | ||
| 125 | + 'max' => 4, | ||
| 126 | + 'min' => 1, | ||
| 127 | + 'on' => self::SCENARIO_STATE, | ||
| 128 | + ], | ||
| 129 | + [ | ||
| 130 | + [ 'state' ], | ||
| 131 | + 'required', | ||
| 132 | + 'on' => self::SCENARIO_STATE, | ||
| 133 | + ], | ||
| 134 | + [ | ||
| 135 | + [ 'state' ], | ||
| 136 | + 'required', | ||
| 137 | + 'on' => self::SCENARIO_OWNER, | ||
| 138 | + ], | ||
| 139 | + [ | ||
| 140 | + [ 'state' ], | ||
| 141 | + 'in', | ||
| 142 | + 'range' => [ | ||
| 143 | + 1, | ||
| 144 | + 5, | ||
| 145 | + ], | ||
| 146 | + 'on' => self::SCENARIO_OWNER, | ||
| 147 | + ], | ||
| 107 | ]; | 148 | ]; |
| 108 | } | 149 | } |
| 109 | 150 | ||
| @@ -118,9 +159,15 @@ | @@ -118,9 +159,15 @@ | ||
| 118 | 'term_to', | 159 | 'term_to', |
| 119 | 'file', | 160 | 'file', |
| 120 | ], | 161 | ], |
| 121 | - self::SCENARIO_GUEST => [ | 162 | + self::SCENARIO_GUEST => [ |
| 122 | 163 | ||
| 123 | ], | 164 | ], |
| 165 | + self::SCENARIO_STATE => [ | ||
| 166 | + 'state', | ||
| 167 | + ], | ||
| 168 | + self::SCENARIO_OWNER => [ | ||
| 169 | + 'state', | ||
| 170 | + ], | ||
| 124 | ]; | 171 | ]; |
| 125 | } | 172 | } |
| 126 | 173 | ||
| @@ -150,11 +197,11 @@ | @@ -150,11 +197,11 @@ | ||
| 150 | public function attributeLabels() | 197 | public function attributeLabels() |
| 151 | { | 198 | { |
| 152 | return [ | 199 | return [ |
| 153 | - 'text' => \Yii::t('app', 'Текст ответа'), | 200 | + 'text' => \Yii::t('app', 'Текст ответа'), |
| 154 | 'budget_from' => \Yii::t('app', 'от'), | 201 | 'budget_from' => \Yii::t('app', 'от'), |
| 155 | - 'budget_to' => \Yii::t('app', 'до'), | ||
| 156 | - 'term_from' => \Yii::t('app', 'от'), | ||
| 157 | - 'term_to' => \Yii::t('app', 'до'), | 202 | + 'budget_to' => \Yii::t('app', 'до'), |
| 203 | + 'term_from' => \Yii::t('app', 'от'), | ||
| 204 | + 'term_to' => \Yii::t('app', 'до'), | ||
| 158 | ]; | 205 | ]; |
| 159 | } | 206 | } |
| 160 | 207 | ||
| @@ -163,10 +210,10 @@ | @@ -163,10 +210,10 @@ | ||
| 163 | return $this->guestComment; | 210 | return $this->guestComment; |
| 164 | } | 211 | } |
| 165 | 212 | ||
| 166 | -// public function setGuestComment($value) | ||
| 167 | -// { | ||
| 168 | -// $this->guestComment = $value; | ||
| 169 | -// } | 213 | + // public function setGuestComment($value) |
| 214 | + // { | ||
| 215 | + // $this->guestComment = $value; | ||
| 216 | + // } | ||
| 170 | 217 | ||
| 171 | /** | 218 | /** |
| 172 | * @param string $model | 219 | * @param string $model |
| @@ -181,27 +228,28 @@ | @@ -181,27 +228,28 @@ | ||
| 181 | 'comment_project.model' => $model, | 228 | 'comment_project.model' => $model, |
| 182 | 'comment_project.model_id' => $model_id, | 229 | 'comment_project.model_id' => $model_id, |
| 183 | 'comment_project.status' => 1, | 230 | 'comment_project.status' => 1, |
| 184 | - ]); | 231 | + ]) |
| 232 | + ->with('currency', 'user', 'user.userInfo', 'user.companyInfo', 'user.comments'); | ||
| 185 | } | 233 | } |
| 186 | 234 | ||
| 187 | public function postComment() | 235 | public function postComment() |
| 188 | { | 236 | { |
| 189 | if($this->checkCreate()) { | 237 | if($this->checkCreate()) { |
| 190 | - if(!empty(\Yii::$app->request->post($this->formName())['anonymous'])) { | 238 | + if(!empty( \Yii::$app->request->post($this->formName())[ 'anonymous' ] )) { |
| 191 | $this->status = self::STATUS_ANONYMOUS; | 239 | $this->status = self::STATUS_ANONYMOUS; |
| 192 | } | 240 | } |
| 193 | $this->file = UploadedFile::getInstances($this, 'file'); | 241 | $this->file = UploadedFile::getInstances($this, 'file'); |
| 194 | - if(!empty($this->file)) { | ||
| 195 | - $file_id = []; | ||
| 196 | - if(is_array($this->file)){ | ||
| 197 | - foreach($this->file as $file){ | ||
| 198 | - if($file instanceof UploadedFile){ | 242 | + if(!empty( $this->file )) { |
| 243 | + $file_id = [ ]; | ||
| 244 | + if(is_array($this->file)) { | ||
| 245 | + foreach($this->file as $file) { | ||
| 246 | + if($file instanceof UploadedFile) { | ||
| 199 | $file_model = new File(); | 247 | $file_model = new File(); |
| 200 | $file_id[] = $file_model->saveFile($file); | 248 | $file_id[] = $file_model->saveFile($file); |
| 201 | } | 249 | } |
| 202 | } | 250 | } |
| 203 | } else { | 251 | } else { |
| 204 | - if($this->file instanceof UploadedFile){ | 252 | + if($this->file instanceof UploadedFile) { |
| 205 | $file_model = new File(); | 253 | $file_model = new File(); |
| 206 | $file_id[] = $file_model->saveFile($this->file); | 254 | $file_id[] = $file_model->saveFile($this->file); |
| 207 | } | 255 | } |
| @@ -325,4 +373,65 @@ | @@ -325,4 +373,65 @@ | ||
| 325 | // } | 373 | // } |
| 326 | } | 374 | } |
| 327 | 375 | ||
| 376 | + /** | ||
| 377 | + * @return ActiveQuery | ||
| 378 | + */ | ||
| 379 | + public function getCurrency() | ||
| 380 | + { | ||
| 381 | + return $this->hasOne(Currency::className(), [ 'currency_id' => 'budget_currency' ]); | ||
| 382 | + } | ||
| 383 | + | ||
| 384 | + /** | ||
| 385 | + * @return File[] | ||
| 386 | + */ | ||
| 387 | + public function getFilesList() | ||
| 388 | + { | ||
| 389 | + $files = json_decode($this->files); | ||
| 390 | + if(!empty( $files )) { | ||
| 391 | + return File::findAll($files); | ||
| 392 | + } else { | ||
| 393 | + return [ ]; | ||
| 394 | + } | ||
| 395 | + } | ||
| 396 | + | ||
| 397 | + /** | ||
| 398 | + * @return ActiveRecord | ||
| 399 | + * @throws \TypeError | ||
| 400 | + */ | ||
| 401 | + public function getOwner() | ||
| 402 | + { | ||
| 403 | + $model = new $this->model(); | ||
| 404 | + if($model instanceof ActiveRecord) { | ||
| 405 | + return $model->findOne($this->model_id); | ||
| 406 | + } else { | ||
| 407 | + throw new \TypeError('Model must extends Active Record Class'); | ||
| 408 | + } | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + public function getProject() | ||
| 412 | + { | ||
| 413 | + return $this->hasOne(Project::className(), [ 'project_id' => 'model_id' ]); | ||
| 414 | + } | ||
| 415 | + | ||
| 416 | + /** | ||
| 417 | + * @return User | ||
| 418 | + */ | ||
| 419 | + public function getUser() | ||
| 420 | + { | ||
| 421 | + return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); | ||
| 422 | + } | ||
| 423 | + | ||
| 424 | + public function changeState() | ||
| 425 | + { | ||
| 426 | + if($this->isAttributeChanged('state')) { | ||
| 427 | + if($this->save()) { | ||
| 428 | + return true; | ||
| 429 | + } else { | ||
| 430 | + return false; | ||
| 431 | + } | ||
| 432 | + } else { | ||
| 433 | + return true; | ||
| 434 | + } | ||
| 435 | + } | ||
| 436 | + | ||
| 328 | } | 437 | } |
common/modules/comment/models/CommentProjectSearch.php
0 → 100644
| 1 | +<?php | ||
| 2 | + namespace common\modules\comment\models; | ||
| 3 | + | ||
| 4 | + use common\models\Currency; | ||
| 5 | + use common\models\File; | ||
| 6 | + use common\models\User; | ||
| 7 | + use yii\data\ActiveDataProvider; | ||
| 8 | + use yii\db\ActiveQuery; | ||
| 9 | + use yii\db\ActiveRecord; | ||
| 10 | + use yii\web\UploadedFile; | ||
| 11 | + | ||
| 12 | + /** | ||
| 13 | + * Class Comment | ||
| 14 | + * @property bool $guestComment | ||
| 15 | + * @property integer $comment_id | ||
| 16 | + * @property string $text | ||
| 17 | + * @property int $user_id | ||
| 18 | + * @property int $status | ||
| 19 | + * @property string $date_add | ||
| 20 | + * @property string $date_update | ||
| 21 | + * @property string $date_delete | ||
| 22 | + * @property string $model | ||
| 23 | + * @property int $model_id | ||
| 24 | + * @property string $files | ||
| 25 | + * @property float $budget_from | ||
| 26 | + * @property float $budget_to | ||
| 27 | + * @property int $term_from | ||
| 28 | + * @property int $term_to | ||
| 29 | + * @property int $state | ||
| 30 | + * @property Currency $currency | ||
| 31 | + * @package common\modules\comment\models | ||
| 32 | + */ | ||
| 33 | + class CommentProjectSearch extends CommentProject | ||
| 34 | + { | ||
| 35 | + | ||
| 36 | + const SCENARIO_SEARCH = 'search'; | ||
| 37 | + | ||
| 38 | + public function rules() | ||
| 39 | + { | ||
| 40 | + return [ | ||
| 41 | + [ | ||
| 42 | + [ | ||
| 43 | + 'state', | ||
| 44 | + ], | ||
| 45 | + 'integer', | ||
| 46 | + 'max' => 5, | ||
| 47 | + 'min' => 1, | ||
| 48 | + ], | ||
| 49 | + [ | ||
| 50 | + [ | ||
| 51 | + 'state', | ||
| 52 | + ], | ||
| 53 | + 'default', | ||
| 54 | + 'value' => self::STATE_NEW, | ||
| 55 | + ], | ||
| 56 | + ]; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public function scenarios() | ||
| 60 | + { | ||
| 61 | + return array_merge(parent::scenarios(), [ | ||
| 62 | + self::SCENARIO_SEARCH => [ | ||
| 63 | + 'state', | ||
| 64 | + ], | ||
| 65 | + ]); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public function search($params) | ||
| 69 | + { | ||
| 70 | + $query = CommentProject::find() | ||
| 71 | + ->with('project') | ||
| 72 | + ->with('project.budgetCurrency') | ||
| 73 | + ->with('project.comments') | ||
| 74 | + ->where([ 'user_id' => \Yii::$app->user->getId() ]); | ||
| 75 | + | ||
| 76 | + $dataProvider = new ActiveDataProvider([ | ||
| 77 | + 'query' => $query, | ||
| 78 | + ]); | ||
| 79 | + | ||
| 80 | + $this->load($params); | ||
| 81 | + | ||
| 82 | + if(!$this->validate()) { | ||
| 83 | + $query->andWhere('0=1'); | ||
| 84 | + return $dataProvider; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + $query->andWhere([ 'state' => $this->state ]); | ||
| 88 | + | ||
| 89 | + return $dataProvider; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + } |
common/modules/comment/rbac/ArtboxCommentCreateRule.php
| @@ -11,7 +11,28 @@ | @@ -11,7 +11,28 @@ | ||
| 11 | 11 | ||
| 12 | public function execute($user, $item, $params) | 12 | public function execute($user, $item, $params) |
| 13 | { | 13 | { |
| 14 | + if($params[ 'model' ] == \common\models\Project::className()) { | ||
| 15 | + return $this->checkProject($user, $item, $params); | ||
| 16 | + } | ||
| 14 | return true; | 17 | return true; |
| 15 | } | 18 | } |
| 16 | 19 | ||
| 20 | + public function checkProject($user, $item, $params) | ||
| 21 | + { | ||
| 22 | + $project = \common\models\Project::findOne($params['model_id']); | ||
| 23 | + if($project->user_id == $user) { | ||
| 24 | + return false; | ||
| 25 | + } | ||
| 26 | + $comment = \common\modules\comment\models\CommentProject::find() | ||
| 27 | + ->where([ 'model' => $params[ 'model' ], | ||
| 28 | + 'model_id' => $params[ 'model_id' ], | ||
| 29 | + 'user_id' => $user, | ||
| 30 | + ])->one(); | ||
| 31 | + if(empty($comment)) { | ||
| 32 | + return true; | ||
| 33 | + } else { | ||
| 34 | + return false; | ||
| 35 | + } | ||
| 36 | + } | ||
| 37 | + | ||
| 17 | } | 38 | } |
| 18 | \ No newline at end of file | 39 | \ No newline at end of file |
common/modules/comment/rbac/ArtboxCommentUpdateOwnRule.php
common/modules/comment/widgets/CommentWidget.php
| @@ -167,7 +167,7 @@ | @@ -167,7 +167,7 @@ | ||
| 167 | $this->parts[ 'list' ] = Html::tag($tag, $this->renderItems($view), $this->list_options); | 167 | $this->parts[ 'list' ] = Html::tag($tag, $this->renderItems($view), $this->list_options); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | - if($this->display_comment_form) { | 170 | + if($this->display_comment_form && $this->comment_class->checkCreate()) { |
| 171 | $tag = ArrayHelper::remove($this->form_options, 'tag', 'div'); | 171 | $tag = ArrayHelper::remove($this->form_options, 'tag', 'div'); |
| 172 | $view = ArrayHelper::remove($this->form_options, 'view'); | 172 | $view = ArrayHelper::remove($this->form_options, 'view'); |
| 173 | $this->parts[ 'form' ] = Html::tag($tag, $this->renderForm($view), $this->form_options); | 173 | $this->parts[ 'form' ] = Html::tag($tag, $this->renderForm($view), $this->form_options); |
| @@ -197,12 +197,16 @@ | @@ -197,12 +197,16 @@ | ||
| 197 | if(empty( $view )) { | 197 | if(empty( $view )) { |
| 198 | throw new \yii\base\InvalidConfigException("form_options[view] must be set"); | 198 | throw new \yii\base\InvalidConfigException("form_options[view] must be set"); |
| 199 | } | 199 | } |
| 200 | - return $this->render($view, [ | ||
| 201 | - 'model' => $this->comment_class, | ||
| 202 | - 'rating' => $this->rating_class, | ||
| 203 | - 'user' => \Yii::$app->user->identity, | ||
| 204 | - 'dataProvider' => $this->dataProvider, | ||
| 205 | - ]); | 200 | + if($this->comment_class->guestComment || !empty(\Yii::$app->user->identity)) { |
| 201 | + return $this->render($view, [ | ||
| 202 | + 'model' => $this->comment_class, | ||
| 203 | + 'rating' => $this->rating_class, | ||
| 204 | + 'user' => \Yii::$app->user->identity, | ||
| 205 | + 'dataProvider' => $this->dataProvider, | ||
| 206 | + ]); | ||
| 207 | + } else { | ||
| 208 | + return ''; | ||
| 209 | + } | ||
| 206 | } | 210 | } |
| 207 | 211 | ||
| 208 | public function renderWidget() | 212 | public function renderWidget() |
| @@ -221,8 +225,11 @@ | @@ -221,8 +225,11 @@ | ||
| 221 | { | 225 | { |
| 222 | $data = \Yii::$app->request->post(); | 226 | $data = \Yii::$app->request->post(); |
| 223 | if($this->comment_class->load($data) && $this->comment_class->postComment()) { | 227 | if($this->comment_class->load($data) && $this->comment_class->postComment()) { |
| 224 | - if(is_object($this->rating_class) && $this->comment_class->rating->load($data) && $this->comment_class->rating->save()) { | ||
| 225 | - $this->isSuccess = true; | 228 | + if(is_object($this->rating_class)) { |
| 229 | + $this->comment_class->checkRating(); | ||
| 230 | + if($this->comment_class->rating->load($data) && $this->comment_class->rating->save()) { | ||
| 231 | + $this->isSuccess = true; | ||
| 232 | + } | ||
| 226 | } | 233 | } |
| 227 | } | 234 | } |
| 228 | } | 235 | } |
common/modules/comment/widgets/views/_project_comment_view.php
| @@ -10,13 +10,7 @@ | @@ -10,13 +10,7 @@ | ||
| 10 | * @var \yii\widgets\ListView $widget current ListView instance | 10 | * @var \yii\widgets\ListView $widget current ListView instance |
| 11 | * @var User $user | 11 | * @var User $user |
| 12 | */ | 12 | */ |
| 13 | - $user = NULL; | ||
| 14 | - if(!empty( $model->user_id )) { | ||
| 15 | - $user = User::find() | ||
| 16 | - ->where([ 'id' => $model->user_id ]) | ||
| 17 | - ->with('userInfo') | ||
| 18 | - ->one(); | ||
| 19 | - } | 13 | + $user = $model->user; |
| 20 | ?> | 14 | ?> |
| 21 | <div class="performer-vacancy-sidebar-left-wr"> | 15 | <div class="performer-vacancy-sidebar-left-wr"> |
| 22 | <div class="performer-vacancy-sidebar-left"> | 16 | <div class="performer-vacancy-sidebar-left"> |
| @@ -28,22 +22,22 @@ | @@ -28,22 +22,22 @@ | ||
| 28 | <ul> | 22 | <ul> |
| 29 | <?php | 23 | <?php |
| 30 | if(!empty( $user->userInfo->social_fb )) { | 24 | if(!empty( $user->userInfo->social_fb )) { |
| 31 | - echo '<li>'.Html::a(Html::img('/images/ico-fb.png'), $user->userInfo->social_fb, ['target' => '_blank']).'</li>'; | 25 | + echo '<li>' . Html::a(Html::img('/images/ico-fb.png'), $user->userInfo->social_fb, [ 'target' => '_blank' ]) . '</li>'; |
| 32 | } | 26 | } |
| 33 | ?> | 27 | ?> |
| 34 | <?php | 28 | <?php |
| 35 | if(!empty( $user->userInfo->social_t )) { | 29 | if(!empty( $user->userInfo->social_t )) { |
| 36 | - echo '<li>'.Html::a(Html::img('/images/ico-tw.png'), $user->userInfo->social_t, ['target' => '_blank']).'</li>'; | 30 | + echo '<li>' . Html::a(Html::img('/images/ico-tw.png'), $user->userInfo->social_t, [ 'target' => '_blank' ]) . '</li>'; |
| 37 | } | 31 | } |
| 38 | ?> | 32 | ?> |
| 39 | <?php | 33 | <?php |
| 40 | if(!empty( $user->userInfo->social_in )) { | 34 | if(!empty( $user->userInfo->social_in )) { |
| 41 | - echo '<li>'.Html::a(Html::img('/images/ico-in.png'), $user->userInfo->social_in, ['target' => '_blank']).'</li>'; | 35 | + echo '<li>' . Html::a(Html::img('/images/ico-in.png'), $user->userInfo->social_in, [ 'target' => '_blank' ]) . '</li>'; |
| 42 | } | 36 | } |
| 43 | ?> | 37 | ?> |
| 44 | <?php | 38 | <?php |
| 45 | if(!empty( $user->userInfo->social_vk )) { | 39 | if(!empty( $user->userInfo->social_vk )) { |
| 46 | - echo '<li>'.Html::a(Html::img('/images/ico-vk.png'), $user->userInfo->social_vk, ['target' => '_blank']).'</li>'; | 40 | + echo '<li>' . Html::a(Html::img('/images/ico-vk.png'), $user->userInfo->social_vk, [ 'target' => '_blank' ]) . '</li>'; |
| 47 | } | 41 | } |
| 48 | ?> | 42 | ?> |
| 49 | </ul> | 43 | </ul> |
| @@ -54,60 +48,96 @@ | @@ -54,60 +48,96 @@ | ||
| 54 | <div class="sidebarvievstxt"><?= $user->userInfo->view_count ?></div> | 48 | <div class="sidebarvievstxt"><?= $user->userInfo->view_count ?></div> |
| 55 | </li> | 49 | </li> |
| 56 | <li><img src="/images/sidebar-ico/ico-9.png" alt=""> | 50 | <li><img src="/images/sidebar-ico/ico-9.png" alt=""> |
| 57 | - <div class="sidebarvievstxt"><span class="sidebar-views-txt">Статус: </span><?= (empty($user->userInfo->busy)?'Свободен':'Занят') ?> | 51 | + <div class="sidebarvievstxt"> |
| 52 | + <span class="sidebar-views-txt">Статус: </span><?= ( empty( $user->userInfo->busy ) ? 'Свободен' : 'Занят' ) ?> | ||
| 58 | </div> | 53 | </div> |
| 59 | </li> | 54 | </li> |
| 60 | <li><img src="/images/sidebar-ico/ico-2.png" alt=""> | 55 | <li><img src="/images/sidebar-ico/ico-2.png" alt=""> |
| 61 | <div class="sidebarvievstxt"> | 56 | <div class="sidebarvievstxt"> |
| 62 | - <span class="sidebar-views-txt">На сайте: </span>1г. 8 мес. | 57 | + <span class="sidebar-views-txt">На сайте: </span><?= $user->liveTime ?> |
| 63 | </div> | 58 | </div> |
| 64 | </li> | 59 | </li> |
| 65 | <li><img src="/images/sidebar-ico/ico-3.png" alt=""> | 60 | <li><img src="/images/sidebar-ico/ico-3.png" alt=""> |
| 66 | - <div class="sidebarvievstxt"><span class="sidebar-views-txt">Последний визит:<br></span>2 дня назад | 61 | + <div class="sidebarvievstxt"><span class="sidebar-views-txt">Последний визит:<br></span><?= $user->lastVisit ?> |
| 67 | </div> | 62 | </div> |
| 68 | </li> | 63 | </li> |
| 69 | </ul> | 64 | </ul> |
| 70 | - <a href="#" class="tender-see-profile style">Посмотреть профиль</a> | 65 | + <?= Html::a('Посмотреть профиль', $user->link, [ 'class' => 'tender-see-profile style' ]) ?> |
| 71 | </div> | 66 | </div> |
| 72 | </div> | 67 | </div> |
| 73 | </div> | 68 | </div> |
| 74 | </div> | 69 | </div> |
| 75 | <div class="tender-offer-proj-block-right-wr"> | 70 | <div class="tender-offer-proj-block-right-wr"> |
| 76 | <div class="tender-offer-proj-block-right"> | 71 | <div class="tender-offer-proj-block-right"> |
| 77 | - <div class="tender-offer-proj-min-blocks"><span>2000 грн</span></div> | ||
| 78 | - <div class="tender-offer-proj-min-blocks"><span>3 ДНЯ</span></div> | 72 | + <div class="tender-offer-proj-min-blocks"> |
| 73 | + <span><?= $model->budget_from . '-' . $model->budget_to . ' ' . $model->currency->label ?></span> | ||
| 74 | + </div> | ||
| 75 | + <div class="tender-offer-proj-min-blocks"> | ||
| 76 | + <span><?= $model->term_from . '-' . $model->term_to ?> ДНЯ</span></div> | ||
| 79 | </div> | 77 | </div> |
| 80 | <div class="tender-offer-proj-block-left"> | 78 | <div class="tender-offer-proj-block-left"> |
| 81 | <div class="search-worker-blocks-title-wr"> | 79 | <div class="search-worker-blocks-title-wr"> |
| 82 | - <div class="search-worker-blocks-title-title">Петер Цумтор</div> | 80 | + <div class="search-worker-blocks-title-title"><?= $user->name ?></div> |
| 83 | <div class="rating-new"> | 81 | <div class="rating-new"> |
| 84 | <!--оценка--> | 82 | <!--оценка--> |
| 85 | - <input type="hidden" class="val" value="4"/> | 83 | + <input type="hidden" class="val" value="<?= $user->userInfo->rating ?>"/> |
| 86 | </div> | 84 | </div> |
| 87 | - <a href="#" class="link-to-comm">30 отзывов</a> | 85 | + <?= Html::a(count($user->comments) . ' отзывов', $user->getLink('review'), [ 'class' => 'link-to-comm' ]) ?> |
| 88 | </div> | 86 | </div> |
| 89 | <div class="tender-offer-proj-txt"> | 87 | <div class="tender-offer-proj-txt"> |
| 90 | - <p>1.1 Строительная площадка расположена по адресу: г. Киев.</p> | ||
| 91 | - <p>1.2 Существующий объект представляет собой помещение общей площадью ориентировочно – 140 м2.</p> | ||
| 92 | - <p>1.3. Цель проекта состоит в проведении внутренних общестроительных и отделочных работ.</p> | ||
| 93 | - <p>1.4. При разработке методов строительства и выборе материалов, используемых в настоящем проекте, необходимо учитывать климатические условия, характерные для г. Киева.</p> | ||
| 94 | - <p>1.5. Требования к проектированию и производству работ определяются следующими документами:</p> | ||
| 95 | - <p>- Техническим заданием.</p> | ||
| 96 | - <p>- Строительными нормами и правилами.</p> | ||
| 97 | - <p>Все проектные решения и все разделы рабочего проекта должны быть согласованы с Заказчиком в объеме, необходимом для последующей сдачи инженерных систем и коммуникаций.</p> | 88 | + <?= $model->text ?> |
| 98 | </div> | 89 | </div> |
| 99 | <ul class="download-list-files"> | 90 | <ul class="download-list-files"> |
| 100 | - <li> | ||
| 101 | - <span></span><a href="#" class="download-link-file">КП.doc</a><a href="#" class="download-link">Скачать</a> | ||
| 102 | - </li> | ||
| 103 | - <li> | ||
| 104 | - <span></span><a href="#" class="download-link-file">Резюме.txt</a><a href="#" class="download-link">Скачать</a> | ||
| 105 | - </li> | 91 | + <?php |
| 92 | + foreach($model->getFilesList() as $file) { | ||
| 93 | + ?> | ||
| 94 | + <li> | ||
| 95 | + <span></span> | ||
| 96 | + <?= Html::a($file->name, $file->dir, [ 'class' => 'download-link-file' ]) ?> | ||
| 97 | + <?= Html::a('Скачать', $file->dir, [ | ||
| 98 | + 'class' => 'download-link', | ||
| 99 | + 'download' => 'download', | ||
| 100 | + ]) ?> | ||
| 101 | + </li> | ||
| 102 | + <?php | ||
| 103 | + } | ||
| 104 | + ?> | ||
| 106 | </ul> | 105 | </ul> |
| 107 | </div> | 106 | </div> |
| 108 | <div class="tender-more-buttons-wr"> | 107 | <div class="tender-more-buttons-wr"> |
| 109 | - <a class="get-project-new" href="#">Портфолио</a> | ||
| 110 | - <a class="get-list-new" href="#">Конаткты</a> | 108 | + <?= Html::a('Портфолио', $user->getLink('portfolio'), [ 'class' => 'get-project-new' ]) ?> |
| 109 | + <?= Html::a('Контакты', $user->link, [ 'class' => 'get-list-new' ]) ?> | ||
| 111 | </div> | 110 | </div> |
| 111 | + <?php | ||
| 112 | + if(\Yii::$app->user->getId() == $model->owner->user_id) { | ||
| 113 | + ?> | ||
| 114 | + <div class="project_owner_control" style="clear:both"> | ||
| 115 | + <span>Отметить как: </span> | ||
| 116 | + <?php | ||
| 117 | + echo Html::a('новый', [ '#' ], [ | ||
| 118 | + 'data-project-id' => $model->owner->project_id, | ||
| 119 | + 'data-comment-id' => $model->comment_id, | ||
| 120 | + 'class' => 'artbox_project_make_new', | ||
| 121 | + ]); | ||
| 122 | + echo Html::a('кандидат', [ '#' ], [ | ||
| 123 | + 'data-project-id' => $model->owner->project_id, | ||
| 124 | + 'data-comment-id' => $model->comment_id, | ||
| 125 | + 'class' => 'artbox_project_make_candidate', | ||
| 126 | + ]); | ||
| 127 | + echo Html::a('исполнитель', [ '#' ], [ | ||
| 128 | + 'data-project-id' => $model->owner->project_id, | ||
| 129 | + 'data-comment-id' => $model->comment_id, | ||
| 130 | + 'class' => 'artbox_project_make_performer', | ||
| 131 | + ]); | ||
| 132 | + echo Html::a('отказать', [ '#' ], [ | ||
| 133 | + 'data-project-id' => $model->owner->project_id, | ||
| 134 | + 'data-comment-id' => $model->comment_id, | ||
| 135 | + 'class' => 'artbox_project_make_deny', | ||
| 136 | + ]); | ||
| 137 | + ?> | ||
| 138 | + </div> | ||
| 139 | + <?php | ||
| 140 | + } | ||
| 141 | + ?> | ||
| 112 | 142 | ||
| 113 | </div> | 143 | </div> |
common/modules/comment/widgets/views/_review_comment_view.php
0 → 100644
| 1 | +<?php | ||
| 2 | + use common\models\User; | ||
| 3 | + use yii\helpers\Html; | ||
| 4 | + | ||
| 5 | + /** | ||
| 6 | + * @var \common\modules\comment\models\Comment $model Current comment model | ||
| 7 | + * @var integer $key ID of current comment | ||
| 8 | + * @var integer $index index of current element according | ||
| 9 | + * to current page, starting from 0 | ||
| 10 | + * @var \yii\widgets\ListView $widget current ListView instance | ||
| 11 | + * @var User $user | ||
| 12 | + */ | ||
| 13 | + $user = $model->user; | ||
| 14 | +?> | ||
| 15 | + <div class="comments-name"><?= $user->name ?></div> | ||
| 16 | +<?php | ||
| 17 | + /* == STATUS PRO == | ||
| 18 | + ?> | ||
| 19 | + <div class="comments-status"><span>Pro</span></div> | ||
| 20 | + <?php | ||
| 21 | + */ | ||
| 22 | +?> | ||
| 23 | + <div class="comments-date"><?= \Yii::$app->formatter->asDate($model->date_add, 'php:d.m.Y') ?></div> | ||
| 24 | +<?php | ||
| 25 | + if(!empty( $model->rating )) { | ||
| 26 | + ?> | ||
| 27 | + <div class="rating"> | ||
| 28 | + <!--оценка--> | ||
| 29 | + <input type="hidden" class="val" value="<?= $model->rating->value ?>"/> | ||
| 30 | + </div> | ||
| 31 | + <?php | ||
| 32 | + } | ||
| 33 | +?> | ||
| 34 | + <div class="comments-content"> | ||
| 35 | + <?= $model->text ?> | ||
| 36 | + </div> | ||
| 37 | +<?php | ||
| 38 | + /* == PROJECT INFO == | ||
| 39 | + ?> | ||
| 40 | + <div class="comments-project-link">Проект: <a href="#">Ремонт спальни</a></div> | ||
| 41 | + <?php | ||
| 42 | + */ | ||
| 43 | +?> | ||
| 0 | \ No newline at end of file | 44 | \ No newline at end of file |
common/modules/comment/widgets/views/form-comment-review.php
0 → 100644
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * @var \common\modules\comment\models\Comment $model | ||
| 4 | + * @var \common\models\User $user | ||
| 5 | + * @var \yii\data\ActiveDataProvider $dataProvider | ||
| 6 | + * @var null|\common\modules\comment\models\Rating $rating | ||
| 7 | + */ | ||
| 8 | + use yii\widgets\ActiveForm; | ||
| 9 | + use yii\helpers\Html; | ||
| 10 | + | ||
| 11 | +?> | ||
| 12 | +<div class="workplace-title style"> | ||
| 13 | + <p></p>Мнения о пользователе: <?= $dataProvider->totalCount ?></p></div> | ||
| 14 | +<div class="new-portf-add-comm style"> | ||
| 15 | + <?php | ||
| 16 | + $form = ActiveForm::begin(); | ||
| 17 | + echo $form->field($rating, 'value') | ||
| 18 | + ->label(false) | ||
| 19 | + ->radioList([ | ||
| 20 | + 1 => 1, | ||
| 21 | + 2 => 2, | ||
| 22 | + 3 => 3, | ||
| 23 | + 4 => 4, | ||
| 24 | + 5 => 5, | ||
| 25 | + ]); | ||
| 26 | + if($model->scenario == $model::SCENARIO_GUEST) { | ||
| 27 | + echo $form->field($model, 'user_name', [ | ||
| 28 | + 'options' => [ | ||
| 29 | + 'class' => 'input-blocks-comm', | ||
| 30 | + ], | ||
| 31 | + 'inputOptions' => [ | ||
| 32 | + 'class' => 'custom-input-4', | ||
| 33 | + ], | ||
| 34 | + ]) | ||
| 35 | + ->textInput(); | ||
| 36 | + echo $form->field($model, 'user_email', [ | ||
| 37 | + 'options' => [ | ||
| 38 | + 'class' => 'input-blocks-comm', | ||
| 39 | + ], | ||
| 40 | + 'inputOptions' => [ | ||
| 41 | + 'class' => 'custom-input-4', | ||
| 42 | + ], | ||
| 43 | + ]) | ||
| 44 | + ->textInput(); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + ?> | ||
| 48 | + <div class="artbox_comment_reply_block"></div> | ||
| 49 | + <?php | ||
| 50 | + echo $form->field($model, 'text', [ | ||
| 51 | + 'options' => [ | ||
| 52 | + 'class' => 'input-blocks-comm area-comm', | ||
| 53 | + ], | ||
| 54 | + 'inputOptions' => [ | ||
| 55 | + 'class' => 'custom-area-4', | ||
| 56 | + ], | ||
| 57 | + ]) | ||
| 58 | + ->textarea(); | ||
| 59 | + ?> | ||
| 60 | + <div class="input-blocks-comm-button style"> | ||
| 61 | + <?= Html::submitButton('Добавить комментарий') ?> | ||
| 62 | + </div> | ||
| 63 | + <?php | ||
| 64 | + $form->end(); | ||
| 65 | + ?> | ||
| 66 | +</div> | ||
| 0 | \ No newline at end of file | 67 | \ No newline at end of file |
common/modules/comment/widgets/views/form-project-comment.php
| @@ -14,7 +14,7 @@ | @@ -14,7 +14,7 @@ | ||
| 14 | <div class="new-portf-add-comm style"> | 14 | <div class="new-portf-add-comm style"> |
| 15 | <div class="box-wr"> | 15 | <div class="box-wr"> |
| 16 | <div class="box-all"> | 16 | <div class="box-all"> |
| 17 | - <div class="tender-add-answer-title">Добавить ответ</div> | 17 | + <div class="tender-add-answer-title"><?= Yii::t('app', 'add_answer') ?></div> |
| 18 | <div class="form-tender-answer style"> | 18 | <div class="form-tender-answer style"> |
| 19 | <?php | 19 | <?php |
| 20 | $form = ActiveForm::begin([ 'options' => [ 'class' => 'resformsfile MultiFile-intercepted', 'enctype' => 'multipart/form-data' ] ]); | 20 | $form = ActiveForm::begin([ 'options' => [ 'class' => 'resformsfile MultiFile-intercepted', 'enctype' => 'multipart/form-data' ] ]); |
| @@ -22,7 +22,7 @@ | @@ -22,7 +22,7 @@ | ||
| 22 | <div class="form-value-wr style"> | 22 | <div class="form-value-wr style"> |
| 23 | <div class="form-ico-ded-wr"> | 23 | <div class="form-ico-ded-wr"> |
| 24 | <div class="header-cabinet-foto"> | 24 | <div class="header-cabinet-foto"> |
| 25 | - <?= Html::img($user->userInfo->image) ?> | 25 | + <?= Html::img(($user->userInfo->image)?:'') ?> |
| 26 | </div> | 26 | </div> |
| 27 | <div class="form-value-ded-name"> | 27 | <div class="form-value-ded-name"> |
| 28 | <?= $user->name ?> | 28 | <?= $user->name ?> |
common/modules/comment/widgets/views/list-comment-review.php
0 → 100644
| 1 | +<?php | ||
| 2 | + /** | ||
| 3 | + * @var \yii\data\DataProviderInterface $dataProvider | ||
| 4 | + */ | ||
| 5 | +echo \yii\widgets\ListView::widget([ | ||
| 6 | + 'dataProvider' => $dataProvider, | ||
| 7 | + 'itemView' => '_review_comment_view', | ||
| 8 | + 'options' => [ | ||
| 9 | + 'tag' => 'ul', | ||
| 10 | + 'class' => 'proektant-comments style' | ||
| 11 | + ], | ||
| 12 | + 'itemOptions' => [ | ||
| 13 | + 'tag' => 'li', | ||
| 14 | + ], | ||
| 15 | + 'layout' => "{items}\n{pager}", | ||
| 16 | +]); | ||
| 0 | \ No newline at end of file | 17 | \ No newline at end of file |
common/modules/comment/widgets/views/list-project-comment.php
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | ?> | 5 | ?> |
| 6 | <div class="box-wr"> | 6 | <div class="box-wr"> |
| 7 | <div class="box-all"> | 7 | <div class="box-all"> |
| 8 | - <div class="tender-offer-proj-title-all style">Предложения проектантов</div> | 8 | + <div class="tender-offer-proj-title-all style">Предложения проектантов (<?=$dataProvider->getTotalCount()?>)</div> |
| 9 | <div class="tender-offer-proj-blocks-wr style"> | 9 | <div class="tender-offer-proj-blocks-wr style"> |
| 10 | <?php | 10 | <?php |
| 11 | echo \yii\widgets\ListView::widget([ | 11 | echo \yii\widgets\ListView::widget([ |
common/modules/product/models/Brand.php
| @@ -27,6 +27,12 @@ class Brand extends \yii\db\ActiveRecord | @@ -27,6 +27,12 @@ class Brand extends \yii\db\ActiveRecord | ||
| 27 | public function behaviors() | 27 | public function behaviors() |
| 28 | { | 28 | { |
| 29 | return [ | 29 | return [ |
| 30 | + 'slug' => [ | ||
| 31 | + 'class' => Slug::className(), | ||
| 32 | + 'in_attribute' => 'name', | ||
| 33 | + 'out_attribute' => 'alias', | ||
| 34 | + 'translit' => true | ||
| 35 | + ], | ||
| 30 | 'artboxsynonym' => [ | 36 | 'artboxsynonym' => [ |
| 31 | 'class' => ArtboxSynonymBehavior::className(), | 37 | 'class' => ArtboxSynonymBehavior::className(), |
| 32 | 'keyNameValue' => 'brand_name_id', | 38 | 'keyNameValue' => 'brand_name_id', |
| @@ -35,13 +41,7 @@ class Brand extends \yii\db\ActiveRecord | @@ -35,13 +41,7 @@ class Brand extends \yii\db\ActiveRecord | ||
| 35 | 'valueFields' => [ // postKey => DBFieldName | 41 | 'valueFields' => [ // postKey => DBFieldName |
| 36 | 'name' => 'value' | 42 | 'name' => 'value' |
| 37 | ] | 43 | ] |
| 38 | - ], | ||
| 39 | - 'slug' => [ | ||
| 40 | - 'class' => Slug::className(), | ||
| 41 | - 'in_attribute' => 'name', | ||
| 42 | - 'out_attribute' => 'alias', | ||
| 43 | - 'translit' => true | ||
| 44 | - ], | 44 | + ] |
| 45 | ]; | 45 | ]; |
| 46 | } | 46 | } |
| 47 | 47 |
common/modules/product/models/ProductVariant.php
| @@ -34,7 +34,7 @@ class ProductVariant extends \yii\db\ActiveRecord | @@ -34,7 +34,7 @@ class ProductVariant extends \yii\db\ActiveRecord | ||
| 34 | public function rules() | 34 | public function rules() |
| 35 | { | 35 | { |
| 36 | return [ | 36 | return [ |
| 37 | - [['product_id', 'sku', 'product_unit_id'], 'required'], | 37 | + [['product_id', 'name', 'sku', 'product_unit_id'], 'required'], |
| 38 | [['product_id', 'product_unit_id'], 'integer'], | 38 | [['product_id', 'product_unit_id'], 'integer'], |
| 39 | [['price', 'price_old', 'stock'], 'number'], | 39 | [['price', 'price_old', 'stock'], 'number'], |
| 40 | [['name', 'sku'], 'string', 'max' => 255], | 40 | [['name', 'sku'], 'string', 'max' => 255], |
common/modules/rubrication/models/TaxGroup.php
| @@ -15,7 +15,7 @@ use Yii; | @@ -15,7 +15,7 @@ use Yii; | ||
| 15 | * @property string $module | 15 | * @property string $module |
| 16 | * @property boolean $hierarchical | 16 | * @property boolean $hierarchical |
| 17 | * @property string $settings | 17 | * @property string $settings |
| 18 | - * @property boolean $is_filter | 18 | + * @property boolean is_filter |
| 19 | * | 19 | * |
| 20 | * @property TaxGroupToGroup[] $taxGroupToGroups | 20 | * @property TaxGroupToGroup[] $taxGroupToGroups |
| 21 | * @property TaxGroupToGroup[] $taxGroupToGroups0 | 21 | * @property TaxGroupToGroup[] $taxGroupToGroups0 |
| @@ -62,7 +62,7 @@ class TaxGroup extends \yii\db\ActiveRecord | @@ -62,7 +62,7 @@ class TaxGroup extends \yii\db\ActiveRecord | ||
| 62 | return [ | 62 | return [ |
| 63 | [['name', 'module'], 'required'], | 63 | [['name', 'module'], 'required'], |
| 64 | [['description', 'settings'], 'string'], | 64 | [['description', 'settings'], 'string'], |
| 65 | - [['hierarchical', 'is_filter'], 'boolean'], | 65 | + [['hierarchical'], 'boolean'], |
| 66 | [['alias', 'module'], 'string', 'max' => 50], | 66 | [['alias', 'module'], 'string', 'max' => 50], |
| 67 | [['name'], 'string', 'max' => 255], | 67 | [['name'], 'string', 'max' => 255], |
| 68 | [['group_to_category'], 'safe'] | 68 | [['group_to_category'], 'safe'] |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +class m160225_143331_comment_test extends Migration | ||
| 6 | +{ | ||
| 7 | + public function up() | ||
| 8 | + { | ||
| 9 | + $this->createTable('{{%comment}}', [ | ||
| 10 | + 'comment_id' => $this->primaryKey(), | ||
| 11 | + 'entity' => $this->string()->notNull(), | ||
| 12 | + 'text' => $this->text()->notNull(), | ||
| 13 | + 'user_id' => $this->integer(), | ||
| 14 | + 'user_name' => $this->string(), | ||
| 15 | + 'user_email' => $this->string(), | ||
| 16 | + 'comment_pid' => $this->integer(), | ||
| 17 | + 'status' => $this->integer(), | ||
| 18 | + 'date_add' => $this->timestamp()->notNull()->defaultExpression('NOW()'), | ||
| 19 | + 'date_update' => $this->timestamp()->notNull()->defaultExpression('NOW()'), | ||
| 20 | + 'date_delete' => $this->timestamp(), | ||
| 21 | + ]); | ||
| 22 | + | ||
| 23 | + $this->addForeignKey('comment_user', '{{%comment}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE'); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public function down() | ||
| 27 | + { | ||
| 28 | + $this->dropForeignKey('comment_user', '{{%comment}}'); | ||
| 29 | + $this->dropTable('{{%comment}}'); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + /* | ||
| 33 | + // Use safeUp/safeDown to run migration code within a transaction | ||
| 34 | + public function safeUp() | ||
| 35 | + { | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public function safeDown() | ||
| 39 | + { | ||
| 40 | + } | ||
| 41 | + */ | ||
| 42 | +} |
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +class m160304_081817_rating_table extends Migration | ||
| 6 | +{ | ||
| 7 | + public function up() | ||
| 8 | + { | ||
| 9 | + $this->createTable('{{%rating}}', [ | ||
| 10 | + 'rating_id' => $this->primaryKey(), | ||
| 11 | + 'date_add' => $this->timestamp()->notNull()->defaultExpression('NOW()'), | ||
| 12 | + 'date_update' => $this->timestamp()->notNull()->defaultExpression('NOW()'), | ||
| 13 | + 'user_id' => $this->integer(), | ||
| 14 | + 'entity' => $this->string(), | ||
| 15 | + 'value' => $this->integer(), | ||
| 16 | + ]); | ||
| 17 | + | ||
| 18 | + $this->addForeignKey('rating_user', '{{%rating}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE'); | ||
| 19 | + } | ||
| 20 | + | ||
| 21 | + public function down() | ||
| 22 | + { | ||
| 23 | + $this->dropForeignKey('rating_user', '{{%rating}}'); | ||
| 24 | + $this->dropTable('{{%rating}}'); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | +} |
console/migrations/m160311_132124_rating_comment_restyle.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +use yii\db\Migration; | ||
| 4 | + | ||
| 5 | +class m160311_132124_rating_comment_restyle extends Migration | ||
| 6 | +{ | ||
| 7 | + public function up() | ||
| 8 | + { | ||
| 9 | + $this->truncateTable('{{%comment}}'); | ||
| 10 | + $this->truncateTable('{{%rating}}'); | ||
| 11 | + $this->dropColumn('{{%comment}}', 'entity'); | ||
| 12 | + $this->dropColumn('{{%rating}}', 'entity'); | ||
| 13 | + $this->addColumn('{{%comment}}', 'model', $this->string()->notNull()); | ||
| 14 | + $this->addColumn('{{%comment}}', 'model_id', $this->integer()->notNull()); | ||
| 15 | + $this->addColumn('{{%rating}}', 'model', $this->string()->notNull()); | ||
| 16 | + $this->addColumn('{{%rating}}', 'model_id', $this->integer()->notNull()); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public function down() | ||
| 20 | + { | ||
| 21 | + $this->truncateTable('{{%comment}}'); | ||
| 22 | + $this->truncateTable('{{%rating}}'); | ||
| 23 | + $this->dropColumn('{{%comment}}', 'model'); | ||
| 24 | + $this->dropColumn('{{%rating}}', 'model'); | ||
| 25 | + $this->dropColumn('{{%comment}}', 'model_id'); | ||
| 26 | + $this->dropColumn('{{%rating}}', 'model_id'); | ||
| 27 | + $this->addColumn('{{%comment}}', 'entity', $this->string()->notNull()); | ||
| 28 | + $this->addColumn('{{%rating}}', 'entity', $this->string()->notNull()); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | +} |
frontend/views/event/view.php
| @@ -20,6 +20,31 @@ $this->params['name'] = $this->title; | @@ -20,6 +20,31 @@ $this->params['name'] = $this->title; | ||
| 20 | <div class="content-last-block-text-wrap"> | 20 | <div class="content-last-block-text-wrap"> |
| 21 | <?= $model->body?> | 21 | <?= $model->body?> |
| 22 | </div> | 22 | </div> |
| 23 | + <?php | ||
| 24 | + echo \common\modules\comment\widgets\CommentWidget::widget([ | ||
| 25 | + 'context' => $this, | ||
| 26 | + 'model' => $model->className(), | ||
| 27 | + 'model_id' => $model->event_id, | ||
| 28 | + 'comment_class' => \common\modules\comment\models\Comment::className(), | ||
| 29 | + 'rating_class' => \common\modules\comment\models\Rating::className(), | ||
| 30 | + 'class_options' => [ | ||
| 31 | + 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, | ||
| 32 | + 'user_id' => \Yii::$app->user->getId(), | ||
| 33 | + 'guestComment' => true, | ||
| 34 | + 'status' => \common\modules\comment\models\Comment::STATUS_ACTIVE, | ||
| 35 | + ], | ||
| 36 | + 'list_options' => [ | ||
| 37 | + 'view' => 'list-comment-review', | ||
| 38 | + ], | ||
| 39 | + 'form_options' => [ | ||
| 40 | + 'view' => 'form-comment-review', | ||
| 41 | + 'tag' => 'span', | ||
| 42 | + ], | ||
| 43 | + 'options' => [ | ||
| 44 | + 'class' => 'proektant-comments-wr style', | ||
| 45 | + ], | ||
| 46 | + ]); | ||
| 47 | + ?> | ||
| 23 | </div> | 48 | </div> |
| 24 | <div class="seo-text"> | 49 | <div class="seo-text"> |
| 25 | <!-- --><?//= Seo::widget(['row'=>'seo_text'])?> | 50 | <!-- --><?//= Seo::widget(['row'=>'seo_text'])?> |
frontend/web/css/concat_all.css