Example #1
0
 public function actionStates()
 {
     $data = '';
     $countryId = $_POST['country_id'];
     $states = \common\models\States::find()->where(['countryID' => $countryId])->orderBy('name ASC')->all();
     $list = "<option value=''>Select State</option>";
     if (count($states) > 0) {
         foreach ($states as $state) {
             $list .= "<option value='" . $state->id . "'>" . $state->name . "</option>";
         }
     } else {
         $list = "<option>-</option>";
     }
     if (empty($data)) {
         $citydata = \common\models\Cities::findAll(['countryID' => $countryId]);
         $citylist = "<option value=''>Select City</option>";
         if (count($citydata) > 0) {
             foreach ($citydata as $city) {
                 $citylist .= "<option value='" . $city->id . "'>" . $city->name . "</option>";
             }
         } else {
             $citylist = "<option>-</option>";
         }
     } else {
         $citylist = "<option>-</option>";
     }
     \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['list' => $list, 'citylist' => $citylist, 'code' => 100];
 }
Example #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = States::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['idstates' => $this->idstates, 'idcountry' => $this->idcountry]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Example #3
0
 public function getState()
 {
     return $this->hasOne(States::className(), ['id' => 'state_id']);
 }
Example #4
0
                            	<div class="col-3 addmarginB30 clearfix">
                                	<div class="col col1">
                                    	<label>Country</label>
                                    	<?php 
if (empty($address->country_id)) {
    $address->country_id = 'MYS';
}
$coutrylist = ArrayHelper::map(\common\models\Countries::findAll(['is_visible' => 1, 'status' => 1]), 'countryID', 'countryName');
echo $form->field($address, 'country_id')->dropDownList($coutrylist, ['prompt' => 'Select Country', 'class' => 'singleSelectBox', 'data-tags' => true, 'onChange' => 'signup_obj.countrychange("' . Url::toRoute(['site/states']) . '")'])->label(false);
?>
                                    </div>
                                    <div class="col col2">
                                    	<label>State</label>
                                    	<?php 
if (!empty($addre->state_id)) {
    $state = ArrayHelper::map(\common\models\States::findAll(['id' => $address->state_id]), 'id', 'name');
} else {
    $state = [];
}
// print_r($state);die;
echo $form->field($address, 'state_id')->dropDownList($state, ['prompt' => 'Select State', 'class' => 'singleSelectBox', 'data-tags' => true, 'onChange' => 'signup_obj.statechange("' . Url::toRoute(['site/city']) . '")'])->label(false);
?>
                                    </div>
                                    <div class="col col3">
                                    	<label>City</label>
                                    	<?php 
if (!empty($address->city_id)) {
    $city = ArrayHelper::map(\common\models\Cities::findAll(['id' => $address->city_id]), 'id', 'name');
} else {
    $city = [];
}
Example #5
0
 /**
  * Finds the States model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return States the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = States::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #6
0
 public function getStates($countryId)
 {
     $statesModel = States::find()->where(['countryID' => $countryId])->orderBy(['name' => SORT_ASC])->all();
     if ($statesModel) {
         $stateList = ArrayHelper::map($statesModel, 'id', 'name');
         //$stateList=  CHtml::listData($statesModel, 'id', 'name');
         return $stateList;
     } else {
         return array();
     }
 }
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStates()
 {
     return $this->hasMany(States::className(), ['idcountry' => 'idcountries']);
 }
Example #8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getIdstates0()
 {
     return $this->hasOne(States::className(), ['idstates' => 'idstates']);
 }
Example #9
0
                        <?php 
$form = ActiveForm::begin(['id' => 'search-form', 'enableAjaxValidation' => false, 'enableClientValidation' => true, 'validateOnSubmit' => true, 'action' => Yii::$app->urlManager->createUrl('university/searchcollege')]);
?>
                        <div class="sb-filters sb-filters-2 addmarginB20">
                        	<i class="sprite i-location"></i>
                            <div class="sb-dropdown">
                               <?php 
echo Html::dropDownList('state', null, ArrayHelper::map(\common\models\States::find()->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), ['prompt' => 'Select State', 'class' => 'form-control singleSelectBox', 'id' => 'userprofile-state_id', 'readonly' => 'readonly', 'data-tags' => true, 'onChange' => 'signup_obj.statechange("' . Url::toRoute(['site/city']) . '")']);
?>
                            </div>
                        </div>
                        <div class="sb-filters addmarginB20">
                        	<i class="sprite i-location"></i>
                            <div class="sb-dropdown">
                                <?php 
echo Html::dropDownList('city', null, ArrayHelper::map(\common\models\States::find()->all(), 'id', 'name'), ['prompt' => 'Select City', 'class' => 'form-control singleSelectBox', 'id' => 'userprofile-city_id', 'readonly' => 'readonly', 'data-tags' => true]);
?>
                            </div>
                        </div>
                        <?php 
echo Html::submitButton('search', ['class' => 'searchBtn']);
?>
                        <?php 
ActiveForm::end();
?>
                    </div>
                </div>
                
            </div>
        </div>
    </div>
Example #10
0
                        </div>
                    </div>
                    <div class="df-states">
                    	<i class="sprite"></i>
                        <div class="df-dropdown">
                            <?php 
echo Html::dropDownList('id', null, ArrayHelper::map(\common\models\States::find()->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), ['prompt' => 'Select State', 'class' => 'singleSelectBox', 'id' => 'userprofile-state_id', 'readonly' => 'readonly', 'data-tags' => true, 'onChange' => 'signup_obj.statechange("' . Url::toRoute(['site/city']) . '"),UniversityByState("' . Url::toRoute(['university/search']) . '")']);
?>
                        </div>
                    </div>
                    <div class="df-city">
                    	<i class="sprite"></i>
                        <div class="df-dropdown">

                            <?php 
echo Html::dropDownList('id', null, ArrayHelper::map(\common\models\States::find()->all(), 'id', 'name'), ['prompt' => 'Select City', 'class' => 'singleSelectBox', 'id' => 'userprofile-city_id', 'readonly' => 'readonly', 'data-tags' => true, 'onChange' => 'UniversityByState("' . Url::toRoute(['university/search']) . '")']);
?>
<!--                            
                        	<select data-tags="true" data-placeholder="Select City" class="form-control singleSelectBox">
                                <option></option>
                            </select>-->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12">
                <a href="#" onClick="$('#sideFilters').slideToggle(); return false;" class="filterMobBtn"><i class="sprite i-otherinfo"></i>Filters</a>
                <div class="sideFilters" id="sideFilters">
                	<div class="browse-items">