public function actionMore() { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/enjoy.css'); $city_id = Yii::app()->request->getQuery('city', 0); $time_sort = Yii::app()->request->getQuery('time_sort', 'DESC'); $price_sort = Yii::app()->request->getQuery('lp_dol'); $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; if (!empty($city_id)) { $criteria->addCondition('city_id=' . $city_id); } if (!empty($time_sort)) { $criteria->order = 'accessDate ' . $time_sort; } if (!empty($price_sort)) { $criteria->order = 'lp_dol ' . $price_sort; } $criteria->addCondition('lp_dol>3000000'); $count = House::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 10; $pager->applyLimit($criteria); $house_list = House::model()->findAll($criteria); $subject_list = Subject::model()->findAll(array('order' => 'id DESC')); $cur_city = City::model()->findByPk($city_id); $data = array('house_list' => $house_list, 'subject_list' => $subject_list, 'cur_city' => $cur_city, 'count' => $count, 'time_sort' => $time_sort, 'price_sort' => $price_sort, 'pages' => $pager); $this->render('more', $data); }
public function actionHouseNews() { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/post.css'); $catalog_id = Yii::app()->request->getQuery('catalog_id', 11); $special_news = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => $catalog_id), 'order' => 'id DESC', 'limit' => 1)); $special_id = $special_news[0]->id; $criteria = new CDbCriteria(); $criteria->order = 'id DESC'; if (!empty($catalog_id)) { $criteria->addCondition('catalog_id=' . $catalog_id); } $criteria->addCondition('id!=' . $special_id); $count = Post::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 30; $pager->applyLimit($criteria); $more_news = Post::model()->findAll($criteria); //房展会 $exhibition = Post::model()->findAll(array('select' => 'id, title, image', 'condition' => 'catalog_id=:catalog_id AND image<>""', 'params' => array(':catalog_id' => 10), 'order' => 'id DESC', 'limit' => 5)); //房展会 //学区房新闻 $school_distrcit_house_news = Post::model()->findAll(array('select' => 'id, title', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 11), 'order' => 'id DESC', 'limit' => 5)); //房产热点新闻 $house_hotspots = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 12), 'order' => 'id DESC', 'limit' => 5)); //房产资讯 $house_zixun = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 10), 'order' => 'id DESC', 'limit' => 5)); $house_property_special_news = Post::model()->findAll(array('select' => 'id, title, summary', 'condition' => 'catalog_id = :catalog_id', 'params' => array(':catalog_id' => 13), 'order' => 'id DESC', 'limit' => 1)); $house_property_special_id = $house_property_special_news[0]->id; //房产置业宝典 $house_property = Post::model()->findAll(array('select' => 'id, title, create_time,last_update_time', 'condition' => 'catalog_id = :catalog_id AND id != :id', 'params' => array(':catalog_id' => 13, ':id' => $house_property_special_id), 'order' => 'id DESC', 'limit' => 5)); //最新学区房 $school_distrcit_house = House::model()->findAll(array('select' => 'id, name, house_image', 'condition' => 'investType_id = :investType_id', 'params' => array(':investType_id' => 1), 'order' => 'id DESC', 'limit' => 3)); $data = array('catalog_id' => $catalog_id, 'special_news' => $special_news[0], 'more_news' => $more_news, 'exhibition' => $exhibition, 'school_distrcit_house_news' => $school_distrcit_house_news, 'house_hotspots' => $house_hotspots, 'house_zixun' => $house_zixun, 'house_property_special_news' => $house_property_special_news[0], 'house_property' => $house_property, 'school_distrcit_house' => $school_distrcit_house, 'pages' => $pager); $this->render('house_news', $data); }
public function actionGetMapHouse() { ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); $result = array(); if (empty($_POST)) { $result['IsError'] = true; $result['Message'] = '数据接收失败'; } else { $result['IsError'] = false; //根据条件查询地图 $criteria = new CDbCriteria(); $criteria->select = 'id,ml_num,zip,county,municipality,lp_dol,num_kit,construction_year,depth,front_ft,br,addr,house_image,longitude,latitude,area,bath_tot'; //Search By Lease or Sale if ($_POST['type'] == "rent") { $criteria->addCondition('s_r = "Lease"'); $ss = " AND s_r = 'Lease' "; } else { $criteria->addCondition('s_r = "Sale"'); $ss = " AND s_r = 'Sale' "; } /* 排序 * <span data-value="1">价格:从高到低</span> <span data-value="2">价格:从低到高</span> <span data-value="3">日期:从后到前</span> <span data-value="4">日期:从前到后</span> */ if ($_POST['orderby'] == 1) { $criteria->order = 't.lp_dol desc'; } else { if ($_POST['orderby'] == 2) { $criteria->order = 't.lp_dol asc'; } else { if ($_POST['orderby'] == 3) { $criteria->order = 't.construction_year asc'; } else { if ($_POST['orderby'] == 4) { $criteria->order = 't.construction_year desc'; } else { $criteria->order = 't.id desc'; } } } } //city_id - province //if (!empty($_POST['province']) && trim($_POST['country']) != 'undefined') { // // $criteria->addCondition("t.city_id = :city_id"); // $criteria->params += array(':city_id' => intval($_POST['province'])); //} //district_id // if (!empty($_POST['district']) && trim($_POST['district']) != 'undefined') { // $criteria->addCondition("t.district_id = :district_id"); // $criteria->params += array(':district_id' => intval($_POST['district'])); // } //卫生间数量 1-5 if (!empty($_POST['housebaths']) && intval($_POST['housebaths']) > 0) { $criteria->addCondition("t.bath_tot = :bath_tot"); $criteria->params += array(':bath_tot' => intval($_POST['housebaths'])); $ss = $ss . " AND bath_tot = " . $_POST['housebaths']; } //土地面积 if (!empty($_POST['houseground'])) { $ground = explode(',', $_POST['houseground']); $minGround = intval($ground[0]); $maxGround = intval($ground[1]); if ($minGround != 0 || $maxGround != 0) { if ($maxGround > $minGround) { $criteria->addCondition("t.depth*t.front_ft <= :maxGround"); $criteria->params += array(':maxGround' => $maxGround); } $criteria->addCondition("t.depth*t.front_ft >= :minGround"); $criteria->params += array(':minGround' => $minGround); } } //价格区间 if (!empty($_POST['houseprice'])) { $price = explode(',', $_POST['houseprice']); $minPrice = intval($price[0]) * 10000; $maxPrice = intval($price[1]) * 10000; if ($maxPrice != 0 || $minPrice != 0) { if ($maxPrice > $minPrice) { $criteria->addCondition("t.lp_dol <= :maxPrice"); $criteria->params += array(':maxPrice' => $maxPrice); $ss = $ss . " AND lp_dol <= " . $maxPrice; } $criteria->addCondition("t.lp_dol >= :minPrice"); $criteria->params += array(':minPrice' => $minPrice); $ss = $ss . " AND lp_dol >= " . $minPrice; } } //房型 if (!empty($_POST['houseroom']) && intval($_POST['houseroom']) > 0) { $houseroom = intval($_POST['houseroom']); if ($houseroom == '6') { $criteria->addCondition("t.br >= :br"); } else { if ($houseroom > 0) { $criteria->addCondition("t.br = :br"); } } $criteria->params += array(':br' => $houseroom); } //房屋类型 if (!empty($_POST['housetype']) && intval($_POST['housetype']) != 0) { $criteria->addSearchCondition('propertyType_id', $_POST['housetype']); $ss = $ss . " AND propertyType_id = " . $_POST['housetype']; } //根据地区名字搜索 //if (!empty($_POST['city']) && trim($_POST['city']) != '州名/市名(中英)') { // $city = trim($_POST['city']); // $criteria->addCondition("t.addr like '%" . $city . "%' OR b.pinyin like '%" . $city . "%' OR b.englishName like '%" . $city . "%'"); //} // //建造年份 if (!empty($_POST['houseyear'])) { //$year = explode(',', $_POST['houseyear']); $year = $_POST['houseyear']; //$minYear = intval($year[0]); // $maxYear = intval($year[1]); $criteria->addCondition("t.yr_built = :year"); $criteria->params += array(':year' => $year); } //lat and long selection if (!empty($_POST['bounds'])) { $latlon = explode(',', $_POST['bounds']); $minLat = floatval($latlon[0]); $maxLat = floatval($latlon[2]); $minLon = floatval($latlon[1]); $maxLon = floatval($latlon[3]); $criteria->addCondition("t.latitude <= :maxLat"); $criteria->params += array(':maxLat' => $maxLat); $criteria->addCondition("t.latitude >= :minLat"); $criteria->params += array(':minLat' => $minLat); $criteria->addCondition("t.longitude <= :maxLon"); $criteria->params += array(':maxLon' => $maxLon); $criteria->addCondition("t.longitude >= :minLon"); $criteria->params += array(':minLon' => $minLon); } $criteria->with = array('mname', 'propertyType', 'city'); //End of Condition //Check number of house group by city $sql = "\r\n\t\t\tSELECT count(*) c, h.municipality m , municipality_cname cn,\tm.lat lat,m.lng lng\r\n\t\t\tFROM h_house h,h_mname m\r\n\t\t\tWHERE latitude <=" . $maxLat . "\r\n\t\t\tAND latitude >=" . $minLat . "\r\n\t\t\tAND longitude <=" . $maxLon . "\r\n\t\t\tAND longitude >=" . $minLon . $ss . "\r\n\t\t\t\r\n\t\t\tAND h.municipality = m.municipality\r\n\t\t\tGROUP BY m\r\n\t\t\tORDER BY c DESC\t"; $db = Yii::app()->db; $groupresult = $db->createCommand($sql)->query(); $citytotal = 0; $citylimit = 20; //control how many city marker displayed $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); if (count($groupresult) > 0) { $cityint = 0; foreach ($groupresult as $citycount) { $result['Message'] = '成功'; $count = $citycount["c"]; $city = $citycount["m"]; $lat = $citycount["lat"]; $lng = $citycount["lng"]; ++$cityint; $citytotal += $count; if ($lat > 20 && $cityint < $citylimit) { //error_log($city.":".$count.":".$cityint); $result['Data']['AreaHouseCount'][$city]['Count']['NameCn'] = !empty($citycount["cn"]) ? $citycount["cn"] : "其他"; $result['Data']['AreaHouseCount'][$city]['Count']['HouseCount'] = $count; $result['Data']['AreaHouseCount'][$city]['Count']['GeocodeLat'] = $lat; $result['Data']['AreaHouseCount'][$city]['Count']['GeocodeLng'] = $lng; //$result['Data']['AreaHouseCount'][$val->municipality]['Count'] ['MaxZoom'] = 2; //$result['Data']['AreaHouseCount'][$val->municipality]['List'][] = $mapHouseList; } $result['Data']['Total'] = $citytotal; } //error_log("Total:".$citytotal); } //End of check $maxmarkers = 2000; if ($citytotal < $maxmarkers) { $house = House::model()->findAll($criteria); $totalcount = count($house); $result['Data']['Total'] = $totalcount; $result['Message'] = '成功'; foreach ($house as $val) { $mapHouseList = array(); $mapHouseList['Beds'] = $val->br; $mapHouseList['Baths'] = $val->bath_tot; $mapHouseList['Kitchen'] = $val->num_kit; $mapHouseList['GeocodeLat'] = $val->latitude; $mapHouseList['GeocodeLng'] = $val->longitude; $mapHouseList['Address'] = $val->addr; $mapHouseList['sqft'] = $val->sqft; $mapHouseList['Price'] = $val->lp_dol / 10000; $mapHouseList['Id'] = $val->id; $mapHouseList['HouseType'] = !empty($val->propertyType->name) ? $val->propertyType->name : '其他'; $mapHouseList['MunicipalityName'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $mapHouseList['CountryName'] = $val->municipality; $mapHouseList['Zip'] = $val->zip; $mapHouseList['Country'] = $val->city_id; $mapHouseList['ProvinceEname'] = $val->county; $mapHouseList['ProvinceCname'] = $val->city->name; $mapHouseList['Money'] = 'CAD'; //$area2Name = District::model()->findByPk($val->district_id); $mapHouseList['Area2Name'] = !empty($area2Name) ? $area2Name->name : ''; //Get image from county $county = $val->county; $county = preg_replace('/\\s+/', '', $county); $county = str_replace("&", "", $county); $dir = "mlspic/crea/" . $county . "/Photo" . $val->ml_num . "/"; $num_files = 0; if (is_dir($dir)) { $picfiles = scandir($dir); $num_files = count(scandir($dir)) - 2; } //error_log($county.":".$dir); if ($num_files > 1) { $mapHouseList['CoverImg'] = $dir . $picfiles[2]; } else { $mapHouseList['CoverImg'] = 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; } //$mapHouseList['CoverImg'] = !empty($val->house_image) ? $val->house_image : 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; $mapHouseList['BuildYear'] = $val->yr_built; $result['Data']['MapHouseList'][] = $mapHouseList; } } } //error_log(json_encode($result)) ; echo json_encode($result); }
public function actionGetMapHouse() { ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); $result = array(); if (empty($_POST)) { $result['IsError'] = true; $result['Message'] = '数据接收失败'; } else { $result['IsError'] = false; //根据条件查询地图 $criteria = new CDbCriteria(); $criteria->select = 'id,municipality,lp_dol,num_kit,construction_year,depth,front_ft,br,addr,house_image,longitude,latitude,area,bath_tot'; /* 排序 * <span data-value="1">价格:从高到低</span> <span data-value="2">价格:从低到高</span> <span data-value="3">日期:从后到前</span> <span data-value="4">日期:从前到后</span> */ if ($_POST['orderby'] == 1) { $criteria->order = 't.lp_dol desc'; } else { if ($_POST['orderby'] == 2) { $criteria->order = 't.lp_dol asc'; } else { if ($_POST['orderby'] == 3) { $criteria->order = 't.construction_year asc'; } else { if ($_POST['orderby'] == 4) { $criteria->order = 't.construction_year desc'; } else { $criteria->order = 't.id desc'; } } } } //city_id if (!empty($_POST['country']) && trim($_POST['country']) != 'undefined') { $criteria->addCondition("t.city_id = :city_id"); $criteria->params += array(':city_id' => intval($_POST['country'])); } //district_id if (!empty($_POST['district']) && trim($_POST['district']) != 'undefined') { $criteria->addCondition("t.district_id = :district_id"); $criteria->params += array(':district_id' => intval($_POST['district'])); } //卫生间数量 1-5 if (!empty($_POST['housebaths']) && intval($_POST['housebaths']) > 0) { $criteria->addCondition("t.bath_tot = :bath_tot"); $criteria->params += array(':bath_tot' => intval($_POST['housebaths'])); } //土地面积 if (!empty($_POST['houseground'])) { $ground = explode(',', $_POST['houseground']); $minGround = intval($ground[0]); $maxGround = intval($ground[1]); if ($minGround != 0 || $maxGround != 0) { if ($maxGround > $minGround) { $criteria->addCondition("t.depth*t.front_ft <= :maxGround"); $criteria->params += array(':maxGround' => $maxGround); } $criteria->addCondition("t.depth*t.front_ft >= :minGround"); $criteria->params += array(':minGround' => $minGround); } } //价格区间 if (!empty($_POST['houseprice'])) { $price = explode(',', $_POST['houseprice']); $minPrice = intval($price[0]) * 10000; $maxPrice = intval($price[1]) * 10000; if ($maxPrice != 0 || $minPrice != 0) { if ($maxPrice > $minPrice) { $criteria->addCondition("t.lp_dol <= :maxPrice"); $criteria->params += array(':maxPrice' => $maxPrice); } $criteria->addCondition("t.lp_dol >= :minPrice"); $criteria->params += array(':minPrice' => $minPrice); } } //房型 if (!empty($_POST['houseroom']) && intval($_POST['houseroom']) > 0) { $houseroom = intval($_POST['houseroom']); if ($houseroom == '6') { $criteria->addCondition("t.br >= :br"); } else { if ($houseroom > 0) { $criteria->addCondition("t.br = :br"); } } $criteria->params += array(':br' => $houseroom); } //房屋类型 if (!empty($_POST['housetype']) && intval($_POST['housetype']) != 0) { $criteria->addSearchCondition('propertyType_id', $_POST['housetype']); } //根据地区名字搜索 if (!empty($_POST['city']) && trim($_POST['city']) != '州名/市名(中英)') { $city = trim($_POST['city']); $criteria->addCondition("t.addr like '%" . $city . "%' OR b.pinyin like '%" . $city . "%' OR b.englishName like '%" . $city . "%'"); } //建造年份 if (!empty($_POST['houseyear'])) { //$year = explode(',', $_POST['houseyear']); $year = $_POST['houseyear']; //$minYear = intval($year[0]); // $maxYear = intval($year[1]); $criteria->addCondition("t.yr_built = :year"); $criteria->params += array(':year' => $year); } //lat and long selection if (!empty($_POST['bounds'])) { $latlon = explode(',', $_POST['bounds']); $minLat = floatval($latlon[0]); $maxLat = floatval($latlon[2]); $minLon = floatval($latlon[1]); $maxLon = floatval($latlon[3]); $criteria->addCondition("t.latitude <= :maxLat"); $criteria->params += array(':maxLat' => $maxLat); $criteria->addCondition("t.latitude >= :minLat"); $criteria->params += array(':minLat' => $minLat); $criteria->addCondition("t.longitude <= :maxLon"); $criteria->params += array(':maxLon' => $maxLon); $criteria->addCondition("t.longitude >= :minLon"); $criteria->params += array(':minLon' => $minLon); } $criteria->with = array('mname', 'propertyType'); //$criteria->with = array('municipality'=>array('select'=>array('municipality_cname')),'propertyType'); $house = House::model()->findAll($criteria); $maxmarkers = 2000; $totalcount = count($house); $result['Data']['Total'] = $totalcount; //error_log(count($house)); //数据重组 $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); if (!empty($house) && $totalcount < $maxmarkers) { error_log("HouseList Start:" . $totalcount); $result['Message'] = '成功'; $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); foreach ($house as $val) { $mapHouseList = array(); $mapHouseList['Beds'] = $val->br; $mapHouseList['Baths'] = $val->bath_tot; $mapHouseList['Kitchen'] = $val->num_kit; $mapHouseList['GeocodeLat'] = $val->latitude; $mapHouseList['GeocodeLng'] = $val->longitude; $mapHouseList['Address'] = $val->addr; $mapHouseList['sqft'] = $val->sqft; $mapHouseList['Price'] = $val->lp_dol / 10000; $mapHouseList['Id'] = $val->id; $mapHouseList['HouseType'] = !empty($val->propertyType->name) ? $val->propertyType->name : '其他'; $mapHouseList['MunicipalityName'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $mapHouseList['CountryName'] = $val->municipality; $mapHouseList['Country'] = $val->city_id; $mapHouseList['Money'] = 'CAD'; //$area2Name = District::model()->findByPk($val->district_id); $mapHouseList['Area2Name'] = !empty($area2Name) ? $area2Name->name : ''; $mapHouseList['CoverImg'] = !empty($val->house_image) ? $val->house_image : 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; $mapHouseList['BuildYear'] = $val->yr_built; $result['Data']['MapHouseList'][] = $mapHouseList; //数据总数拼装 if (!empty($countryInfo)) { $provinceInfo = Province::model()->findByPk($countryInfo->province_id); } if (intval($_POST['zoom']) < 14 && intval($_POST['zoom']) >= 6) { $result['Data']['AreaHouseCount'][$val->municipality]['Count']['NameCn'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['HouseCount'] += 1; //$result['Data']['AreaHouseCount'][$val->city_id]['Count'] ['GeocodeLat'] = !empty($countryInfo) ? $countryInfo->lat : ''; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLat'] = !empty($val->mname->lat) ? $val->mname->lat : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLng'] = !empty($val->mname->lng) ? $val->mname->lng : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$val->municipality]['List'][] = $mapHouseList; } else { if (intval($_POST['zoom']) < 6) { if (!empty($provinceInfo)) { $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['NameCn'] = $val['name']; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['HouseCount'] += 1; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLat'] = $provinceInfo->lat; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLng'] = $provinceInfo->lnt; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$provinceInfo->id]['List'][] = $mapHouseList; } } } } //} else { // $result['IsError'] = true; // $result['Message'] = '无数据'; } if (!empty($house) && $totalcount >= $maxmarkers) { error_log("City Count Start:" . $totalcount); $result['Message'] = '成功'; foreach ($house as $val) { $result['Data']['AreaHouseCount'][$val->municipality]['Count']['NameCn'] = !empty($val->mname->municipality_cname) ? $val->mname->municipality_cname : "其他"; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['HouseCount'] += 1; //$result['Data']['AreaHouseCount'][$val->city_id]['Count'] ['GeocodeLat'] = !empty($countryInfo) ? $countryInfo->lat : ''; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLat'] = !empty($val->mname->lat) ? $val->mname->lat : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['GeocodeLng'] = !empty($val->mname->lng) ? $val->mname->lng : ""; $result['Data']['AreaHouseCount'][$val->municipality]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$val->municipality]['List'][] = $mapHouseList; } } //error_log(json_encode($result)) ; } //error_log(json_encode($result)) ; echo json_encode($result); }
public function actionGlobalSearch() { $msl = Yii::app()->request->getPost('msl'); if (empty($msl) || trim($msl) == '请输入房源MSL号') { echo CJSON::encode(array('success' => false, 'msg' => '请输入房源MSL号')); } else { $house = House::model()->find('ml_num=:ml_num', array(':ml_num' => $msl)); if (!empty($house)) { $url = Yii::app()->createUrl('house/view', array('id' => $house->id)); echo CJSON::encode(array('success' => true, 'msg' => $url)); } else { echo CJSON::encode(array('success' => false, 'msg' => '抱歉!没有找到相应的房源')); } } }
public function actionViewHistory() { Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/club.css'); $cookies = Yii::app()->request->getCookies(); $house_ids = explode(',', $cookies['fzd_house']->value); $criteria = new CDbCriteria(); $criteria->addInCondition('id', $house_ids); $count = House::model()->count($criteria); $pager = new CPagination($count); $pager->pageSize = 2; $pager->applyLimit($criteria); $house_list = House::model()->findAll($criteria); $data = array('count' => $count, 'pages' => $pager, 'house_list' => $house_list); $this->render('viewHistory', $data); }
public function actionCompare() { $this->layout = ' '; Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/compare.css'); $data = Yii::app()->request->getQuery('id'); $ids = explode(',', $data); $criteria = new CDbCriteria(); $criteria->addInCondition('id', $ids); $house_list = House::model()->findAll($criteria); $link_list = Link::model()->findAll(); $matches = Match::model()->findAll(); $this->render('compare', array('house_list' => $house_list, 'link_list' => $link_list, 'matches' => $matches)); }
/** * 取用户组列表 * @param $type */ protected function _groupList($type = 'user') { switch ($type) { case 'user': return AdminGroup::model()->findAll(); break; case 'subject': return Subject::model()->findAll(); break; case 'city': return City::model()->findAll(); break; case 'district': return District::model()->findAll(); break; case 'investType': return InvestType::model()->findAll(); break; case 'propertyType': return PropertyType::model()->findAll(); break; case 'house': return House::model()->findAll(); break; case 'match': return Match::model()->findAll(); break; } }
public function actionGetMapHouse() { $result = array(); if (empty($_POST)) { $result['IsError'] = true; $result['Message'] = '数据接收失败'; } else { $result['IsError'] = false; //根据条件查询地图 $criteria = new CDbCriteria(); // $criteria->join = 'join city_id as b on b.id = t.city_id'; // $criteria->join .= ' join propertyType_id as c on c.id = t.propertyType_id'; /* 排序 * <span data-value="1">价格:从高到低</span> <span data-value="2">价格:从低到高</span> <span data-value="3">日期:从后到前</span> <span data-value="4">日期:从前到后</span> */ if ($_POST['orderby'] == 1) { $criteria->order = 't.lp_dol desc'; } else { if ($_POST['orderby'] == 2) { $criteria->order = 't.lp_dol asc'; } else { if ($_POST['orderby'] == 3) { $criteria->order = 't.yr_built asc'; } else { if ($_POST['orderby'] == 4) { $criteria->order = 't.yr_built desc'; } else { $criteria->order = 't.id desc'; } } } } //city_id if (!empty($_POST['country']) && trim($_POST['country']) != 'undefined') { $criteria->addCondition("t.city_id = :city_id"); $criteria->params += array(':city_id' => intval($_POST['country'])); } //district_id if (!empty($_POST['district']) && trim($_POST['district']) != 'undefined') { $criteria->addCondition("t.district_id = :district_id"); $criteria->params += array(':district_id' => intval($_POST['district'])); } //卫生间数量 1-5 if (!empty($_POST['housebaths']) && intval($_POST['housebaths']) > 0) { $criteria->addCondition("t.toilet_num = :toilet_num"); $criteria->params += array(':toilet_num' => intval($_POST['housebaths'])); } //土地面积 if (!empty($_POST['houseground'])) { $ground = explode(',', $_POST['houseground']); $minGround = intval($ground[0]); $maxGround = intval($ground[1]); if ($minGround != 0 || $maxGround != 0) { if ($maxGround > $minGround) { $criteria->addCondition("t.depth*t.front_ft <= :maxGround"); $criteria->params += array(':maxGround' => $maxGround); } $criteria->addCondition("t.depth*t.front_ft >= :minGround"); $criteria->params += array(':minGround' => $minGround); } } //价格区间 if (!empty($_POST['houseprice'])) { $price = explode(',', $_POST['houseprice']); $minPrice = intval($price[0]); $maxPrice = intval($price[1]); if ($maxPrice != 0 || $minPrice != 0) { if ($maxPrice > $minPrice) { $criteria->addCondition("t.lp_dol <= :maxPrice"); $criteria->params += array(':maxPrice' => $maxPrice); } $criteria->addCondition("t.lp_dol >= :minPrice"); $criteria->params += array(':minPrice' => $minPrice); } } //房型 if (!empty($_POST['houseroom']) && intval($_POST['houseroom']) > 0) { $houseroom = intval($_POST['houseroom']); if ($houseroom == '6') { $criteria->addCondition("t.br_plus >= :bedroom_num"); } else { if ($houseroom > 0) { $criteria->addCondition("t.br_plus = :bedroom_num"); } } $criteria->params += array(':br_plus' => $houseroom); } //房屋类型 if (!empty($_POST['housetype']) && intval($_POST['housetype']) != 0) { if ($_POST['housetype'] == 1) { $criteria->addCondition('type_own1_out="Detached"'); } elseif ($_POST['housetype'] == 2) { $criteria->addCondition('type_own1_out="Townhouse" or type_own1_out="Att∕Row∕Twnhouse" or type_own1_out="Triplex" or type_own1_out="Fourplex" or type_own1_out="Multiplex"'); } elseif ($_POST['housetype'] == 3) { $criteria->addCondition('lp_dol>3000000'); } elseif ($_POST['housetype'] == 4) { $criteria->addCondition('type_own1_out="Semi-Detached" or type_own1_out="Link" or type_own1_out="Duplex"'); } elseif ($_POST['housetype'] == 5) { $criteria->addCondition('type_own1_out="Cottage" or type_own1_out="Rural Resid"'); } elseif ($_POST['housetype'] == 6) { $criteria->addCondition('type_own1_out="Farm"'); } elseif ($_POST['housetype'] == 7) { $criteria->addCondition('type_own1_out="Vacant Land"'); } elseif ($_POST['housetype'] == 8) { $criteria->addCondition('type_own1_out="Mobile/Trailer" or type_own1_out="Det W/Com Elements" or type_own1_out="Store W/Apt/offc"'); } // $criteria->addCondition("t.propertyType_id = :propertyType_id"); // $criteria->params += array(':propertyType_id' => intval($_POST['housetype'])); } //根据地区名字搜索 if (!empty($_POST['city']) && trim($_POST['city']) != '州名/市名(中英)') { $city = trim($_POST['city']); $criteria->addCondition("t.addr like '%" . $city . "%' OR b.pinyin like '%" . $city . "%' OR b.englishName like '%" . $city . "%'"); } //建造年份 if (!empty($_POST['houseyear'])) { $year = explode(',', $_POST['houseyear']); $minYear = intval($year[0]); $maxYear = intval($year[1]); if ($maxYear != 0 || $minYear != 0) { if ($maxYear > $minYear) { $criteria->addCondition("t.yr <= :maxYear"); $criteria->params += array(':maxYear' => $maxYear); } $criteria->addCondition("t.yr >= :minYear"); $criteria->params += array(':minYear' => $minYear); } } $house = House::model()->findAll($criteria); //经纬度范围 if ((empty($_POST['city']) || trim($_POST['city']) == '州名/市名(中英)') && empty($_POST['country']) && !empty($_POST['city'])) { if (!empty($house)) { $bound = explode(',', $_POST['bounds']); foreach ($house as $key => $val) { $jingweidu = actionGetCodeAddress2($val->country . $val->community . $val->addr); if (floatval($val->latitude) >= floatval($bound[0]) && floatval($jingweidu['lat']) <= floatval($bound[2]) && floatval($jingweidu['lng']) >= floatval($bound[1]) && floatval($jingweidu['lng']) <= floatval($bound[3])) { } else { unset($house[$key]); } } } } $count = count($house); //数据重组 if (!empty($house)) { $result['Message'] = '成功'; $result['Data']['AreaHouseCount'] = array(); $result['Data']['MapHouseList'] = array(); foreach ($house as $key => $val) { $jingweidu = actionGetCodeAddress2($val->country . $val->community . $val->addr); $mapHouseList = array(); $mapHouseList['Beds'] = $val->br_plus; $mapHouseList['Baths'] = $val->bath_tot; $mapHouseList['Kitchen'] = $val->kit_plus; $mapHouseList['GeocodeLat'] = $jingweidu['lat']; $mapHouseList['GeocodeLng'] = $jingweidu['lng']; $mapHouseList['Address'] = $val->addr; $mapHouseList['Price'] = $val->lp_dol; $mapHouseList['Id'] = $val->id; $propertyType = PropertyType::model()->findByPk($val->propertyType_id); $mapHouseList['HouseType'] = !empty($propertyType) ? $propertyType->name : ''; $countryInfo = City::model()->findByPk($val->city_id); $mapHouseList['CountryName'] = !empty($countryInfo) ? $countryInfo->name : ''; $mapHouseList['Country'] = $val->city_id; $mapHouseList['Money'] = 'CAD'; $area2Name = District::model()->findByPk($val->district_id); $mapHouseList['Area2Name'] = !empty($area2Name) ? $area2Name->name : ''; $mapHouseList['CoverImg'] = !empty($val->house_image) ? $val->house_image : 'uploads/201501/29cd77e5f187df554a1ff9facdc190e2.jpg'; $mapHouseList['BuildYear'] = $val->construction_year; $result['Data']['MapHouseList'][] = $mapHouseList; //数据总数拼装 if (!empty($countryInfo)) { $provinceInfo = Province::model()->findByPk($countryInfo->province_id); } if (intval($_POST['zoom']) < 10 && intval($_POST['zoom']) >= 6) { $result['Data']['AreaHouseCount'][$val->city_id]['Count']['NameCn'] = $val['name']; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['HouseCount'] += 1; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['GeocodeLat'] = !empty($countryInfo) ? $countryInfo->lat : ''; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['GeocodeLng'] = !empty($countryInfo) ? $countryInfo->lnt : ''; $result['Data']['AreaHouseCount'][$val->city_id]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$val->city_id]['List'][] = $mapHouseList; } else { if (intval($_POST['zoom']) < 6) { if (!empty($provinceInfo)) { $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['NameCn'] = $val['name']; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['HouseCount'] += 1; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLat'] = $provinceInfo->lat; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['GeocodeLng'] = $provinceInfo->lnt; $result['Data']['AreaHouseCount'][$provinceInfo->id]['Count']['MaxZoom'] = 2; $result['Data']['AreaHouseCount'][$provinceInfo->id]['List'][] = $mapHouseList; } } } } } else { $result['IsError'] = true; $result['Message'] = '无数据'; } } echo json_encode($result); }
$form = $this->beginWidget('CActiveForm', array('id' => 'xform', 'htmlOptions' => array('name' => 'xform'))); ?> <table class="form_table"> <tr> <td class="tb_title">房源名称:</td> </tr> <tr > <?php if ($model->isNewRecord) { ?> <td> <?php echo $form->hiddenField($model, 'house_id', array('value' => $house_id)); ?> <p><?php echo House::model()->findByPk($house_id)->name; ?> </p> </td> <?php } else { ?> <td> <?php echo $form->hiddenField($model, 'house_id', array('value' => $model->house_id)); ?> <p><?php echo $model->house->name; ?> </p> </td>
function favlist($username, $type) { //get house detail for fav list ini_set("display_errors", "1"); // shows all errors ini_set("log_errors", 1); ini_set("error_log", "/tmp/php-error.log"); $db = Yii::app()->db; $criteria = new CDbCriteria(); //get list of fav $sql = 'select ' . $type . ' from h_user_data where username="******"'; $resultsql = $db->createCommand($sql)->queryRow(); $favlist = explode(',', $resultsql[$type]); //get list of house $criteria->select = 'id,ml_num,zip,s_r,county,municipality,lp_dol,num_kit,construction_year,br,addr,longitude,latitude,area,bath_tot,pix_updt'; $criteria->addInCondition('ml_num', $favlist); $criteria->with = array('mname', 'propertyType', 'city'); //$criteria->order = "field(ml_num, 'N3571091', 'N3577563', 'N3586413', 'N3586138')"; $criteria->order = "field(ml_num,'" . implode("','", $favlist) . "')"; $house = House::model()->findAll($criteria); $result = $this->house2Array($house, 0, 'house'); if (count($house) > 0) { // listed mls list $funcName = function ($value) { return $value["ml_num"]; }; $houseMLS = array_map($funcName, $house); // delisted mls list $houseEmptyMLS = array_diff($favlist, $houseMLS); if (count($houseEmptyMLS) > 0) { $result1 = $this->emptyHouse2Array($houseEmptyMLS); $result2 = $result1['Data']['EmptyHouseList']; if (count($house) > 0) { foreach ($result['Data']['HouseList'] as $row) { $result2[] = $row; } } $result['Data']['HouseList'] = $result2; } } return $result; }