Пример #1
0
 public function actionLocales()
 {
     $model = City::findOne($_POST['id']);
     $aux = array();
     foreach ($model->locales as $k => $locale) {
         $aux[$k]['id'] = $locale->id;
         $aux[$k]['address'] = $locale->address;
     }
     echo json_encode($aux);
 }
Пример #2
0
             $add_s = '';
         }
         if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd_country)) {
             $add_co = Country::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd_country)->country_name;
         } else {
             $add_co = '';
         }
         echo "<td class='text-center'>" . EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_cadd . " " . $add_c . " " . $add_s . " " . $add_co . "</td>";
     } else {
         echo "<td class='text-center'>&nbsp;</td>";
     }
 } else {
     if ($s == 'emp_padd') {
         if ($sd['emp_master_emp_address_id'] != 0) {
             if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)) {
                 $add_c = "<br/>" . City::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_city)->city_name . ", ";
             } else {
                 $add_c = '';
             }
             if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)) {
                 $add_s = State::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_state)->state_name . ", ";
             } else {
                 $add_s = '';
             }
             if (!empty(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)) {
                 $add_co = Country::findOne(EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd_country)->country_name;
             } else {
                 $add_co = '';
             }
             echo "<td class='text-center'>" . EmpAddress::findOne($sd['emp_master_emp_address_id'])->emp_padd . " " . $add_c . " " . $add_s . " " . $add_co . "</td>";
         } else {
Пример #3
0
 function actionGetStations()
 {
     $id_city = $this->get["id_city"];
     $city = City::findOne(['id' => $id_city]);
     if (count($city) == 0) {
         $r = $this->setError(150);
     } else {
         $stations = Stations::find()->where("id_city='" . $id_city . "' ")->asArray()->all();
         $r["status"] = "ok";
         $r["stations"] = $stations;
     }
     return json_encode($r);
 }
Пример #4
0
         }
         if (!empty(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)) {
             $add_co = Country::findOne(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)->country_name;
         } else {
             $add_co = '';
         }
         echo "<td style='text-align:center; width:400px;'>" . StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd . $add_city_c . " " . $add_s . " " . $add_co . "</td>";
     } else {
         echo "<td>&nbsp;</td>";
     }
 } else {
     if ($s == 'city') {
         if ($sd['stu_master_stu_address_id'] != 0) {
             $add = StuAddress::findOne($sd['stu_master_stu_address_id']);
             if (!empty($add)) {
                 $city = City::findOne($add->stu_cadd_city);
             }
             if (!empty($add->stu_cadd_city)) {
                 echo "<td style='text-align:center;'>" . $city['city_name'] . "</td>";
             } else {
                 echo "<td>&nbsp;</td>";
             }
         } else {
             echo "<td>&nbsp;</td>";
         }
     } else {
         if ($s == 'stu_email_id') {
             if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) {
                 echo "<td style='text-align:center;width:250px;'>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td>";
             } else {
                 echo "<td style='text-align:center;'>&nbsp;</td>";
 /**
  * Finds the City model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return City the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = City::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #6
0
 public function actionGetCoords()
 {
     $data = Yii::$app->request->post();
     $cityID = $data['city'];
     $city = City::findOne($cityID);
     $cityName = null;
     if ($city) {
         $cityName = $city->name;
     }
     $address = Address::find()->andFilterWhere(['city' => $cityName])->asArray()->all();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $responce = ['coords' => $address];
     return $responce;
 }
Пример #7
0
 public function getCountKidsCity()
 {
     $city = City::findOne($this->id_city);
     return $city->count_kids;
 }
Пример #8
0
         if (!empty(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)) {
             $add_co = Country::findOne(StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd_country)->country_name;
         } else {
             $add_co = '';
         }
         echo "<td >" . StuAddress::findOne($sd['stu_master_stu_address_id'])->stu_padd . " " . $add_city_c . " " . $add_s . " " . $add_co . "</td></tr>";
     } else {
         echo "<td>&nbsp;</td></tr>";
     }
 } else {
     if ($s == 'city') {
         echo "<tr><td class='label'>" . Yii::t('report', 'City') . "</td>";
         if ($sd['stu_master_stu_address_id'] != 0) {
             $add = StuAddress::findOne($sd['stu_master_stu_address_id']);
             if ($add->stu_cadd_city != null) {
                 echo "<td>" . (!empty(City::findOne($add->stu_cadd_city)->city_name) ? City::findOne($add->stu_cadd_city)->city_name : " Not Set ") . "</td></tr>";
             } else {
                 echo "<td>&nbsp;</td></tr>";
             }
         } else {
             echo "<td>&nbsp;</td></tr>";
         }
     } else {
         if ($s == 'stu_email_id') {
             if (StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} != null) {
                 echo "<tr><td class='label'>" . Yii::t('report', 'Email Id') . "</td> <td>" . StuInfo::findOne($sd['stu_master_stu_info_id'])->{$s} . "</td> </tr>";
             } else {
                 echo "<tr><td class='label'>" . Yii::t('report', 'Email ID') . "</td> <td >&nbsp;</td></tr>";
             }
         } else {
             if ($s == 'stu_admission_date') {
Пример #9
0
     }
 } else {
     if ($s == 'emp_category_name') {
         echo "<tr><td class='label'>Category Name </td>";
         if ($sd['emp_master_category_id'] != 0) {
             echo "<td>" . Category::findOne($sd['emp_master_category_id'])->emp_category_name . "</td></tr>";
         } else {
             echo "<td>&nbsp;</td></tr>";
         }
     } else {
         if ($s == 'city') {
             echo "<tr><td class='label'>City</td>";
             if ($sd['emp_master_emp_address_id'] != 0) {
                 $add = EmpAddress::findOne($sd['emp_master_emp_address_id']);
                 if ($add->emp_cadd_city != null) {
                     echo "<td>" . City::findOne($add->emp_cadd_city)->city_name . "</td></tr>";
                 } else {
                     echo "<td>&nbsp;</td></tr>";
                 }
             } else {
                 echo "<td>&nbsp;</td></tr>";
             }
         } else {
             if ($s == 'emp_guardian_mobile_no') {
                 echo "<tr><td class='label'>Guardian No </td>";
                 echo "<td>" . $sd[$s] . "</td></tr>";
             } else {
                 if ($s == 'emp_bloodgroup') {
                     echo "<tr><td class='label'>Blood Group</td><td>" . $sd[$s] . "</td></tr>";
                 } else {
                     echo "<tr><td class='label'>" . Html::ActiveLabel($emp_info, $s) . " </td><td>" . $sd[$s] . "</td></tr>";
Пример #10
0
 /**
  * Finds the City model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return City the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = City::findOne($id)) !== null) {
         return $model;
     } else {
         $this->getHeader(400);
         echo json_encode(array('status' => 0, 'error_code' => 400, 'message' => 'Bad request'), JSON_PRETTY_PRINT);
         exit;
         // throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #11
0
 public function getCityName()
 {
     return City::findOne(['id' => $this->city_id])->title;
 }
Пример #12
0
 public function actionGetYandexWeather()
 {
     foreach ($this->cities as $city) {
         $cityIn = City::findOne(['name' => $city]);
         $url = 'http://export.yandex.ru/weather-ng/forecasts/' . $cityIn->yndid . '.xml';
         //$url =  'http://api.openweathermap.org/data/2.5/weather?q=London,uk&appid=1a415db9cc13a7d753bcc5fc25ee5972';
         //echo $url; exit;
         try {
             $xml = simplexml_load_file($url);
         } catch (\ErrorException $e) {
             echo $e->getMessage();
             continue;
         }
         $this->temp = $xml->fact->temperature;
         $this->weather_type = $xml->fact->weather_type;
         $this->wind_direction = $xml->fact->wind_direction;
         $this->wind_speed = $xml->fact->wind_speed;
         $this->humidity = $xml->fact->humidity;
         $this->pressure = $xml->fact->pressure;
         $this->cityId = $cityIn->id;
         $this->putDatasInTableNew();
     }
 }
Пример #13
0
 public function getSrchRes($city = null, $brand = null, $service = null, $district = null, $name = null, $address = null, $twfhr = null)
 {
     $cityObj = City::findOne($city);
     if ($address) {
         $a1 = str_replace(' ', ',', trim($address));
         $a2 = explode(',', $a1);
         if ($a2) {
             $a4 = [];
             foreach ($a2 as $a3) {
                 if (mb_strlen($a3, 'UTF-8') > 4) {
                     $a4[] = $a3;
                 }
             }
             if (count($a4) > 0) {
                 $a5 = implode('%', $a4);
                 $address = $a5;
             }
         }
     }
     $srchres = $this->find()->select(['company.id', 'company.name', 'company.phone', 'company.twenty_four_hours', 'address.city', 'address.district', 'address.street', 'address.home', 'address.housing', 'address.building', 'address.latitude', 'address.longitude', 'special_offer.id AS special_offer_id', 'company_brands.id AS company_brands_id', 'company_services.id AS company_services_id'])->leftJoin('address', '`address`.`id` = `company`.`address_id`')->leftJoin('special_offer', '`special_offer`.`company_id` = `company`.`id`')->leftJoin('company_brands', '`company_brands`.`company_id` = `company`.`id`')->leftJoin('company_services', '`company_services`.`company_id` = `company`.`id`')->filterWhere(['company_brands.brand_id' => $brand, 'company_services.service_id' => $service, 'address.city' => $cityObj['name'], 'address.district' => $district, 'company.name' => $name, 'company.twenty_four_hours' => $twfhr])->andFilterWhere(['like', 'address.street', $address])->asArray()->all();
     $id = ArrayHelper::getColumn($srchres, 'id');
     $shedule = Shedule::find()->where(['company_id' => $id])->asArray()->all();
     $shedule2 = [];
     foreach ($shedule as $sh) {
         $companyID = $sh['company_id'];
         $shedule2[$companyID][] = $sh;
     }
     for ($i = 0; $i < count($srchres); $i++) {
         $companyID = $srchres[$i]['id'];
         $srchres[$i]['shedule'] = $shedule2[$companyID];
     }
     return $srchres;
 }