Commit 91842edd3babe3889d4ccb87433bc6f4768b26cc

Authored by Timur Kastemirov
1 parent 0c1e7d9b

feedback backend

backend/config/main.php
... ... @@ -27,7 +27,7 @@
27 27 'page-category' => 'artbox\core\controllers\PageCategoryController',
28 28 'alias' => 'artbox\core\controllers\AliasController',
29 29 'seo' => 'artbox\core\controllers\SeoController',
30   - 'feedback' => 'artbox\core\controllers\FeedbackController',
  30 +// 'feedback' => 'artbox\core\controllers\FeedbackController',
31 31 'blog-article' => 'artbox\weblog\controllers\ArticleController',
32 32 'blog-category' => 'artbox\weblog\controllers\CategoryController',
33 33 'blog-tag' => 'artbox\weblog\controllers\TagController',
... ...
backend/controllers/FeedbackController.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace backend\controllers;
  4 +
  5 +use Yii;
  6 +use common\models\Feedback;
  7 +use common\models\FeedbackSearch;
  8 +use yii\web\Controller;
  9 +use yii\web\NotFoundHttpException;
  10 +use yii\filters\VerbFilter;
  11 +use yii\web\Response;
  12 +use artbox\core\widgets\FeedbackWidget;
  13 +use yii\helpers\Html;
  14 +use yii\data\ActiveDataProvider;
  15 +
  16 +/**
  17 + * FeedbackController implements the CRUD actions for Feedback model.
  18 + */
  19 +class FeedbackController extends Controller
  20 +{
  21 + /**
  22 + * @inheritdoc
  23 + */
  24 + public function behaviors()
  25 + {
  26 + return [
  27 + 'verbs' => [
  28 + 'class' => VerbFilter::className(),
  29 + 'actions' => [
  30 + 'delete' => ['POST'],
  31 + ],
  32 + ],
  33 + ];
  34 + }
  35 +
  36 + /**
  37 + * Lists all Feedback models.
  38 + * @return mixed
  39 + */
  40 + public function actionIndex()
  41 + {
  42 + $searchModel = new FeedbackSearch();
  43 + $dataProvider = new ActiveDataProvider(
  44 + [
  45 + 'query' => Feedback::find()->orderBy(['created_at' => SORT_DESC]),
  46 + ]
  47 + );
  48 +
  49 + return $this->render('index', [
  50 + 'searchModel' => $searchModel,
  51 + 'dataProvider' => $dataProvider,
  52 + ]);
  53 + }
  54 +
  55 + /**
  56 + * Displays a single Feedback model.
  57 + * @param integer $id
  58 + * @return mixed
  59 + */
  60 + public function actionView($id)
  61 + {
  62 + $model = $this->findModel($id);
  63 +
  64 + $model->status = true;
  65 + $model->save(false, [ 'status' ]);
  66 +
  67 + return $this->render('view', [
  68 + 'model' => $model,
  69 + ]);
  70 + }
  71 +
  72 + /**
  73 + * Creates a new Feedback model.
  74 + * If creation is successful, the browser will be redirected to the 'view' page.
  75 + * @return mixed
  76 + */
  77 + public function actionCreate()
  78 + {
  79 + $model = new Feedback();
  80 +
  81 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  82 + return $this->redirect(['view', 'id' => $model->id]);
  83 + } else {
  84 + return $this->render('create', [
  85 + 'model' => $model,
  86 + ]);
  87 + }
  88 + }
  89 +
  90 + /**
  91 + * Updates an existing Feedback model.
  92 + * If update is successful, the browser will be redirected to the 'view' page.
  93 + * @param integer $id
  94 + * @return mixed
  95 + */
  96 + public function actionUpdate($id)
  97 + {
  98 + $model = $this->findModel($id);
  99 +
  100 + $model->status = true;
  101 + $model->save(false, [ 'status' ]);
  102 +
  103 + if ($model->load(Yii::$app->request->post()) && $model->save()) {
  104 + return $this->redirect(['view', 'id' => $model->id]);
  105 + } else {
  106 + return $this->render('update', [
  107 + 'model' => $model,
  108 + ]);
  109 + }
  110 + }
  111 +
  112 + /**
  113 + * Deletes an existing Feedback model.
  114 + * If deletion is successful, the browser will be redirected to the 'index' page.
  115 + * @param integer $id
  116 + * @return mixed
  117 + */
  118 + public function actionDelete($id)
  119 + {
  120 + $this->findModel($id)->delete();
  121 +
  122 + return $this->redirect(['index']);
  123 + }
  124 +
  125 + /**
  126 + * Finds the Feedback model based on its primary key value.
  127 + * If the model is not found, a 404 HTTP exception will be thrown.
  128 + * @param integer $id
  129 + * @return Feedback the loaded model
  130 + * @throws NotFoundHttpException if the model cannot be found
  131 + */
  132 + protected function findModel($id)
  133 + {
  134 + if (($model = Feedback::findOne($id)) !== null) {
  135 + return $model;
  136 + } else {
  137 + throw new NotFoundHttpException('The requested page does not exist.');
  138 + }
  139 + }
  140 +
  141 + public function actionViewed($id)
  142 + {
  143 + if (Yii::$app->request->isPost) {
  144 + $model = $this->findModel($id);
  145 +
  146 + Yii::$app->response->format = Response::FORMAT_JSON;
  147 +
  148 + $model->status = true;
  149 + if ($model->save(false, [ 'status' ])) {
  150 +
  151 + $widget = FeedbackWidget::widget();
  152 +
  153 + return [
  154 + 'text' => Html::tag(
  155 + 'span',
  156 + '',
  157 + [
  158 + 'class' => 'glyphicon glyphicon-ok',
  159 + ]
  160 + ),
  161 + 'message' => [
  162 + 'title' => Yii::t('core', 'Notification') . ':',
  163 + 'text' => Yii::t('core', 'Status changed'),
  164 + ],
  165 + 'widget' => $widget,
  166 + ];
  167 + }
  168 + }
  169 + return [];
  170 + }
  171 +
  172 +}
