Ejemplo n.º 1
0
 public function findAllArea($id)
 {
     $AreaArea = Area::find()->where(array('parentId' => $id))->asArray()->all();
     if ($AreaArea) {
         return $AreaArea;
     }
     return null;
 }
Ejemplo n.º 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";
     }
 }
Ejemplo n.º 3
0
 public function actionArea()
 {
     $model = new Area();
     for ($i = 1; $i <= 100; $i++) {
         $id_regional = 1;
         if ($i % 8 == 0) {
             $id_regional = 8;
         } else {
             if ($i % 7 == 0) {
                 $id_regional = 7;
             } else {
                 if ($i % 6 == 0) {
                     $id_regional = 6;
                 } else {
                     if ($i % 5 == 0) {
                         $id_regional = 5;
                     } else {
                         if ($i % 4 == 0) {
                             $id_regional = 4;
                         } else {
                             if ($i % 3 == 0) {
                                 $id_regional = 3;
                             } else {
                                 if ($i % 2 == 0) {
                                     $id_regional = 2;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $model->FIELD1 = $i;
         $model->FIELD2 = "AREA " . $i;
         $model->FIELD3 = $id_regional;
         if ($model->insert()) {
             echo "sukses" . $i;
         } else {
             print_r($model->getErrors());
         }
     }
 }
Ejemplo n.º 4
0
 public function actionEditaddress()
 {
     $Area = new Area();
     $UserAddress = new UserAddress();
     $AreaProvince = $Area->findAllProvince(0);
     $AddressForm = new AddAddressForm();
     $userId = Yii::$app->session->get(FVariable::$session_userId_str);
     if (!$userId) {
         return $this->redirect(FVariable::$siteLogin_view);
     }
     $userAddressId = Yii::$app->request->get('id');
     $EditUserAddress = $UserAddress->findByUserIdEvaluate($userId, $userAddressId);
     $AddressForm->userName = $EditUserAddress->userName;
     $AddressForm->provinceId = $EditUserAddress->provinceId;
     $AddressForm->cityId = $EditUserAddress->cityId;
     $AddressForm->areaId = $EditUserAddress->areaId;
     $AreaCity = $Area->findAllCity($AddressForm->provinceId);
     $AreaArea = $Area->findAllCity($AddressForm->cityId);
     $AddressForm->detailAddress = $EditUserAddress->detailAddress;
     $AddressForm->userMobile = $EditUserAddress->userMobile;
     $AddressForm->userPhone = $EditUserAddress->userPhone;
     $AddressForm->postNumber = $EditUserAddress->postNumber;
     $AddressForm->isDefault = $EditUserAddress->isDefault;
     $editAddressReq = Yii::$app->request;
     //创建一个请求对象
     if ($AddressForm->load($editAddressReq->post())) {
         if ($AddressForm->validate()) {
             if (!$AddressForm->isDefault) {
                 $AddressForm->isDefault = 0;
             } else {
                 $UserAddress->findByUserIdUpdate($userId);
             }
             $UserAddress->findByIdEdit($userAddressId, $AddressForm);
             return $this->redirect(FVariable::$userVipcenter_view);
         }
     }
     return $this->render(FVariable::$userEditAddress_view, ['AddressForm' => $AddressForm, 'AreaProvince' => $AreaProvince, 'AreaCity' => $AreaCity, 'AreaArea' => $AreaArea]);
 }
Ejemplo n.º 5
0
 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);
 }