<?php
/**
* 积分兑换后台处理操作
* @author moufer<moufer@163.com>
* @copyright www.modoer.com
* @version $Id gifts.inc.php 1 2008-2-23 20:57 $
*/
(!defined('IN_ADMIN') || !defined('IN_MUDDER')) && exit('Access Denied');

if(!$dosubmit) {

    $arr_status = array('1' => '申请中', '2'=>'处理中', '3' => '已发货', '4' => '已退款');

    $status = array_key_exists($status, $arr_status) ? $status : '1';
    $total = $db->get_value("SELECT COUNT(*) FROM {$dbpre}exchange WHERE status='$status' ORDER BY exchangetime");
    if($total > 0) {
        $offset = 20;
        $limit = get_limit($page, $offset);
        $query = $db->query("SELECT a.*,b.username FROM {$dbpre}exchange a LEFT JOIN {$dbpre}members b ON(a.uid=b.uid) WHERE a.status='$status' ORDER BY exchangetime LIMIT $limit");
        while($gift = $db->fetch_array($query)) {
            $gift['status_name'] = $arr_status[$gift['status']];
            $gift['exchangetime'] = date('Y-m-d H:i:s', $gift['exchangetime']);
            $gift['totalprice'] = $gift['price'] * $gift['number'];
            $gifts[] = $gift;
        }
        $multipage = multi($total, $offset, $page, 'admincp.php?action=exchange&status='.$suatus);
    }

    include cptpl('list', MOD_ROOT.'./admin/templates/');

} else {

    cpmsg('未定义操作。');

}
?>
