/** * 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; }
<?php use yii\helpers\Html; use yii\widgets\DetailView; use lukisongroup\master\models\Kategoricus; /* @var $this yii\web\View */ /* @var $model lukisongroup\master\models\Kategoricus */ $data = Kategoricus::find()->where(['CUST_KTG' => $model->CUST_KTG_PARENT])->one(); $hasil = $data['CUST_KTG_NM']; $this->title = $hasil; $this->params['breadcrumbs'][] = ['label' => 'Kategoricuses', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> <div class="kategoricus-view"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['CUST_KTG_NM']]); ?> <p> <!-- Html::a('Delete', ['delete', 'id' => $model->CUST_KTG], [ 'class' => 'btn btn-danger', 'data' => [ 'confirm' => 'Are you sure you want to delete this item?',
public function getCustype() { return $this->hasOne(Kategoricus::className(), ['CUST_KTG' => 'CUST_TYPE']); }
protected function findModel($id) { if (($model = Kategoricus::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php /*extensions*/ use yii\helpers\Html; use yii\widgets\ActiveForm; use kartik\widgets\Select2; use yii\helpers\ArrayHelper; use kartik\widgets\DepDrop; use yii\helpers\Url; /*namespace models*/ use lukisongroup\master\models\Kategoricus; /* @var $this yii\web\View */ /* @var $model lukisongroup\esm\models\Kategoricus */ /* @var $form yii\widgets\ActiveForm */ $dropparentkategori = ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'); ?> <div class="kategoricus-form"> <?php $form = ActiveForm::begin(['id' => $model->formName(), 'enableClientValidation' => true]); ?> <?php echo $form->field($model, 'cus_Type')->widget(Select2::classname(), ['options' => ['placeholder' => 'Select Category ...'], 'data' => $dropparentkategori])->label('Kategori'); ?> <?php echo $form->field($model, 'cust_ktga')->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'options' => ['placeholder' => 'Select ...', 'id' => 'customers-cust_ktga'], 'select2Options' => ['pluginOptions' => ['allowClear' => true]], 'pluginOptions' => ['depends' => ['customers-cus_type'], 'initialize' => true, 'loadingText' => 'Loading ...', 'url' => Url::to(['/master/customers/lisdata'])]])->label('Type');
/** * Deletes an existing Kategori model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param string $id * @return mixed */ public function actionDelete($id) { $model = Kategoricus::find()->where(['CUST_KTG' => $id])->one(); $model->STATUS = 3; $model->save(); return $this->redirect(['index']); }
}, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Customers Group'], 'group' => true], ['attribute' => 'CUST_KTG_NM'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => ' {edit} {view} {update}', 'dropdown' => true, 'dropdownOptions' => ['class' => 'pull-right dropup'], 'dropdownButton' => ['class' => 'btn btn-default btn-xs'], 'header' => 'Action', 'buttons' => ['edit' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-plus"></span>' . Yii::t('app', 'Tambah'), ['create', 'id' => $model->CUST_KTG_PARENT], ['data-toggle' => "modal", 'data-target' => "#formparent", 'data-title' => $model->CUST_KTG_NM]) . '<li>'; }, 'view' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-eye-open"></span>' . Yii::t('app', 'View'), ['view', 'id' => $model->CUST_KTG], ['data-toggle' => "modal", 'data-target' => "#viewparent", 'data-title' => $model->CUST_KTG_PARENT]) . '</li>'; }, 'update' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-pencil"></span>' . Yii::t('app', 'Update'), ['update', 'id' => $model->CUST_KTG], ['data-toggle' => "modal", 'data-target' => "#formparent", 'data-title' => $model->CUST_KTG_PARENT]) . '</li>'; }]]], 'panel' => ['type' => GridView::TYPE_SUCCESS, 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('app', 'Create Parent ', ['modelClass' => 'Kategoricus']), '/master/customers/createparent', ['data-toggle' => "modal", 'data-target' => "#formparent", 'class' => 'btn btn-success'])], 'pjax' => true, 'pjaxSettings' => ['options' => ['enablePushState' => false, 'id' => 'gv-kat']], 'hover' => true, 'responsiveWrap' => true, 'bordered' => true, 'striped' => '4px', 'autoXlFormat' => true, 'export' => ['fontAwesome' => true, 'showConfirmAlert' => false, 'target' => GridView::TARGET_BLANK]]); /* * GRID CUSTOMER * @author ptrnov [piter@lukison.com] * @since 1.2 */ $aryStt = [['STATUS' => 0, 'STT_NM' => 'DISABLE'], ['STATUS' => 1, 'STT_NM' => 'ENABLE']]; $valStt = ArrayHelper::map($aryStt, 'STATUS', 'STT_NM'); $dropType = ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'); $dropKtg = ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT<>CUST_KTG')->asArray()->all(), 'CUST_KTG_NM', 'CUST_KTG_NM'); $tabcustomers = \kartik\grid\GridView::widget(['id' => 'gv-cus', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'filterRowOptions' => ['style' => 'background-color:rgba(126, 189, 188, 0.9); align:center'], 'columns' => [['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '10px', 'header' => 'No.', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'verdana, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['attribute' => 'CUST_KD', 'label' => 'Customer.Id', 'hAlign' => 'left', 'vAlign' => 'middle', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '120px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'left', 'width' => '120px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['attribute' => 'CUST_KD_ALIAS', 'label' => 'Alias Code', 'hAlign' => 'left', 'vAlign' => 'middle', 'format' => 'raw', 'value' => function ($model) { // return Html::a('link_text','site/index'); $title = Yii::t('app', 'Alias Code'); $options = ['id' => 'cust-code-id', 'data-toggle' => 'modal', 'data-target' => '#cust-code', 'title' => 'Add Alias Customer']; $url = Url::toRoute(['/master/customers/alias-code-view', 'id' => $model->CUST_KD]); $content = Html::a($title, $url, $options); return $content; }, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '120px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'center', 'width' => '120px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['attribute' => 'CUST_NM', 'label' => 'Customer Name', 'hAlign' => 'left', 'vAlign' => 'middle', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '250px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'left', 'width' => '250px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['attribute' => 'custype.CUST_KTG_NM', 'filter' => $dropType, 'hAlign' => 'left', 'vAlign' => 'middle', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '150px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'left', 'width' => '150px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['attribute' => 'cus.CUST_KTG_NM', 'filter' => $dropKtg, 'hAlign' => 'left', 'vAlign' => 'middle', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '200px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'left', 'width' => '200px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['label' => 'PIC', 'attribute' => 'PIC', 'hAlign' => 'left', 'vAlign' => 'middle', 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '200px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(126, 189, 188, 0.9)']], 'contentOptions' => ['style' => ['text-align' => 'left', 'width' => '200px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]], ['attribute' => 'STATUS', 'filter' => $valStt, 'format' => 'raw', 'hAlign' => 'center', 'value' => function ($model) { if ($model->STATUS == 1) { return Html::a('<i class="fa fa-edit"></i> Enable', '', ['class' => 'btn btn-success btn-xs', 'title' => 'Aktif']); } else { if ($model->STATUS == 0) { return Html::a('<i class="fa fa-close"></i> Disable', '', ['class' => 'btn btn-danger btn-xs', 'title' => 'Deactive']); } }
public function actionUpdatecus($id) { $readonly = Customers::find()->where(['CUST_KD' => $id])->asArray()->one(); // data for view $model = $this->findModelcust($id); $model->scenario = "detail"; $dropparentkategori = ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'); $droppro = ArrayHelper::map(Province::find()->asArray()->all(), 'PROVINCE_ID', 'PROVINCE'); $dropdis = ArrayHelper::map(\lukisongroup\master\models\Distributor::find()->all(), 'KD_DISTRIBUTOR', 'NM_DISTRIBUTOR'); if ($model->load(Yii::$app->request->post())) { if ($model->validate()) { $model->UPDATED_AT = date("Y-m-d H:i:s"); $model->UPDATED_BY = Yii::$app->user->identity->username; // $model->save(); if ($model->save()) { echo 1; } else { echo 0; } } // print_r($model->save()); // die(); // return $this->redirect(['index']); } else { return $this->renderAjax('_updatealamat', ['model' => $model, 'dropparentkategori' => $dropparentkategori, 'droppro' => $droppro, 'dropdis' => $dropdis, 'readonly' => $readonly]); } }
$gvHeadColomnBT = ArrayHelper::map($headColomnBT, 'ID', 'ATTR'); /*GRIDVIEW ARRAY ACTION*/ $attDinamik[] = ['class' => 'kartik\\grid\\ActionColumn', 'dropdown' => true, 'template' => '{edit} {view} {update}', 'dropdownOptions' => ['class' => 'pull-left dropup', 'style' => ['disable' => true]], 'dropdownButton' => ['class' => $actionClass], 'buttons' => ['edit' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-plus"></span>' . Yii::t('app', 'Tambah'), ['create', 'id' => $model->CUST_KTG_PARENT], ['data-toggle' => "modal", 'data-target' => "#formparent", 'data-title' => $model->CUST_KTG_NM]) . '<li>'; }, 'view' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-eye-open"></span>' . Yii::t('app', 'View'), ['view', 'id' => $model->CUST_KTG], ['data-toggle' => "modal", 'data-target' => "#viewparent", 'data-title' => $model->CUST_KTG_PARENT]) . '</li>'; }, 'update' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-pencil"></span>' . Yii::t('app', 'Update'), ['update-kate', 'id' => $model->CUST_KTG], ['data-toggle' => "modal", 'data-target' => "#formparent", 'data-title' => $model->CUST_KTG_PARENT]) . '</li>'; }], 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt', 'background-color' => 'rgba(97, 211, 96, 0.3)']], 'contentOptions' => ['style' => ['text-align' => 'center', 'width' => '10px', 'height' => '10px', 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '9pt']]]; /*GRIDVIEW ARRAY ROWS*/ foreach ($gvHeadColomnBT as $key => $value[]) { if ($value[$key]['FIELD'] == 'CUST_KTG_PARENT') { $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'value' => function ($model, $key, $index, $widget) { $kategori = Kategoricus::find()->where(['CUST_KTG' => $model->CUST_KTG_PARENT])->one(); return $kategori->CUST_KTG_NM; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Customers Group'], 'group' => true, 'hAlign' => 'right', 'vAlign' => 'middle', 'noWrap' => true, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => $value[$key]['FIELD'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt', 'background-color' => 'rgba(' . $value[$key]['warna'] . ')']], 'contentOptions' => ['style' => ['text-align' => $value[$key]['align'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt']], 'width' => '12px']; } else { # code... $attDinamik[] = ['attribute' => $value[$key]['FIELD'], 'label' => $value[$key]['label'], 'filter' => true, 'hAlign' => 'right', 'vAlign' => 'middle', 'noWrap' => true, 'headerOptions' => ['style' => ['text-align' => 'center', 'width' => $value[$key]['FIELD'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt', 'background-color' => 'rgba(' . $value[$key]['warna'] . ')']], 'contentOptions' => ['style' => ['text-align' => $value[$key]['align'], 'font-family' => 'tahoma, arial, sans-serif', 'font-size' => '8pt']], 'width' => '12px']; } } /*SHOW GRID VIEW LIST*/ $tabcrud = GridView::widget(['id' => 'gv-kat', 'dataProvider' => $dataProviderkat, 'filterModel' => $searchModel1, 'filterRowOptions' => ['style' => 'background-color:rgba(97, 211, 96, 0.3); align:center'], 'columns' => $attDinamik, 'pjax' => true, 'pjaxSettings' => ['options' => ['enablePushState' => false, 'id' => 'gv-kat']], 'panel' => ['type' => GridView::TYPE_SUCCESS, 'before' => Html::a('<i class="glyphicon glyphicon-plus"></i> ' . Yii::t('app', 'Create Parent ', ['modelClass' => 'Kategoricus']), '/master/customers/createparent', ['data-toggle' => "modal", 'data-target' => "#formparent", 'class' => 'btn btn-success'])], 'toolbar' => [], 'hover' => true, 'responsive' => true, 'responsiveWrap' => true, 'bordered' => true, 'striped' => true]); $navmenu = NavX::widget(['options' => ['class' => 'nav nav-tabs'], 'encodeLabels' => false, 'items' => [['label' => 'MENU', 'active' => true, 'items' => [['label' => '<span class="fa fa-user fa-md"></span>Customers', 'url' => '/master/customers/esm-index'], ['label' => '<span class="fa fa-cogs fa-md"></span>Alias Customers', 'url' => '/master/customers/index-alias'], '<li class="divider"></li>', ['label' => 'Properties', 'items' => [['label' => '<span class="fa fa-flag fa-md"></span>Kota', 'url' => '/master/customers/esm-index-city'], ['label' => '<span class="fa fa-flag-o fa-md"></span>Province', 'url' => '/master/customers/esm-index-provinsi'], ['label' => '<span class="fa fa-table fa-md"></span>Category', 'url' => '/master/customers/esm-index-kategori'], ['label' => '<span class="fa fa-table fa-md"></span>Geografis', 'url' => '/master/customers/esm-index-geo'], ['label' => '<span class="fa fa-table fa-md"></span>Layers', 'url' => '/master/customers/esm-index-layer'], ['label' => '<span class="fa fa-table fa-md"></span>Layers Mutasi', 'url' => '/master/customers/esm-index-layermutasi'], '<li class="divider"></li>', ['label' => '<span class="fa fa-map-marker fa-md"></span>Customers Map', 'url' => '/master/customers/esm-map']]]]]]]); ?> <div class="content"> <div class="row" style="padding-left:3px"> <div class="col-sm-12 col-md-12 col-lg-12" > <!-- CUTI !--> <?php echo $navmenu;
} else { $button_create = ""; } ?> <div class="row"> <div class="col-sm-12"> <?php $kategori = \kartik\grid\GridView::widget(['id' => 'gv-kat-crm', 'dataProvider' => $dataProviderkat, 'filterModel' => $searchModel1, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'CUST_KTG_PARENT', 'width' => '310px', 'value' => function ($model, $key, $index, $widget) { $kategori = Kategoricus::find()->where(['CUST_KTG' => $model->CUST_KTG_PARENT])->one(); return $kategori->CUST_KTG_NM; }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Kategoricus::find()->where('CUST_KTG_PARENT = CUST_KTG')->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'Customers Group'], 'group' => true], ['attribute' => 'CUST_KTG_NM'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => Helper::filterActionColumn('{create}{view}{update}'), 'dropdown' => true, 'dropdownOptions' => ['class' => 'pull-right dropup'], 'dropdownButton' => ['class' => 'btn btn-default btn-xs'], 'header' => 'Action', 'buttons' => ['create' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-plus"></span>' . Yii::t('app', 'Tambah'), ['create', 'id' => $model->CUST_KTG_PARENT], ['data-toggle' => "modal", 'data-target' => "#formparent", 'data-title' => $model->CUST_KTG_NM]) . '<li>'; }, 'view' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-eye-open"></span>' . Yii::t('app', 'View'), ['view', 'id' => $model->CUST_KTG], ['data-toggle' => "modal", 'data-target' => "#viewparent", 'data-title' => $model->CUST_KTG_PARENT]) . '</li>'; }, 'update' => function ($url, $model, $key) { return '<li>' . Html::a('<span class="glyphicon glyphicon-pencil"></span>' . Yii::t('app', 'Update'), ['update', 'id' => $model->CUST_KTG], ['data-toggle' => "modal", 'data-target' => "#formparent", 'data-title' => $model->CUST_KTG_PARENT]) . '</li>'; }]]], 'panel' => ['type' => GridView::TYPE_SUCCESS, 'before' => $button_create], 'pjax' => true, 'pjaxSettings' => ['options' => ['enablePushState' => false, 'id' => 'gv-kat-crm']], 'hover' => true, 'responsiveWrap' => true, 'bordered' => true, 'striped' => '4px', 'autoXlFormat' => true, 'export' => ['fontAwesome' => true, 'showConfirmAlert' => false, 'target' => GridView::TARGET_BLANK]]); ?> </div> </div> <?php $navmenu = NavX::widget(['options' => ['class' => 'nav nav-tabs'], 'encodeLabels' => false, 'items' => [['label' => 'MENU', 'active' => true, 'items' => [['label' => '<span class="fa fa-user fa-md"></span>Customers', 'url' => '/mastercrm/customers-crm/index'], ['label' => '<span class="fa fa-cogs fa-md"></span>Alias Customers', 'url' => '/mastercrm/customers-crm/login-alias', 'linkOptions' => ['id' => 'performance', 'data-toggle' => 'modal', 'data-target' => '#formlogin']], '<li class="divider"></li>', ['label' => 'Properties', 'items' => [['label' => '<span class="fa fa-flag fa-md"></span>Kota', 'url' => '/mastercrm/kota-customers-crm/index'], ['label' => '<span class="fa fa-flag-o fa-md"></span>Province', 'url' => '/mastercrm/provinsi-customers-crm/index'], ['label' => '<span class="fa fa-table fa-md"></span>Category', 'url' => '/mastercrm/kategori-customers-crm/index'], '<li class="divider"></li>', ['label' => '<span class="fa fa-map-marker fa-md"></span>Customers Map', 'url' => '/mastercrm/customers-crm/crm-map']]]]]]]); ?> <div class="content"> <div class="row" style="padding-left:3px">
/** * Depdrop Kategoricus * @author wawan * @since 1.1.0 * @return mixed */ public function actionLisdata() { $out = []; if (isset($_POST['depdrop_parents'])) { $parents = $_POST['depdrop_parents']; if ($parents != null) { $id = $parents[0]; $model = Kategoricus::find()->asArray()->where(['CUST_KTG_PARENT' => $id])->andwhere('CUST_KTG_PARENT <> CUST_KTG')->all(); // print_r($model); // die(); //$out = self::getSubCatList($cat_id); // the getSubCatList function will query the database based on the // cat_id and return an array like below: // [ // ['id'=>'<sub-cat-id-1>', 'name'=>'<sub-cat-name1>'], // ['id'=>'<sub-cat_id_2>', 'name'=>'<sub-cat-name2>'] // ] foreach ($model as $key => $value) { $out[] = ['id' => $value['CUST_KTG_NM'], 'name' => $value['CUST_KTG_NM']]; } echo json_encode(['output' => $out, 'selected' => '']); return; } } echo Json::encode(['output' => '', 'selected' => '']); }