// 导出订单 if(isset($_POST['export'])){ // 统计金额 $sl = "SELECT SUM(goods_amount) as total from".$ecs->table('depot_order')." where order_id in($order_id)"; $total = $db->getRow($sl); //print_r($total);exit; // 商品关联订单 $sql = "SELECT o.order_sn,g.goods_name,g.goods_price,g.goods_number,(g.goods_number*g.goods_price) as goods_total FROM ".$ecs->table('depot_order')." AS o,".$ecs->table('depot_goods')." AS g where g.order_id = o.order_id and o.order_id in($order_id)"; $result = $db->getAll($sql); //表格格式 $file_name = '微仓订单'; header("Content-type: application/vnd.ms-excel; charset=utf-8"); header("Content-Disposition: attachment; filename=$file_name.xls"); /* 文件标题 */ // echo ecs_iconv(EC_CHARSET, 'GB2312', $_REQUEST['start_date']. $_LANG['to'] .$_REQUEST['end_date']. $_LANG['sales_list']) . " "; /* 商品名称,订单号,商品数量,销售价格,销售日期 */ echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['goods_name']) . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_sn']) . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', '数量') . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', '商品单价') . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', '商品总价') . " "; echo " "; foreach ($result AS $key => $value) { echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_name']) . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', $value['order_sn'] ) . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_number']) . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_price']) . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_total']) . " "; echo " "; } echo " "; echo ecs_iconv(EC_CHARSET, 'GB2312', '统计') . " "; echo ecs_iconv(EC_CHARSET, 'GB2312', $total['total']) . " "; exit; }