/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Checkin::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, 'user_id' => $this->user_id, 'event_id' => $this->event_id, 'created_date' => $this->created_date, 'created_by' => $this->created_by, 'updated_date' => $this->updated_date, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'user_type', $this->user_type]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (!isset($_GET['id'])) {
         $id = '';
     } else {
         $id = $_GET['id'];
     }
     $query = Checkin::find()->where(['event_id' => $id]);
     $query->joinWith(['event', 'users']);
     $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_date' => $this->created_date, 'created_by' => $this->created_by, 'updated_date' => $this->updated_date, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'event.title', $this->event_id]);
     $query->andFilterWhere(['or', ['like', 'user.firstname', $this->fullName], ['like', 'user.lastname', $this->fullName]]);
     //$query->andFilterWhere(['like', 'user.firstname', $this->fullName],['like', 'user.lastnam', $this->fullName]);
     $query->andFilterWhere(['like', 'user.email', $this->user_id]);
     $query->andFilterWhere(['like', 'user_type', $this->user_type]);
     return $dataProvider;
 }
Beispiel #3
0
    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Checkin', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'users.username', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\Users::find()->orderBy('username')->asArray()->all(), 'id', 'username')], 'event.title', ['attribute' => 'user_type', 'filter' => \yii\helpers\ArrayHelper::map(\common\models\Checkin::find()->orderBy('user_type')->asArray()->all(), 'id', 'user_type')], 'created_date', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

    <?php 
// You only need add this,
$this->registerJs('
        var gridview_id = ""; // specific gridview
        var columns = [2]; // index column that will grouping, start 1

        var column_data = [];
            column_start = [];
            rowspan = [];

        for (var i = 0; i < columns.length; i++) {
            column = columns[i];
            column_data[column] = "";
 public static function showCheckin($id)
 {
     $checkin = Checkin::find()->where('event_id=' . $id)->count();
     return '<span class="label label-danger">' . $checkin . '</span>';
 }