public function actionContact()
 {
     $model = new LeaveMessage();
     $model->status = LeaveMessage::STATUS_NEW;
     if ($model->load(\Yii::$app->request->post())) {
         $model->user_ip = \Yii::$app->request->userIP;
         if ($model->save()) {
             \Yii::$app->session->setFlash('info', 'В скором времени вам ответят');
         }
     }
     return $this->render('contact', ['model' => $model]);
 }
 /**
  * Finds the LeaveMessage model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return LeaveMessage the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = LeaveMessage::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = LeaveMessage::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'message', $this->message])->andFilterWhere(['like', 'user_ip', $this->user_ip]);
     return $dataProvider;
 }
Exemple #4
0
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model common\models\LeaveMessage */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => 'Leave Messages', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="leave-message-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Пометить как помечанный', ['mark', 'id' => $model->id, 'status' => \common\models\LeaveMessage::STATUS_MARKED], ['class' => 'btn btn-warning']);
?>
        <?php 
echo Html::a('Пометить как закрытый', ['mark', 'id' => $model->id, 'status' => \common\models\LeaveMessage::STATUS_CLOSED], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'name', 'email:email', 'message:ntext', ['attribute' => 'status', 'value' => \common\models\LeaveMessage::statusNames()[$model->status]], 'user_ip', 'created_at', 'updated_at']]);
?>

</div>
Exemple #5
0
use common\models\LeaveMessage;
use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\guest\models\LeaveMessageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Leave Messages';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="leave-message-index">

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

    <p>
        <?php 
echo Html::a('Create Leave Message', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', 'name', 'email:email', 'message:ntext', ['format' => 'html', 'attribute' => 'status', 'value' => function ($model) {
    return Html::tag('span', LeaveMessage::statusNames()[$model->status], ['class' => 'label label-' . LeaveMessage::statusClasses()[$model->status]]);
}, 'filter' => LeaveMessage::statusNames()], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view}']]]);
?>
</div>