示例#1
0
 public function findAllArea($id)
 {
     $AreaArea = Area::find()->where(array('parentId' => $id))->asArray()->all();
     if ($AreaArea) {
         return $AreaArea;
     }
     return null;
 }
示例#2
0
 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";
     }
 }
 public function actionCreatejsonarea()
 {
     $mcustomer = new Customer();
     $marea = new Area();
     $area = $marea->find()->all();
     $total = $mcustomer->find()->count();
     $labels = $mcustomer->attributeLabels();
     $array = array();
     $file = "uploads/json/customer/attributearea.json";
     fopen($file, "w");
     foreach ($area as $row) {
         $namearea = $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('area' => $namearea, 'attribute' => array('labels' => $label, 'count' => $total, 'filled' => $filled, 'notfilled' => $notfilled)));
         }
     }
     $data = json_encode($array, JSON_PRETTY_PRINT);
     file_put_contents($file, $data);
 }