Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 public function actionView($userId)
 {
     Yii::beginProfile('builder_view');
     $builderRatingReadOnly = false;
     $session = Yii::app()->session;
     $builder = BuilderProfileApi::getBuilderDetails($userId);
     if (!$builder) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     $builderInfo = UserApi::getUserProfileDetails($builder->user_id);
     $builderAddress = DbUtils::getAddress($builder->city_id);
     $builderProjectTypeIds = ProjectApi::getProjectTypesByUserId($builder->user_id);
     $builderProjectTypes = "";
     if ($builderProjectTypeIds) {
         foreach ($builderProjectTypeIds as $builderProjectTypeId) {
             $builderProjectTypes[$builderProjectTypeId->project_type_id] = ProjectTypesApi::getProjectTypeById($builderProjectTypeId->project_type_id);
         }
     }
     $builderProjects = ProjectApi::getProjectsOfUser($builder->user_id, Yii::app()->params['dashboardResultsPerPage']);
     $builderLocations = UserBuilderLocationsApi::getLocations($builder->id);
     $builderProjectLocations = "";
     if ($builderLocations) {
         foreach ($builderLocations as $builderLocation) {
             $builderProjectLocations[] = DbUtils::getAddress($builderLocation->city_id);
         }
     }
     $builderRatingReadOnly = BuilderRatingApi::isRated($builder->id, Yii::app()->user->id);
     $builderRating = BuilderRatingApi::getRating($builder->id);
     if (!$builderRatingReadOnly) {
         if ($builder->user_id == Yii::app()->user->id) {
             $builderRatingReadOnly = true;
         } else {
             $builderRatingReadOnly = false;
         }
     } else {
         $builderRatingReadOnly = true;
     }
     $this->render('view', array('builder' => $builder, 'builderInfo' => $builderInfo, 'builderAddress' => $builderAddress, 'builderProjectTypes' => $builderProjectTypes, 'builderProjectLocations' => $builderProjectLocations, 'builderProjects' => $builderProjects, 'builderRatingReadOnly' => $builderRatingReadOnly, 'builderRating' => $builderRating));
     Yii::endProfile('builder_view');
 }