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

	 //设置顶部查询部分
	$cond_arr_1=array("blockname"=>"小区名称",
	                  "id"=>"小区编号"
	                 );
    $cond_arr_2=array("0"=>"待审核"
					  );
 
	//排序条件
    $orderby_arr=array("id"=>"小区编号"
					  );
 

	$asc_desc_arr=array("desc"=>"倒序排列",
	                    "asc"=>"正序排列"
					   );
 

    $cond_search_1	= tonyForm("select","search_type",$cond_arr_1,$search_type);
    $cond_search_2	= tonyForm("select","status",$cond_arr_2,$status);
    $orderby_arr_search	= tonyForm("select","orderby_arr_s",$orderby_arr,$orderby_arr_s);
    $asc_desc_arr_search	= tonyForm("select","asc_desc_arr_s",$asc_desc_arr,$asc_desc_arr_s);
    
	//组合页面查询条件
	$where = " where b.esta = '2' ";
	$orderby = '';

	if($keyword = trim($keyword)){
		if(!empty($search_type) and $search_type != 'none'){
			if($search_type == 'id'){
				$where .= " and b.id =  '".$keyword."' ";
			}else{
				$where .= " and b.".$search_type." like '".$keyword."%' ";
			}
        }
    }

	//审核(暂取待审核的)
	$where .= " and g.status = '0' ";
 
    
	//排序
	if($orderby_arr_s == 'id'){
		if($asc_desc_arr_s){
			$orderby = " order by g.block_id ".$asc_desc_arr_s." ";
		}
	}
	if(!$orderby){
		$orderby = " order by g.block_id  desc ";
	}
    

    //分页参数
	$pagesize = $disp_rows ? intval($disp_rows) : 20; ;
	$page_now = $page_now ? $page_now : 1;
	//获得数据当前页面数据
	$sql = "select count(b.id) as num from growth_block_improve_audit as g  left join block as b on   g.block_id = b.id {$where} group by g.block_id,g.attr_field";
	$result = $dbback->GetAll($sql);
	$total_num = count($result);

	$page_total = ceil($total_num/$pagesize);
	if ($page_now != '' && $page_now > $page_total) {
		$page_now = $page_total;
	}elseif($page_now <  0){
		$page_now = 1;
	}

	$start = ($page_now-1)*$pagesize;
	if($total_num <= 0 || $page_total <=0){
		$pages = 0 ;  //计算总页数
	}else{
		$new_pagenavi = new_pagenavi2($page_now,$page_total,$total_num);
	}

    
    //查询小区完善属性字段名和属性名称对应数据
    $block_attrs = getBlockAttrs();

	$sql = "select g.id,g.block_id,count(g.id) as num ,g.attr_field,g.status,b.blockname from   growth_block_improve_audit as g  left join block as b on g.block_id = b.id {$where} group by g.block_id,g.attr_field  {$orderby} limit ".$start.",".$pagesize;
    $data_info = $dbback->GetAll($sql);
 
    //引用模版文件
    include_once(Template("header"));
    include_once(Template("block/improve_audit"));
    include_once(Template("footer"));
?>