diff --git a/common/models/TenderSearch.php b/common/models/TenderSearch.php index 1971337..67941a5 100644 --- a/common/models/TenderSearch.php +++ b/common/models/TenderSearch.php @@ -193,41 +193,127 @@ 'project_payment.payment_id' => $this->payment, ]); - if(!empty( $this->contractual )) { + $currencies = Currency::find() + ->select([ + 'rate', + 'currency_id', + ]) + ->asArray() + ->indexBy('currency_id') + ->column(); + + if(empty( $this->contractual )) { $query->andWhere([ - 'contractual' => $this->contractual, + 'not', + [ 'contractual' => 1 ], ]); - } else { - $currencies = Currency::find() - ->select([ - 'rate', - 'currency_id', - ]) - ->asArray() - ->indexBy('currency_id') - ->column(); - - if(!empty($this->budget_from) && !empty($this->budget_to)) { + if(!empty( $this->budget_from ) && !empty( $this->budget_to )) { $query->andFilterWhere([ 'between', 'total_budget', $this->budget_from * $currencies[ $this->budget_currency ], $this->budget_to * $currencies[ $this->budget_currency ], ]); - } elseif(!empty($this->budget_from)) { + } elseif(!empty( $this->budget_from )) { $query->andFilterWhere([ '>=', 'total_budget', $this->budget_from * $currencies[ $this->budget_currency ], ]); - } elseif(!empty($this->budget_to)) { + } elseif(!empty( $this->budget_to )) { $query->andFilterWhere([ '<=', 'total_budget', $this->budget_to * $currencies[ $this->budget_currency ], ]); } - + } else { + if(!empty( $this->budget_from ) && !empty( $this->budget_to )) { + $query->andWhere([ + 'or', + [ + 'and', + [ + 'between', + 'total_budget', + $this->budget_from * $currencies[ $this->budget_currency ], + $this->budget_to * $currencies[ $this->budget_currency ], + ], + [ + 'not', + [ + 'contractual' => 1, + ], + ], + ], + [ + 'contractual' => 1, + ], + ]); + } elseif(!empty( $this->budget_from )) { + $query->andWhere([ + 'or', + [ + 'and', + [ + '>=', + 'total_budget', + $this->budget_from * $currencies[ $this->budget_currency ], + ], + [ + 'not', + [ + 'contractual' => 1, + ], + ], + ], + [ + 'contractual' => 1, + ], + ]); + } elseif(!empty( $this->budget_to )) { + $query->andWhere([ + 'or', + [ + 'and', + [ + '<=', + 'total_budget', + $this->budget_to * $currencies[ $this->budget_currency ], + ], + [ + 'not', + [ + 'contractual' => 1, + ], + ], + ], + [ + 'contractual' => 1, + ], + ]); + } else { + $query->andWhere([ + 'or', + [ + 'and', + [ + '>=', + 'total_budget', + 0, + ], + [ + 'not', + [ + 'contractual' => 1, + ], + ], + ], + [ + 'contractual' => 1, + ], + ]); + } } return $dataProvider; diff --git a/common/modules/comment/models/CommentProject.php b/common/modules/comment/models/CommentProject.php new file mode 100644 index 0000000..7cc3793 --- /dev/null +++ b/common/modules/comment/models/CommentProject.php @@ -0,0 +1,328 @@ + 0, + ], + [ + [ + 'budget_currency', + ], + 'default', + 'value' => 3, + ], + [ + [ 'budget_currency' ], + 'exist', + 'targetClass' => Currency::className(), + 'targetAttribute' => 'currency_id', + ], + [ + [ + 'files', + ], + 'string', + ], + [ + [ + 'file', + ], + 'safe', + ], + [ + [ 'status' ], + 'default', + 'value' => 1, + ], + ]; + } + + public function scenarios() + { + return [ + self::SCENARIO_USER => [ + 'text', + 'budget_from', + 'budget_to', + 'term_from', + 'term_to', + 'file', + ], + self::SCENARIO_GUEST => [ + + ], + ]; + } + + /** + * @inheritdoc + */ + public function behaviors() + { + return [ + [ + 'class' => \yii\behaviors\TimestampBehavior::className(), + 'createdAtAttribute' => 'date_add', + 'updatedAtAttribute' => 'date_update', + 'value' => new \yii\db\Expression('NOW()'), + ], + ]; + } + + public static function tableName() + { + return '{{%comment_project}}'; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'text' => \Yii::t('app', 'Текст ответа'), + 'budget_from' => \Yii::t('app', 'от'), + 'budget_to' => \Yii::t('app', 'до'), + 'term_from' => \Yii::t('app', 'от'), + 'term_to' => \Yii::t('app', 'до'), + ]; + } + + public function getGuestComment() + { + return $this->guestComment; + } + +// public function setGuestComment($value) +// { +// $this->guestComment = $value; +// } + + /** + * @param string $model + * @param integer $model_id + * + * @return ActiveQuery + */ + public function getComments($model, $model_id) + { + return $this->find() + ->where([ + 'comment_project.model' => $model, + 'comment_project.model_id' => $model_id, + 'comment_project.status' => 1, + ]); + } + + public function postComment() + { + if($this->checkCreate()) { + if(!empty(\Yii::$app->request->post($this->formName())['anonymous'])) { + $this->status = self::STATUS_ANONYMOUS; + } + $this->file = UploadedFile::getInstances($this, 'file'); + if(!empty($this->file)) { + $file_id = []; + if(is_array($this->file)){ + foreach($this->file as $file){ + if($file instanceof UploadedFile){ + $file_model = new File(); + $file_id[] = $file_model->saveFile($file); + } + } + } else { + if($this->file instanceof UploadedFile){ + $file_model = new File(); + $file_id[] = $file_model->saveFile($this->file); + } + } + $this->files = json_encode($file_id); + } + if($this->insert()) { + $this->clearSafe(); + return true; + } else { + return false; + } + } else { + $this->addError('comment_id', 'You can`t post comment here'); + return false; + } + } + + public function updateComment() + { + if($this->checkUpdate()) { + if(empty( $this->comment_id )) { + $this->addError('comment_id', 'Comment ID not found'); + return false; + } else { + if($this->update()) { + $this->clearSafe(); + return true; + } else { + return false; + } + } + } else { + $this->addError('comment_id', 'You can`t update this post'); + return false; + } + } + + public function deleteComment() + { + if($this->checkDelete()) { + if(empty( $this->comment_id )) { + $this->addError('comment_id', 'Comment ID not found'); + return false; + } else { + if($this->status == self::STATUS_DELETED) { + return false; + } + $this->status = self::STATUS_DELETED; + if($this->update()) { + $this->clearSafe(); + return true; + } else { + return false; + } + } + } else { + $this->addError('comment_id', 'You can`t delete this post'); + return false; + } + } + + public function checkCreate() + { + if($this->getGuestComment()) { + return true; + } else { + return \Yii::$app->user->can(\common\modules\comment\Permissions::CREATE, [ + 'model' => $this->model, + 'model_id' => $this->model_id, + ]); + } + } + + public function checkUpdate() + { + if($this->scenario == self::SCENARIO_GUEST) { + return false; + } else { + return \Yii::$app->user->can(\common\modules\comment\Permissions::UPDATE, [ + 'model' => $this->model, + 'model_id' => $this->model_id, + ]) || \Yii::$app->user->can(\common\modules\comment\Permissions::UPDATE_OWN, [ + 'model' => $this->model, + 'model_id' => $this->model_id, + ]); + } + } + + public function checkDelete() + { + if($this->scenario == self::SCENARIO_GUEST) { + return false; + } else { + return \Yii::$app->user->can(\common\modules\comment\Permissions::DELETE, [ + 'model' => $this->model, + 'model_id' => $this->model_id, + ]) || \Yii::$app->user->can(\common\modules\comment\Permissions::DELETE_OWN, [ + 'model' => $this->model, + 'model_id' => $this->model_id, + ]); + } + } + + protected function clearSafe($setNew = true) + { + $safe = $this->safeAttributes(); + $count = count($safe); + $values = array_fill(0, $count, NULL); + $result = array_combine($safe, $values); + $this->setAttributes($result); + $this->setIsNewRecord($setNew); + } + + public function getAuthor() + { + // 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]; + // } + } + + } diff --git a/common/modules/comment/widgets/views/_project_comment_view.php b/common/modules/comment/widgets/views/_project_comment_view.php new file mode 100644 index 0000000..8e3c04f --- /dev/null +++ b/common/modules/comment/widgets/views/_project_comment_view.php @@ -0,0 +1,113 @@ +user_id )) { + $user = User::find() + ->where([ 'id' => $model->user_id ]) + ->with('userInfo') + ->one(); + } +?> +
+
+
+ userInfo->image) ?> +
+
+
+
    + userInfo->social_fb )) { + echo '
  • '.Html::a(Html::img('/images/ico-fb.png'), $user->userInfo->social_fb, ['target' => '_blank']).'
  • '; + } + ?> + userInfo->social_t )) { + echo '
  • '.Html::a(Html::img('/images/ico-tw.png'), $user->userInfo->social_t, ['target' => '_blank']).'
  • '; + } + ?> + userInfo->social_in )) { + echo '
  • '.Html::a(Html::img('/images/ico-in.png'), $user->userInfo->social_in, ['target' => '_blank']).'
  • '; + } + ?> + userInfo->social_vk )) { + echo '
  • '.Html::a(Html::img('/images/ico-vk.png'), $user->userInfo->social_vk, ['target' => '_blank']).'
  • '; + } + ?> +
+
+
+
    +
  • +
    userInfo->view_count ?>
    +
  • +
  • +
    Статус: userInfo->busy)?'Свободен':'Занят') ?> +
    +
  • +
  • +
    + На сайте: 1г. 8 мес. +
    +
  • +
  • +
    Последний визит:
    2 дня назад +
    +
  • +
