Esempio n. 1
0
 function get_countries($args = null)
 {
     //return GeoCountry::findByField();
     $countries = GeoCountry::findByEnable(array("value" => "1"));
     $res = array();
     foreach ($countries as $country) {
         $res[] = array("code" => $country->COUNTRYCODE, "name" => $country->NAME);
     }
     return array("success" => array("hand_enter" => 0, "res" => $res));
 }
Esempio n. 2
0
 public static function getStateListByCountry($country = 'india')
 {
     $country = GeoCountry::model()->find('LOWER(country)=:country', array('country' => $country));
     if ($country) {
         $model = GeoState::model()->findAll('country_id=:country_id', array(':country_id' => $country->id));
         $stateList = null;
         foreach ($model as $state) {
             $stateList[$state->id] = $state->state;
         }
         return $stateList;
     } else {
         return array();
     }
 }
Esempio n. 3
0
 public static function getAddressByLocalityId($localityId)
 {
     $address[] = "";
     $locality = GeoLocality::model()->findByPk($localityId);
     if ($locality) {
         $address['locality'] = $locality->locality;
         $city = GeoCity::model()->findByPk($locality->city_id);
         $address['city'] = $city->city;
         $state = GeoState::model()->findByPk($city->state_id);
         $address['state'] = $state->state;
         $country = GeoCountry::model()->findByPk($state->country_id);
         $address['country'] = $country->country;
         return $address;
     } else {
         return false;
     }
 }
Esempio n. 4
0
<?php 
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array('id' => 'geo-region-form', 'enableAjaxValidation' => false, 'enableClientValidation' => false, 'type' => 'horizontal'));
?>

    <!-- Fields with <span class="required">*</span> are required. -->
	<!--<p class="help-block"><?php 
echo Yii::t("Bootstrap", "PHRASE.FIELDS_REQUIRED");
?>
</p>-->

	<?php 
echo $form->errorSummary($model);
?>

<?php 
echo $form->dropDownListRow($model, "country_id", CHtml::listData(GeoCountry::model()->findAll(), "id", "name_ru"), array("empty" => "Не выбран"));
echo $form->textFieldRow($model, 'name_ru', array('class' => 'span5', 'maxlength' => 50));
echo $form->textFieldRow($model, 'name_en', array('class' => 'span5', 'maxlength' => 50));
echo $form->textFieldRow($model, 'sort', array('class' => 'span5'));
?>

	<div class="form-actions">

		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'htmlOptions' => array('style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE')));
?>

		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'htmlOptions' => array('name' => 'go_to_list', 'style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE_RETURN') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE_RETURN')));
?>
Esempio n. 5
0
</li>
	<li class="error_message"><?php 
    echo $form->error($locationCity, 'city_id');
    ?>
</li>
</ul>
<div id="city_content_more"></div>
<?php 
}
?>
</fieldset>
<fieldset><legend>Location Details</legend>
<ul>
	<li><span>Country<span class="required">*</span></span>
		<?php 
echo $form->dropdownList($model, 'country_id', CHtml::listData(GeoCountry::model()->findAll(), 'id', 'country'), array('empty' => 'All', 'class' => 'slctbox', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('/location/state/getList/page/agent'), 'update' => '#state_content', 'data' => 'js:jQuery(this).serialize()')));
?>
       
	</li>
	<li class="error_message"><?php 
echo $form->error($model, 'country_id');
?>
</li>
</ul>
<div id="state_content">
<ul>
	<li>
			<span>State<span class="required">*</span></span>
			<?php 
echo $form->dropdownList($model, 'state_id', CHtml::listData(GeoState::model()->findAll('country_id=:country_id', array(':country_id' => $model->country_id)), 'id', 'state'), array('empty' => 'All', 'class' => 'slctbox', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('/location/city/getList/page/agent'), 'update' => '#city_content', 'data' => 'js:jQuery(this).serialize()')));
?>
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = GeoCountry::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Esempio n. 7
0
 public static function getCountryByName($countryName)
 {
     $dependency = new CDbCacheDependency('SELECT MAX(updated_time) FROM geo_country');
     return GeoCountry::model()->find('lower(country)=:country', array(':country' => strtolower($countryName)));
 }
