Esempio n. 1
0
 /**
  * Creates a new StockRcvd model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new StockRcvd();
     $searchModel = new StockRcvdSearch();
     $dataProvider = $searchModel->searchRcvd(Yii::$app->request->queryParams);
     // * data tipe for form stock rcvd
     $tipe = ArrayHelper::map(TipeStock::find()->asArray()->all(), 'ID', 'NOTE');
     // $brg = ArrayHelper::map(::find()->asArray()->all(), 'ID', 'NOTE');
     // $tipe = TipeStock::find()->asArray()->all();
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         return $this->redirect(['view', 'id' => $model->ID]);
     } else {
         return $this->renderAjax('_form', ['model' => $model, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'tipe' => $tipe]);
     }
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TipeStock::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['ID' => $this->ID, 'TYPE_ID' => $this->TYPE_ID]);
     $query->andFilterWhere(['like', 'TYPE_PARENT', $this->TYPE_PARENT])->andFilterWhere(['like', 'TYPE_KAT', $this->TYPE_KAT])->andFilterWhere(['like', 'TYPE_NAME', $this->TYPE_NAME])->andFilterWhere(['like', 'NOTE', $this->NOTE]);
     return $dataProvider;
 }