... ...
backend/controllers/PersoneController.php 100644 → 100755
backend/views/feedback/_form.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Feedback */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="feedback-form">
  12 +
  13 + <?php $form = ActiveForm::begin(); ?>
  14 +
  15 + <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
  16 +
  17 + <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
  18 +
  19 + <?= $form->field($model, 'phone')->textInput(['maxlength' => true]) ?>
  20 +
  21 + <?= $form->field($model, 'message')->textarea(['rows' => 6]) ?>
  22 +
  23 + <?= $form->field($model, 'status')->checkbox() ?>
  24 +
  25 + <?= $form->field($model, 'date')->textInput(['maxlength' => true]) ?>
  26 +
  27 + <?= $form->field($model, 'service')->textInput(['maxlength' => true]) ?>
  28 +
  29 + <?= $form->field($model, 'time')->textInput(['maxlength' => true]) ?>
  30 +
  31 + <div class="form-group">
  32 + <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
  33 + </div>
  34 +
  35 + <?php ActiveForm::end(); ?>
  36 +
  37 +</div>
... ...
backend/views/feedback/_search.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\ActiveForm;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\FeedbackSearch */
  8 +/* @var $form yii\widgets\ActiveForm */
  9 +?>
  10 +
  11 +<div class="feedback-search">
  12 +
  13 + <?php $form = ActiveForm::begin([
  14 + 'action' => ['index'],
  15 + 'method' => 'get',
  16 + ]); ?>
  17 +
  18 + <?= $form->field($model, 'id') ?>
  19 +
  20 + <?= $form->field($model, 'name') ?>
  21 +
  22 + <?= $form->field($model, 'email') ?>
  23 +
  24 + <?= $form->field($model, 'phone') ?>
  25 +
  26 + <?= $form->field($model, 'message') ?>
  27 +
  28 + <?php // echo $form->field($model, 'created_at') ?>
  29 +
  30 + <?php // echo $form->field($model, 'ip') ?>
  31 +
  32 + <?php // echo $form->field($model, 'url') ?>
  33 +
  34 + <?php // echo $form->field($model, 'status')->checkbox() ?>
  35 +
  36 + <?php // echo $form->field($model, 'date') ?>
  37 +
  38 + <?php // echo $form->field($model, 'service') ?>
  39 +
  40 + <?php // echo $form->field($model, 'time') ?>
  41 +
  42 + <div class="form-group">
  43 + <?= Html::submitButton(Yii::t('app', 'Search'), ['class' => 'btn btn-primary']) ?>
  44 + <?= Html::resetButton(Yii::t('app', 'Reset'), ['class' => 'btn btn-default']) ?>
  45 + </div>
  46 +
  47 + <?php ActiveForm::end(); ?>
  48 +
  49 +</div>
... ...
backend/views/feedback/create.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Feedback */
  8 +
  9 +$this->title = Yii::t('app', 'Create Feedback');
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Feedbacks'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="feedback-create">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <?= $this->render('_form', [
  18 + 'model' => $model,
  19 + ]) ?>
  20 +
  21 +</div>
... ...
backend/views/feedback/index.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\grid\GridView;
  5 +use yii\widgets\Pjax;
  6 +use common\models\Feedback;
  7 +/* @var $this yii\web\View */
  8 +/* @var $searchModel common\models\FeedbackSearch */
  9 +/* @var $dataProvider yii\data\ActiveDataProvider */
  10 +
  11 +$this->title = Yii::t('app', 'Feedbacks');
  12 +$this->params['breadcrumbs'][] = $this->title;
  13 +?>
  14 +<div class="feedback-index">
  15 +
  16 + <h1><?= Html::encode($this->title) ?></h1>
  17 + <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
  18 +
  19 + <p>
  20 + <?= Html::a(Yii::t('app', 'Create Feedback'), ['create'], ['class' => 'btn btn-success']) ?>
  21 + </p>
  22 +<?php Pjax::begin(); ?> <?= GridView::widget([
  23 + 'dataProvider' => $dataProvider,
  24 + 'rowOptions' => function (Feedback $model) {
  25 + if ($model->status) {
  26 + return [];
  27 + } else {
  28 + return [
  29 + 'class' => 'success',
  30 + ];
  31 + }
  32 + },
  33 + 'filterModel' => $searchModel,
  34 + 'columns' => [
  35 + ['class' => 'yii\grid\SerialColumn'],
  36 +
  37 + 'id',
  38 + 'name',
  39 + 'email:email',
  40 + 'phone',
  41 + // 'message:ntext',
  42 + // 'created_at',
  43 + // 'ip',
  44 + // 'url:url',
  45 + // 'status:boolean',
  46 + 'date',
  47 + 'service',
  48 + 'time',
  49 +
  50 + [
  51 + 'class' => 'yii\grid\ActionColumn',
  52 + 'buttons' => [
  53 + 'viewed' => function (string $url, Feedback $model) {
  54 + if ($model->status) {
  55 + return Html::tag(
  56 + 'span',
  57 + '',
  58 + [
  59 + 'class' => 'glyphicon glyphicon-ok',
  60 + ]
  61 + );
  62 + } else {
  63 + return Html::a(
  64 + Html::tag(
  65 + 'span',
  66 + '',
  67 + [
  68 + 'class' => 'glyphicon glyphicon-flag',
  69 + ]
  70 + ),
  71 + $url,
  72 + [
  73 + 'class' => 'viewed-toggle',
  74 + ]
  75 + );
  76 + }
  77 + },
  78 + ],
  79 + 'template' => '{viewed} {view} {update} {delete}',
  80 + ],
  81 + ],
  82 + ]); ?>
  83 +<?php Pjax::end(); ?></div>
... ...
backend/views/feedback/update.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +
  5 +/* @var $this yii\web\View */
  6 +/* @var $model common\models\Feedback */
  7 +
  8 +$this->title = Yii::t('app', 'Update {modelClass}: ', [
  9 + 'modelClass' => 'Feedback',
  10 +]) . $model->name;
  11 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Feedbacks'), 'url' => ['index']];
  12 +$this->params['breadcrumbs'][] = ['label' => $model->name, 'url' => ['view', 'id' => $model->id]];
  13 +$this->params['breadcrumbs'][] = Yii::t('app', 'Update');
  14 +?>
  15 +<div class="feedback-update">
  16 +
  17 + <h1><?= Html::encode($this->title) ?></h1>
  18 +
  19 + <?= $this->render('_form', [
  20 + 'model' => $model,
  21 + ]) ?>
  22 +
  23 +</div>
... ...
backend/views/feedback/view.php 0 → 100644
  1 +<?php
  2 +
  3 +use yii\helpers\Html;
  4 +use yii\widgets\DetailView;
  5 +
  6 +/* @var $this yii\web\View */
  7 +/* @var $model common\models\Feedback */
  8 +
  9 +$this->title = $model->name;
  10 +$this->params['breadcrumbs'][] = ['label' => Yii::t('app', 'Feedbacks'), 'url' => ['index']];
  11 +$this->params['breadcrumbs'][] = $this->title;
  12 +?>
  13 +<div class="feedback-view">
  14 +
  15 + <h1><?= Html::encode($this->title) ?></h1>
  16 +
  17 + <p>
  18 + <?= Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
  19 + <?= Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], [
  20 + 'class' => 'btn btn-danger',
  21 + 'data' => [
  22 + 'confirm' => Yii::t('app', 'Are you sure you want to delete this item?'),
  23 + 'method' => 'post',
  24 + ],
  25 + ]) ?>
  26 + </p>
  27 +
  28 + <?= DetailView::widget([
  29 + 'model' => $model,
  30 + 'attributes' => [
  31 + 'id',
  32 + 'name',
  33 + 'email:email',
  34 + 'phone',
  35 + 'message:ntext',
  36 + [
  37 + 'attribute' => 'created_at',
  38 + 'format' => [
  39 + 'datetime',
  40 + 'php:d.m.Y H:i',
  41 + ],
  42 + ],
  43 + 'ip',
  44 + 'url:url',
  45 + 'status:boolean',
  46 + 'date',
  47 + 'service',
  48 + 'time',
  49 + ],
  50 + ]) ?>
  51 +
  52 +</div>
