public function actionCreateparent()
 {
     $model = new Kategoricus();
     if ($model->load(Yii::$app->request->post())) {
         $data = Kategoricus::find()->count();
         if ($data == 0) {
             $model->CUST_KTG_PARENT = 1;
         } else {
             $datax = Kategoricus::find()->MAX('CUST_KTG');
             $model->CUST_KTG_PARENT = $datax + 1;
         }
         if ($model->validate()) {
             $model->CREATED_BY = Yii::$app->user->identity->username;
             $model->CREATED_AT = date("Y-m-d H:i:s");
             if ($model->save()) {
                 echo 1;
             } else {
                 echo 0;
             }
         }
     } else {
         return $this->renderAjax('_formparent', ['model' => $model]);
     }
 }
 /**
  * Create  Kategoricus model.
  * Create child Kategoricus By parent.
  * @author wawan
  * @since 1.1.0
  * @param string $id
  * @return mixed
  */
 public function actionCreate($id)
 {
     $model = new Kategoricus();
     $cus = Kategoricus::find()->where(['CUST_KTG' => $id])->one();
     $par = $cus['CUST_KTG'];
     if ($model->load(Yii::$app->request->post())) {
         $model->CUST_KTG_PARENT = $par;
         if ($model->validate()) {
             $model->STATUS = 1;
             $model->CREATED_BY = Yii::$app->user->identity->username;
             $model->CREATED_AT = date("Y-m-d H:i:s");
             $model->save();
         }
         return $this->redirect(['esm-index-kategori']);
     } else {
         return $this->renderAjax('_form', ['model' => $model]);
     }
 }