Esempio n. 8
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.GeoCountry");
?>
</legend>
<a class="btn" href="/admin/geocountry/geocountry/create">Добавить</a>
<?php 
$assetsDir = Yii::app()->basePath;
$labels = GeoCountry::model()->attributeLabels();
/*
$this->widget('backendfilterWidget', array(
    'listId' => 'geo-country-grid',
    'model' => $model,
    'columns'=>array(


            
            array(
            'name_ru',
            'htmlOptions'=>array('class'=>'span5')
        ),
        
            array(
            'name_en',
            'htmlOptions'=>array('class'=>'span5')
        ),
        
            array(
            'code',
            'htmlOptions'=>array('class'=>'span5')
        ),
Esempio n. 9
0
 public static function getLocation($cityId)
 {
     $userModel = UserProfiles::model()->find('city_id=:cityId', array(':cityId' => $cityId));
     $address[] = "";
     if ($userModel) {
         $city = GeoCity::model()->findByPk($userModel->city_id);
         $address['city'] = $city ? $city->city : "";
         $state = GeoState::model()->findByPk($city->state_id);
         $address['state'] = $state->state;
         $country = GeoCountry::model()->findByPk($state->country_id);
         $address['country'] = $country->country;
         return $address;
     } else {
         return false;
     }
 }
Esempio n. 10
0
echo $form->labelEx($profilesModel, 'zip');
?>
        <?php 
echo $form->textField($profilesModel, 'zip');
?>
        <?php 
echo $form->error($profilesModel, 'zip');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($profilesModel, 'country');
?>
         <?php 
echo $form->dropDownList($profilesModel, 'country', CHtml::listData(GeoCountry::model()->findAll(), 'id', 'country'), array('empty' => 'Select'));
?>
        <?php 
echo $form->error($profilesModel, 'country');
?>
    </div>

    <div class="row">
        <?php 
echo $form->labelEx($profilesModel, 'mobile');
?>
        <?php 
echo $form->textField($profilesModel, 'mobile', array('size' => 20, 'maxlength' => 20));
?>
        <?php 
echo $form->error($profilesModel, 'mobile');
Esempio n. 11
0
 public static function getLocation($projectId)
 {
     $project = Projects::model()->findByPk($projectId);
     $address[] = "";
     if ($project) {
         $locality = isset($_POST['GeoLocality']['locality_id']) ? $_POST['GeoLocality']['locality_id'] : '';
         if ($locality) {
             $locality = GeoLocality::model()->findByPk($project->locality_id);
             $address['locality'] = $locality ? $locality->locality : "";
             $city = GeoCity::model()->findByPk($locality->city_id);
             $address['city'] = $city->city;
             $state = GeoState::model()->findByPk($city->state_id);
             $address['state'] = $state->state;
             $country = GeoCountry::model()->findByPk($state->country_id);
             $address['country'] = $country->country;
             return $address;
         }
     } else {
         return false;
     }
 }
Esempio n. 12
0
 public static function getLocationForSession($sessionProperty)
 {
     $locality = GeoLocality::model()->findByPk($sessionProperty['locality_id']);
     $address['locality'] = $locality ? $locality->locality : "";
     $city = GeoCity::model()->findByPk($sessionProperty['city_id']);
     $address['city'] = $city->city;
     $state = GeoState::model()->findByPk($city->state_id);
     $address['state'] = $state->state;
     $country = GeoCountry::model()->findByPk($state->country_id);
     $address['country'] = $country->country;
     return $address;
 }
Esempio n. 13
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.GeoRegion");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = GeoRegion::model()->attributeLabels();
$this->widget('backendfilterWidget', array('listId' => 'geo-region-grid', 'model' => $model, 'columns' => array(array('country_id', 'select', 'listData' => CHtml::listData(GeoCountry::model()->findAll(array('order' => 'name_ru')), 'id', 'name_ru'), 'htmlOptions' => array('class' => 'span5')))));
echo '<a class="btn" href="/admin/georegion/georegion/create">Добавить</a>';
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'geo-region-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->with("country")->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["country_id"], 'name' => 'country_id', 'value' => '$data->country ? $data->country->name_ru : ""', 'filter' => CHtml::listData(GeoCountry::model()->findAll(array('order' => 'name_ru')), 'id', 'name_ru')), array('header' => $labels["name_ru"], 'name' => "name_ru"), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));