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

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

//查询条件
$wherecond = " kind in ('p_4_1','p_4_2')";

if($select_cond != "" && $select_cond_info != "")
{
	$uidstr = "";
	$uidarr = $dao->getAll("broker", " ".$select_cond." like '%".$select_cond_info."%' order by uid desc limit 10", " uid ");
	if(is_array($uidarr) && !empty($uidarr))
	{
		foreach($uidarr as $uid)
		{
			$uidstr .= $uidstr == '' ? $uid['uid'] : ','.$uid['uid'];
		}
	}

	if($uidstr != "")
	{
		$wherecond .= " and uid IN (".$uidstr.") ";
	}
}


if(isset($select_stat) && $select_stat!='*请选择*')
{
	$select_stat = intval($select_stat);
	$wherecond .= " and valid_flag = '".$select_stat."' ";
}

//分页参数
$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 broker_certificate WHERE ".$wherecond;
$numrows = $dbback->GetOne($sql);

//获得数据当前页面数据
$sql = "SELECT * FROM broker_certificate WHERE $wherecond ORDER BY id DESC LIMIT ".$offset.",".$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 = 3600;
		$brokerinfo = $dao->getRow("broker", " uid = '".$uid."' ", " username,truename,idno,telno,agentcode ", $memkey, $memsec);

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

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

$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("broker/real_manage"));
include_once(Template("footer"));
?> 