<?php
/*
  CP后台学区房列表 by mada
  文件名：univercity_manage.php
  创建日期：2011.3.16
  更改日期：2011.3.16
 */
$conf_basedir = "../../"; //相对主目录的位置
$conf_where = "admin"; //选择调用相应模块
require_once($conf_basedir . "/base.inc.php");
require_once("./univercity_func.php");
checkAuth('34');
//有关本页面的信息
//$page_id = 8130;
//header_auth_check($page_id);  //权限判断

//基本配置
include_once($conf_basedir."model/univercityChannel/univercityChannelFunction.php");
$uc = new UnivercityChannel('test');
$tbl = $uc->getSchoolTable();
$tblSchoolImg = $uc->getSchoolImgTable();
$tblSchoolBlock = $uc->getSchoolBlockTable();
$univercityModifySuffix = $uc->getSuffix();
//基本配置结束
//var_dump($db_sys);exit;$dbback_sys
$title = "学区房列表";
$js = "<script src='script/cp.js' type='text/javascript' ></script>";

//-----取得条件
if ($act != "search") { //缺省值设定
    //缺省的条件
    //$vars["valid_flag"]	="1"; //显示有效的帐户
    //缺省排序条件
    $vars["orderby"] = "id";
    $vars["asc_desc"] = "desc";
}

get_cond_arr(); //一些数据的准备包括$orderby_arr,$cond_arr,$asc_desc_arr
//echo getFunctionFile('new_pagenavi2');
$cond_str = get_query_str($vars, $q_ext);
$orderby_str = get_orderby_str($vars);
/**搜索条件**/
$searchKey = $_GET['cond2'];
$searchValue = $_GET['cond2_val'];
$searchConf = '';
if($searchKey&&$searchKey!='none'&&$searchValue) {
    $searchConf = " where ".mysql_real_escape_string($searchKey)." like '%".mysql_real_escape_string($searchValue)."%' ";
}
/**********/

/**排序**/
$orderByKey = $_GET['orderby'];
$orderBySort = $_GET['asc_desc'];
$orderBy = '';
if($orderByKey&&$orderBySort) {
    $orderBy = " order by ".mysql_real_escape_string($orderByKey)." ".mysql_real_escape_string($orderBySort);
}
/********/

//-----分页的处理 [取得总记录数,每页记录数,当前页号] [生成导航栏table]
//取得总记录数
$q = " select count(*) as count_num from $tbl " . $searchConf . $orderBy;
$rows_all = $dbback->GetOne($q);

$rows_perpage = (intval($disp_rows) <= 0) ? (10) : (intval($disp_rows));
$total_page = ceil($rows_all / $rows_perpage);
$pg = $page_now;
if ($pg != '' && $pg > $total_page) {
    $pg = $total_page;
}
if ($pg == '' || $pg == 0) {
    $pg = 1;
}
$limitstar = ($pg - 1) * $rows_perpage;
$zpage->page_now = $pg;
$zpage->page_url = $page_url;
$zpage->url_mode = "submit";
//$zpage->page_exec();
//-------生成table

//从数据库中读取数据,取前n条记录,并跳转至开始显示记录
$q = " select * from $tbl   " . $searchConf . $orderBy . " limit " . $limitstar . "," . $rows_perpage;
$rs = $db->Execute($q);
if ($rs->RecordCount()) {
    $data_info = $rs->GetAll();
} else {
    $data_info = array();
}

$pages = $total_page ;  //计算总页数
$new_pagenavi = new_pagenavi($pg,$pages,$rows_all);
$templateName = substr(basename ($_SERVER['SCRIPT_NAME']),0,-4);

include_once(Template("header"));
//include_once(Template("left"));
include_once(Template('xuequ/'.$templateName));
include_once(Template("footer"));

function getFunctionFile($functionName) {
    try {
        $refun = new ReflectionFunction($functionName);
        return $refun->getFileName(); 
    } catch (Exception $exc) {
        return  $exc->getMessage();
    }
}
?>