Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Trip::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $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, 'type' => $this->type, 'date' => $this->date, 'vehicle' => $this->vehicle, 'wifi' => $this->wifi, 'fridge' => $this->fridge, 'conditioner' => $this->conditioner, 'luggage' => $this->luggage, 'status' => $this->status, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'city_from', $this->city_from])->andFilterWhere(['like', 'city_to', $this->city_to])->andFilterWhere(['like', 'city_between', $this->city_between])->andFilterWhere(['like', 'schedule', $this->schedule])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'vehicle_model', $this->vehicle_model])->andFilterWhere(['like', 'contacts', $this->contacts])->andFilterWhere(['like', 'details', $this->details]);
     return $dataProvider;
 }
Пример #2
0
 public function getCommentsCount()
 {
     try {
         return Comment::find()->where(['model' => Trip::className()])->andWhere(['model_id' => $this->primaryKey])->andWhere(['status' => Comment::STATUS_APPROVED])->count();
     } catch (Exception $exc) {
         return 0;
     }
 }
Пример #3
0
                </div>

                <div class="col-sm-6 text-right">
                    <?php 
echo GridPageSize::widget(['pjaxId' => 'trip-grid-pjax']);
?>
                </div>
            </div>

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

            <?php 
echo GridView::widget(['id' => 'trip-grid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'bulkActionOptions' => ['gridId' => 'trip-grid', 'actions' => [Url::to(['bulk-delete']) => Yii::t('yee', 'Delete')]], 'columns' => [['class' => 'yeesoft\\grid\\CheckboxColumn', 'options' => ['style' => 'width:10px']], ['attribute' => 'vehicle_model', 'class' => 'yeesoft\\grid\\columns\\TitleActionColumn', 'controller' => '/trip/default', 'title' => function (Trip $model) {
    $vehicle = $model->getVehicles()[$model->vehicle] . ' > ' . Html::encode($model->vehicle_model);
    return Html::a($vehicle, ['update', 'id' => $model->id], ['data-pjax' => 0]);
}, 'buttonsTemplate' => '{update} {delete}', 'options' => ['style' => 'width:260px']], 'city_from', 'city_to', ['attribute' => 'created_by', 'filter' => User::getUsersList(), 'value' => function (Trip $model) {
    return Html::a(Html::encode($model->author->username), ['/user/default/update', 'id' => $model->created_by], ['data-pjax' => 0]);
}, 'format' => 'raw', 'visible' => User::hasPermission('viewUsers')], ['class' => 'yeesoft\\grid\\columns\\StatusColumn', 'attribute' => 'type', 'optionsArray' => Trip::getTypeOptionsList(), 'options' => ['style' => 'width:60px']], ['class' => 'yeesoft\\grid\\columns\\StatusColumn', 'attribute' => 'status', 'optionsArray' => Trip::getStatusOptionsList(), 'options' => ['style' => 'width:60px']]]]);
?>

            <?php 
Pjax::end();
?>
        </div>
    </div>
</div>


Пример #4
0
echo $form->field($model, 'wifi')->checkbox();
?>

                        <?php 
echo $form->field($model, 'fridge')->checkbox();
?>

                    </div>
                </div>
            </div>

            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="record-info">
                        <?php 
echo $form->field($model, 'status')->dropDownList(Trip::getStatusList());
?>

                        <?php 
if (!$model->isNewRecord) {
    ?>

                            <div class="form-group clearfix">
                                <label class="control-label"
                                       style="float: left; padding-right: 5px;"><?php 
    echo $model->attributeLabels()['id'];
    ?>
                                    : </label>
                                <span><?php 
    echo $model->id;
    ?>