public function search($params) { $query = BranchModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_branch' => $this->id_branch, 'id_orgn' => $this->id_orgn, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'cd_branch', $this->cd_branch])->andFilterWhere(['like', 'nm_branch', $this->nm_branch])->andFilterWhere(['like', 'create_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]); return $dataProvider; }
* @var yii\widgets\ActiveForm $form */ ?> <div class="warehouse-form col-lg-6" style="padding-left: 0px;"> <?php $form = ActiveForm::begin(); ?> <div class="panel panel-primary"> <div class="panel-heading"> Warehouse </div> <div class="panel-body"> <?php echo $form->field($model, 'id_branch')->dropDownList(ArrayHelper::map(Branch::find()->all(), 'id_branch', 'nm_branch'), ['style' => 'width:200px;']); ?> <?php echo $form->field($model, 'cd_whse')->textInput(['maxlength' => 4, 'style' => 'width:120px;']); ?> <?php echo $form->field($model, 'nm_whse')->textInput(['maxlength' => 32]); ?> </div> </div> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?>
public static function getBranchList($id_user = null) { if ($id_user === null) { return ArrayHelper::map(Branch::find()->all(), 'id_branch', 'nm_branch'); } else { $query = UserToBranch::find()->with('idBranch')->where(['user_id' => $id_user]); return ArrayHelper::map($query->all(), 'id_branch', 'idBranch.nm_branch'); } }