<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
$title = '经纪人虚假举报黑名单';

$complainBrokerBlacklist = new ComplainBrokerBlacklist();


$settingSearch = array(0=>'请选择','brokername'=>'经纪人帐号');//查询条件
$settingOrderBy = array('ctime'=>'按时间排序');
$settingAscDesc = array('desc'=>'倒序排列','asc'=>'正序排列',);
$settingDispRows = array(20=>'20',30=>'30',40=>'40');



//查询条件，关键字
if($search_type&&$keyword) {
   
    if ($search_type == 'brokername') {
        $uid = getUsernameByUid($username);
        $conf_sql['broker_id'] = $uid;
    } 
}

//排序
$asc_desc_order = $asc_desc ? " id ".$asc_desc : " id ".'desc';

//条数
$page_now = intval($page_now)==0?1:intval($page_now);
$disp_rows = intval($disp_rows)==0?20:intval($disp_rows);
$startRow = ($page_now-1)*$disp_rows;

//条件组装
if(CommonBase::isFullArray($conf_sql)){
    $conf_num = count($conf_sql);
    foreach ($conf_sql as $key=>$value){
        $sql_where .= $key."='".$value."'"; 
        $sql_where .= $conf_num != 1 ? ' and ' : ''; 
        $conf_num--;        
    }    
}



$recordList = $complainBrokerBlacklist->findByConf($sql_where,$asc_desc_order,$startRow,$disp_rows);

$total_num = $complainBrokerBlacklist->findNumberBy($sql_where);
$page_total = ceil($total_num/$disp_rows);
$new_pagenavi = new_pagenavi2($page_now,$page_total,$total_num);



    
include_once(Template("header"));
include_once(Template("complain/broker_blacklist"));
include_once(Template("footer"));


//获取经纪人id
function getUidByUsername($mc, $dbback, $username){
    $sql = SqlCombinHelper::select_sql('broker', 'uid', "username = '".$username."'");	
	$brokerUid = $mc->get($sql);
	if ($brokerUid === false) {
		$brokerUid = $dbback->getOne($sql);
		$mc->add($sql, $brokerUid, 3600);
	}
    return $brokerUid;
}

//根据经纪人id获取username
function getUsernameByUid($uid){
    global $mc,$dbback;
    $sql = SqlCombinHelper::select_sql('broker', 'username', "uid = '".$uid."'");	
	$username = $mc->get($sql);
	if ($username === false) {
		$username = $dbback->getOne($sql);
		$mc->add($sql, $username, 3600);
	}
    return $username;
    
}
