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

    //设置顶部查询部分
	$cond_arr_1=array("blockname"=>"小区名称",
	                  "id"=>"小区编号"
	                 );
    $cond_arr_2=array("none"=>"*请选择*",
	                  "1"=>"未锁定",
	                  "2"=>"已锁定"
	                  );

	//排序条件
    $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","lock_flag",$cond_arr_2,$lock_flag);
    $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 esta = '2' ";
	$orderby = '';

	if(trim($keyword)){
		if(!empty($search_type) and $search_type != 'none'){
			if($search_type == 'id'){
				$where .= " and id =  '".$keyword."'";
			}else{
				$where .= " and ".$search_type." like '".$keyword."%'";
			}
        }
    }
 
    
	if($lock_flag == 1){
		$where .= " and lock_flag = '0'";
	}elseif($lock_flag == 2){
		$where .= " and lock_flag = '1'";
	}

	if($orderby_arr_s == 'id'){
		if($asc_desc_arr_s){
			$orderby = " order by id ".$asc_desc_arr_s." ";
		} 
	}
	if(!$orderby){
		$orderby = " order by id  desc ";
	}
 

	//分页参数
	$pagesize = $disp_rows ? intval($disp_rows) : 20; ;
	$page_now = $page_now ? $page_now : 1;
	//获得数据当前页面数据
	$sql = "select count(id) as num from block ".$where."";
	$total_num = $dbback->GetOne($sql);

	$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);
	}

    //查询结果
    $sql = " select id,blockname,lock_flag from block ".$where.$orderby."  LIMIT ".$start .",".$pagesize."";
    $data_info = $dbback->GetAll($sql);
 
  // print_r( $sql);
	//引用模版文件
    include_once(Template("header"));
    include_once(Template("block/attr_lock"));
    include_once(Template("footer"));
    

?>