Ejemplo n.º 1
0
 public function testShouldUpdateCurrentLocation()
 {
     $currentLocation = null;
     $latitude = -23.48033;
     $longitude = -46.63459;
     $city = new City();
     $city->setName("São Paulo");
     $city->setState("SP");
     $address = new Address();
     $address->setCity($city);
     $address->setStreet("Rua Funchal");
     $address->setDistrict("Vila Olímpia");
     $api = $this->getMock("ApontadorApi", array("revgeocode"));
     $api->expects($this->once())->method("revgeocode")->with($latitude, $longitude)->will($this->returnValue($address));
     $locationController = new LocationController();
     $locationController->setApi($api);
     $locationController->disableSession();
     $locationController->update($latitude, $longitude);
     $current = $locationController->current();
     $currentLocation = new Location($current['location']);
     $this->assertNotNull($currentLocation);
     $this->assertSame("SP", $currentLocation->getAddress()->getCity()->getState());
     $this->assertSame("São Paulo", $currentLocation->getAddress()->getCity()->getName());
     $this->assertSame("Vila Olímpia", $currentLocation->getAddress()->getDistrict());
     $this->assertSame("Rua Funchal", $currentLocation->getAddress()->getStreet());
     $this->assertSame($latitude, $currentLocation->getPoint()->getLat());
     $this->assertSame($longitude, $currentLocation->getPoint()->getLng());
 }
 public function saveNewCityRecord()
 {
     $city = new City();
     $city['city'] = Input::get('txtCity');
     if ($city->save()) {
         return 1;
     } else {
         return 0;
     }
 }
Ejemplo n.º 3
0
 public function createCity($name, $attr = [])
 {
     if (!($model = $this->findCity($name))) {
         $model = new City();
         $model->name = $name;
         $model->setAttributes($attr);
         $model->save(false);
     }
     return $model;
 }
Ejemplo n.º 4
0
 public function actionCity()
 {
     $model = new City();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate()) {
             // form inputs are valid, do something here
             return;
         }
     }
     return $this->render('city', ['model' => $model]);
 }
Ejemplo n.º 5
0
 public function load()
 {
     $this->populate(unserialize(Session::read('location')));
     $lat = $this->point->getLat();
     $lng = $this->point->getLng();
     if (empty($lat) || empty($lng)) {
         $city = new City();
         $city->setName("São Paulo");
         $city->setState("SP");
         $this->point->setLat(-23.48033);
         $this->point->setLng(-46.63459);
         $this->address->setCity($city);
     }
 }
Ejemplo n.º 6
0
 public function actionDeliveryCost($code)
 {
     //check the api for the returned data
     //check country
     $city = City::find()->where('Name="' . $code . '"')->one();
     //var_dump($city);
     if ($city->CountryCode == 'EGY') {
         //calculate weight
         $sum = 0;
         foreach (Shopcart::goods() as $good) {
             $sum += $good->item->product_weight;
         }
         // return "the new cost--".$city->Name .$city->CountryCode;
         //$city->CountryCode;
         $cost = $this->GetCost($city->Name, $sum);
         if ($cost == '' or $cost == 0) {
             return Setting::get('deliver_cost');
         } else {
             return $cost;
         }
     } else {
         return Setting::get('deliver_cost');
         //.'-99'. $city->CountryCode;
     }
 }
Ejemplo n.º 7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $place = Place::with(['city', 'category'])->whereId($id)->first();
     $categories = Category::all();
     $cities = City::all();
     return view('client.placeinfo', compact('place', 'categories', 'cities'));
 }
Ejemplo n.º 8
0
 public function testSetGetName()
 {
     $this->object->setName('city');
     $this->assertEquals('city', $this->object->getName());
     $this->object->setName('City');
     $this->assertEquals('City', $this->object->getName());
 }
Ejemplo n.º 9
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('Cities')->delete();
     City::create(['id' => 1, 'city_name' => 'Vilnius']);
     City::create(['id' => 2, 'city_name' => 'Kaunas']);
     City::create(['id' => 3, 'city_name' => 'Klaipeda']);
     City::create(['id' => 4, 'city_name' => 'Kita']);
 }
Ejemplo n.º 10
0
 public function actionGetorgcity($id)
 {
     $rows = \app\models\City::find()->where(['state_id' => $id, 'is_status' => 0])->ALL();
     echo Html::tag('option', Html::encode(Yii::t('app', '--- Select City ---')), ['value' => '']);
     foreach ($rows as $row) {
         echo Html::tag('option', Html::encode($row->city_name), ['value' => $row->city_id]);
     }
 }
Ejemplo n.º 11
0
 public function actionGetRegionCities($region_id)
 {
     $cities = \app\models\City::find()->where(['region_id' => $region_id])->all();
     $content = '';
     foreach ($cities as $city) {
         $content .= '<option value="' . $city->id . '">' . $city->title . '</option>';
     }
     return $content;
 }
Ejemplo n.º 12
0
 /**
  * @todo Save location by session
  *
  * @param \Illuminate\Http\Request $request
  * @param int                      $id City id
  *
  * @return Redirect
  */
 public function selectLocation($id)
 {
     $id = (int) $id;
     if (!is_null(City::find($id))) {
         Session::put(_const('SESSION_LOCATION'), $id);
         Session::save();
     }
     return redirect(route('front_home'));
 }
Ejemplo n.º 13
0
 public static function addAcl($data)
 {
     $city = City::with('state')->where('id', '=', $data['city'])->first();
     $acl = new Acl();
     $acl->dni = $data['dni'];
     $acl->topic = $city->state->name . '/' . $city->name . '/water/' . $acl->dni;
     //Definir Mendoza/water/dni
     $acl->rw = 1;
     $acl->save();
 }
Ejemplo n.º 14
0
 public function getCity(Request $req)
 {
     $state = State::find($req->id);
     $city = City::where('state_code', $state->code)->get();
     $html = '<option value="" selected>Choose Option</option>';
     foreach ($city as $cities) {
         $html .= '<option value="' . $cities->id . '">' . $cities->name . '</option>';
     }
     echo $html;
 }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'region_id' => $this->region_id, 'region_global_id' => $this->region_global_id, 'gmt' => $this->gmt, 'sort_id' => $this->sort_id, 'old_region_id' => $this->old_region_id, 'is_deleted' => $this->is_deleted, 'is_published' => $this->is_published, 'timezone' => $this->timezone]);
     $query->andFilterWhere(['like', 'id_1c', $this->id_1c])->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'region_1c', $this->region_1c])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'title_1c', $this->title_1c])->andFilterWhere(['like', 'geoip_city', $this->geoip_city])->andFilterWhere(['like', 'path', $this->path])->andFilterWhere(['like', 'alternative_path', $this->alternative_path])->andFilterWhere(['like', 'old_path', $this->old_path])->andFilterWhere(['like', 'service_center', $this->service_center])->andFilterWhere(['like', 'manufacturer_service_center', $this->manufacturer_service_center])->andFilterWhere(['like', 'yandex_confirm_code', $this->yandex_confirm_code])->andFilterWhere(['like', 'yandex_confirm_code_tp', $this->yandex_confirm_code_tp])->andFilterWhere(['like', 'yandex_confirm_code_bazar', $this->yandex_confirm_code_bazar]);
     return $dataProvider;
 }
Ejemplo n.º 17
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'createdAt' => $this->createdAt, 'updatedAt' => $this->updatedAt]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 18
0
 public function allCity()
 {
     $response = array();
     $infos = City::all();
     if (!empty($infos)) {
         foreach ($infos as $info) {
             $response[] = array("info_id" => $info['id'], "data_description" => $info['city']);
         }
     }
     return $response;
 }
Ejemplo n.º 19
0
 public function actionEmp_p_city($id)
 {
     $rows = \app\models\City::find()->where(['city_state_id' => $id, 'is_status' => 0])->all();
     echo "<option value=''>---Select City---</option>";
     if (count($rows) > 0) {
         foreach ($rows as $row) {
             echo "<option value='{$row->city_id}'>{$row->city_name}</option>";
         }
     } else {
         echo "";
     }
 }
Ejemplo n.º 20
0
 public function actionFillTeams()
 {
     foreach ($this->arrOfTeams as $team => $city) {
         $model = new Khlteams();
         $model->name = $team;
         $city_id = City::find()->where("name like('" . $city . "')")->one()->id;
         if (!$city_id) {
             $city_id = 1513;
         }
         $model->city_id = $city_id;
         $model->save(false);
     }
 }
Ejemplo n.º 21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::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;
     }
     $query->andFilterWhere(['id' => $this->id, 'country_id' => $this->country_id, 'state_id' => $this->state_id, 'created_by' => $this->created_by, 'modified_by' => $this->modified_by, 'created_date' => $this->created_date, 'modified_date' => $this->modified_date]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
Ejemplo n.º 22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::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;
     }
     $query->andFilterWhere(['id' => $this->id, 'have_event' => $this->have_event]);
     $query->andFilterWhere(['like', 'title_uk', $this->title_uk])->andFilterWhere(['like', 'title_ru', $this->title_ru])->andFilterWhere(['like', 'title_en', $this->title_en]);
     return $dataProvider;
 }
Ejemplo n.º 23
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::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;
     }
     $query->andFilterWhere(['id' => $this->id, 'rec_status_id' => $this->rec_status_id, 'user_id' => $this->user_id, 'dc' => $this->dc]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'note', $this->note]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = City::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'province_id' => $this->province_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'citycol', $this->citycol]);
     return $dataProvider;
 }
Ejemplo n.º 25
0
 /**
  * Run the database seeds.
  */
 public function run()
 {
     Province::truncate();
     City::truncate();
     $jsonProvinces = File::get(database_path('json/provinces.json'));
     $dataProvinces = json_decode($jsonProvinces);
     $dataProvinces = collect($dataProvinces);
     foreach ($dataProvinces as $d) {
         $d = collect($d)->toArray();
         $p = new Province();
         $p->fill($d);
         $p->save();
     }
     $jsonCities = File::get(database_path('json/cities.json'));
     $dataCities = json_decode($jsonCities);
     $dataCities = collect($dataCities);
     foreach ($dataCities as $d) {
         $d = collect($d)->toArray();
         $p = new City();
         $p->fill($d);
         $p->save();
     }
 }
Ejemplo n.º 26
0
 public function cityAutocompleteAction()
 {
     $c = $this->query->get('c');
     $cities = City::where('active', '=', 1)->where('name', '=', $c);
     //
     //        $cities = $this->em->getRepository('PoiskRabotyMainBundle:City')->get(array(
     //            'enabled' => true,
     //            'search_start' => $c,
     //        ));
     $json = array();
     foreach ($cities as $city) {
         $json[] = array('value' => $this->helper->getTranslation($city, 'title'), 'label' => $this->helper->getTranslation($city, 'title'));
     }
     return new JsonResponse($json);
 }
Ejemplo n.º 27
0
 public function search($input)
 {
     $query = City::query();
     $columns = Schema::getColumnListing('cities');
     $attributes = array();
     foreach ($columns as $attribute) {
         if (isset($input[$attribute]) and !empty($input[$attribute])) {
             $query->where($attribute, $input[$attribute]);
             $attributes[$attribute] = $input[$attribute];
         } else {
             $attributes[$attribute] = null;
         }
     }
     return [$query->get(), $attributes];
 }
Ejemplo n.º 28
0
 public function run()
 {
     DB::table('users')->delete();
     $VK = new VK(env('VK_APP_ID'), env('VK_KEY_SECRET'));
     $vkCities = $VK->api('database.getCities', ['need_all' => 1, 'count' => 1000, 'lang' => 'ru']);
     while (count($vkCities) == 1000) {
         foreach ($vkCities['response'] as $country) {
             City::create(['id' => $country['id'], 'title' => $country['title']]);
         }
         $vkCities = $VK->api('database.getCities', ['need_all' => 1, 'count' => 1000, 'lang' => 'ru']);
     }
     foreach ($vkCities['response'] as $country) {
         City::create(['id' => $country['id'], 'title' => $country['title']]);
     }
 }
Ejemplo n.º 29
0
 public function create($input)
 {
     $user = new $this->model();
     $user->first_name = $input['first_name'];
     $user->user_type = $input['user_type'];
     $user->last_name = $input['last_name'];
     $user->pseudo = $input['pseudo'];
     $user->phone = $input['phone'];
     $user->email = $input['email'];
     $user->valid = '0';
     $user->temp = '0';
     $user->city()->associate(City::find($input['id_city']));
     $user->password = Hash::make($input['password']);
     return $user;
 }
 /**
  * @todo Save location by session
  *
  * @param \Illuminate\Http\Request $request
  * @param int                      $id City id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function ajaxSelectLocation(Request $request, $id)
 {
     //Only accept ajax request
     if ($request->ajax()) {
         $id = (int) $id;
         if (City::find($id) !== null) {
             //Start session if it wasn't started
             if (!$request->session()->isStarted()) {
                 $request->session()->start();
             }
             $request->session()->put(_const('SESSION_LOCATION'), $id);
             return pong(1, _t('saved_info'));
         }
     }
 }