diff --git a/common/models/Project.php b/common/models/Project.php index ec0ce81..29b230e 100644 --- a/common/models/Project.php +++ b/common/models/Project.php @@ -4,11 +4,9 @@ use common\modules\comment\models\CommentProject; use common\modules\fileloader\behaviors\FileloaderBehavior; - use common\modules\fileloader\models\Fileloader; use Yii; use yii\behaviors\BlameableBehavior; use yii\behaviors\TimestampBehavior; - use yii\db\ActiveQuery; use yii\db\Expression; /** diff --git a/common/modules/comment/models/Comment.php b/common/modules/comment/models/Comment.php index 2b2370b..24cf9bb 100644 --- a/common/modules/comment/models/Comment.php +++ b/common/modules/comment/models/Comment.php @@ -331,13 +331,17 @@ } } - public function getAuthor() + public function getAuthor($guestMark = '') { - // if($this->user_id != NULL) { - return $this->hasOne(\common\models\User::className(), [ 'id' => 'user_id' ]); - // } else { - // return ['firstname' => $this->user_name, 'email' => $this->user_email]; - // } + if(!empty($this->user)) { + return $this->user->name; + } else { + $name = $this->user_name; + if(!empty($guestMark)) { + $name .= $guestMark; + } + return $name; + } } public function checkRating() @@ -391,25 +395,31 @@ return $this->hasOne(User::className(), [ 'id' => 'user_id' ]); } - public function buildButtons() + public function buildButtons($buttons = ['delete', 'update', 'reply']) { - if($this->checkDelete()) { - $this->buttons[ 'delete' ] = Url::to([ - 'artbox-comment/delete', - 'comment_id' => $this->comment_id, - ]); + if(in_array('delete', $buttons)) { + if($this->checkDelete()) { + $this->buttons[ 'delete' ] = Url::to([ + 'artbox-comment/delete', + 'comment_id' => $this->comment_id, + ]); + } } - if($this->checkUpdate()) { - $this->buttons[ 'update' ] = Url::to([ - 'artbox-comment/update', - 'comment_id' => $this->comment_id, - ]); + if(in_array('update', $buttons)) { + if($this->checkUpdate()) { + $this->buttons[ 'update' ] = Url::to([ + 'artbox-comment/update', + 'comment_id' => $this->comment_id, + ]); + } } - if($this->checkReply()) { - $this->buttons[ 'reply' ] = Url::to([ - 'artbox-comment/reply', - 'comment_id' => $this->comment_id, - ]); + if(in_array('reply', $buttons)) { + if($this->checkReply()) { + $this->buttons[ 'reply' ] = Url::to([ + 'artbox-comment/reply', + 'comment_id' => $this->comment_id, + ]); + } } } diff --git a/common/modules/comment/models/CommentProject.php b/common/modules/comment/models/CommentProject.php index 173e2d8..20411d9 100644 --- a/common/modules/comment/models/CommentProject.php +++ b/common/modules/comment/models/CommentProject.php @@ -155,6 +155,7 @@ 'text', 'budget_from', 'budget_to', + 'budget_currency', 'term_from', 'term_to', 'file', @@ -223,13 +224,34 @@ */ public function getComments($model, $model_id) { - return $this->find() - ->where([ - 'comment_project.model' => $model, - 'comment_project.model_id' => $model_id, - 'comment_project.status' => 1, - ]) - ->with('currency', 'user', 'user.userInfo', 'user.companyInfo', 'user.comments'); + /** + * @var User $user + */ + $user = \Yii::$app->user->identity; + if(!empty($user)) { + $project = Project::findOne($model_id); + if(!empty($project) && $user->id == $project->user_id) { + return $this->find() + ->where([ + 'comment_project.model' => $model, + 'comment_project.model_id' => $model_id, + 'comment_project.status' => [self::STATUS_ANONYMOUS, self::STATUS_ACTIVE, self::STATUS_PERSONAL], + ]) + ->with('currency', 'user', 'user.userInfo', 'user.companyInfo', 'user.comments'); + } + } + $query = $this->find() + ->where([ + 'comment_project.model' => $model, + 'comment_project.model_id' => $model_id, + ]) + ->with('currency', 'user', 'user.userInfo', 'user.companyInfo', 'user.comments'); + if(!empty($user)) { + $query->andWhere(['or', ['comment_project.status' => self::STATUS_ACTIVE], ['comment_project.status' => self::STATUS_ANONYMOUS, 'comment_project.user_id' => $user->id]]); + } else { + $query->andWhere(['comment_project.status' => 1]); + } + return $query; } public function postComment() diff --git a/common/modules/comment/widgets/views/_project_comment_view.php b/common/modules/comment/widgets/views/_project_comment_view.php index d35e120..81f2812 100644 --- a/common/modules/comment/widgets/views/_project_comment_view.php +++ b/common/modules/comment/widgets/views/_project_comment_view.php @@ -108,35 +108,66 @@ getLink('portfolio'), [ 'class' => 'get-project-new' ]) ?> link, [ 'class' => 'get-list-new' ]) ?> +
status == $model::STATUS_ANONYMOUS) { + echo Html::tag('div', 'Анонимное предложение', [ 'class' => 'project_status' ]); + } if(\Yii::$app->user->getId() == $model->owner->user_id) { ?> -
- Отметить как: - $model->owner->project_id, - 'data-comment-id' => $model->comment_id, - 'class' => 'artbox_project_make_new', - ]); - echo Html::a('кандидат', [ '#' ], [ - 'data-project-id' => $model->owner->project_id, - 'data-comment-id' => $model->comment_id, - 'class' => 'artbox_project_make_candidate', - ]); - echo Html::a('исполнитель', [ '#' ], [ - 'data-project-id' => $model->owner->project_id, - 'data-comment-id' => $model->comment_id, - 'class' => 'artbox_project_make_performer', - ]); - echo Html::a('отказать', [ '#' ], [ - 'data-project-id' => $model->owner->project_id, - 'data-comment-id' => $model->comment_id, - 'class' => 'artbox_project_make_deny', - ]); - ?> +
+

