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)); }
// Produce utf8 encoded json $this->headers[] = "Content-type: text/json; charset=utf-8"; $this->body = json_encode($rows); } } protected function do_put() { parent::do_put(); // TODO: Change the autogenerated stub parse_str(file_get_contents("php://input"), $_PUT); if (empty($_PUT["title"])) { $this->exit_error(400, "titleMandatoryAndNotEmpty"); } else { $title = $_PUT["title"]; $date = '02/07/2016 12:00:00'; // to set deadline - maybe change this but it works -_- $date = preg_replace('#(\\d{2})/(\\d{2})/(\\d{4})\\s(.*)#', '$3-$2-$1 $4', $date); ProjectModel::updateProject($title, "test1", $date, 2); echo $title; } } protected function do_post() { parent::do_post(); // TODO: Change the autogenerated stub $var = $_POST["title"]; echo $var; } } ProjectApi::run();
public function actionSearch() { Yii::beginProfile('search_project'); $projects = null; $data = null; $amenities = null; $projects = ProjectApi::searchProject($data); $modelProject = new Projects(); $modelCity = new GeoCity(); $projectAmenities = new ProjectAmenities(); if (isset($_POST['submit']) && isset($_POST['mode'])) { $modelProject->attributes = $_POST['Projects']; $amenities = isset($_POST['ProjectAmenities']['amenity_id']) ? $_POST['ProjectAmenities']['amenity_id'] : null; if ($amenities) { $amenity_data = null; foreach ($amenities as $i => $amenity) { if ($i != 0) { $amenity_data .= ','; } $amenity_data .= $amenity; } $amenities = $amenity_data; } $data = $_POST['Projects']; $data['keyword'] = $_POST['keyword']; $data['city'] = $_POST['GeoCity']['city']; $data['budget_min'] = $_POST['budget_min']; $data['budget_max'] = $_POST['budget_max']; $data['ProjectAmenities'] = isset($_POST['ProjectAmenities']['amenity_id']) ? $_POST['ProjectAmenities']['amenity_id'] : null; $data['posted_by_all'] = isset($_POST['posted_by_all']) ? $_POST['posted_by_all'] : 0; $data['posted_by'] = isset($_POST['posted_by']) ? $_POST['posted_by'] : null; $projects = ProjectApi::searchProject($data); } $this->render('search', array('modelProject' => $modelProject, 'modelCity' => $modelCity, 'projectAmenities' => $projectAmenities, 'projects' => $projects, 'amenities' => $amenities)); Yii::endProfile('search_project'); }
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'); }
public function actionSearch() { Yii::beginProfile('search_property_and_people'); // Initiate the entities. $properties = null; $users = null; $projects = null; $data = null; $data_user = null; $data_project = null; $data_user['user_type'] = 'agent'; $amenities = null; $pages = null; $pagesAgent = null; $pagesBuilder = null; $pagesSpecialists = null; $pagesProject = null; $criteria = PropertyApi::getCriteriaObject($data); $totalProp = Property::model()->count(); $pages = new CPagination($totalProp); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $properties = PropertyApi::searchPropertyWithCriteria($criteria); $propertiesCount = $totalProp; $totalUser = 0; $criteria = UserApi::getCriteriaObject($data_user); $users = UserApi::searchUser($data_user); if ($users) { $totalUser = count($users); } $pagesUser = new CPagination($totalUser); $pagesUser->pageSize = Yii::app()->params['resultsPerPage']; $pagesUser->applyLimit($criteria); $users = UserApi::searchUserWithCriteria($criteria); //$users = UserApi::searchUser($data_user); $projects = ProjectApi::searchProject($data_project); /* Property Model */ $modelProperty = new Property(); $modelState = new GeoState(); $modelCity = new GeoCity(); $propertyAmenities = new PropertyAmenities(); // echo '<pre>';var_dump($pages);die(); /* People Models */ $modelUser = new UserCredentials(); $modelProfile = new UserProfiles(); $modelSpecialistType = new UserSpecialistType(); /* Project Model */ $modelProject = new Projects(); $projectAmenities = new ProjectAmenities(); if (isset($_POST['search']) && isset($_POST['mode'])) { if ($_POST['mode'] == "property") { $modelProperty->attributes = $_POST['Property']; //$modelProperty['i_want_to'] = isset($_POST['Property']['i_want_to'])?$_POST['Property']['i_want_to'] : null; $data = $_POST['Property']; $data['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null; $data['city'] = $_POST['GeoCity']['city']; $data['budget_min'] = $_POST['budget_min']; $data['budget_max'] = $_POST['budget_max']; $data['without_budget'] = isset($_POST['without_budget']) ? $_POST['without_budget'] : 0; $data['PropertyAmenities'] = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null; $data['posted_by_all'] = isset($_POST['posted_by_all']) ? $_POST['posted_by_all'] : 0; $data['posted_by'] = isset($_POST['posted_by']) ? $_POST['posted_by'] : null; $criteria = PropertyApi::getCriteriaObject($data); $totalProp = Property::model()->count(); $pages = new CPagination($totalProp); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $properties = PropertyApi::searchPropertyWithCriteria($criteria); $propertiesCount = $totalProp; //$properties = PropertyApi::searchProperty($data); } elseif ($_POST['mode'] == "people") { $modelProfile->attributes = $_POST['UserProfiles']; $data_user = null; $data_user = $_POST['UserProfiles']; $data_user['user_type'] = $_POST['user_type']; $data_user['property_type_id'] = isset($_POST['property_type_id']) ? $_POST['property_type_id'] : null; $data_user['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null; $data_user['specialist_type_id'] = isset($_POST['specialist_type_id']) ? $_POST['specialist_type_id'] : null; //$users = UserApi::searchUser($data_user); if ($_POST['user_type'] == "agent") { $totalAgent = '0'; $criteria = AgentProfileApi::getCriteriaObject($data_user); $users = AgentProfileApi::searchAgents($data_user); if ($users) { $totalAgent = count($users); } $pagesAgent = new CPagination($totalAgent); $pagesAgent->pageSize = Yii::app()->params['resultsPerPage']; $pagesAgent->applyLimit($criteria); $users = AgentProfileApi::searchAgentWithCriteria($criteria); // $users = AgentProfileApi::searchAgents($data_user); } if ($_POST['user_type'] == "builder") { $totalBuilder = '0'; $criteria = BuilderProfileApi::getCriteriaObject($data_user); $users = BuilderProfileApi::searchBuilderWithCriteria($criteria); if ($users) { $totalBuilder = count($users); } $pagesBuilder = new CPagination($totalBuilder); $pagesBuilder->pageSize = Yii::app()->params['resultsPerPage']; $pagesBuilder->applyLimit($criteria); $users = BuilderProfileApi::searchBuilderWithCriteria($criteria); } if ($_POST['user_type'] == "specialist") { $totalSpecialists = '0'; $criteria = SpecialistProfileApi::getCriteriaObject($data_user); $users = SpecialistProfileApi::searchSpecialistsWithCriteria($criteria); if ($users) { $totalSpecialists = count($users); } $pagesSpecialists = new CPagination($totalSpecialists); $pagesSpecialists->pageSize = Yii::app()->params['resultsPerPage']; $pagesSpecialists->applyLimit($criteria); $users = SpecialistProfileApi::searchSpecialistsWithCriteria($criteria); } } elseif ($_POST['mode'] == "project") { $modelProject->attributes = $_POST['Projects']; $amenities = isset($_POST['ProjectAmenities']['amenity_id']) ? $_POST['ProjectAmenities']['amenity_id'] : null; if ($amenities) { $amenity_data = null; foreach ($amenities as $i => $amenity) { if ($i != 0) { $amenity_data .= ','; } $amenity_data .= $amenity; } $amenities = $amenity_data; } $data = $_POST['Projects']; $data['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null; $data['city'] = $_POST['GeoCity']['city']; $data['budget_min'] = $_POST['budget_min']; $data['budget_max'] = $_POST['budget_max']; $data['ProjectAmenities'] = isset($_POST['ProjectAmenities']['amenity_id']) ? $_POST['ProjectAmenities']['amenity_id'] : null; $data['posted_by_all'] = isset($_POST['posted_by_all']) ? $_POST['posted_by_all'] : 0; $data['posted_by'] = isset($_POST['posted_by']) ? $_POST['posted_by'] : null; $totalProject = '0'; $criteria = ProjectApi::getCriteriaObject($data); $users = ProjectApi::searchProjectWithCriteria($criteria); if ($users) { $totalProject = count($users); } $pagesProject = new CPagination($totalProject); $pagesProject->pageSize = Yii::app()->params['resultsPerPage']; $pagesProject->applyLimit($criteria); $projects = ProjectApi::searchProjectWithCriteria($criteria); } } // echo '<br><pre>';var_dump($pages);die(); $this->render('search', array('pages' => $pages, 'modelState' => $modelState, 'modelProperty' => $modelProperty, 'modelCity' => $modelCity, 'propertyAmenities' => $propertyAmenities, 'modelUser' => $modelUser, 'modelProfile' => $modelProfile, 'modelSpecialistType' => $modelSpecialistType, 'properties' => $properties, 'amenities' => $amenities, 'users' => $users, 'modelProject' => $modelProject, 'projectAmenities' => $projectAmenities, 'projects' => $projects, 'pagesAgent' => $pagesAgent, 'pagesUser' => $pagesUser, 'pagesBuilder' => $pagesBuilder, 'pagesSpecialists' => $pagesSpecialists, 'pagesProject' => $pagesProject, 'propertiesCount' => $propertiesCount)); $this->render('search', array('pages' => $pages, 'modelProperty' => $modelProperty, 'modelCity' => $modelCity, 'propertyAmenities' => $propertyAmenities, 'modelUser' => $modelUser, 'modelProfile' => $modelProfile, 'modelSpecialistType' => $modelSpecialistType, 'properties' => $properties, 'amenities' => $amenities, 'users' => $users, 'modelProject' => $modelProject, 'projectAmenities' => $projectAmenities, 'projects' => $projects, 'pagesAgent' => $pagesAgent, 'pagesUser' => $pagesUser, 'pagesBuilder' => $pagesBuilder, 'pagesSpecialists' => $pagesSpecialists, 'pagesProject' => $pagesProject, 'propertiesCount' => $propertiesCount)); $this->render('search', array('pages' => $pages, 'modelProperty' => $modelProperty, 'modelCity' => $modelCity, 'propertyAmenities' => $propertyAmenities, 'modelUser' => $modelUser, 'modelProfile' => $modelProfile, 'modelSpecialistType' => $modelSpecialistType, 'properties' => $properties, 'amenities' => $amenities, 'users' => $users, 'modelProject' => $modelProject, 'projectAmenities' => $projectAmenities, 'projects' => $projects, 'pagesAgent' => $pagesAgent, 'pagesUser' => $pagesUser, 'pagesBuilder' => $pagesBuilder, 'pagesSpecialists' => $pagesSpecialists, 'pagesProject' => $pagesProject, 'propertiesCount' => $propertiesCount)); Yii::endProfile('search_property_and_people'); }
public function actionProject() { Yii::beginProfile('search_project'); $session = new CHttpSession(); $session->open(); //$session->destroy(); // Initiate the entities. $projects = null; $data = null; $modelProject = new Projects(); $modelState = new GeoState(); $modelCity = new GeoCity(); $projectAmenities = new ProjectAmenities(); $data['new_launches'] = isset($_POST['new_launches']) ? $_POST['new_launches'] : ''; if (isset($_POST['Projects'])) { $modelProject->attributes = $_POST['Projects']; $projectAmenities = isset($_POST['ProjectAmenities']['amenity_id']) ? $_POST['ProjectAmenities']['amenity_id'] : null; if ($projectAmenities) { $amenity_data = null; foreach ($projectAmenities as $i => $amenity) { if ($i != 0) { $amenity_data .= ','; } $amenity_data .= $amenity; } $projectAmenities = $amenity_data; } $data = $_POST['Projects']; $data['keyword'] = isset($_POST['keyword']) ? $_POST['keyword'] : null; $data['new_launches'] = isset($_POST['new_launches']) ? $_POST['new_launches'] : ''; $data['city_id'] = isset($_POST['GeoCity']['city']) ? $_POST['GeoCity']['city'] : ''; $data['state_id'] = isset($_POST['GeoState']['state']) ? $_POST['GeoState']['state'] : ''; $data['locality_id'] = isset($_POST['GeoLocality']['locality']) ? $_POST['GeoLocality']['locality'] : ''; if ($data['locality_id'] != '') { $locality = GeoLocality::model()->find('locality=:locality', array(':locality' => $data['locality_id'])); if ($locality) { $data['locality_id'] = $locality->id; } } $data['budget_min'] = $_POST['budget_min']; $data['budget_max'] = $_POST['budget_max']; $data['without_budget'] = isset($_POST['without_budget']) ? $_POST['without_budget'] : 0; $data['ProjectAmenities'] = isset($_POST['amenity_id']) ? $_POST['amenity_id'] : null; $data['posted_by_all'] = isset($_POST['posted_by_all']) ? $_POST['posted_by_all'] : 0; $data['posted_by'] = isset($_POST['posted_by']) ? $_POST['posted_by'] : null; $criteria = ProjectApi::getCriteriaObject($data); $total = Projects::model()->count($criteria); $pages = new CPagination($total); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $projects = ProjectApi::searchProjectWithCriteria($criteria); $projectsCount = $total; if (isset($_SERVER['HTTP_REFERER'])) { unset($session['search-criteria-project']); unset($session['results-page']); } $session['search-criteria-project'] = $criteria; $session['results-page'] = $total; } else { if (isset($_SERVER['HTTP_REFERER'])) { unset($session['search-criteria-project']); unset($session['results-page']); } if (isset($session['search-criteria-project'])) { $criteria = $session['search-criteria-project']; } else { $criteria = new CDbCriteria(); } //$criteria = PropertyApi::getCriteriaObject($data); $totalProj = Projects::model()->count($criteria); $pages = new CPagination($totalProj); $pages->pageSize = Yii::app()->params['resultsPerPage']; $pages->applyLimit($criteria); $projects = ProjectApi::searchProjectWithCriteria($criteria); $projectsCount = $totalProj; // } } $this->render('project', array('pages' => $pages, 'modelState' => $modelState, 'modelProject' => $modelProject, 'modelCity' => $modelCity, 'modelLocality' => $modelLocality, 'projectAmenities' => $projectAmenities, 'projects' => $projects, 'projectsCount' => $projectsCount)); Yii::endProfile('search_project'); }