Ejemplo n.º 1
0
 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_at', $this->create_at])->andFilterWhere(['like', 'update_at', $this->update_at]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBranches()
 {
     return $this->hasMany(Branch::className(), ['id_orgn' => 'id_orgn']);
 }
Ejemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdBranch()
 {
     return $this->hasOne(Branch::className(), ['id_branch' => 'id_branch']);
 }
Ejemplo n.º 4
0
 * @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 function actionChangeBranch()
 {
     $model = new DynamicModel(['selected' => Yii::$app->user->branch]);
     $model->addRule('selected', 'safe');
     $ids = UserToBranch::find()->select('id_branch')->where(['id_user' => Yii::$app->user->id])->column();
     $branchs = Branch::findAll(['id_branch' => $ids]);
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->user->branch = $model->selected;
     }
     return $this->render('change-branch', ['model' => $model, 'branchs' => $branchs]);
 }
Ejemplo n.º 6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdBranch()
 {
     return $this->hasOne(\biz\master\models\Branch::className(), ['id_branch' => 'id_branch']);
 }
Ejemplo n.º 7
0
 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');
     }
 }
Ejemplo n.º 8
0
 /**
  * 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.');
     }
 }
Ejemplo n.º 9
0
 * @var biz\master\models\User2Branch $model
 * @var yii\widgets\ActiveForm $form
 */
?>

<div class="box box-primary">
    <div class="box-body">
        <?php 
$form = ActiveForm::begin();
?>

        <?php 
echo '';
?>
        <?php 
echo $form->field($model, 'id_branch')->dropDownList(ArrayHelper::map(Branch::find()->all(), 'id_branch', 'nm_branch'));
?>

        <?php 
echo '';
?>
        <?php 
$listUser = User::find()->select('username')->asArray()->column();
$dUser = [];
//            foreach ($listUser as $row) {
//                $dUser[]=$row['username'];
//            }
echo $form->field($model, 'nmUser')->widget('yii\\jui\\AutoComplete', ['options' => ['class' => 'form-control'], 'clientOptions' => ['source' => $listUser]]);
?>
    </div>
    <div class="box-footer">