public function actionIndex()
 {
     $userId = Yii::app()->user->id;
     $projectImages = '';
     $propertyImages = '';
     $projectCount = '';
     $propertyCount = '';
     $propertyTypes = '';
     $propertyLocations = '';
     $propertyid = '';
     $projectLocations = '';
     $projectOwnerships = '';
     $projectTypes = '';
     $users = '';
     $userIds[] = '';
     $myJukeBox = '';
     $jukeBoxcategoryName = '';
     $jukecount = '0';
     $propertyWishList = '';
     $propertyName = '';
     $projectWishlist = '';
     $projectName = '';
     $propertywishlistcount = 0;
     $inbox = PmbApi::getInbox($userId);
     $userName = UserApi::getUserProfileDetails($userId);
     if ($inbox) {
         foreach ($inbox as $messages) {
             $userIds[] = $messages->from_user_id;
         }
         $users = DbUtils::getDbValues(new UserProfiles(), 'user_id', $userIds, 'first_name');
     }
     $properties = PropertyApi::getPropertiesOfUser($userId, Yii::app()->params['dashboardResultsPerPage']);
     $countUnread = PmbApi::getUnreadInboxCount($userId);
     $propertyCount = PropertyApi::getAllPropertiesCount($userId);
     $locations = '';
     if ($properties) {
         foreach ($properties as $location) {
             $locations[] = $location->city_id;
         }
         $propertyLocations = DbUtils::getDbValues(new GeoCity(), 'id', $locations, 'city');
     }
     if ($properties) {
         foreach ($properties as $property) {
             $propertyTypes[] = $property->property_type_id;
             $propertyid[] = $property->id;
         }
         $propertyImages = PropertyImagesApi::getPrimaryImageForProperties($propertyid);
         $propertyTypes = DbUtils::getDbValues(new PropertyTypes(), 'id', $propertyTypes, 'property_type');
     }
     $projects = ProjectApi::getProjectsOfUser($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($projects) {
         foreach ($projects as $project) {
             $projectLocationIds[] = $project->city_id;
             $projectTypeIds[] = $project->project_type_id;
             $projectOwnershipIds[] = $project->ownership_type_id;
             $projectIds[] = $project->id;
         }
         $projectImages = ProjectImagesApi::getPrimaryImageForProjects($projectIds);
         $projectLocations = DbUtils::getDbValues(new GeoCity(), 'id', $projectLocationIds, 'city');
         $projectTypes = DbUtils::getDbValues(new ProjectTypes(), 'id', $projectTypeIds, 'project_type');
         $projectOwnerships = DbUtils::getDbValues(new CategoryOwnershipTypes(), 'id', $projectOwnershipIds, 'ownership_type');
     }
     $projectCount = ProjectApi::getProjectsofUserCount($userId);
     $isProfile['agent'] = AgentProfileApi::isAgent($userId);
     $isProfile['builder'] = BuilderProfileApi::isBuilder($userId);
     $isProfile['specialist'] = SpecialistProfileApi::isSpecialist($userId);
     //MyJuckbox
     $myJukeBox = JukeboxQuestionsApi::getAllJukeboxQuestionsOfUser($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($myJukeBox) {
         foreach ($myJukeBox as $jukeBox) {
             $categoryIdArray[] = $jukeBox->category_id;
         }
         $jukeBoxcategoryName = DbUtils::getDbValues(new JukeboxCategory(), 'id', $categoryIdArray, 'category');
         $jukecount = count($myJukeBox);
     }
     //my wishlists
     $propertyWishList = PropertyWishlistApi::getWishlist($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($propertyWishList) {
         foreach ($propertyWishList as $propertyWish) {
             $propertyWishlistArray[] = $propertyWish->property_id;
         }
         $propertyName = DbUtils::getDbValues(new Property(), 'id', $propertyWishlistArray, 'property_name');
     }
     $propertywishlistcount = PropertyWishlistApi::getWishlistCount($userId);
     $totalWishlistCount = $propertywishlistcount;
     //+$projectwishlistcount;
     //requirements
     $requirements = RequirementApi::getRequirementByUserId($userId, Yii::app()->params['dashboardResultsPerPage']);
     if ($requirements) {
         $requirementscount = count($requirements);
     } else {
         $requirementscount = 0;
     }
     $this->render('index', array('inbox' => $inbox, 'users' => $users, 'properties' => $properties, 'countUnread' => $countUnread, 'propertyLocations' => $propertyLocations, 'propertyTypes' => $propertyTypes, 'projects' => $projects, 'projectLocations' => $projectLocations, 'projectTypes' => $projectTypes, 'projectOwnerships' => $projectOwnerships, 'propertyCount' => $propertyCount, 'projectCount' => $projectCount, 'propertyid' => $propertyid, 'propertyImages' => $propertyImages, 'projectImages' => $projectImages, 'isProfile' => $isProfile, 'myJukeBox' => $myJukeBox, 'jukeBoxcategoryName' => $jukeBoxcategoryName, 'jukecount' => $jukecount, 'propertyWishList' => $propertyWishList, 'propertyName' => $propertyName, 'projectName' => $projectName, 'totalWishlistCount' => $totalWishlistCount, 'requirements' => $requirements, 'requirementscount' => $requirementscount, 'userName' => $userName));
 }
Exemple #2
0
 public function actionView($userId)
 {
     Yii::beginProfile('agent_view');
     $agentRatingReadOnly = false;
     $session = Yii::app()->session;
     $agent = AgentProfileApi::getAgentDetails($userId);
     if (!$agent) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $agentInfo = UserApi::getUserProfileDetails($agent->user_id);
     $agentAddress = DbUtils::getAddress($agent->city_id);
     $agentPropertyTypeIds = PropertyApi::getPropertyTypesByUserId($agent->user_id);
     $agentPropertyTypes = "";
     if ($agentPropertyTypeIds) {
         foreach ($agentPropertyTypeIds as $agentPropertyTypeId) {
             $agentPropertyTypes[$agentPropertyTypeId->property_type_id] = PropertyTypesApi::getPropertyTypeById($agentPropertyTypeId->property_type_id);
         }
     }
     $agentProperties = PropertyApi::getPropertiesOfUser($agent->user_id, Yii::app()->params['dashboardResultsPerPage']);
     $agentLocations = UserAgentLocationsApi::getLocations($agent->id);
     $agentPropertyLocations = "";
     if ($agentLocations) {
         foreach ($agentLocations as $agentLocation) {
             $agentPropertyLocations[] = DbUtils::getAddress($agentLocation->city_id);
         }
     }
     $agentRatingReadOnly = AgentRatingApi::isRated($agent->id, Yii::app()->user->id);
     $agentRating = AgentRatingApi::getRating($agent->id);
     if (!$agentRatingReadOnly) {
         if ($agent->user_id == Yii::app()->user->id) {
             $agentRatingReadOnly = true;
         } else {
             $agentRatingReadOnly = false;
         }
     } else {
         $agentRatingReadOnly = true;
     }
     $this->render('view', array('agent' => $agent, 'agentInfo' => $agentInfo, 'agentAddress' => $agentAddress, 'agentPropertyTypes' => $agentPropertyTypes, 'agentPropertyLocations' => $agentPropertyLocations, 'agentProperties' => $agentProperties, 'agentRatingReadOnly' => $agentRatingReadOnly, 'agentRating' => $agentRating));
     Yii::endProfile('agent_view');
 }