Esempio n. 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function searchparent($params)
 {
     $query = Kategoricus::find()->where('CUST_KTG_PARENT <> 0')->orderBy('CUST_KTG_PARENT');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 20]]);
     $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(['CUST_KTG_NM' => $this->CUST_KTG_NM, 'CUST_KTG_PARENT' => $this->CUST_KTG_PARENT]);
     $query->andFilterWhere(['like', 'CUST_KTG_NM', $this->CUST_KTG_NM])->andFilterWhere(['like', 'CUST_KTG', $this->CUST_KTG])->andFilterWhere(['like', 'CUST_KTG_PARENT', $this->CUST_KTG_PARENT]);
     return $dataProvider;
 }
 public function actionUpdatekat($id)
 {
     $readonly = Customers::find()->where(['CUST_KD' => $id])->asArray()->one();
     // data for view
     $model = $this->findModelcust($id);
     $model->scenario = "updatekat";
     $dropparentkategori = ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM');
     if ($model->load(Yii::$app->request->post())) {
         $tanggal = \Yii::$app->formatter->asDate($model->JOIN_DATE, 'Y-M-d');
         $model->JOIN_DATE = $tanggal;
         if ($model->validate()) {
             $model->UPDATED_AT = date("Y-m-d H:i:s");
             $model->UPDATED_BY = Yii::$app->user->identity->username;
             if ($model->save()) {
                 echo 1;
             } else {
                 echo 0;
             }
         }
         //  return $this->redirect(['index']);
     } else {
         return $this->renderAjax('type', ['model' => $model, 'dropparentkategori' => $dropparentkategori, 'readonly' => $readonly]);
     }
 }