<?php
/**
* 商家收支统计
* @Copyright (C) 2016 汉潮 All rights reserved.
* @License http://www.hanchao9999.com
* @Author xiaogg <xiaogg@sina.cn>
*/

namespace Admin\Controller;
class BusinessController extends BaseController{
//订单统计

    public function index(){
        $type = I('type');
        $date_from = $date_to= '';
        if($type == 2){
            $riqi = 1;
        }elseif($type == 3){
            $riqi = 7;
        }elseif($type == 99){
            $riqi = -1;
            $date_from = I('date_from');
            $date_to = I('date_to');
//            if(!$date_from || !$date_to){
//                $riqi = 7;
//                $type = 7;
//                $date_from = '';$date_to = '';
//            }
        }else{
            $riqi = $type;
        }
        //订单分析开始
        $this->num_count($riqi,$date_from,$date_to);
        //订单分析结束
//        中间3个表开始
        $this->type_type($riqi,$date_from,$date_to);
//        中间3个表结束

//        订单类型统计结束

        //优惠统计开始
        $this->discount($riqi,$date_from,$date_to);
        //优惠统计结束
//        订单来源统计开始
        $this->source($riqi,$date_from,$date_to);
//        订单来源统计结束
        $this->assign('type',$type);
        $this->assign('date_from',$date_from);
        $this->assign('date_to',$date_to);
        $this->display();
    }
        /**
          *订单分析
          */
    private function num_count($riqi=7,$date_from=0,$date_to=0,$is_return=0){
        $map=$return=array();
        if($riqi == -1){
            if($date_from)$map['addtime'][] = array('egt',strtotime($date_from));
            if($date_to)$map['addtime'][] = array('lt',strtotime($date_to));

        }elseif($riqi == 1){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d'),date('Y')));
            $map['addtime'][] = array('lt',NOW_TIME);
        }elseif($riqi == 2){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-1,date('Y')));
            $map['addtime'][] = array('lt',mktime(0,0,0,date('m'),date('d'),date('Y'))-1);
        }elseif($riqi == 7){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y')));
            $map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y')));
        }elseif($riqi == 30){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),1,date('Y')));
            $map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('t'),date('Y')));
        }
        $map['pay_status']=3;
        $map['type']=array('in','11,12,13,14,6,1');
        $map['status']=3;
        $map['is_delete']=0;
        $return['order_total']=$order_total = M('OrderInfo')->where($map)->count('id');
        $return['order_amount']=$order_amount = M('OrderInfo')->where($map)->sum('order_amount');
        $youhui = M('OrderInfo')->where($map)->field("sum(first_money) as first_money,sum(bonus_money) as bonus_money,sum(discount) as act_money")->find();
        $return['discount']=$discount=array_sum($youhui);
        unset($map['status']);
        $map['status']=array('in','4,7');
        $return['order_tui']=$order_tui=M('OrderInfo')->where($map)->count('id');
        $return['tui_amount']=$tui_amount = M('OrderInfo')->where($map)->sum('order_amount');
        $this->assign('order_total',$order_total);
        $this->assign('order_amount',floatval($order_amount));
        $this->assign('order_tui',$order_tui);
        $this->assign('tui_amount',floatval($tui_amount));
        $this->assign('discount',floatval($discount));
        if($is_return == 1){
            return $return;
        }

    }
    private function type_type($riqi=7,$date_from=0,$date_to=0,$is_return=0){

        //支付方式统计
        $return=$map=$list=$map_t= array();
        if($riqi == -1){
            if($date_from)$map_t['addtime'][]=$map['addtime'][] = array('egt',strtotime($date_from));
            if($date_to)$map_t['addtime'][]=$map['addtime'][] = array('lt',strtotime($date_to));

        }elseif($riqi == 1){
            $map_t['addtime'][]=$map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d'),date('Y')));
            $map_t['addtime'][]=$map['addtime'][] = array('lt',NOW_TIME);
        }elseif($riqi == 2){
            $map_t['addtime'][]=$map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-1,date('Y')));
            $map_t['addtime'][]=$map['addtime'][] = array('lt',mktime(0,0,0,date('m'),date('d'),date('Y'))-1);
        }elseif($riqi == 7){
            $map_t['addtime'][]=$map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y')));
            $map_t['addtime'][]=$map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y')));
        }elseif($riqi == 30){
            $map_t['addtime'][]=$map['addtime'][] = array('egt',(NOW_TIME-30*24*3600));
            $map_t['addtime'][]=$map['addtime'][] = array('lt',NOW_TIME);
        }

        $map['type'] = array('in','1,6,11,12,13,14');
        $map['pay_status'] = 3;
        $map['status'] = 3;
        $map['is_delete']=0;

        $map['pay_code'] = 'weixinpay';
        $return['paytype'][]='总计';
        $weixin = M('OrderInfo')->where($map)->field("shop_id,sum(pay_amount) as allmoney")->group('shop_id')->select();
        $pay_weixin=$pay_alipay=$pay_scanalipay=$pay_scanalipay=$pay_wxs=$pay_hanchao=0;
        foreach($weixin as $v){
            $list[$v['shop_id']]['weixin']=$v['allmoney'];
            $pay_weixin += $v['allmoney'];
        }unset($v);
        $return['paytype'][]=$pay_weixin;
        unset($map['pay_code']);
        $map['pay_code'] = array('in','alipay,Alipayapi,Alibarpay');
        $alipay= M('OrderInfo')->where($map)->field("shop_id,sum(pay_amount) as allmoney")->group('shop_id')->select();
        foreach($alipay as $v){
            $list[$v['shop_id']]['alipay']=$v['allmoney'];
            $pay_alipay += $v['allmoney'];
        }unset($v);

        $return['paytype'][]=$pay_alipay;

        unset($map['pay_code']);
        $map['pay_code'] = array('in',"'',Hanchao");
        $hanchao= M('OrderInfo')->where($map)->field("shop_id,sum(pay_amount) as allmoney")->group('shop_id')->select();

        foreach($hanchao as $v){
            $list[$v['shop_id']]['hanchao']=round($v['allmoney'],2);
            $pay_hanchao += $v['allmoney'];
        }unset($v);
        $return['paytype'][]=$pay_hanchao;
        unset($map['pay_code']);
        $map['pay_code'] = 'scanalipay';
        $scanalipay= M('OrderInfo')->where($map)->field("shop_id,sum(pay_amount) as allmoney")->group('shop_id')->select();
        foreach($scanalipay as $v){
            $list[$v['shop_id']]['scanalipay']=$v['allmoney'];
            $pay_scanalipay += $v['allmoney'];
        }unset($v);

        $return['paytype'][]=$pay_scanalipay;
        unset($map['pay_code']);
        $map['pay_code'] = 'weixinsmall';
        $weixinsmall= M('OrderInfo')->where($map)->field("shop_id,sum(pay_amount) as allmoney")->group('shop_id')->select();
        foreach($weixinsmall as $v){
            $list[$v['shop_id']]['weixinsmall']=floatval($v['allmoney'],2);
            $pay_wxs += $v['allmoney'];
        }unset($v);
        $return['paytype'][]=$pay_wxs;
        $return['list']=$list;

        $this->assign('list',$list);
        $this->assign('pay_weixin',$pay_weixin);
        $this->assign('pay_alipay',$pay_alipay);
        $this->assign('pay_scanalipay',$pay_scanalipay);
        $this->assign('pay_wxs',$pay_wxs);
        $this->assign('pay_hanchao',$pay_hanchao);
