<?php
require('path.inc.php');
$page->name = 'index'; //页面名字,和文件名相同	
$page->title = $page->city.'二手房，'.$page->city.'租房 - '. $page->titlec.' 专业的'.$page->city.'房产网站';   //网站名称
$page->addJs('jquery-1.2.6.min.js');

//图片Flash滚动播放
$params= array('id'=>1,'num'=>5);
$flashBboxAd = insert_ads($params);
$page->tpl->assign('flashBboxAd', $flashBboxAd);

//首页底部左侧广告
$params= array('id'=>8);
$bbanner = insert_ads($params);
$page->tpl->assign('bbanner', $bbanner[0]);

//首页右侧广告（一）
$params= array('id'=>9);
$rightad = insert_ads($params);
$page->tpl->assign('rightad', $rightad[0]);

//首页右侧广告（二）
$params= array('id'=>12);
$rightad = insert_ads($params);
$page->tpl->assign('rightad1', $rightad[0]);

//首页底部横幅
$params= array('id'=>13);
$footerAd = insert_ads($params);
$page->tpl->assign('footerAd', $footerAd[0]);

$houseSell = new HouseSell($query);
$houseRent = new HouseRent($query);
$borough = new Borough($query);
$statistics = new Statistics($query);
$consign = new Consign($query);
$member = new Member($query);
$todaySell=$houseSell->getCount(6," and timestampdiff(day ,from_unixtime(created, '%Y-%m-%d'),now())<=1");
$todayRent=$houseRent->getCount(6," and timestampdiff(day ,from_unixtime(created, '%Y-%m-%d'),now())<=1");
$addFangNum= $todaySell+$todayRent;
$page->tpl->assign('addFangNum', $addFangNum);
//区域字典
$cityarea_option = Dd::getArray('cityarea');
$page->tpl->assign('cityarea_option', $cityarea_option);

//面积
$house_totalarea_option = array(
	'0-50'=>'50㎡以下',
	'50-70'=>'50-70㎡',
	'70-90'=>'70-90㎡',
	'90-110'=>'90-110㎡',
	'110-130'=>'110-130㎡',
	'130-150'=>'130-150㎡',
	'150-200'=>'150-200㎡',
	'200-250'=>'200-250㎡',
	'300-0'=>'300㎡以上'
);
$page->tpl->assign('house_totalarea_option', $house_totalarea_option);

//二手房价
$house_price_option = array(
	'0-40'=>'40万以下',
	'40-60'=>'40-60万',
	'60-80'=>'60-80万',
	'80-100'=>'80-100万',
	'100-120'=>'100-120万',
	'120-150'=>'120-150万',
	'150-200'=>'150-200万',
	'200-250'=>'200-250万',
	'300-0'=>'300万以上'
);
$page->tpl->assign('house_price_option', $house_price_option);

//租房价格
$house_price_rent_option = array(
	'0-600'=>'600元以下',
	'600-800'=>'600-800元',
	'800-1000'=>'800-1000元',
	'1000-1200'=>'1000-1200元',
	'1200-1500'=>'1200-1500元',
	'1500-2000'=>'1500-2000元',
	'2000-3000'=>'2000-3000元',
);
$page->tpl->assign('house_price_rent_option', $house_price_rent_option);


//取得首页友情文字链接
$lianjie = new outlink($query);
$lianjie_s = $lianjie->getlists('*','link_type = 1','order by list_order asc');
$page->tpl->assign('lianjie_s', $lianjie_s);

//取得首页友情图片链接
$lianjie_a = $lianjie->getlists('*','link_type = 2','order by list_order asc');
$page->tpl->assign('lianjie_a', $lianjie_a);

$company = new Company($query);
//取得推荐中介公司
$companyList = $company->getList(array('rowFrom'=>0,'rowTo'=>5),'*',' and status=1','');
$page->tpl->assign('companyList', $companyList);

//优质二手房
$houseSellBest = $houseSell->getList(array('rowFrom'=>0,'rowTo'=>5),'*',1,' and status =1 and is_index=1' ,' order by order_weight desc');
foreach ($houseSellBest as $key =>$item ){
	$houseSellBest[$key]['title'] = substrs($item['house_title'],14);
	$houseSellBest[$key]['cityarea_name'] = substr($cityarea_option[$item['cityarea_id']],0,-2);
	$houseSellBest[$key]['description'] = $item['house_room'].'室'.$item['house_hall'].'厅，'.$item['house_totalarea'].'平米';
}
$page->tpl->assign('houseSellBest', $houseSellBest);
//优质租房
$houseRentBest = $houseRent->getList(array('rowFrom'=>0,'rowTo'=>5),'*',1,' and status =1 and is_index=1' ,' order by order_weight desc');
foreach ($houseRentBest as $key =>$item ){
	$houseRentBest[$key]['title'] =substrs($item['house_title'],14);
	$houseRentBest[$key]['cityarea_name'] = substr($cityarea_option[$item['cityarea_id']],0,-2);
	$houseRentBest[$key]['description'] = $item['house_room'].'室'.$item['house_hall'].'厅，'.$item['house_totalarea'].'平米';
}
$page->tpl->assign('houseRentBest', $houseRentBest);

//最新二手房
$houseSellNew = $houseSell->getList(array('rowFrom'=>0,'rowTo'=>9),'*',1,' and status =1 ' ,' order by update_order desc');
foreach ($houseSellNew as $key =>$item ){
	$houseSellNew[$key]['title'] = substrs($item['house_title'],12);
	$houseSellNew[$key]['cityarea_name'] = substr($cityarea_option[$item['cityarea_id']],0,-2);
	$houseSellNew[$key]['description'] = $item['house_room'].'室';
}
$page->tpl->assign('houseSellNew', $houseSellNew);
//最新租房
$houseRentNew = $houseRent->getList(array('rowFrom'=>0,'rowTo'=>9),'*',1,' and status =1' ,' order by update_order desc');
foreach ($houseRentNew as $key =>$item ){
	$houseRentNew[$key]['title'] =substrs($item['house_title'],12);
	$houseRentNew[$key]['cityarea_name'] = substr($cityarea_option[$item['cityarea_id']],0,-2);
	$houseRentNew[$key]['description'] = $item['house_room'].'室';
}
$page->tpl->assign('houseRentNew', $houseRentNew);
//小区列表
$boroughList = $borough->getList(array('rowFrom'=>0,'rowTo'=>7),1,' and isdel =0' ,' order by sell_num+rent_num desc');
foreach ($boroughList as $key =>$item ){
	$boroughList[$key]['cityarea_name'] = substr($cityarea_option[$item['cityarea_id']],0,-2);
	$boroughList[$key]['borough_name'] = substrs($item['borough_name'],12);
}
$page->tpl->assign('boroughList', $boroughList);


$allNum = $statistics->getAll('allNum');
$allNum=array_to_hashmap($allNum,'stat_index','stat_value');

//取二手房均价
$val = $statistics->getAll('val');
$val=array_to_hashmap($val,'stat_index','stat_value');
$page->tpl->assign('val', $val);

$page->tpl->assign('statistics', $allNum);


//推荐经纪人
$brokerList = $member->getListBroker(array('rowFrom'=>0,'rowTo'=>3),'*',' m.status = 0 and m.user_type=1 and m.is_index=1',' order by m.order_weight desc');

//积分配置文件
$integral_array = require_once($cfg['path']['conf'].'integral.cfg.php');
foreach ($brokerList as $key=> $item){
	$brokerList[$key]['brokerRank'] = getNumByScore($item['scores'],$integral_array,'pic');
}
$page->tpl->assign('brokerList', $brokerList);


//增加小区的thickBox
$page->addcss("thickbox.css");
$page->addjs("thickbox.js");

$page->addjs($cfg['path']['js']."Autocompleter/lib/jquery.bgiframe.min.js");
$page->addjs($cfg['path']['js']."Autocompleter/lib/ajaxQueue.js");
$page->addcss($cfg['path']['js']."Autocompleter/jquery.autocomplete.css");
$page->addjs($cfg['path']['js']."Autocompleter/jquery.autocomplete.js");

//字典
$house_type_option = Dd::getArray('house_type');
$page->tpl->assign('house_type_option', $house_type_option);

//特色
$house_toword_option = Dd::getArray('house_toward');
$page->tpl->assign('house_toword_option', $house_toword_option);


$page->tpl->assign('menu', 'index');
$page->show();
?>