/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $profile = Yii::$app->getUserOptcrm->Profile_user();
     //component Crm
     $query = ImportView::find()->where(['USER_ID' => $profile->username])->orderBy('TGL DESC');
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 200]]);
     $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, 'TGL' => $this->TGL, 'SO_QTY' => $this->SO_QTY, 'SO_TYPE' => $this->SO_TYPE, 'UNIT_QTY' => $this->UNIT_QTY, 'UNIT_BERAT' => $this->UNIT_BERAT, 'HARGA_PABRIK' => $this->HARGA_PABRIK, 'HARGA_DIS' => $this->HARGA_DIS, 'HARGA_SALES' => $this->HARGA_SALES, 'HARGA_LG' => $this->HARGA_LG, 'STATUS' => $this->STATUS]);
     $query->andFilterWhere(['like', 'CUST_KD', $this->CUST_KD])->andFilterWhere(['like', 'CUST_KD_ALIAS', $this->CUST_KD_ALIAS])->andFilterWhere(['like', 'CUST_NM', $this->CUST_NM])->andFilterWhere(['like', 'KD_BARANG', $this->KD_BARANG])->andFilterWhere(['like', 'KD_BARANG_ALIAS', $this->KD_BARANG_ALIAS])->andFilterWhere(['like', 'NM_BARANG', $this->NM_BARANG])->andFilterWhere(['like', 'POS', $this->POS])->andFilterWhere(['like', 'KD_DIS', $this->KD_DIS])->andFilterWhere(['like', 'NM_DIS', $this->NM_DIS])->andFilterWhere(['like', 'USER_ID', $this->USER_ID])->andFilterWhere(['like', 'UNIT_BARANG', $this->UNIT_BARANG])->andFilterWhere(['like', 'NOTED', $this->NOTED]);
     return $dataProvider;
 }
 /**
  * Finds the ImportView model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return ImportView the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = ImportView::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }