public function search($params) { $query = Staffer::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new \yii\data\Sort(['attributes' => ['name', 'status', 'id']])]); $dataProvider->sort = ['defaultOrder' => ['id' => SORT_DESC]]; $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'organization_id' => $this->organization_id, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'text', $this->text]); return $dataProvider; }
</div> <div class="col-md-10"> <?php echo $this->render('../parts/menu'); ?> </div> </div> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title">Новый штраф</h3> </div> <div class="panel-body"> <div class="col-md-6"> <?php echo $this->render('_form', ['model' => $model, 'module' => $module]); ?> </div> </div> </div> <br style="clear: both;"></div> <?php echo \kartik\grid\GridView::widget(['export' => false, 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'filter' => false, 'options' => ['style' => 'width: 55px;']], ['attribute' => 'reason', 'filter' => $module->fineReasons, 'content' => function ($model) use($module) { return $module->fineReasons[$model->reason]; }], 'sum', 'created_at', 'comment', ['attribute' => 'staffer_id', 'filter' => Html::activeDropDownList($searchModel, 'staffer_id', ArrayHelper::map(Staffer::find()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Сотрудник']), 'value' => 'staffer.name'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}', 'buttonOptions' => ['class' => 'btn btn-default'], 'options' => ['style' => 'width: 125px;']]]]); ?> </div>
<div class="fine-form"> <div class="row"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <input type="hidden" name="backUrl" value="<?php echo Html::encode(yii::$app->request->referrer); ?> " /> <div class="col-md-6"> <?php echo $form->field($model, 'staffer_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Staffer::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите сотрудника ...'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'reason')->widget(Select2::classname(), ['data' => $module->fineReasons, 'language' => 'ru', 'options' => ['placeholder' => 'Выберите причину ...'], 'pluginOptions' => ['allowClear' => true]]); ?> </div> <div class="col-md-6"> <?php echo $form->field($model, 'sum')->textInput(); ?> <?php echo $form->field($model, 'comment')->textArea(); ?> </div>
public function init() { $this->finder = StafferModel::find(); parent::init(); }