This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/pc/tmpl/order_print_export.php
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

232 lines
9.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
//-----------------------------------------------------后台->订单打印->明细导出
function get_order_by_client($u_sql){
global $table_pre,$db;
$_tbody="<html xmlns:o=\"urn:schemas-microsoft-com:office:office\"
xmlns:x=\"urn:schemas-microsoft-com:office:excel\"
xmlns=\"http://www.w3.org/TR/REC-html40\">
<head>
<meta http-equiv=Content-Type content=\"text/html; charset=utf-8\">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content=\"Microsoft Excel 11\">
<style>
<!--table
{mso-displayed-decimal-separator:\"\.\";
mso-displayed-thousand-separator:\"\,\";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;}
tr
{mso-height-source:auto;
mso-ruby-visibility:none;}
col
{mso-width-source:auto;
mso-ruby-visibility:none;}
br
{mso-data-placement:same-cell;}
.style0
{mso-number-format:General;
text-align:general;
vertical-align:middle;
white-space:nowrap;
mso-rotate:0;
mso-background-source:auto;
mso-pattern:auto;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
border:none;
mso-protection:locked visible;
mso-style-name:常规;
mso-style-id:0;}
td
{mso-style-parent:style0;
padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;
display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:Selected/>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>8640</x:WindowHeight>
<x:WindowWidth>17955</x:WindowWidth>
<x:WindowTopX>720</x:WindowTopX>
<x:WindowTopY>315</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
</head>
<body link=blue vlink=purple><table x:str border=0 cellpadding=0 cellspacing=0 style='border-collapse:
collapse;table-layout:fixed;'>";
//-------------------处理尺码表头
//取得合并尺码
$arr_size_merged=get_size_merged();
$num_size_total=count($arr_size_merged);
//取得尺码合计sql
$sql_sum_num="";
for($k=0;$k<$num_size_total;$k++){
$sql_sum_num.="sum(num_".$arr_size_merged[$k].") 'num_".$arr_size_merged[$k]."',";
}
//取得尺码表头内容
$num_size_group=0;
$size_tr=array();
$r1=$db->query("select * from ".$table_pre."keyword where cate='size' order by ord");
while($m1=$db->fetch_array($r1)){
$size_tr[$num_size_group]="";
for($i=1;$i<=$num_size_total;$i++){
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'");
$t=$tmp["title"]?$tmp["title"]:"&nbsp;";
$size_tr[$num_size_group].="<td bgcolor=\"#f0f0f0\" align=\"center\" width=\"5%\">".$t."</td>";
}
$num_size_group++;
}
//-------------------/处理尺码表头结束
$_tbody.="<tr><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">区域</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">代理</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">客户名称</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">客户代码</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">款号</td>";
//取得定制选项
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' order by ord";
$r=$db->query($q);
$num_dz=0;
while($m=$db->fetch_array($r)){
$_tbody.="<td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">".get_cate_title_no("arr_select",$m["no"])."</td>";
$num_dz++;
}
$_tbody.="<td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">单价</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">颜色</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">颜色代码</td>".$size_tr[0]."<td rowspan=\"".$num_size_group."\" align=\"center\" bgcolor=\"#f0f0f0\">小计</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">金额(元)</td></tr>";
for($i=1;$i<$num_size_group;$i++){
$_tbody.="<tr>".$size_tr[$i]."</tr>";
}
$sql_con="where ka<>'y'".$u_sql;
$q="select * from ".$table_pre."order ".$sql_con." order by uid,no,color";
//echo $q."<br>";
$r=$db->query($q);
$count=0;
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'");
$m3=get_db_msg("select * from ".$table_pre."client where id='".$m["uid"]."'");
$arr_p=explode("-",$m3["path"]);
//取得区域
$tmp=get_db_msg("select title from ".$table_pre."client where id='".$arr_p[1]."'");
$qy=$tmp["title"];
//取得代理
$tmp=get_db_msg("select title from ".$table_pre."client where id='".$arr_p[count($arr_p)-1]."'");
$dl=$tmp["title"];
$num=0;
$td_size1="";
for($k=0;$k<$num_size_total;$k++){
$num+=$m["num_".$arr_size_merged[$k]];
$td_size1.="<td bgcolor=\"".$bg."\">".$m["num_".$arr_size_merged[$k]]."</td>";
}
if($num>0){
$money=$num*$m1["price"];
$total_num+=$num;
$total_money+=$money;
$_tbody.="<tr height=\"25\"><td bgcolor=\"".$bg."\">".$qy."</td><td bgcolor=\"".$bg."\">".$dl."</td><td bgcolor=\"".$bg."\">".$m3["title"]."</td><td bgcolor=\"".$bg."\">".$m3["username"]."</td><td bgcolor=\"".$bg."\">".$m1["no"]."</td>";
//取得定制选项
$q4="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' order by ord";
$r4=$db->query($q4);
while($m4=$db->fetch_array($r4)){
if($m4["no"]=="zd1" || $m4["no"]=="zd2" || $m4["no"]=="zd3")
$_tbody.="<td bgcolor=\"".$bg."\">".$m1[$m4["no"]]."</td>";
else
$_tbody.="<td bgcolor=\"".$bg."\">".get_cate_title_no($m4["no"],$m1[$m4["no"]])."</td>";
}
$_tbody.="<td bgcolor=\"".$bg."\">".$m1["price"]."</td><td bgcolor=\"".$bg."\">".get_cate_title_no("color",$m["color"])."</td><td bgcolor=\"".$bg."\">".$m["color"]."</td>".$td_size1."<td bgcolor=\"".$bg."\" align=\"right\">".$num."</td><td bgcolor=\"".$bg."\" align=\"right\">".$money."</td></tr>";
$count++;
}
}
$_tbody.="<tr height=\"25\"><td colspan=\"".(8+$num_size_total+$num_dz)."\" align=\"right\" bgcolor=\"#f0f0f0\">合计</td><td bgcolor=\"#f0f0f0\" align=\"right\">".deel_td($total_num)."</td><td bgcolor=\"#f0f0f0\" align=\"right\">".deel_td($total_money)."</td></tr>";
$_tbody.="</table></body></html>";
return $_tbody;
}
//-------------------------------mysql connect
//导出数据
$con_u="";
if($s_username){
$s_username=str_replace("",",",$s_username);
//去掉最后一个逗号
if(substr($s_username,strlen($s_username)-1,1)==",")
$s_username1=substr($s_username,0,-1);
else
$s_username1=$s_username;
$arr_username=explode(",",$s_username1);
//去掉重复值
$arr_username=array_unique($arr_username);
for($i=0;$i<count($arr_username);$i++){
//检查是否存在
$m_client=get_db_msg("select * from ".$table_pre."client where username='".$arr_username[$i]."'");
//
if($m_client["id"]){
if($m_client["face"]=="4"){
$con_u.=" (uid='".$m_client["id"]."') or ";
if($m_client["is_checked"]!="y"){
$error_confirm.=$arr_username[$i].",";
$confirm_str.="<span style=\"color:#0000ff;\">".$arr_username[$i]."(未确认)</span>,";
}else{
$confirm_str.="<span style=\"color:#ff0000;\">".$arr_username[$i]."(已确认)</span>,";
}
}else{
$con_u.=" (upath='".$m_client["path"]."-".$m_client["id"]."' or upath like '".$m_client["path"]."-".$m_client["id"]."-%') or ";
}
}else{
$error.=$arr_username[$i].",";
}
}
}
if($con_u)
$con.=" and (".substr($con_u,0,-3).") ";
$filename="detail_".date("YmdHis").".xls";
$mime_type=ereg('MSIE ([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'])||ereg('Opera(/| )([0-9].[0-9]{1,2})',$_SERVER['HTTP_USER_AGENT'])?"application/octetstream":"application/octet-stream";
header("Content-Type:".$mime_type);
header('Content-Disposition: attachment; filename="'.$filename.'"');
$content=get_order_by_client($con);
echo $content;
?>