Esempio n. 1
0
 public function actionGetkota()
 {
     $provinsi = $_POST['provinsi'];
     $idprovinsi = Provinsi::find()->select(['FIELD1'])->where(['FIELD2' => $provinsi])->scalar();
     $kota = Kota::find()->where(['FIELD3' => $idprovinsi])->all();
     $datakota = array();
     $no = 1;
     $json = "";
     if ($provinsi != "all") {
         foreach ($kota as $data) {
             array_push($datakota, array("kota" => $data->FIELD2));
             $no++;
             $json['kota'] = $datakota;
         }
         echo json_encode($json);
     } else {
         echo "error";
     }
 }
Esempio n. 2
0
 public function actionSubcat()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $cat_id = $parents[0];
             $model = Kota::find()->asArray()->where(['province_id' => $cat_id])->all();
             //$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['province_id'], 'name' => $value['city_name']];
             }
             echo json_encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
Esempio n. 3
0
 public function actionCreatejsonkota()
 {
     $mcustomer = new Customer();
     $mkota = new Kota();
     $kota = $mkota->find()->all();
     $total = $mcustomer->find()->count();
     $labels = $mcustomer->attributeLabels();
     $array = array();
     $file = "uploads/json/customer/attributekota.json";
     fopen($file, "w");
     foreach ($kota as $row) {
         $namekota = $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('kota' => $namekota, 'attribute' => array('labels' => $label, 'count' => $total, 'filled' => $filled, 'notfilled' => $notfilled)));
         }
     }
     $data = json_encode($array, JSON_PRETTY_PRINT);
     file_put_contents($file, $data);
 }