public function search($params)
 {
     $query = Feedback::find();
     //		$query->joinWith(['parent']);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['feedback.id' => $this->id, 'feedback.status' => $this->status, 'feedback.parent_id' => $this->parent_id, 'feedback.admin_comment' => $this->admin_comment, 'feedback.created_at' => $this->created_at, 'feedback.updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'feedback.name', $this->name])->andFilterWhere(['like', 'feedback.title', $this->title]);
     return $dataProvider;
 }
 /**
  * Show form (usually via AJAX) for feedback
  *
  * @param null|int $id parent feedback ID (for comments)
  *
  * @throws \yii\web\NotFoundHttpException
  * @throws \yii\web\BadRequestHttpException
  * @return string
  */
 public function actionSendFeedback($id = null)
 {
     if ($id) {
         $parent = Feedback::findOne(['id' => $id, 'status' => Feedback::STATUS_APPROVED]);
         if (!$parent) {
             throw new NotFoundHttpException(FeedbackModule::t('front', 'Отзыв не найден'));
         }
     }
     $model = new Feedback();
     if ($model->load(Yii::$app->request->post())) {
         $model->parent_id = isset($parent) ? $parent->id : null;
         $model->status = Feedback::STATUS_PENDING;
         $model->admin_comment = 0;
         if ($model->save()) {
             Yii::$app->session->setFlash('success', FeedbackModule::t('front', 'Спасибо за Ваш отзыв !'));
             $this->redirect(['index']);
         }
     }
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax('sendFeedback', compact('model', 'id'));
     } else {
         return $this->render('sendFeedback', compact('model', 'id'));
     }
 }
Example #3
0
	<div class="panel panel-default">
		<div class="panel-heading">
			<strong>
				<span class="glyphicon glyphicon-th"></span> <?php 
echo Html::encode($this->title);
?>
			</strong>
		</div>
		<div class="panel-body">

			<p>
				<?php 
echo Html::a('Редактировать', ['update', 'id' => $model->id], ['class' => 'btn btn-sm btn-primary']);
?>
				<?php 
echo Html::a('Создать', ['create'], ['class' => 'btn btn-sm btn-success']);
?>
				<?php 
echo Html::a('Удалить', ['delete', 'id' => $model->id], ['class' => 'btn btn-sm btn-danger pull-right', 'data' => ['confirm' => 'Вы уверены, что хотите удалить этот элемент?', 'method' => 'post']]);
?>
			</p>

			<?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', ['attribute' => 'status', 'value' => Feedback::getStatusValue($model->status), 'format' => 'raw'], ['attribute' => 'admin_comment', 'value' => Feedback::getAdminCommentValue($model->admin_comment), 'format' => 'raw'], ['label' => 'Комментарий к отзыву', 'value' => Html::a(@$model->parent->title . ' [ ' . @$model->parent->name . ' ]', ['view', 'id' => $model->parent_id], ['target' => '_blank']), 'visible' => $model->parent_id !== null, 'format' => 'raw'], 'title', 'body:ntext', 'created_at:datetime', 'updated_at:datetime']]);
?>

		</div>
	</div>
</div>
Example #4
0
		<div class="form-group">
			<div class="col-sm-6 col-sm-offset-3">
				<b>Комментарий к: </b>
				<?php 
    echo Html::a($model->parent->title . ' [ ' . $model->parent->name . ' ]', ['view', 'id' => $model->parent_id], ['target' => '_blank']);
    ?>
			</div>

		</div>
		<br/>
	<?php 
}
?>

	<?php 
echo $form->field($model, 'status')->dropDownList(Feedback::getStatusList(), ['prompt' => '']);
?>

	<?php 
echo $form->field($model->loadDefaultValues(), 'admin_comment')->checkbox(['class' => 'b-switch'], false);
?>

	<?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 255, 'autofocus' => $model->isNewRecord ? true : false]);
?>

	<?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 255]);
?>

	<?php 
Example #5
0
echo GridBulkActions::widget(['gridId' => 'feedback-grid', 'actions' => [Url::to(['bulk-approve']) => 'Одобрить', Url::to(['bulk-set-as-pending']) => 'Перевести в ожидающие', Url::to(['bulk-deny']) => 'Отклонить', '----' => [Url::to(['bulk-delete']) => 'Удалить']]]);
?>
				</div>
			</div>


			<?php 
Pjax::begin(['id' => 'feedback-grid-pjax']);
?>

			<?php 
echo GridView::widget(['id' => 'feedback-grid', 'dataProvider' => $dataProvider, 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'hideOnSinglePage' => true, 'lastPageLabel' => '>>', 'firstPageLabel' => '<<'], 'layout' => '{items}<div class="row"><div class="col-sm-8">{pager}</div><div class="col-sm-4 text-right">{summary}</div></div>', 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'options' => ['style' => 'width:10px']], ['attribute' => 'name', 'value' => function ($model) {
    return Html::a($model->name, ['update', 'id' => $model->id], ['data-pjax' => 0]);
}, 'format' => 'raw'], 'title', ['attribute' => 'parent_id', 'label' => 'Комментарий', 'filter' => false, 'value' => function ($model) {
    if ($model->parent_id === null) {
        return 'Отзыв';
    } else {
        return 'Комментарий к ' . Html::a($model->parent_id, ['view', 'id' => $model->parent_id], ['target' => '_blank', 'data-pjax' => 0]);
    }
}, 'format' => 'raw'], 'created_at:datetime', ['class' => 'webvimark\\components\\StatusColumn', 'attribute' => 'admin_comment'], ['attribute' => 'status', 'filter' => Feedback::getStatusList(), 'value' => function ($model) {
    return Feedback::getStatusValue($model->status);
}, 'format' => 'raw', 'contentOptions' => ['style' => 'width:120px; text-align:center;']], ['class' => 'yii\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px; text-align:center;']]]]);
?>
		
			<?php 
Pjax::end();
?>
		</div>
	</div>
</div>
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getComments()
 {
     return $this->hasMany(Feedback::className(), ['parent_id' => 'id'])->andWhere(['status' => Feedback::STATUS_APPROVED])->orderBy('id DESC');
 }