/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Province::find(); $dataproviderpro = 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 $dataproviderpro; } $query->andFilterWhere(['PROVINCE_ID' => $this->PROVINCE_ID]); $query->andFilterWhere(['like', 'PROVINCE', $this->PROVINCE]); return $dataproviderpro; }
public function getCustprov() { return $this->hasOne(Province::className(), ['PROVINCE_ID' => 'PROVINCE_ID']); }
/** * Finds the Kategoricus model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Kategoricus the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModelpro($id) { if (($model = Province::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use lukisongroup\master\models\Kategoricus; use lukisongroup\master\models\Province; use lukisongroup\master\models\Kota; use yii\web\JsExpression; use yii\bootstrap\Modal; use yii\helpers\Url; use kartik\widgets\DepDrop; /* @var $this yii\web\View */ /* @var $model lukisongroup\master\models\Customerskat */ /* @var $form yii\widgets\ActiveForm */ $dropdis = ArrayHelper::map(\lukisongroup\master\models\Distributor::find()->all(), 'KD_DISTRIBUTOR', 'NM_DISTRIBUTOR'); $config = ['template' => "{input}\n{error}\n{hint}"]; // $dropparent = ArrayHelper::map(\lukisongroup\master\models\Kategori::find()->all(),'CUST_KTG_PARENT', 'CUST_KTG_NM'); $no = 0; $dropparentkategori = ArrayHelper::map(Kategoricus::find()->where(['CUST_KTG_PARENT' => $no])->asArray()->all(), 'CUST_KTG', 'CUST_KTG_NM'); $droppro = ArrayHelper::map(Province::find()->asArray()->all(), 'PROVINCE_ID', 'PROVINCE'); // $dropcity = ArrayHelper::map(Kota::find()->all(),'POSTAL_CODE','CITY_NAME'); // print_r( $dropparentkategori); // die(); // Modal::begin([ // 'header'=>'<h4>Vlookup</h4>', // 'id'=> 'modal', // 'size'=>'modal-lg', // ]); // echo"<div id='modalcalon'></div>"; // modal::end(); ?> <div class="customerskat-form"> <?php
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]); } }
<?php use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\helpers\ArrayHelper; use lukisongroup\master\models\Province; use kartik\widgets\Select2; /* @var $this yii\web\View */ /* @var $model lukisongroup\master\models\Kota */ /* @var $form yii\widgets\ActiveForm */ $prov = ArrayHelper::map(Province::find()->all(), 'PROVINCE_ID', 'PROVINCE'); ?> <div class="kota-form"> <?php $form = ActiveForm::begin(['id' => $model->formName(), 'enableClientValidation' => true]); ?> <!-- $form->field($model, 'CITY_ID')->textInput() ?> --> <?php echo $form->field($model, 'PROVINCE_ID')->widget(Select2::classname(), ['data' => $prov, 'options' => ['placeholder' => 'Pilih Province..'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'PROVINCE')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'TYPE')->textInput(['maxlength' => true]);