public function actionGetSublocations()
 {
     if (isset($_GET['location'])) {
         $sublocations = Sublocation::model()->findAll('location_id=:l', array(':l' => $_GET['location']));
         echo CJSON::encode($sublocations);
     }
 }
Example #2
0
 public function actionGetSublocations($ap_location)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $data = Sublocation::model()->findAll('location_id=:location_id', array(':location_id' => (int) $ap_location));
         $data = CHtml::listData($data, 'id', 'name');
         $chooseTranslate = tt("Choose sublocation", 'apartments');
         $new_data = array();
         $new_data[0] = $chooseTranslate;
         foreach ($data as $key => $value) {
             $new_data[$key] = $value;
         }
         foreach ($new_data as $value => $name) {
             echo CHtml::tag('option', array('value' => $value), CHtml::encode($name), true);
         }
     } else {
         return 0;
     }
 }
Example #3
0
 public function getSublocationsOfLocation($location_id)
 {
     $data = Sublocation::model()->findAll('location_id=:location_id', array(':location_id' => $location_id));
     $data = CHtml::listData($data, 'id', 'name');
     $chooseTranslate = tt("Choose sublocation", 'apartments');
     array_unshift($data, $chooseTranslate);
     return $data;
     /*foreach($data as $value=>$name)
       {
           echo CHtml::tag('option',
               array('value'=>$value),CHtml::encode($name),true);
       }*/
 }