+ state) { + case 1: + echo 'Предложение не рассмотрено'; + break; + case 2: + echo 'Исполнитель поставлен на рассмотрение'; + break; + case 3: + echo 'Исполнитель назначен исполнителем'; + break; + case 4: + echo 'Вы отказали данному исполнителю'; + break; + case 5: + echo 'Исполнитель отказался от данного предложения'; + break; + } + ?> +

state != $model::STATE_TRASH) { + ?> +
+ Отметить как: + $model->owner->project_id, + 'data-comment-id' => $model->comment_id, + 'class' => 'artbox_project_make_new', + ]); + echo Html::a('кандидат', [ '#' ], [ + 'data-project-id' => $model->owner->project_id, + 'data-comment-id' => $model->comment_id, + 'class' => 'artbox_project_make_candidate', + ]); + echo Html::a('исполнитель', [ '#' ], [ + 'data-project-id' => $model->owner->project_id, + 'data-comment-id' => $model->comment_id, + 'class' => 'artbox_project_make_performer', + ]); + echo Html::a('отказать', [ '#' ], [ + 'data-project-id' => $model->owner->project_id, + 'data-comment-id' => $model->comment_id, + 'class' => 'artbox_project_make_deny', + ]); + ?> +
+ diff --git a/common/modules/comment/widgets/views/_review_comment_view.php b/common/modules/comment/widgets/views/_review_comment_view.php index d106429..c7e9689 100644 --- a/common/modules/comment/widgets/views/_review_comment_view.php +++ b/common/modules/comment/widgets/views/_review_comment_view.php @@ -14,9 +14,11 @@ * @var User $user */ $user = $model->user; - $model->buildButtons(); + $model->buildButtons(['delete']); ?> -
name ?>
+
+ getAuthor(' (Гость)') ?> +
@@ -41,7 +43,7 @@
buttons[ 'delete' ] )) { - echo Html::a('Удалить', $model->buttons[ 'delete' ], [ 'class' => CommentWidget::$baseClass[ 'comment_delete' ] ]); + echo Html::a(($model->user_id != NULL && $model->user_id == \Yii::$app->user->id)?'Удалить':'Пожаловаться ', $model->buttons[ 'delete' ], [ 'class' => CommentWidget::$baseClass[ 'comment_delete' ] ]); } if(!empty( $model->buttons[ 'update' ] )) { echo Html::a('Редактировать', $model->buttons[ 'update' ], [ 'class' => CommentWidget::$baseClass[ 'comment_update' ] ]); diff --git a/frontend/controllers/AccountsController.php b/frontend/controllers/AccountsController.php index e786471..a7c20d1 100755 --- a/frontend/controllers/AccountsController.php +++ b/frontend/controllers/AccountsController.php @@ -556,14 +556,17 @@ if($portfolioUser->load($post)) { $portfolioUser->status = 1; if($portfolioUser->save()) { - if(!empty($portfolioUser->gallery)) { + if(!empty( $portfolioUser->gallery )) { $portfolioUser->gallery->load($post); $portfolioUser->portfolioGallery->load($post); if($portfolioUser->gallery->save() && $portfolioUser->portfolioGallery->save()) { - return $this->redirect(['accounts/participant']); + return $this->redirect([ 'accounts/participant' ]); } } else { - return $this->redirect(['accounts/participant-edit', 'id' => $portfolioUser->portfolio_user_id]); + return $this->redirect([ + 'accounts/participant-edit', + 'id' => $portfolioUser->portfolio_user_id, + ]); } } } @@ -580,6 +583,7 @@ $searchModel = new PortfolioSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $dataProvider->pagination->pageSize = 5; + $dataProvider->sort->defaultOrder = [ 'portfolio_id' => SORT_ASC ]; return $this->render('portfolio', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, diff --git a/frontend/controllers/TenderController.php b/frontend/controllers/TenderController.php index c3dbfa8..cb4a37b 100755 --- a/frontend/controllers/TenderController.php +++ b/frontend/controllers/TenderController.php @@ -117,9 +117,10 @@ $project = Project::findOne($project_id); if(empty( $project )) { return [ 'error' => 'Проект не найден' ]; - } elseif($project->user_id != $user->id) { - return [ 'error' => 'Вы можете менять статус только собственных проектов' ]; } +// elseif($project->user_id != $user->id) { +// return [ 'error' => 'Вы можете менять статус только собственных проектов' ]; +// } /** * @var CommentProject $comment */ @@ -133,7 +134,10 @@ if(empty( $comment )) { return [ 'error' => 'Данного предложения не существует' ]; } - if($comment->user_id == \Yii::$app->user->getId()) { + if($project->user_id != $user->id && $comment->user_id != $user->id) { + return ['error' => 'Вы можете менять статус только своих предложений, либо предложений по своим проектам']; + } + if($comment->user_id == $user->id) { $comment->scenario = $comment::SCENARIO_OWNER; } else { $comment->scenario = $comment::SCENARIO_STATE; diff --git a/frontend/views/projects/_projects_list_view.php b/frontend/views/projects/_projects_list_view.php index 9cd9e28..8b1e944 100644 --- a/frontend/views/projects/_projects_list_view.php +++ b/frontend/views/projects/_projects_list_view.php @@ -10,7 +10,7 @@ use yii\data\ActiveDataProvider; use yii\helpers\Html; use yii\widgets\ListView; - + $chat = \Yii::$app->user->identity->getChat($model->project->user_id)->one(); ?>
user->identity->getChat($model->project->user_id) - ->one()->messages) . ' сообщения', [ + echo Html::a((empty($chat))?0:count($chat->messages) . ' сообщения', [ 'chat/message', 'user_id' => $model->project->user_id, ]); - if($model->state == 5) { + if($model->state == $model::STATE_DENY) { + + } elseif($model->state == $model::STATE_TRASH) { echo Html::a('Отменить', [ '#' ], [ 'data-project-id' => $model->project->project_id, 'data-comment-id' => $model->comment_id, diff --git a/frontend/web/js/forms.js b/frontend/web/js/forms.js index bf93f07..884d1f9 100755 --- a/frontend/web/js/forms.js +++ b/frontend/web/js/forms.js @@ -364,6 +364,7 @@ $(document).ready( alert(data.error); } else { alert(data.message); + location.reload(); } }, 'json').fail( function() @@ -383,6 +384,7 @@ $(document).ready( alert(data.error); } else { alert(data.message); + location.reload(); } }, 'json').fail( function() @@ -402,6 +404,7 @@ $(document).ready( alert(data.error); } else { alert(data.message); + location.reload(); } }, 'json').fail( function() @@ -421,6 +424,7 @@ $(document).ready( alert(data.error); } else { alert(data.message); + location.reload(); } }, 'json').fail( function() @@ -440,6 +444,7 @@ $(document).ready( alert(data.error); } else { alert(data.message); + location.reload(); } }, 'json').fail( function() -- libgit2 0.21.4