/** * Lists all Schedulegroup models. * @return mixed */ public function actionIndex() { $params_group = Yii::$app->request->queryParams; /*search group*/ $paramCari_group = Yii::$app->getRequest()->getQueryParam('SCDL_GROUP'); if (count($paramCari_group) == 0) { $field_cust = $params_group['CustomersSearch']['SCDL_GROUP']; } else { $field_cust = $params_group['SCDL_GROUP']; } /*if parent not equal null then search parent*/ if ($paramCari_group != '') { $cari = ['SCDL_GROUP' => $paramCari_group]; $cari_scdl_group = ['ID' => $paramCari_group]; } else { $cari = ''; } $searchModel = new SchedulegroupSearch($cari_scdl_group); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $searchModelCustGrp = new CustomersSearch($cari); $dpListCustGrp = $searchModelCustGrp->searchCustGrp(Yii::$app->request->queryParams); $aryStt = [['STATUS' => 0, 'STT_NM' => 'DISABLE'], ['STATUS' => 1, 'STT_NM' => 'ENABLE']]; $valStt = ArrayHelper::map($aryStt, 'STATUS', 'STT_NM'); //query for select2 in schedule-group = index $query = Yii::$app->db_esm->createCommand("SELECT * FROM `c0007` c7 WHERE NOT EXISTS (SELECT SCDL_GROUP FROM `c0001` `c1` WHERE c1.SCDL_GROUP = c7.ID)")->queryAll(); $data = ArrayHelper::map($query, 'ID', 'SCDL_GROUP_NM'); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'dpListCustGrp' => $dpListCustGrp, 'data' => $data, 'valStt' => $valStt, 'field_cust' => $field_cust]); }
public function actionEsmIndex() { $datacus = Customers::find()->where('CUST_GRP = CUST_KD')->asArray()->all(); $parent = ArrayHelper::map($datacus, 'CUST_KD', 'CUST_NM'); /*layer $cari_layer = "select * from c0016"; $hasil = Yii::$app->db_esm->createCommand($cari_layer)->queryAll(); $data_layer = ArrayHelper::map($hasil,'ID',function ($hasil, $defaultValue) { return $hasil['LAYER'].'-'.$hasil['DCRIPT']; }); $config_layer = ArrayHelper::map($hasil,'ID','LAYER' ); $cari_group = "select * from c0007_temp"; $hasil_grup = Yii::$app->db_esm->createCommand($cari_group)->queryAll(); $data_group = ArrayHelper::map($hasil_grup,'ID','SCDL_GROUP_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->search(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; } } // 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()]); }