Esempio n. 1
0
 /**
  * Finds the Feedback model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Feedback the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Feedback::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Feedback::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function actionSendMail()
 {
     $data = \Yii::$app->request->post('Feedback', false);
     $result = Email::sendFeedbackMail($data);
     if ($result) {
         /**
          * @var $feedback \backend\modules\feedback\models\db\Feedback
          */
         $feedback = Feedback::findOne(['id' => $data['id']]);
         $feedback->status = Feedback::PROCESSED;
         if ($feedback->save(false, ['status'])) {
             echo 1;
         } else {
             echo 0;
         }
     } else {
         echo 0;
     }
 }
Esempio n. 4
0
File: index.php Progetto: apuc/api
<div class="feedback-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
<!--    --><?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
<!--        --><?//= Html::a('Create Feedback', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'name', 'filter' => false], ['attribute' => 'text', 'filter' => false], ['attribute' => 'status', 'filter' => \backend\modules\feedback\models\db\Feedback::getStatusList(), 'value' => function ($model) {
    return $model->getStatus();
}], ['attribute' => 'created_at', 'format' => 'datetime', 'filter' => false], ['class' => DataColumn::className(), 'header' => 'Действия', 'format' => 'html', 'value' => function ($model, $index, $widget) {
    $delete = Html::a("<span class='glyphicon glyphicon-trash'></span>", Yii::$app->urlManager->createUrl(['feedback/feedback/delete', 'id' => $model->id]), ['class' => 'btn btn-default', 'title' => 'Удалить']);
    $buttons = "<div class='row text-center'>" . Html::a("<span class='glyphicon glyphicon-envelope'></span>", Yii::$app->urlManager->createUrl(['feedback/ajax/view-form', 'id' => $model->id]), ['class' => 'btn btn-default view-action-btn', 'title' => 'Ответить']) . $delete . "</div>";
    return $model->status ? $delete : $buttons;
}]]]);
?>

</div>
<div id="modal-window" class="well modal-window">
    <a class="close-modal btn btn-default pull-right" href="#">x</a>

    <div class="content">

    </div>