//        支付方式统计结束

//        退款方式统计开始
        $map_t['rg.status']=1;
        $tui_list=array();
        $tui_wein=$tui_alipay=$tui_hanchao=$tui_scanalipay=$tui_wxs=0;
        $map_t['oi.pay_code'] = 'weixinpay';
        $weixin = M('RefundOrder')->alias('rg')->JOIN('__ORDER_INFO__ oi on rg.order_id = oi.id')->where($map_t)->field("oi.shop_id,sum(rg.refund_web) as allmoney")->group('oi.shop_id')->select();
        $return['tui_pay'][]='总计';
        foreach($weixin as $v){
            $tui_list[$v['shop_id']]['weixin']=$v['allmoney'];
            $tui_wein+=$v['allmoney'];
        }unset($v);
        $return['tui_pay'][]=$tui_wein;

        unset($map_t['oi.pay_code']);
        $map_t['oi.pay_code'] = array('in','alipay,Alipayapi,Alibarpay');
        $alipay= M('RefundOrder')->alias('rg')->JOIN('__ORDER_INFO__ oi on rg.order_id = oi.id')->where($map_t)->field("oi.shop_id,sum(rg.refund_web) as allmoney")->group('oi.shop_id')->select();
        foreach($alipay as $v){
            $tui_list[$v['shop_id']]['alipay']=$v['allmoney'];
            $tui_alipay+=$v['allmoney'];
        }unset($v);
        $return['tui_pay'][]=$tui_alipay;

        unset($map_t['oi.pay_code']);
        $map_t['oi.pay_code'] = array('in',"'',Hanchao");
        $hanchao= M('RefundOrder')->alias('rg')->JOIN('__ORDER_INFO__ oi on rg.order_id = oi.id')->where($map_t)->field("oi.shop_id,sum(rg.refund_money) as allmoney")->group('oi.shop_id')->select();

        foreach($hanchao as $v){
            $tui_list[$v['shop_id']]['hanchao']=number_format($v['allmoney'],2);
            $tui_hanchao+=$v['allmoney'];
        }unset($v);

        $return['tui_pay'][]=$tui_hanchao;

        unset($map_t['oi.pay_code']);
        $map_t['oi.pay_code'] = 'scanalipay';
        $scanalipay= M('RefundOrder')->alias('rg')->JOIN('__ORDER_INFO__ oi on rg.order_id = oi.id')->where($map_t)->field("oi.shop_id,sum(rg.refund_web) as allmoney")->group('oi.shop_id')->select();
        foreach($scanalipay as $v){
            $tui_list[$v['shop_id']]['scanalipay']=$v['allmoney'];
            $tui_scanalipay+=$v['allmoney'];
        }unset($v);

        $return['tui_pay'][]=$tui_scanalipay;
        unset($map_t['oi.pay_code']);
        $map_t['oi.pay_code'] = 'weixinsmall';
        $weixinsmall= M('RefundOrder')->alias('rg')->JOIN('__ORDER_INFO__ oi on rg.order_id = oi.id')->where($map_t)->field("oi.shop_id,sum(rg.refund_web) as allmoney")->group('oi.shop_id')->select();
        foreach($weixinsmall as $v){
            $tui_list[$v['shop_id']]['weixinsmall']=number_format($v['allmoney'],2);
            $tui_wxs+=$v['allmoney'];
        }unset($v);
        $return['tui_list']=$tui_list;
        $return['tui_pay'][]=$tui_wxs;
        $this->assign('tui_list',$tui_list);
        $this->assign('tui_wein',$tui_wein);
        $this->assign('tui_alipay',$tui_alipay);
        $this->assign('tui_scanalipay',$tui_scanalipay);
        $this->assign('tui_wxs',$tui_wxs);
        $this->assign('tui_hanchao',$tui_hanchao);

