用于导出
订单
详情,打印该订单的
商品
列表和商品
属性,以下
代码提供大部分框架,如对EXCEL有特殊要求,请自行修改定制EXCEL格式
1, 修改 admin\templates\order_info.htm
在这个位置下增加一行:
复制代码
2.新建 文件放于 admin 目录下,文件名为excel_export.php, 内容如下:
复制代码
1, 修改 admin\templates\order_info.htm
在这个位置下增加一行:
- <input type="button" οnclick="window.open('order.php?act=info&order_id={$order.order_id}&print=1')" class="button" value="{$lang.print_order}" />
- <input type="button" οnclick="window.open('excel_export.php?order_id={$order.order_id}')" class="button" value="导出EXCEL" />
2.新建 文件放于 admin 目录下,文件名为excel_export.php, 内容如下:
-
- <?php
- define('IN_ECS', true);
- include ('includes/init.php');
- $filename='excel_export';
- header("Content-type: application/vnd.ms-excel; charset=gbk");
- header("Content-Disposition: attachment; filename=$filename.xls");
- $order_id = intval($_REQUEST['order_id']);
- $sql="select gt.goods_thumb, g.goods_name, g.goods_sn, g.goods_price, g.goods_number, (g.goods_price*g.goods_number) as num_price, g.goods_attr from ecs_goods gt, ecs_order_info i, ecs_order_goods g where g.order_id=i.order_id and gt.goods_id = g.goods_id and i.order_id = '$order_id'";
-
- $res=$db->getAll($sql);
- $data1.='商品图片'."\t";
- $data1.='商品名称'."\t";
- $data1.='商品编号'."\t";
- $data1.='商品单价'."\t";
- $data1.='商品数量'."\t";
- $data1.='小计价格'."\t";
- $data1.='属性备注'."\t\n";
- while (!empty($res))
- {
- foreach ($res as $key=>$var)
- {
- $a=$var['goods_sn'];
- foreach ($res as $keys=>$vars)
- {
- if($a==$vars['goods_sn'])
- {
- $res1[$key]['goods_thumb']=$vars['goods_thumb'];
- $res1[$key]['goods']=$vars['goods_name'];
- $res1[$key]['goods_sn']=$vars['goods_sn'];
- $res1[$key]['goods_price']=$vars['goods_price'];
- $res1[$key]['goods_number']=$vars['goods_number'];
- $res1[$key]['num_price']=$vars['num_price'];
- $res1[$key]['goods_attr']=$vars['goods_attr'];
- unset ($res[$keys]);
- }
- }
- }
- }
- foreach ($res1 as $key =>$var)
- {
- $data.=$var['goods_thumb']."\t";
- $data.=$var['goods']."\t";
- $data.=$var['goods_sn']."\t";
- $data.=$var['goods_price']."\t";
- $data.=$var['goods_number']."\t";
- $data.=$var['num_price']."\t";
- $data.=$var['goods_attr']."\t";
- $data.="\t\n";
- }
- if (EC_CHARSET != 'gbk')
- {
- echo $data1.ecs_iconv(EC_CHARSET, 'gbk', $data) . "\t";
- }
- else
- {
- echo $data1.$data. "\t";
- }
- ?>