/** * ESM INDEX * Lists all Customers models. * @author wawan * @since 1.1.0 */ public function actionEsmIndex() { $datacus = Customers::find()->where('CUST_GRP = CUST_KD')->asArray()->all(); $parent = ArrayHelper::map($datacus, 'CUST_KD', 'CUST_NM'); /*search individual*/ $paramCari = Yii::$app->getRequest()->getQueryParam('id'); /*search group*/ $paramCari_prn = Yii::$app->getRequest()->getQueryParam('id_prn'); // if parent not equal null then search parent if ($paramCari_prn != '') { $cari = ['CUST_GRP' => $paramCari_prn]; } elseif ($paramCari != '') { $cari = ['CUST_KD' => $paramCari]; } else { $cari = ''; } $searchModel = new CustomersSearch($cari); $dataProvider = $searchModel->searchNoo(Yii::$app->request->queryParams); if (Yii::$app->request->post('hasEditable')) { $ID = \Yii::$app->request->post('editableKey'); Yii::$app->response->format = Response::FORMAT_JSON; $model = Customers::findOne($ID); $out = Json::encode(['output' => '', 'message' => '']); // fetch the first entry in posted data (there should // only be one entry anyway in this array for an // editable submission) // - $posted is the posted data for Book without any indexes // - $post is the converted array for single model validation $post = []; $posted = current($_POST['Customers']); $post['Customers'] = $posted; // load model like any single model validation if ($model->load($post)) { // can save model or do something before saving model // custom output to return to be displayed as the editable grid cell // data. Normally this is empty - whereby whatever value is edited by // in the input by user is updated automatically. $output = ''; if (isset($posted['CUST_KD'])) { /*save parent customers*/ $parent_model = Customers::find()->where(['CUST_KD' => $ID])->one(); $parent_model->CUST_GRP = $posted['CUST_KD']; $parent_model->save(); /* output parent*/ $output = $parent_model->CUST_GRP; } if (isset($posted['LAYER'])) { $model->save(); $output = $model->LAYER; } if (isset($posted['GEO'])) { $model->save(); $output = $model->GEO; } if (isset($posted['DC_STATUS'])) { $model->save(); $output = $model->DC_STATUS; } } // specific use case where you need to validate a specific // editable column posted when you have more than one // EditableColumn in the grid view. We evaluate here a // check to see if buy_amount was posted for the Book model // similarly you can check if the name attribute was posted as well $out = Json::encode(['output' => $output, 'message' => '']); // return ajax json encoded response and exit echo $out; return; } /*Tambahal menu side Dinamik */ $sideMenu_control = 'esm_customers'; return $this->render('index', ['sideMenu_control' => $sideMenu_control, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'parent' => $parent, 'data_layer' => $this->aryData_layer(), 'config_layer' => $config_layer, 'data_group' => $this->aryData_Geo()]); }