/** * Creates data provider instance with search query applied * @param array $params * @return ActiveDataProvider */ public function search($params) { $query = Employees::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['branch_id' => SORT_ASC, 'snp' => SORT_ASC]], 'pagination' => ['pagesize' => 100]]); $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->joinWith('branch'); $query->andFilterWhere(['employees.id' => $this->id]); $query->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'patronymic', $this->patronymic])->andFilterWhere(['like', 'job_title', $this->job_title])->andFilterWhere(['like', 'employee_number', $this->employee_number])->andFilterWhere(['like', 'unique_1c_number', $this->unique_1c_number])->andFilterWhere(['like', 'LOWER(snp)', mb_strtolower($this->snp) . '%', false])->andFilterWhere(['like', 'branches.branch_title', $this->branch_id]); return $dataProvider; }
/* @var $model backend\models\WpOwners */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="wp-owners-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'workplace_id')->dropDownList(ArrayHelper::map(Workplaces::find()->all(), 'id', 'workplaces_title'), ['prompt' => 'Выберите рабочее место...']); ?> <?php echo $form->field($model, 'employee_id')->dropDownList(ArrayHelper::map(Employees::find()->all(), 'id', function ($model) { return $model->surname . ' ' . $model->name; }), ['prompt' => 'Выберите сотрудника...']); ?> <?php echo $form->field($model, 'event')->checkbox(); ?> <?php echo $form->field($model, 'date')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
/** * @return array|\yii\db\ActiveRecord[] */ public static function arraySnpId() { return Employees::find()->select("snp as value, snp as label, id as id")->where("snp > ''")->orderBy('snp')->asArray()->all(); }