<?php
$conf_basedir	= "../../";	//相对主目录的位置
$conf_where		= "admin";	//选择调用相应模块
$directory		= basename(dirname(__FILE__));	//定义当前所在的目录，引入模块公用函数
include_once($conf_basedir."base.inc.php");
include_once(WEB_MODEL."/broker_house_base_func.php");//模块公用集合
checkAuth('48');	//判断登录和权限

$js = "<script type='text/javascript' src='http://esfadmin.house365.com/script/js/showpic.js'></script>";

$act = 'head';
//查询条件
$wherecond = " type = 'p_1' ";
$type = "头像图";

$mem_key = "broker_qa_".$act;
//过滤正在审核的
$idarr = getCheckRowidByType($mem_key);
//print_r($idarr);die;
if(is_array($idarr) && !empty($idarr)){
	$notidsql = "";
	foreach($idarr as $val){
		$id = intval($val);
		$notidsql .= $notidsql != "" ? " AND id != ".$id." " : " id != ".$id." ";
	}

	$wherecond .= " AND (".$notidsql.") ";
}
 
$title = "经纪人".$type."质检";
//前台查询参数
$search_arr = array('1'=>1,'2'=>2,'3'=>3,'4'=>4,'5'=>5,'6'=>6,'7'=>7);
$search_display = getSelect($search_arr,'search_day',$search_day);
//查询时间设置
$search_day = $search_day ? $search_day : 1;
$search_time = strtotime('-'.$search_day.' day');
$wherecond = $wherecond.' and dateline >='.$search_time ;
 
//分页参数
$pagesize	= $display_rows ? intval($display_rows) : 10;
$page_now	= $page_now ? max(1, intval($page_now)) : 1 ; // 获取当前页数
$offset		= ( $page_now - 1 ) * $pagesize;

//获得数据总条数
$sql = "SELECT COUNT(*) FROM admin_broker_qa WHERE ".$wherecond;
$numrows = $dbback->GetOne($sql);

//获得数据当前页面数据
$sql = "SELECT * FROM admin_broker_qa WHERE ".$wherecond." ORDER BY id ASC LIMIT ".$pagesize." ";
$data_info = $dbback->GetAll($sql);


//获得详细信息
if($data_info){
	$brokerarr = array();
	foreach($data_info as $key=>$data){
		$uid = intval($data['uid']);

		$memkey = $conf_cityflag."_brokerinfo_uid_".$uid;
		$memsec = 1;
		$brokerinfo = $dao->getRow("broker", " uid = '".$uid."' ", " username,truename,idno,telno,agentcode ", $memkey, $memsec);

		if($brokerinfo['agentcode'] != ''){
			$memkey = $conf_cityflag."_agentshortname_agency_".$brokerinfo['agentcode'];
			$memsec = 1;
			$agentshortname = $dao->getOne("agency", " agentcode = '".$brokerinfo['agentcode']."' ", " agentshortname ", $memkey, $memsec);
		}
		
		$memkey = $conf_cityflag."_broker_certificate_head_uid_".$brokerinfo['agentcode'];
		$memsec = 1;
		$idcardpic = $dao->getOne("broker_certificate", " kind = 'p_2' and uid = '".$uid."'", " pic1 ", $memkey, $memsec);
		
		$brokerinfo['agentshortname'] = $agentshortname;
		$brokerinfo['idcardpic'] = $idcardpic;

		$brokerarr[$uid] = $brokerinfo;
	}
}


//设置正在审核记录
if($data_info)
{
	$idarr = array();
	foreach($data_info as $data)
	{
		$idarr[] = $data['id'];
	}
	resetCheckLog($mem_key, $idarr);
}

$pagenum = count($data_info);//当前页面数量
$numrows = $numrows >0 ? $numrows : 0;
$time = time();
if( $numrows <= 0 || $pagenum <=0){
	$pages = 0 ;  //计算总页数
}else{
	$pages = ceil($numrows/$pagesize) ;  //计算总页数
	$new_pagenavi = new_pagenavi($page_now,$pages,$numrows);
}


//引用模版文件
include_once(Template("header"));
include_once(Template("qa/head_manage"));
include_once(Template("footer"));
?>