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

//分页参数
$pagesize = 10 ;
$page_now = $page_now ? $page_now : 1;
//获得数据当前页面数据
$sql = "select count(id) as num from $table where del_flag = '0'";
$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 * from {$table} where del_flag = '0' order by etime desc limit ".$start.",".$pagesize.";";
$data_info = $dbback->GetAll($sql);

if(is_array($data_info)){
	foreach($data_info as $key=>$val){
		if($val['open_flag'] == '0'){
			$data_info[$key]['status'] = '未进行';
		}elseif($val['open_flag'] == '1' && strtotime($val['etime']) >= time()){
		    $data_info[$key]['status'] = '进行中';
		}else{
			$data_info[$key]['status'] = '已结束';
		}
    }
}

$title = '兑换礼品管理';
include_once(Template("header"));
include_once(Template("growth/gift_manage"));
include_once(Template("footer"));
?>