Exemplo n.º 1
0
 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionHome()
 {
     Yii::beginProfile('home');
     $session = new CHttpSession();
     $session->open();
     $location = null;
     $properties = new Property();
     $modelCity = new GeoCity();
     $modelState = new GeoState();
     $localityList = GeoLocalityApi::getAllNameList();
     if ($session['top-country'] && $session['top-location']) {
         $location['country'] = $session['top-country'];
         $location['city'] = $session['top-location'];
     }
     $this->render('home', array('properties' => $properties, 'modelCity' => $modelCity, 'modelState' => $modelState, 'localityList' => $localityList, 'location' => $location));
     Yii::endProfile('home');
 }
Exemplo n.º 2
0
<label>City </label><?php 
echo $form->dropdownList($modelCity, 'city', $cityList, array('empty' => 'Select', 'id' => 'geo_city_rent', 'class' => 'selectbox1'));
?>
 </td>
	</tr>
	<tr>
		<td width="210px" align="right">
		 <label>Property type</label> 
			<?php 
echo $form->dropDownList($properties, 'property_type_id', $propertyType, array('class' => 'selectbox1', 'empty' => 'All'));
?>
		
		 </td>
		 <td width="200px" align="right"><label>Locality</label>
		 <?php 
$this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'Property[locality]', 'source' => array_values(GeoLocalityApi::getAllNameList()), 'htmlOptions' => array('class' => 'mytxtbox')));
?>
		 </td>
		 </tr>
		 
		 <tr>
		 	<td width="210px" align="right"><label>Keywords</label> <input id="keyword_search" type="text" name="keyword" class="mytxtbox" onFocus="javascript:ClearText(this);" onBlur="javascript:ClearText(this);" value="Eg: Builder"></td>
		 
		<td width="200px" align="right">
<label style="width:50px;float:left;">Budget</label>
		<span id="budget_change_rent" style="display:none;padding:0px;">
		<select name="budget_min_rent" class="selectbox2" id="buy_budget_min_rent" valtype="budget_min" onchange="javascript:validateMin('buy_budget_min_rent','buy_budget_max_rent');">
			<option value="">Min</option>
			<option value="1" class="">Below 5000</option>
			<option value="5000" class="">5000</option>
			<option value="10000" class="">10000</option>
Exemplo n.º 3
0
 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');
 }
Exemplo n.º 4
0
 public function run()
 {
     $localityList = GeoLocalityApi::getAllNameList(true);
     $this->render('propertyCriteria', array('modelProperty' => $this->modelProperty, 'modelState' => $this->modelState, 'modelCity' => $this->modelCity, 'modelLocality' => $this->modelLocality, 'propertyAmenities' => $this->propertyAmenities, 'localityList' => $localityList, 'amenities' => $this->amenities));
 }
Exemplo n.º 5
0
 public function run()
 {
     $localityList = GeoLocalityApi::getAllNameList(true);
     $this->render('peopleCriteria', array('modelProperty' => $this->modelProperty, 'modelUser' => $this->modelUser, 'modelProfile' => $this->modelProfile, 'modelSpecialistType' => $this->modelSpecialistType, 'modelCity' => $this->modelCity, 'modelState' => $this->modelState, 'modelLocality' => $this->modelLocality, 'localityList' => $localityList));
 }