+ Посмотреть профиль +
+
+
+
+
+
+
2000 грн
+
3 ДНЯ
+
+
+
+
Петер Цумтор
+
+ + +
+ 30 отзывов +
+
+

1.1 Строительная площадка расположена по адресу: г. Киев.

+

1.2 Существующий объект представляет собой помещение общей площадью ориентировочно – 140 м2.

+

1.3. Цель проекта состоит в проведении внутренних общестроительных и отделочных работ.

+

1.4. При разработке методов строительства и выборе материалов, используемых в настоящем проекте, необходимо учитывать климатические условия, характерные для г. Киева.

+

1.5. Требования к проектированию и производству работ определяются следующими документами:

+

- Техническим заданием.

+

- Строительными нормами и правилами.

+

Все проектные решения и все разделы рабочего проекта должны быть согласованы с Заказчиком в объеме, необходимом для последующей сдачи инженерных систем и коммуникаций.

+
+ +
+
+ Портфолио + Конаткты +
+ +
diff --git a/common/modules/comment/widgets/views/form-project-comment.php b/common/modules/comment/widgets/views/form-project-comment.php new file mode 100644 index 0000000..240d241 --- /dev/null +++ b/common/modules/comment/widgets/views/form-project-comment.php @@ -0,0 +1,101 @@ + + +
+
+
+
Добавить ответ
+
+ [ 'class' => 'resformsfile MultiFile-intercepted', 'enctype' => 'multipart/form-data' ] ]); + ?> +
+
+
+ userInfo->image) ?> +
+
+ name ?> +
+
+
+
Стоимость
+
+ field($model, 'budget_from', [ + 'template' => "{input}\n{error}", + 'options' => [ 'tag' => 'span' ], + ]) + ->input('number', [ 'placeholder' => $model->getAttributeLabel('budget_from') ]) ?> + field($model, 'budget_to', [ + 'template' => "{input}\n{error}", + 'options' => [ 'tag' => 'span' ], + ]) + ->input('number', [ 'placeholder' => $model->getAttributeLabel('budget_to') ]) ?> + field($model, 'budget_currency', [ + 'template' => "{input}
\n{error}", + 'options' => [ 'class' => 'blocks-check-list-wrapp check-valuta' ], + ]) + ->dropDownList($currencies) ?> +
+
+
+
+ Сроки(в днях) +
+
+ field($model, 'term_from', [ + 'template' => "{input}\n{error}", + 'options' => [ 'tag' => 'span' ], + ]) + ->input('number', [ 'placeholder' => $model->getAttributeLabel('term_from') ]) ?> + field($model, 'term_to', [ + 'template' => "{input}\n{error}", + 'options' => [ 'tag' => 'span' ], + ]) + ->input('number', [ 'placeholder' => $model->getAttributeLabel('term_to') ]) ?> +
+
+
+ field($model, 'text', [ + 'template' => "{input}\n{error}", + 'options' => [ 'class' => 'form-tender-txt style' ], + ]) + ->textarea([ 'placeholder' => $model->getAttributeLabel('text') ]) ?> +
+ field($model, 'file[]') + ->fileInput([ 'class' => 'multi' ]) + ->label(false) ?> + Прикрепить файл +
Максимальный размер
файла 5 МБ
+
+
+ 'get-project-new' ]); + echo Html::submitInput('ответить анонимно', [ + 'class' => 'get-list-new', + 'name' => 'CommentProject[anonymous]', + ]); + echo Html::a('Очистить', [ + 'tender/view', + 'tender_id' => \Yii::$app->request->get('tender_id'), + '#' => 'w1', + ]); + ?> +
+ end(); + ?> +
+
+
+
\ No newline at end of file diff --git a/common/modules/comment/widgets/views/list-project-comment.php b/common/modules/comment/widgets/views/list-project-comment.php new file mode 100644 index 0000000..f592675 --- /dev/null +++ b/common/modules/comment/widgets/views/list-project-comment.php @@ -0,0 +1,22 @@ + +
+
+
Предложения проектантов
+
+ $dataProvider, + 'itemView' => '_project_comment_view', + 'itemOptions' => [ + 'class' => 'tender-offer-proj-blocks style', + ], + 'summary' => '', + ]); + ?> +
+
+
\ No newline at end of file diff --git a/console/migrations/m160314_090858_project_comment.php b/console/migrations/m160314_090858_project_comment.php new file mode 100644 index 0000000..41af404 --- /dev/null +++ b/console/migrations/m160314_090858_project_comment.php @@ -0,0 +1,36 @@ +createTable('{{%comment_project}}', [ + 'comment_id' => $this->primaryKey(), + 'model' => $this->string()->notNull(), + 'model_id' => $this->integer()->notNull(), + 'text' => $this->text()->notNull(), + 'files' => $this->string(), + 'budget_from' => $this->float()->notNull()->defaultValue(0), + 'budget_to' => $this->float()->notNull()->defaultValue(0), + 'budget_currency' => $this->integer()->notNull()->defaultValue(3), + 'term_from' => $this->integer()->notNull()->defaultValue(0), + 'term_to' => $this->integer()->notNull()->defaultValue(0), + 'user_id' => $this->integer()->notNull(), + 'status' => $this->integer(), + 'date_add' => $this->timestamp()->notNull()->defaultExpression('NOW()'), + 'date_update' => $this->timestamp()->notNull()->defaultExpression('NOW()'), + 'date_delete' => $this->timestamp(), + ]); + + $this->addForeignKey('comment_project_user', '{{%comment_project}}', 'user_id', '{{%user}}', 'id', 'CASCADE', 'CASCADE'); + } + + public function down() + { + $this->dropForeignKey('comment_project_user', '{{%comment_project}}'); + $this->dropTable('{{%comment_project}}'); + } + +} diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index 69be64e..53ca630 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -19,7 +19,7 @@ class AppAsset extends AssetBundle public $css = [ 'css/style.css', '/admin/css/flags32.css', - 'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', + //'https://fonts.googleapis.com/css?family=Roboto:400,700&subset=cyrillic,latin', ]; public $js = [ '/js/script.js', diff --git a/frontend/views/search/_projects_list_view.php b/frontend/views/search/_projects_list_view.php index 00036b2..1a2408c 100644 --- a/frontend/views/search/_projects_list_view.php +++ b/frontend/views/search/_projects_list_view.php @@ -1,12 +1,28 @@
name, Url::toRoute( ['tender/view','tender_id' =>$model->project_id] ), ['class' => 'srch-prof-title']) ?> -
Бюджет: budget?> budgetCurrency->label?> (contractual ? "Договорной" : "Недоговорной" ?>)
+
+ + Бюджет: + contractual)) { + echo $model->budget.' '.$model->budgetCurrency->label; + } else { + echo "Договорной"; + } + ?> +
parent->name)):?> @@ -28,7 +44,7 @@ use yii\helpers\Url; formatter->asDatetime($model->date_end, 'dd.MM.Y')?>
- 4 предложения + X предложения
\ No newline at end of file diff --git a/frontend/views/search/project.php b/frontend/views/search/project.php index e2c5130..d4cf341 100755 --- a/frontend/views/search/project.php +++ b/frontend/views/search/project.php @@ -70,25 +70,21 @@ ]) ->dropDownList($currencies) ?> - field($model, 'contractual', [ 'template' => "{input}\n{error}", 'options' => ['class' => ''] ]) - ->checkboxList([1 => $model->getAttributeLabel('contractual')], [ - 'item' => function($index, $label, $name, $checked, $value) { - $return = '
'; - $return .= ''; - $return .= ''; - $return .= '
'; - return $return; - } - ]); ?> + field($model, 'contractual', [ + 'template' => "{input}\n{label}\n{hint}\n{error}", + 'options' => [ 'class' => 'blocks-check-list' ], + ]) + ->label("{$model->getAttributeLabel('contractual')}", ['class' => '']) + ->checkbox([ 'uncheck' => NULL ], false) ?> field($model, 'payment', [ 'template' => "{input}\n{error}" ]) ->checkboxList($payments, [ 'item' => function($index, $label, $name, $checked, $value) { $return = '
'; - $return .= ''; - $return .= ''; + $return .= ''; + $return .= ''; $return .= '
'; return $return; - } + }, ]); ?>
@@ -184,7 +180,7 @@
- */?> + */ ?>
Сейчас totalCount ?> предложений
diff --git a/frontend/views/tender/view.php b/frontend/views/tender/view.php index e56d06d..9d45d06 100755 --- a/frontend/views/tender/view.php +++ b/frontend/views/tender/view.php @@ -1,10 +1,14 @@ title = 'My Yii Application'; ?> @@ -197,6 +201,35 @@ $this->title = 'My Yii Application';
+ $this, + 'model' => $model::className(), + 'model_id' => $model->project_id, + 'comment_class' => \common\modules\comment\models\CommentProject::className(), + 'class_options' => [ + 'scenario' => is_int(\Yii::$app->user->getId()) ? \common\modules\comment\models\Comment::SCENARIO_USER : \common\modules\comment\models\Comment::SCENARIO_GUEST, + 'user_id' => \Yii::$app->user->getId(), + 'guestComment' => false, + 'status' => \common\modules\comment\models\CommentProject::STATUS_ACTIVE, + ], + 'list_options' => [ + 'view' => 'list-project-comment', + 'class' => 'section box tender-offer-proj-wr', + ], + 'form_options' => [ + 'view' => 'form-project-comment', + 'tag' => 'div', + 'class' => 'artbox_comment_form section-box tender-add-answer', + ], + 'options' => [ + 'tag' => false, + ], + ]); + ?> +
@@ -383,6 +416,9 @@ $this->title = 'My Yii Application';
+