public function cekalias($model) { # code... $data = $this->KD_CUSTOMERS; $datadis = $this->KD_DISTRIBUTOR; $kondisi = Customersalias::find()->where(['KD_CUSTOMERS' => $data, 'KD_DISTRIBUTOR' => $datadis])->one(); if ($kondisi) { $this->addError($model, 'Duplicated code because the code already exists in this distributor !, attention change name distributor or change code '); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customersalias::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->custpnma, 'KD_CUSTOMERS' => $this->custnm, 'CREATED_AT' => $this->CREATED_AT, 'UPDATED_AT' => $this->UPDATED_AT, 'KD_DISTRIBUTOR' => $this->disnm]); $query->andFilterWhere(['like', 'KD_CUSTOMERS', $this->custnm])->andFilterWhere(['like', 'KD_ALIAS', $this->KD_ALIAS])->andFilterWhere(['like', 'KD_PARENT', $this->custpnma])->andFilterWhere(['like', 'KD_DISTRIBUTOR', $this->disnm])->andFilterWhere(['like', 'CREATED_BY', $this->CREATED_BY])->andFilterWhere(['like', 'UPDATED_BY', $this->UPDATED_BY]); return $dataProvider; }
public function actionUpdateAlias($id) { $model = Customersalias::find()->where(['KD_CUSTOMERS' => $id])->one(); $id = Customers::find()->where(['CUST_KD' => $id])->one(); $nama = $id->CUST_NM; if (Yii::$app->request->isAjax && $model->load($_POST)) { Yii::$app->response->format = 'json'; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post())) { $model->UPDATED_AT = date('Y-m-d'); $model->UPDATED_BY = Yii::$app->user->identity->username; $model->save(); return $this->redirect(['index-alias']); } else { return $this->renderAjax('alias_customers', ['model' => $model, 'id' => $id, 'nama' => $nama]); } }
public function actionUpdateAlias($id) { $model = Customersalias::find()->where(['KD_CUSTOMERS' => $id])->one(); if ($model->load(Yii::$app->request->post())) { $model->UPDATED_AT = date('Y-m-d'); $model->UPDATED_BY = Yii::$app->user->identity->username; $model->save(); return $this->redirect(['index-alias']); } else { return $this->renderAjax('alias_customers', ['model' => $model, 'cus_data' => self::aryData_Customers(), 'cus_dis' => self::aryData_Dis()]); } }
public function actionDeleteAlias($id) { $model = Customersalias::find()->where(['ID' => $id])->one(); $model->delete(); return $this->redirect(['index-alias']); }