//        退款方式统计结束


//        订单类型统计开始
        unset($map['status']);
        $map['status']=3;
        unset($map['pay_code']);
        unset($map['type']);
        $map['type'] = array('in','6,13,14');
        $type_list=array();
        $goodslist = M('OrderInfo')->where($map)->field("shop_id,sum(goods_allmoney) as goods_allmoney,count(id) as num")->group('shop_id')->select();
        $goodsnum=$goods_allmoney=$chongnum=$chongmoney=0;
        $return['type_zong'][]='总计';
        foreach($goodslist as $v){
            $type_list[$v['shop_id']]['goodsnum']=$v['num'];
            $type_list[$v['shop_id']]['goods_allmoney']=$v['goods_allmoney'];
            $goodsnum+=$v['num'];
            $goods_allmoney+=$v['goods_allmoney'];
        }unset($v);
        $return['type_zong'][]=$goodsnum;
        $return['type_zong'][]=$goods_allmoney;
        unset($map['type']);
        $map['type'] = array('in','2,5');
        $chongzhilist = M('OrderInfo')->where($map)->field("shop_id,sum(order_amount) as money,count(id) as num")->group('shop_id')->select();

        foreach($chongzhilist as $v){
            $type_list[$v['shop_id']]['chongnum']=$v['num'];
            $type_list[$v['shop_id']]['chongmoney']=$v['money'];
            $chongnum+=$v['num'];
            $chongmoney+=$v['goods_allmoney'];
        }unset($v);
        $return['type_zong'][]=$chongnum;
        $return['type_zong'][]=$chongmoney;
        $return['type_list']=$type_list;

        if($is_return==1){
            return $return;
        }
        $this->assign('type_list',$type_list);
        $this->assign('goodsnum',$goodsnum);
        $this->assign('goods_allmoney',$goods_allmoney);
        $this->assign('chongnum',$chongnum);
        $this->assign('chongmoney',$chongmoney);
    }

    private function discount($riqi=7,$date_from=0,$date_to=0,$is_return=0){
        $map=array();
        if($riqi == -1){
            if($date_from)$map['addtime'][] = array('egt',strtotime($date_from));
            if($date_to)$map['addtime'][] = array('lt',strtotime($date_to));

        }elseif($riqi == 1){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d'),date('Y')));
            $map['addtime'][] = array('lt',NOW_TIME);
        }elseif($riqi == 2){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-1,date('Y')));
            $map['addtime'][] = array('lt',mktime(0,0,0,date('m'),date('d'),date('Y'))-1);
        }elseif($riqi == 7){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y')));
            $map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y')));
        }elseif($riqi == 30){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),1,date('Y')));
            $map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('t'),date('Y')));
        }

        $map['status']=3;
        $map['pay_status']=3;
        $map['is_delete']=0;
        $map['type']=array('in','11,12,13,14,1,6');
        $youhui_dis = M('OrderInfo')->where($map)->field("sum(first_money) as first_money,sum(bonus_money) as bonus_money,sum(discount) as act_money,sum(used_score_money) as score_money")->find();
        $zongji = array_sum($youhui_dis);
        $this->assign($youhui_dis);
        $this->assign('zongji',number_format($zongji,2));
        if($is_return == 1){


            return $youhui_dis;
        }
    }
    public function source($riqi=7,$date_from=0,$date_to=0,$is_return=0){
        $return=$map=array();
        if($riqi == -1){
            if($date_from)$map['addtime'][] = array('egt',strtotime($date_from));
            if($date_to)$map['addtime'][] = array('lt',strtotime($date_to));

        }elseif($riqi == 1){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d'),date('Y')));
            $map['addtime'][] = array('lt',NOW_TIME);
        }elseif($riqi == 2){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-1,date('Y')));
            $map['addtime'][] = array('lt',mktime(0,0,0,date('m'),date('d'),date('Y'))-1);
        }elseif($riqi == 7){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),date('d')-date('w')+1-7,date('Y')));
            $map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('d')-date('w')+7-7,date('Y')));
        }elseif($riqi == 30){
            $map['addtime'][] = array('egt',mktime(0,0,0,date('m'),1,date('Y')));
            $map['addtime'][] = array('lt',mktime(23,59,59,date('m'),date('t'),date('Y')));
        }
        $map['pay_status']=3;
        $map['type']=array('in','11,12,13,14,6,1');
        $map['status']=3;
        $map['is_delete']=0;
        $map['source']=1;
        $source_wexin = M('OrderInfo')->where($map)->field('count(id) as wexin_num,sum(order_amount) as wexin_amount')->find();
        $return['num'][]=$source_wexin['wexin_num']?$source_wexin['wexin_num']:0;
        $return['amount'][]=$source_wexin['wexin_amount']?$source_wexin['wexin_amount']:0;
        $this->assign($source_wexin);
        unset($map['source']);
        $map['source']=3;
        $source_wxs = M('OrderInfo')->where($map)->field('count(id) as wxs_num,sum(order_amount) as wxs_amount')->find();
        $return['num'][]=$source_wxs['wxs_num']?$source_wxs['wxs_num']:0;
        $return['amount'][]=$source_wxs['wxs_amount']?$source_wxs['wxs_amount']:0;
        $this->assign($source_wxs);
        unset($map['source']);
        $map['in_online']=1;
        $source_xs = M('OrderInfo')->where($map)->field('count(id) as xs_num,sum(order_amount) as xs_amount')->find();
        $this->assign($source_xs);
        $return['num'][]=$source_xs['xs_num']?$source_xs['xs_num']:0;
        $return['amount'][]=$source_xs['xs_amount']?$source_xs['xs_amount']:0;
        if($is_return==1){
            return $return;
        }

    }
    public function tong_detail_export(){
        $null = array();
        $postdata=I('param.');
		if($postdata){
            $type = $postdata['type'];
            $date_from = $date_to= '';
            if($type == 2){
                $riqi = 1;
            }elseif($type == 3){
                $riqi = 7;
            }elseif($type == 99){
                $riqi = -1;
                $date_from = I('date_from');
                $date_to = I('date_to');
//                if(!$date_from || !$date_to){
//                    $riqi = 7;
//                    $type = 7;
//                    $date_from = '';$date_to = '';
//                }
            }else{
                $riqi = $type;
            }
            //表一开始（订单分析）
            $one_count = $this->num_count($riqi,$date_from,$date_to,1);
            $one_title=array('订单总数','实收总额','退款订单总数','退款总额','优惠总额');
            $one_cont[0] = array($one_count['order_total'],$one_count['order_amount'],$one_count['order_tui'],$one_count['tui_amount'],$one_count['discount']);
            $title_name = array('订单分析');
            export_xls($title_name,$null,'utf8');
            export_xls($one_title,$one_cont,'utf8');
            export_xls(array(),$null,'utf8');
            //表一结束
            //表二开始（会员来源分析）
            $two_count = $this->type_type($riqi,$date_from,$date_to,1);
            $two_title=array('仓库','微信','支付宝','余额','双乾支付','微信小程序支付');
            $list1=array();
            $i=0;
            foreach($two_count['list'] as $k=>$v){
                $i++;
                $shop_name=idtoname($k,'Shops','name','id',false);
                $list[$i]['shop_name']=$shop_name;
                if($v['weixin']){
                    $list[$i]['weixin']=$v['weixin'];
                }else{
                    $list[$i]['weixin']=0.00;
                }

                if($v['alipay']){
                    $list[$i]['alipay']=$v['alipay'];
                }else{
                    $list[$i]['alipay']=0.00;
                }
                if($v['hanchao']){
                    $list[$i]['hanchao']=$v['hanchao'];
                }else{
                    $list[$i]['hanchao']=0.00;
                }
                if($v['scanalipay']){
                    $list[$i]['scanalipay']=$v['scanalipay'];
                }else{
                    $list[$i]['scanalipay']=0.00;
                }
                if($v['weixinsmall']){
                    $list[$i]['weixinsmall']=$v['weixinsmall'];
                }else{
                    $list[$i]['weixinsmall']=0.00;
                }
            }unset($k,$v);

            $title_name = array('支付方式统计');
            export_xls($title_name,$null,'utf8');
            export_xls($two_title,$list,'utf8');
            export_xls($two_count['paytype'],$null,'utf8');
            export_xls(array(),$null,'utf8');
            //表二结束
            //表三开始（退款方式统计）
            $i=0;
            $list3=array();
            foreach($two_count['tui_list'] as $k=>$v){
                $i++;
                $shop_name=idtoname($k,'Shops','name','id',false);
                $list3[$i]['shop_name']=$shop_name;
                if($v['weixin']){
                    $list3[$i]['weixin']=$v['weixin'];
                }else{
                    $list3[$i]['weixin']=0.00;
                }

                if($v['alipay']){
                    $list3[$i]['alipay']=$v['alipay'];
                }else{
                    $list3[$i]['alipay']=0.00;
                }
                if($v['hanchao']){
                    $list3[$i]['hanchao']=$v['hanchao'];
                }else{
                    $list3[$i]['hanchao']=0.00;
                }
                if($v['scanalipay']){
                    $list3[$i]['scanalipay']=$v['scanalipay'];
                }else{
                    $list3[$i]['scanalipay']=0.00;
                }
                if($v['weixinsmall']){
                    $list3[$i]['weixinsmall']=$v['weixinsmall'];
                }else{
                    $list3[$i]['weixinsmall']=0.00;
                }
            }unset($k,$v);

            $title_name = array('退款方式统计');
            export_xls($title_name,$null,'utf8');
            export_xls($two_title,$list3,'utf8');
            export_xls($two_count['tui_pay'],$null,'utf8');
            export_xls(array(),$null,'utf8');
            //表三结束
            //表四开始（订单类型统计）

            $four_title=array("仓库	商品订单数","商品消费金额","充值次数","充值金额");
            $i=0;
            $list4=array();
            foreach($two_count['type_list'] as $k=>$v){
                $i++;
                $shop_name=idtoname($k,'Shops','name','id',false);
                $list4[$i]['shop_name']=$shop_name;
                if($v['goodsnum']){
                    $list4[$i]['goodsnum']=$v['goodsnum'];
                }else{
                    $list4[$i]['goodsnum']=0.00;
                }

                if($v['goods_allmoney']){
                    $list4[$i]['goods_allmoney']=$v['goods_allmoney'];
                }else{
                    $list4[$i]['goods_allmoney']=0.00;
                }
                if($v['chongnum']){
                    $list4[$i]['chongnum']=$v['chongnum'];
                }else{
                    $list4[$i]['chongnum']=0.00;
                }
                if($v['chongmoney']){
                    $list4[$i]['chongmoney']=$v['chongmoney'];
                }else{
                    $list4[$i]['chongmoney']=0.00;
                }
            }
            $title_name = array('订单类型统计');
            export_xls($title_name,$null,'utf8');
            export_xls($four_title,$list4,'utf8');
            export_xls($two_count['type_zong'],$null,'utf8');
            export_xls(array(),$null,'utf8');
            //表四结束
            //表五开始（优惠统计）
            $youhui_dis=$this->discount($riqi,$date_from,$date_to,1);


            $five_title=array('等级折扣','积分低现','优惠券','新用户下单立减','优惠活动','总计');

            $return=array();
            $zongji=array_sum($youhui_dis);
            $member_discount=$youhui_dis['member_discount']?$youhui_dis['member_discount']:0.00;
            $score_money=$youhui_dis['score_money']?$youhui_dis['score_money']:0.00;
            $bonus_money=$youhui_dis['bonus_money']?$youhui_dis['bonus_money']:0.00;
            $first_money=$youhui_dis['first_money']?$youhui_dis['first_money']:0.00;
            $act_money=$youhui_dis['act_money']?$youhui_dis['act_money']:0.00;
            $zongji=$zongji?$zongji:0.00;
            $five_count[0]=array($member_discount,$score_money,$bonus_money,$first_money,$act_money,$zongji);




            $title_name = array('优惠统计');
            export_xls($title_name,$null,'utf8');
            export_xls($five_title,$five_count,'utf8');
            export_xls(array(),$null,'utf8');
            //表6开始
            $data=$this->source($riqi,$date_from,$date_to,1);
            $source_num[0]=$data['num'];
            //表六结束
			$title=array('微信公众号','小程序','到店消费');
            $title_name = array('订单来源统计');
            export_xls($title_name,$null,'utf8');
			export_xls($title,$source_num,'utf8');
            export_xls($data['amount'],$null,'utf8');
            export_xls(array(),$null,'utf8');
			unset($title,$data);exit;
        }
    }
}
?>