Esempio n. 1
0
 public function actionSetcity()
 {
     @session_start();
     if (Yii::$app->request->post('country')) {
         if ($city = GeobaseCity::findOne(['name' => Yii::$app->request->post('country')])) {
             $_SESSION['city'] = $city->name;
             $_SESSION['city_url'] = $city->url;
             return $this->redirect('/' . strtolower($city->url) . '/arenda');
         }
     }
 }
Esempio n. 2
0
 public function actionGetcities($region_id)
 {
     $result = GeobaseCity::find()->where(['region_id' => $region_id])->asArray()->all();
     $options = '<option disabled selected>Выберите</option>';
     foreach ($result as $key => $value) {
         $options .= '<option value="' . $value['id'] . '">' . $value['name'] . '</option>';
     }
     return $options;
 }
Esempio n. 3
0
 public function actionCreate_city($id)
 {
     @session_start();
     $_SESSION['menu'] = 2;
     $functions_model = new Functions();
     $model = new GeobaseCity();
     if ($model->load(Yii::$app->request->post())) {
         if (empty($model->url)) {
             $model->url = $functions_model->translit($model->name);
         }
         if (!empty($model->name)) {
             $model->region_id = $id;
             if ($model->validate()) {
                 if ($model->save()) {
                     $session = new Session();
                     $session->open();
                     $session = Yii::$app->session;
                     $session->setFlash('add_city', '<div class="alert alert-success">Вы успешно добавили город.</div>');
                     return $this->redirect('create_city?id=' . $id);
                 }
             }
         }
     }
     $region = GeobaseRegion::findOne(['id' => $id]);
     return $this->render('edit_city', ['model' => $model, 'region' => $region]);
 }
Esempio n. 4
0
/* @var $this \yii\web\View */
/* @var $content string */
use yii\helpers\Html;
use yii\bootstrap\Nav;
use yii\bootstrap\NavBar;
use yii\widgets\Breadcrumbs;
use app\assets\AppAsset;
use yii\widgets\ActiveForm;
AppAsset::register($this);
@session_start();
if (isset($_SESSION['city'])) {
    $city = \app\modules\arenda\models\GeobaseCity::findOne(['url' => $_SESSION['city_url']]);
} else {
    $geobase = Yii::$app->ipgeobase->getLocation($_SERVER['REMOTE_ADDR'], false)->city;
    if (!empty($geobase)) {
        $city = \app\modules\arenda\models\GeobaseCity::findOne(['name' => $geobase]);
    }
}
$this->beginPage();
?>
<!DOCTYPE html>
<html lang="<?php 
echo Yii::$app->language;
?>
">
<head>
    <meta charset="<?php 
echo Yii::$app->charset;
?>
">
    <meta name="viewport" content="width=device-width, initial-scale=1">