public function actionIndex() { $model = new Provinsi(); $model1 = new Kota(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->G_ORDER]); } else { return $this->render('index', ['model' => $model, 'model1' => $model1]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Provinsi::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $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; } $dataProvider->sort->defaultOrder = ['id_prov' => SORT_DESC]; $query->andFilterWhere(['like', 'id_prov', $this->id_prov])->andFilterWhere(['like', 'nama', $this->nama]); return $dataProvider; }
public function actionGetarea1() { $regional = 2; $query = new Query(); $model = new Area(); $modelprovinsi = new Provinsi(); $datawitel = array(); $datakota = array(); $dataprovinsi = array(); $no = 1; $json = ""; if ($regional != "all") { $witel = $model->find()->select(['FIELD2'])->distinct(true)->where(['FIELD3' => $regional])->orderby(['FIELD2' => SORT_ASC])->all(); $provinsi = $modelprovinsi->find()->select(['FIELD2'])->distinct(true)->where(['FIELD3' => $regional])->orderby(['FIELD2' => SORT_ASC])->all(); $query->select('TABLE24.FIELD2')->from('TABLE24')->join('LEFT OUTER JOIN', 'TABLE25', 'TABLE25.FIELD1 = TABLE24.FIELD3')->join('LEFT OUTER JOIN', 'TABLE7', 'TABLE7.FIELD1 = TABLE25.FIELD3')->where(['TABLE7.FIELD1' => $regional])->all(); $kota = $query->createCommand()->queryAll(); foreach ($witel as $data) { array_push($datawitel, array("witel" => $data->FIELD2)); $no++; $json['witel'] = $datawitel; } foreach ($kota as $data) { array_push($datakota, array("kota" => $data['FIELD2'])); $no++; $json['kota'] = $datakota; } foreach ($provinsi as $data) { array_push($dataprovinsi, array("provinsi" => $data->FIELD2)); $no++; $json['provinsi'] = $dataprovinsi; } echo json_encode($json); } else { echo "error"; } }
protected function findModelProvinsi($id) { if (($model = Provinsi::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
use kartik\depdrop\DepDrop; /* @var $this yii\web\View */ /* @var $model frontend\models\Kecamatan */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="kecamatan-form"> <?php $form = ActiveForm::begin(['validateOnBlur' => false, 'validateOnChange' => false]); ?> <?php $provinsi = ArrayHelper::map(Provinsi::find()->orderBy(['nama' => SORT_ASC])->all(), 'id_prov', 'nama'); ?> <?php echo $form->field($modelProvinsi, 'id_prov')->label('Provinsi Name')->dropDownList($provinsi, ['prompt' => 'Pilih']); ?> <?php if (!$model->isNewRecord) { ?> <?php echo Html::hiddenInput('id_kab', $model->id_kab, ['id' => 'id_kab']); ?> <?php } ?>
public function getProvinsi() { return $this->hasOne(Provinsi::className(), ['id_prov' => 'id_prov']); }
public function actionCreatejsonprovinsi() { $mcustomer = new Customer(); $mprov = new Provinsi(); $provinsi = $mprov->find()->all(); $total = $mcustomer->find()->count(); $labels = $mcustomer->attributeLabels(); $array = array(); $file = "uploads/json/customer/attributeprovinsi.json"; fopen($file, "w"); foreach ($provinsi as $row) { $prov = $row->FIELD2; foreach ($labels as $key => $rows) { $label = strtoupper($rows); $filled = $mcustomer->find()->where($key . ' IS NOT NULL')->count(); $notfilled = $mcustomer->find()->where($key . ' IS NULL')->count(); array_push($array, array('province' => $prov, 'attribute' => array('labels' => $label, 'count' => $total, 'filled' => $filled, 'notfilled' => $notfilled))); } } $data = json_encode($array, JSON_PRETTY_PRINT); file_put_contents($file, $data); }