Example #1
0
 public function validalias($model)
 {
     # code...
     $kondisiTrue = Barangalias::find()->where("KD_ALIAS='" . $this->KD_ALIAS . "' AND KD_DISTRIBUTOR='" . $this->KD_DISTRIBUTOR . "'")->one();
     if ($kondisiTrue) {
         $this->addError($model, 'Duplicated code because the code already exists in this distributor !, attention Better change name distributor or change code ');
     }
 }
Example #2
0
 public function alias_barang_save()
 {
     //if ($this->validate()) {
     $rcBarangalias = new Barangalias();
     //print_r($this->distributor());
     //die();
     //print_r($rcBarangalias->getErrors());
     //die();
     //if ($this->validate()) {
     $rcBarangalias->KD_BARANG = $this->kD_BARANG;
     $rcBarangalias->KD_ALIAS = $this->kD_BARANG_ALIAS;
     //$rcBarangalias->KD_PARENT = '1';
     $rcBarangalias->KD_DISTRIBUTOR = $this->kD_REF;
     $rcBarangalias->CREATED_AT = date('Y-m-d');
     $rcBarangalias->CREATED_BY = $username = Yii::$app->user->identity->username;
     $rcBarangalias->save();
     // print_r($rcBarangalias->save());
     // die();
     return $rcBarangalias;
     //}
     //return null;
     //}
 }
Example #3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Barangalias::find();
     $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;
     }
     $query->andFilterWhere(['ID' => $this->ID, 'KD_PARENT' => $this->KD_PARENT, 'CREATED_AT' => $this->CREATED_AT, 'UPDATED_AT' => $this->UPDATED_AT]);
     $query->andFilterWhere(['like', 'KD_BARANG', $this->KD_BARANG])->andFilterWhere(['like', 'KD_ALIAS', $this->KD_ALIAS])->andFilterWhere(['like', 'KD_DISTRIBUTOR', $this->KD_DISTRIBUTOR])->andFilterWhere(['like', 'CREATED_BY', $this->CREATED_BY])->andFilterWhere(['like', 'UPDATED_BY', $this->UPDATED_BY]);
     return $dataProvider;
 }
 protected function findModelalias($ID)
 {
     if (($model = Barangalias::findOne($ID)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }