public static function getAllNameListByCity($city_id = '') { $model = GeoLocality::model()->findAll('city_id=:city_id', array(':city_id' => $city_id)); $localityList = null; foreach ($model as $locality) { $localityList[$locality->locality] = $locality->locality; } return $localityList; }
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; } }
?> </li> </ul> <div id="locality_content"> <ul> <li><span><?php echo $form->labelEx($model, 'locality_id'); ?> </span> <?php echo $form->dropdownList($model, 'locality_id', CHtml::listData(GeoLocality::model()->findAll('city_id=:city_id', array(':city_id' => $model->city_id)), 'id', 'locality'), array('empty' => 'All', 'id' => 'geo_locality', 'class' => 'slctbox')); $locality = isset($_POST['GeoLocality']['locality_id']) ? $_POST['GeoLocality']['locality_id'] : ''; ?> </li> <li class="error_message"><?php echo $form->error($model, 'locality_id'); ?> </li> </ul> </div> </div> <ul> <li><span><?php echo $form->labelEx($model, 'address');
<h3>Location</h3> <div class="acc-section"> <table width="92%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td><label>City</label> <?php echo $form->dropdownList($modelProject, 'city_id', CHtml::listData(GeoCity::model()->findAll(), 'id', 'city'), array('empty' => 'All', 'id' => 'geo_city', 'ajax' => array('type' => 'POST', 'url' => CController::createUrl('/location/locality/getList'), 'update' => '#locality_content', 'data' => 'js:jQuery(this).serialize()'))); $city = isset($_POST['Projects']['city_id']) ? $_POST['Projects']['city_id'] : ''; ?> </td> </tr> <tr> <td><label>Locality</label> <div id="locality_content" class="dis_inline"> <?php echo $form->dropdownList($modelProject, 'locality_id', CHtml::listData(GeoLocality::model()->findAll('city_id=:city_id', array(':city_id' => $city)), 'id', 'locality'), array('empty' => 'All', 'id' => 'geo_locality')); ?> </div> </td> </tr> </table> </div> </li> <li> <h3>Price</h3> <div class="acc-section"> <table width="92%" border="0" cellpadding="0" cellspacing="0" align="center"> <tr> <td><label>Budget</label><br /> <select name="budget_min" class="selectbox2" id="budget_min"> <option value="">Min</option>
public function actionUpdate($id, $imageId = '') { // var_dump($_GET);die(); Yii::beginProfile('property_update'); $model = Property::model()->findByPk($id); if (!$model) { throw new CHttpException(404, 'The requested page does not exist.'); } $jackpot = $model->jackpot_investment; $instant = $model->instant_home; $currentImages = PropertyImagesApi::getAllImages($model->id); $localitymodel = GeoLocality::model()->find('id=:id', array(':id' => $model->locality_id)); $locality = $localitymodel->locality; if ($imageId && is_array($currentImages)) { $imageResult = false; if (array_key_exists($imageId, $currentImages)) { $imageResult = PropertyImagesApi::deleteImageByPk($imageId); } $this->renderPartial('_imageDeleted', array('result' => $imageResult)); Yii::app()->end(); } if ($model->user_id != Yii::app()->user->id) { throw new CHttpException(503, 'Unauthorized.'); } // Open session object $session = new CHttpSession(); $session->open(); $userId = Yii::app()->user->id; $model->country = 'india'; $modelCity = new GeoCity(); $propertyAmenities = new PropertyAmenities(); $propertyImages = new PropertyImages(); $amenities = PropertyAmenitiesApi::getAmenitiesIdForProperty($id); $localityNew = false; if ($model->latitude && $model->longitude) { $locationPosition = array($model->latitude, $model->longitude); } else { $locationPosition = array(20.59368, 78.96288); } $localityList = GeoLocalityApi::getAllNameList(); $this->performAjaxValidation($model); //$this->performAjaxValidation($profilesModel); if (isset($_POST['ajax']) && $_POST['ajax'] === 'property-form') { echo CActiveForm::validate($model); //echo CActiveForm::validate($profilesModel); Yii::app()->end(); } if (isset($_POST['submit'])) { $amenity_id = array(); $model->attributes = $_POST['Property']; $amenity_id = array(); if (isset($_POST['PropertyAmenitiesHouse']) && isset($_POST['PropertyAmenitiesExternal'])) { $amenity_id = array_merge($_POST['PropertyAmenitiesHouse'], $_POST['PropertyAmenitiesExternal']); } elseif (isset($_POST['PropertyAmenitiesHouse'])) { $amenity_id = $_POST['PropertyAmenitiesHouse']; } elseif (isset($_POST['PropertyAmenitiesExternal'])) { $amenity_id = $_POST['PropertyAmenitiesExternal']; } // var_dump($amenity_id);die(); $model->user_id = $userId; $valid = true; $data = $_POST['Property']; if (isset($model->city_id)) { $cityModel = GeoCity::model()->findByPk($model->city_id); if ($cityModel) { $model->state_id = $cityModel->state_id; $data['state_id'] = $cityModel->state_id; if (isset($model->locality)) { $criteria = new CDbCriteria(); $criteria->condition = 'city_id=:city_id && locality=:locality'; $criteria->params = array(':city_id' => $cityModel->id, ':locality' => $model->locality); $localityModel = GeoLocality::model()->find($criteria); $locality = $model->locality; if ($localityModel) { $model->locality_id = $localityModel->id; } else { $localityModel = new GeoLocality(); $localityModel->locality = $model->locality; $localityModel->city_id = $model->city_id; $localityModel->save(); $model->locality_id = $localityModel->id; $localityNew = $localityModel; } $data['locality_id'] = $localityModel->id; } } } $valid = $valid && $model->validate(); if ($model->latitude != '' && $model->longitude != '') { $locationPosition = array($model->latitude, $model->longitude); } if (!isset($data['property_type_id'])) { $data['property_type_id'] = $model->property_type_id; } if ($valid) { $data['property_name'] = PropertyTypesApi::getPropertyTypeById($data['property_type_id']); if ($data['jackpot_investment'] != $jackpot) { $data['jackpot_investment'] = 2; } if ($data['instant_home'] != $instant) { $data['instant_home'] = 2; } if (isset($model->video_url)) { $video = explode('&', $model->video_url); $videocode = explode('=', $video[0]); if (isset($videocode[1])) { $data['video_url'] = $videocode[1]; } } $property = PropertyApi::updatePropertyById($model->id, $data); if (!$property->hasErrors()) { if (count($amenity_id) > 0) { PropertyAmenitiesApi::deleteAllAmenitiesForProperty($property->id); $amenities = PropertyAmenitiesApi::addAmenitiesForProperty($property->id, $amenity_id); } $images = $session['PropertyImages']; if (is_array($images)) { foreach ($images as $count => $image) { $valid = $valid && PropertyImagesApi::addImage($property->id, $image) === true; } } if ($valid) { unset($session['PropertyImages']); Yii::app()->user->setFlash('success', 'Great! You have succesfully updated your property.'); $this->redirect('/property/' . $property->id); } else { if ($localityNew && !$localityNew->isNewRecord) { $localityNew->delete(); } unset($session['PropertyImages']); $propertyUpdateUrl = Yii::app()->createUrl('/property/update/' . $property->id . ''); Yii::app()->user->setFlash('error', 'Oops! We faced a problem and hence could not update your property.Please <a href=' . $propertyUpdateUrl . '>retry </a>'); } } } else { if ($localityNew && !$localityNew->isNewRecord) { $localityNew->delete(); } unset($session['PropertyImages']); // var_dump($model->getErrors()); Yii::app()->user->setFlash('error', 'There was an error while updating the property.'); } } $this->render('update', array('model' => $model, 'propertyAmenities' => $propertyAmenities, 'propertyImages' => $propertyImages, 'amenities' => $amenities, 'currentImages' => $currentImages, 'locationPosition' => $locationPosition, 'localityList' => $localityList, 'locality' => $locality)); Yii::endProfile('property_update'); }
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; } }
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; }
echo $form->labelEx($model, 'ownership_type_id'); ?> <?php echo $form->dropDownList($model, 'ownership_type_id', CHtml::listData(CategoryOwnershipTypes::model()->findAll(), 'id', 'ownership_type'), array('empty' => 'Select')); ?> <?php echo $form->error($model, 'ownership_type_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'locality_id'); ?> <?php echo $form->dropDownList($model, 'locality_id', CHtml::listData(GeoLocality::model()->findAll(), 'id', 'locality'), array('empty' => 'Select')); ?> <?php echo $form->error($model, 'locality_id'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'address'); ?> <?php echo $form->textArea($model, 'address', array('rows' => 6, 'cols' => 50)); ?> <?php echo $form->error($model, 'address');
public function actionPeople() { Yii::beginProfile('search_people'); $session = new CHttpSession(); $session->open(); //$session->destroy(); // Initiate the entities. $users = null; $data = null; $modelUser = new UserCredentials(); $modelProfile = new UserProfiles(); $modelSpecialistType = new UserSpecialistType(); $modelState = new GeoState(); $modelCity = new GeoCity(); $modelLocality = new GeoLocality(); if (isset($_POST['GeoCity'])) { $modelCity->attributes = $_POST['GeoCity']; } if (isset($_POST['user_type'])) { //$data = $_POST['UserProfiles']; $data['user_type'] = $_POST['user_type']; $data['property_type_id'] = isset($_POST['property_type_id']) ? $_POST['property_type_id'] : null; $data['state_id'] = isset($_POST['GeoState']['state']) ? $_POST['GeoState']['state'] : null; $data['city_id'] = isset($_POST['GeoCity']['city']) ? $_POST['GeoCity']['city'] : null; $data['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null; $data['specialist_type_id'] = isset($_POST['specialist_type_id']) ? $_POST['specialist_type_id'] : null; $data['locality_id'] = isset($_POST['GeoLocality']['locality']) ? $_POST['GeoLocality']['locality'] : ''; if ($data['specialist_type_id'][0] == '') { $data['specialist_type_id'] = null; } if ($data['locality_id'] != '') { $locality = GeoLocality::model()->find('locality=:locality', array(':locality' => $data['locality_id'])); if ($locality) { $data['locality_id'] = $locality->id; } } $totalResults = 0; if ($_POST['user_type'] == "agent") { $criteria = AgentProfileApi::getCriteriaObject($data); $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = AgentProfileApi::searchAgentWithCriteria($criteria); if (isset($_SERVER['HTTP_REFERER'])) { unset($session['search-criteria-user-type']); } $session['search-criteria-user-type'] = 'agent'; } if ($_POST['user_type'] == "builder") { $criteria = BuilderProfileApi::getCriteriaObject($data); $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = BuilderProfileApi::searchBuilderWithCriteria($criteria); if (isset($_SERVER['HTTP_REFERER'])) { unset($session['search-criteria-user-type']); } $session['search-criteria-user-type'] = 'builder'; } if ($_POST['user_type'] == "specialist") { $criteria = SpecialistProfileApi::getCriteriaObject($data); $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = SpecialistProfileApi::searchSpecialistsWithCriteria($criteria); if (isset($_SERVER['HTTP_REFERER'])) { unset($session['search-criteria-user-type']); } $session['search-criteria-user-type'] = 'specialist'; } $session['search-criteria-user'] = $criteria; $session['results-page'] = $totalResults; } else { if (isset($_SERVER['HTTP_REFERER'])) { unset($session['search-criteria-user-type']); unset($session['search-criteria-user']); } if (isset($session['search-criteria-user']) && isset($session['search-criteria-user-type'])) { $criteria = $session['search-criteria-user']; $userType = $session['search-criteria-user-type']; if ($userType == "agent") { $data['user_type'] = 'agent'; $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = AgentProfileApi::searchAgentWithCriteria($criteria); } elseif ($userType == "builder") { $data['user_type'] = 'builder'; $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = BuilderProfileApi::searchBuilderWithCriteria($criteria); } else { $data['user_type'] = 'specialist'; $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = SpecialistProfileApi::searchSpecialistsWithCriteria($criteria); } } else { $data['user_type'] = 'agent'; $criteria = AgentProfileApi::getCriteriaObject($data); $totalResults = UserCredentials::model()->count($criteria); $pages = new CPagination($totalResults); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $users = AgentProfileApi::searchAgentWithCriteria($criteria); } } $this->render('people', array('pages' => $pages, 'modelState' => $modelState, 'modelUser' => $modelUser, 'modelProfile' => $modelProfile, 'modelCity' => $modelCity, 'modelLocality' => $modelLocality, 'modelSpecialistType' => $modelSpecialistType, 'users' => $users, 'totalResults' => $totalResults, 'userType' => $data['user_type'])); Yii::endProfile('search_people'); }