/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Branches::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->joinWith('companiesCompany'); $query->andFilterWhere(['branch_id' => $this->branch_id, 'branch_created_date' => $this->branch_created_date]); $query->andFilterWhere(['like', 'branch_name', $this->branch_name])->andFilterWhere(['like', 'branch_address', $this->branch_address])->andFilterWhere(['like', 'branch_status', $this->branch_status])->andFilterWhere(['like', 'companies.company_name', $this->companies_company_id]); return $dataProvider; }
/* @var $model app\models\Departments */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="departments-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'companies_company_id')->dropDownList(ArrayHelper::map(Companies::find()->all(), 'company_id', 'company_name'), ['prompt' => 'Select a company..']); ?> <?php echo $form->field($model, 'branches_branch_id')->dropDownList(ArrayHelper::map(Branches::find()->all(), 'branch_id', 'branch_name'), ['prompt' => 'Select a branch..']); ?> <?php echo $form->field($model, 'department_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'department_status')->dropDownList(['active' => 'Active', 'inactive' => 'Inactive', '' => ''], ['prompt' => '']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);