... ...
backend/views/persone/_form.php 100644 → 100755
backend/views/persone/_search.php 100644 → 100755
backend/views/persone/create.php 100644 → 100755
backend/views/persone/index.php 100644 → 100755
backend/views/persone/update.php 100644 → 100755
backend/views/persone/view.php 100644 → 100755
frontend/models/Feedback.php renamed to common/models/Feedback.php 100644 → 100755
1 1 <?php
2 2  
3   - namespace frontend\models;
  3 + namespace common\models;
4 4  
5 5 use Yii;
6 6 /**
... ... @@ -112,6 +112,7 @@
112 112 'email' => Yii::t('core', 'email'),
113 113 'service' => Yii::t('core', 'service'),
114 114 'date' => Yii::t('core', 'date'),
  115 + 'time' => Yii::t('core', 'time'),
115 116 ];
116 117 }
117 118  
... ...
common/models/FeedbackSearch.php 0 → 100644
  1 +<?php
  2 +
  3 +namespace common\models;
  4 +
  5 +use Yii;
  6 +use yii\base\Model;
  7 +use yii\data\ActiveDataProvider;
  8 +use common\models\Feedback;
  9 +
  10 +/**
  11 + * FeedbackSearch represents the model behind the search form about `common\models\Feedback`.
  12 + */
  13 +class FeedbackSearch extends Feedback
  14 +{
  15 + /**
  16 + * @inheritdoc
  17 + */
  18 + public function rules()
  19 + {
  20 + return [
  21 + [['id', 'created_at'], 'integer'],
  22 + [['name', 'email', 'phone', 'message', 'ip', 'url', 'date', 'service', 'time'], 'safe'],
  23 + [['status'], 'boolean'],
  24 + ];
  25 + }
  26 +
  27 + /**
  28 + * @inheritdoc
  29 + */
  30 + public function scenarios()
  31 + {
  32 + // bypass scenarios() implementation in the parent class
  33 + return Model::scenarios();
  34 + }
  35 +
  36 + /**
  37 + * Creates data provider instance with search query applied
  38 + *
  39 + * @param array $params
  40 + *
  41 + * @return ActiveDataProvider
  42 + */
  43 + public function search($params)
  44 + {
  45 + $query = Feedback::find();
  46 +
  47 + // add conditions that should always apply here
  48 +
  49 + $dataProvider = new ActiveDataProvider([
  50 + 'query' => $query,
  51 + ]);
  52 +
  53 + $this->load($params);
  54 +
  55 + if (!$this->validate()) {
  56 + // uncomment the following line if you do not want to return any records when validation fails
  57 + // $query->where('0=1');
  58 + return $dataProvider;
  59 + }
  60 +
  61 + // grid filtering conditions
  62 + $query->andFilterWhere([
  63 + 'id' => $this->id,
  64 + 'created_at' => $this->created_at,
  65 + 'status' => $this->status,
  66 + ]);
  67 +
  68 + $query->andFilterWhere(['like', 'name', $this->name])
  69 + ->andFilterWhere(['like', 'email', $this->email])
  70 + ->andFilterWhere(['like', 'phone', $this->phone])
  71 + ->andFilterWhere(['like', 'message', $this->message])
  72 + ->andFilterWhere(['like', 'ip', $this->ip])
  73 + ->andFilterWhere(['like', 'url', $this->url])
  74 + ->andFilterWhere(['like', 'date', $this->date])
  75 + ->andFilterWhere(['like', 'service', $this->service])
  76 + ->andFilterWhere(['like', 'time', $this->time]);
  77 +
  78 + return $dataProvider;
  79 + }
  80 +}
... ...
frontend/controllers/SiteController.php
1 1 <?php
2 2 namespace frontend\controllers;
3 3  
4   - use frontend\models\Feedback;
  4 + use common\models\Feedback;
5 5 use artbox\core\models\Page;
6 6 use common\models\Gallery;
7 7 use common\models\Settings;
... ...
frontend/views/layouts/main.php
... ... @@ -10,7 +10,7 @@
10 10  
11 11 use artbox\core\components\SeoComponent;
12 12 use artbox\core\helpers\ImageHelper;
13   - use frontend\models\Feedback;
  13 + use common\models\Feedback;
14 14 use artbox\core\models\PageCategory;
15 15 use artbox\core\models\User;
16 16 use common\models\Settings;
... ...