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']); ?>
/** * @return \yii\db\ActiveQuery */ public function getIdBranch() { return $this->hasOne(Branch::className(), ['id_branch' => 'id_branch']); }
/** * @return \yii\db\ActiveQuery */ public function getBranches() { return $this->hasMany(Branch::className(), ['id_orgn' => 'id_orgn']); }
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'); } }
/** * Finds the Branch model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Branch the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Branch::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }