Exemplo n.º 1
0
 public function actionView($id)
 {
     Yii::beginProfile('property_view');
     $session = Yii::app()->session;
     $property = PropertyApi::getPropertyById($id);
     if (!$property) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     if (!$property->furnished) {
         $property->furnished = '-';
     }
     if (!$property->floor_number) {
         $property->floor_number = '-';
     }
     if (!$property->total_floors) {
         $property->total_floors = '-';
     }
     if (!$property->facing) {
         $property->facing = '-';
     }
     $recentlyViewed = UserApi::getUserProfileDetails($property->recently_viewed);
     $propertyAgentInfo = AgentProfileApi::getAgentDetails($property->user_id);
     $propertyUser = "";
     $propertyAgent = "";
     $propertyBuilder = "";
     $propertyBuilderInfo = "";
     $propertySpecialist = "";
     $propertySpecialistInfo = "";
     $propertyRating = "";
     $propertyRating = PropertyRatingApi::getRating($id);
     if ($propertyAgentInfo) {
         $propertyAgent = UserApi::getUserProfileDetails($propertyAgentInfo->user_id);
     } else {
         $propertyBuilderInfo = BuilderProfileApi::getBuilderDetails($property->user_id);
         if ($propertyBuilderInfo) {
             $propertyBuilder = UserApi::getUserProfileDetails($propertyBuilderInfo->user_id);
         } else {
             $propertySpecialistInfo = SpecialistProfileApi::getSpecialistDetails($property->user_id);
             if ($propertySpecialistInfo) {
                 $propertySpecialist = UserApi::getUserProfileDetails($propertySpecialistInfo->user_id);
             } else {
                 $propertyUser = UserApi::getUser($property->user_id);
             }
         }
     }
     $propertySimilar = PropertyApi::getSimilarProperties($property, 3, $id);
     $propertySimilarAddress = "";
     $propertySimilarUser = "";
     if ($propertySimilar) {
         foreach ($propertySimilar as $similar) {
             $propertySimilarAddress[$similar->id] = PropertyApi::getLocation($similar->id);
             $propertySimilarUser[$similar->id] = UserApi::getUserProfileDetails($similar->user_id);
         }
     }
     $recentlyViewedIds[] = '';
     $recentlyViewedIds_total = $session['properties'];
     if ($recentlyViewedIds_total) {
         $re_array = array_reverse($recentlyViewedIds_total);
         $i = 0;
         foreach ($re_array as $re) {
             $recentlyViewedIds = $re;
             $i++;
             if ($i > 2) {
                 break;
             }
         }
     }
     $property_ids[] = $recentlyViewedIds;
     $property_ids[] = $id;
     $session['properties'] = array_unique($property_ids);
     $propertyRecentlyViewed = "";
     $propertyRecentlyViewedAddress = "";
     $propertyRecentlyViewedUser = "";
     if ($recentlyViewedIds) {
         foreach ($recentlyViewedIds as $recent) {
             $modelProperty = PropertyApi::getPropertyById($recent);
             if ($modelProperty) {
                 $propertyRecentlyViewed[] = $modelProperty;
                 $propertyRecentlyViewedAddress[] = PropertyApi::getLocation($recent);
                 $propertyRecentlyViewedUser[] = UserApi::getUserProfileDetails($modelProperty->user_id);
             }
         }
     }
     $propertyImages = PropertyImagesApi::getAllImages($property->id);
     $propertyType = PropertyTypesApi::getPropertyTypeById($property->property_type_id);
     $transactionType = PropertyTransactionTypesApi::getTransactionTypeById($property->transaction_type_id);
     $ownershipType = OwnershipTypesApi::getOwnershipTypeById($property->ownership_type_id);
     $propertyAge = PropertyAgeOfConstructionApi::getpropertyAgeById($property->age_of_construction);
     $propertyAmenities = PropertyAmenitiesApi::getAmenitiesForProperty($property->id);
     $propertyAddress = PropertyApi::getLocation($property->id);
     $propertyRating = PropertyRatingApi::getRating($property->id);
     $propertyWishlist = PropertyWishlistApi::getWishlistUserOnProperty($property->id, Yii::app()->user->id);
     $this->render('view', array('property' => $property, 'recentlyViewed' => $recentlyViewed, 'propertyAgentInfo' => $propertyAgentInfo, 'propertyBuilderInfo' => $propertyBuilderInfo, 'propertySpecialistInfo' => $propertySpecialistInfo, 'propertyUser' => $propertyUser, 'propertyAgent' => $propertyAgent, 'propertyBuilder' => $propertyBuilder, 'propertySpecialist' => $propertySpecialist, 'propertySimilar' => $propertySimilar, 'propertySimilarAddress' => $propertySimilarAddress, 'propertySimilarUser' => $propertySimilarUser, 'propertyRecentlyViewed' => $propertyRecentlyViewed, 'propertyRecentlyViewedAddress' => $propertyRecentlyViewedAddress, 'propertyRecentlyViewedUser' => $propertyRecentlyViewedUser, 'propertyImages' => $propertyImages, 'propertyType' => $propertyType, 'propertyAddress' => $propertyAddress, 'transactionType' => $transactionType, 'ownershipType' => $ownershipType, 'propertyAge' => $propertyAge, 'propertyAmenities' => $propertyAmenities, 'propertyRating' => $propertyRating, 'propertyWishlist' => $propertyWishlist));
     Yii::endProfile('property_view');
 }
Exemplo n.º 2
0
<?php

$this->breadcrumbs = array('Properties' => array('index'), 'View');
$this->menu = array(array('label' => 'List Property', 'url' => array('index')), array('label' => 'Create Property', 'url' => array('create')), array('label' => 'Update Property', 'url' => array('update', 'id' => $model->id)), array('label' => 'Delete Property', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => 'Manage Property', 'url' => array('admin')));
if ($model->projectProperties) {
    $this->menu[] = array('label' => 'Back to Project', 'url' => Yii::app()->request->urlReferrer);
}
?>

<h1>View Property</h1> 

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('label' => 'User Name', 'type' => 'raw', 'value' => CHtml::link(CHtml::encode(UserApi::getNameByUserId($model->user_id)), array('/store/user/view', 'id' => $model->user_id))), 'i_want_to', 'property_name', 'description', 'features', 'featured', 'jackpot_investment', 'instant_home', 'propertyType.property_type', 'transactionType.transaction_type', 'locality.locality', 'address', 'bathrooms', 'bedrooms', 'furnished', 'age_of_construction', 'ownershipType.ownership_type', 'covered_area', 'land_area', 'total_price', 'per_unit_price', 'area_type', 'display_price', 'price_negotiable', 'available_from', 'available_units', 'facing', 'floor_number', 'total_floors', 'landmarks', 'tax_fees', 'terms_and_conditions')));
$images = PropertyImagesApi::getAllImages($model->id);
$propertyAmenities = $model->propertyAmenities;
$amenities = null;
foreach ($propertyAmenities as $i => $propertyAmenity) {
    if ($i != 0) {
        $amenities .= ", ";
    }
    $amenities .= $propertyAmenity->amenity->amenity;
}
?>
<table id="yw0" class="detail-view">
	<tbody>
		<tr class="even">
			<th>Average Rating</th>
			<td><?php 
echo PropertyRatingApi::getRating($model->id);
?>
</td>