<?php

namespace Active\Lib;

use Dever;
Class Excel {
	#活动订单的导出
	public function out_active_order($data){
		$header = array('订单单号', '姓名', '手机号', '活动名称', '购买数量', '金额', '支付状态', '支付类型','购买时间');
        $body = array();
        foreach ($data as $k => $v){
        	$member = Dever::db('agent/member')->find($v['mid']);
        	$active = Dever::db('active/info')->find($v['active_id']);
        	$member_name = '';
        	$member_mobile = '';
        	if($member && $member['name'] && $member['mobile']){
        		$member_name = $member['name'];
        		$member_mobile = $member['mobile'];
        	}
        	$active_name = '';
        	if($active && $active['name']){
        		$active_name = $active['name'];
        	}
        	$config_status = Dever::db('active/order')->config['config_status'];
        	$status = Dever::status($config_status,$v['status']);
        	$config_pay_type = Dever::db('active/order')->config['config_pay_type'];
        	$pay_type = Dever::status($config_pay_type,$v['pay_type']);
        	$cdate = '';
        	if($v['cdate']){
        		$cdate = date('Y-m-d H:i',$v['cdate']);
        	}
        	
        	$d = array
        	(
        		$v['order_num'],
        		$member_name,
        		$member_mobile,
        		$active_name,
        		$v['num'],
        		$v['price'],
        		$status,
        		$pay_type,
        		$cdate,
        	);
        	$body[] = $d;
        }
        $file = Dever::input('excel_name');
        return Dever::excelExport($body, $header, $file);
	}
}