示例#1
0
 /**
  * 首页
  *
  */
 public function actionIndex()
 {
     parent::_acl('house_index');
     $model = new House();
     $criteria = new CDbCriteria();
     $condition = '1';
     $city_id = $this->_gets->getParam('city_id');
     $district_id = $this->_gets->getParam('district_id');
     //$investType_id = $this->_gets->getParam( 'investType_id' );
     $propertyType_id = $this->_gets->getParam('propertyType_id');
     $h_name = trim($this->_gets->getParam('h_name'));
     $is_recommend = $this->_gets->getParam('is_recommend');
     $city_id && ($condition .= ' AND city_id= ' . $city_id);
     $district_id && ($condition .= ' AND district_id= ' . $district_id);
     //$investType_id && $condition .= ' AND investType_id= ' . $investType_id;
     if ($propertyType_id == 1) {
         $propertyType_id && ($condition .= ' AND type_own1_out="Detached" ');
     } elseif ($propertyType_id == 2) {
         $propertyType_id && ($condition .= ' AND 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 ($propertyType_id == 3) {
         $propertyType_id && ($condition .= ' AND lp_dol>3000000');
     } elseif ($propertyType_id == 4) {
         $propertyType_id && ($condition .= ' AND type_own1_out="Semi-Detached" or type_own1_out="Link" or type_own1_out="Duplex"');
     } elseif ($propertyType_id == 5) {
         $propertyType_id && ($condition .= ' AND type_own1_out="Cottage" or type_own1_out="Rural Resid"');
     } elseif ($propertyType_id == 6) {
         $propertyType_id && ($condition .= ' AND type_own1_out="Farm"');
     } elseif ($propertyType_id == 7) {
         $propertyType_id && ($condition .= ' AND type_own1_out="Vacant Land"');
     } elseif ($propertyType_id == 8) {
         $propertyType_id && ($condition .= ' AND type_own1_out="Mobile/Trailer" or type_own1_out="Det W/Com Elements" or type_own1_out="Store W/Apt/offc"');
     }
     $h_name && ($condition .= ' AND addr LIKE \'%' . $h_name . '%\' or ml_num LIKE \'%' . $h_name . '%\'');
     $is_recommend && ($condition .= ' AND recommend= ' . $is_recommend);
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 10;
     $pageParams = XUtils::buildCondition($_GET, array('city_id, district_id, type_own1_out, addr, recommend'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->subject_list = parent::_groupList('subject');
     $this->city_list = parent::_groupList('city');
     $this->district_list = parent::_groupList('district');
     $this->investType_list = parent::_groupList('investType');
     $this->propertyType_list = parent::_groupList('propertyType');
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }