<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
checkAuth('87');	//判断登录和权限
$title = "竞投详情";
$bidId = intval($bid);
//查竞投
$growthBid = new GrowthBidHouse();
$bid = $growthBid->findOneById($bidId);
if(!$bid) {
    echo '不存在该竞投';exit;
}

$bidPeriodsId = $bid['bid_periods_id'];
//查期次
$growthBidPeriods = new GrowthBidPeriods();
$bidP = $growthBidPeriods->findById($bidPeriodsId);
if($growthBidPeriods->isBidOn($bidP)) {
    $growthBidRecord = GrowthBidRecordFactory::getRecordOnClass('house');
} else {
    $growthBidRecord = GrowthBidRecordFactory::getRecordHistoryClass('house');
}


$request = new Request();
if($request->isAjax()) {
    if ($type == 3) {
        $growthBid = new GrowthBidHouseHotSearch();
    } else if ($type == 2) {
        $growthBid = new GrowthBidHouseBlock();
    } 
    $affentRows = $growthBid->stop($bidId);
    if($affentRows==1) {
        $result= array('result'=>1);
    } else {
        $result= array('result'=>0);
    }
    echo json_encode($result);
    exit;
} 
$page_now = intval($page_now)==0?1:intval($page_now);
$disp_rows = 10;
$startRow = ($page_now-1)*$disp_rows;
$limit = "$startRow, $disp_rows";

$detail = $growthBidRecord->findByBid($bidId,"score desc,utime asc",$limit);

$brokerIds = array();
if($detail) {
    foreach($detail as $v) {
        $brokerIds[] = $v['broker_id'];
    }
}
$brokers = array();
$brokerSql = "select uid,username from broker where uid in ('".  implode("','", $brokerIds)."')";
$brokers = $dbback->getAll($brokerSql);
$brokers = SqlCombinHelper::changeToKeyArray($brokers, 'uid');

$total_num = $growthBidRecord->findNumberByBid($bidId);
$page_total = ceil($total_num/$disp_rows);
$new_pagenavi = new_pagenavi2($page_now,$page_total,$total_num);
include_once(Template("header"));
include_once(Template("growth_nj/bid_house_detail"));
include_once(Template("footer"));
?>
