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/tmpl/order_print_export.php
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

262 lines
8.6 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.
<?
//-----------------------------------------------------后台->订单打印->明细导出(分客户,不合并款号)
function get_order_by_client($u_sql){
global $table_pre,$db,$zk_type,$is_gg,$sys_gg_zd,$sys_color_zd,$child_sizegroup_id,$bx_sizegroup_id;
$check_md=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md");
$_tbody="";
//-------------------处理尺码表头
//取得合并尺码
$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]=array();
for($i=1;$i<=$num_size_total;$i++){
$j=$i-1;
$tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'");
$t=$tmp["title"]?$tmp["title"]:"";
$size_tr[$num_size_group][$j]=$t;
}
$num_size_group++;
}
//-------------------/处理尺码表头结束
$data["header"][0][]="区域|rs:".$num_size_group;
$data["header"][0][]="代理|rs:".$num_size_group;
$data["header"][0][]="客户名称|rs:".$num_size_group;
$data["header"][0][]="客户代码|rs:".$num_size_group;
$data["header"][0][]="款号|rs:".$num_size_group;
$data["header"][0][]="款式名|rs:".$num_size_group;
$colsp=6;
$data["col"][]="str";
$data["col"][]="str";
$data["col"][]="str";
$data["col"][]="str";
$data["col"][]="str";
$data["col"][]="str";
//取得定制选项
$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);
while($m=$db->fetch_array($r)){
$colsp++;
$data["col"][]="str";
$data["header"][0][]=get_cate_title_no("arr_select",$m["no"])."|rs:".$num_size_group;
}
$data["header"][0][]="圆牌号|rs:".$num_size_group;
$data["header"][0][]="颜色|rs:".$num_size_group;
$data["header"][0][]="颜色代码|rs:".$num_size_group;
$colsp=$colsp+3;
$data["col"][]="str";
$data["col"][]="str";
if(is_array($sys_color_zd)){
if(count($sys_color_zd)>0){
foreach($sys_color_zd as $k1 => $v1){
$data["header"][0][]=$v1."|rs:".$num_size_group;
$data["col"][]="str";
}
}
}
if($is_gg=="y"){
$data["header"][0][]=d_translate("gg")."|rs:".$num_size_group;
$data["header"][0][]=get_main_value($sys_gg_zd,"price")."|rs:".$num_size_group;
$colsp=$colsp+2;
$data["col"][]="str";
$data["col"][]="num";
}else if($is_gg=="b"){
$data["header"][0][]=d_translate("gg")."|rs:".$num_size_group;
$colsp=$colsp+1;
$data["col"][]="str";
}
if($bx_sizegroup_id>0){
$data["header"][0][]="杯型|rs:".$num_size_group;
$data["col"][]="str";
$colsp++;
}else if($child_sizegroup_id>0){
$data["header"][0][]="款型|rs:".$num_size_group;
$data["col"][]="str";
$colsp++;
}
//尺码
for($i=0;$i<count($size_tr[0]);$i++){
$data["header"][0][]=$size_tr[0][$i];
$data["col"][]="num";
}
$data["header"][0][]="小计|rs:".$num_size_group;
$data["header"][0][]="吊牌价|rs:".$num_size_group;
$data["header"][0][]="吊牌金额|rs:".$num_size_group;
$data["header"][0][]="折扣|rs:".$num_size_group;
$data["header"][0][]="结算金额|rs:".$num_size_group;
$data["col"][]="num";
$data["col"][]="num";
$data["col"][]="num";
$data["col"][]="num";
$data["col"][]="num";
for($i=1;$i<$num_size_group;$i++){
$data["header"][$i]=$size_tr[$i];
}
$sql_con="where ka<>'y'".$u_sql;
$q="select * from ".$table_pre."order ".$sql_con." order by uid,no,color,bx";
//echo $q."<br>";
$r=$db->query($q);
$count=0;
$total_num=$total_je=$total_jsje=0;
while($m=$db->fetch_array($r)){
$m_kh=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'");
$m_client=get_db_msg("select title,username from ".$table_pre."client where id='".$m["uid"]."'");
$arr_p=explode("-",$m_client["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=array();
for($k=0;$k<$num_size_total;$k++){
$v1="hj_num_".$k;
$num+=$m["num_".$arr_size_merged[$k]];
$td_size1[$k]=$m["num_".$arr_size_merged[$k]];
$$v1+=$m["num_".$arr_size_merged[$k]];
}
if($num>0){
$je=$m["je"];
$jsje=$m["jsje"];
$total_num+=$num;
$total_je+=$je;
$total_jsje+=$jsje;
$data["body"][$count][]=$qy;
$data["body"][$count][]=$dl;
$data["body"][$count][]=$m_client["title"];
$data["body"][$count][]=$m_client["username"];
$data["body"][$count][]=$m_kh["no"];
$data["body"][$count][]=$m_kh["title"];
//取得定制选项
$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")
$data["body"][$count][]=$m_kh[$m4["no"]];
else
$data["body"][$count][]=get_cate_title_no($m4["no"],$m_kh[$m4["no"]]);
}
$data["body"][$count][]=get_kh_xh($m_kh,$m["color"]);
$data["body"][$count][]=get_cate_title_no("color",$m["color"]);
$data["body"][$count][]=$m["color"];
if(is_array($sys_color_zd)){
if(count($sys_color_zd)>0){
$tmp=get_db_msg("select * from ".$table_pre."kh_color where iid='".$m["iid"]."' and color='".$m["color"]."'");
foreach($sys_color_zd as $k1 => $v1){
$data["body"][$count][]=$tmp[$k1];
}
}
}
if($is_gg=="y"){
//取得规格价格
$tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m["iid"]."' and color='".$m["color"]."' and gg='".$m["bx"]."'");
$data["body"][$count][]=get_gg_title($m["bx"]);
$data["body"][$count][]=$tmp["price"];
}else if($is_gg=="b"){
$data["body"][$count][]=get_gg_title($m["bx"]);
}
if($bx_sizegroup_id>0 || $child_sizegroup_id>0)
$data["body"][$count][]=$m["bx"];
for($i1=0;$i1<count($td_size1);$i1++){
$data["body"][$count][]=$td_size1[$i1];
}
$data["body"][$count][]=$num;
//if($m["size_group_id"]==$child_sizegroup_id){
////$tmp=get_db_msg("select bx from ".$table_pre."size_bx where id='".$m["bx"]."' ");
//$data["body"][$count][]="";
//}else{
//$data["body"][$count][]=deel_num($m["price"]);
//}
$data["body"][$count][]=deel_num($m["price"]);
$data["body"][$count][]=deel_num($je);
if($m["je"]>0)
$zk=deel_num(keep_float($m["jsje"]/$m["je"],1));
else
$zk="";
$data["body"][$count][]=$zk;
$data["body"][$count][]=deel_num($jsje);
$count++;
}
}
for($k=1;$k<=$colsp;$k++){
$data["body"][$count][]="";
}
$data["body"][$count][]="合计:";
for($k1=0;$k1<$num_size_total;$k1++){
$v1="hj_num_".$k1;
$data["body"][$count][]=deel_0($$v1);
}
$data["body"][$count][]=$total_num;
$data["body"][$count][]="";
$data["body"][$count][]=$total_je;
$data["body"][$count][]=$total_jsje;
$count++;
//
return $data;
}
//-------------------------------mysql connect
//文胸
if($bx_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$bx_sizegroup_title."' limit 0,1");
$bx_sizegroup_id=$tmp["id"];
}else{
$bx_sizegroup_id=0;
}
//童装
if($child_sizegroup_title){
$tmp=get_db_msg("select id from ".$table_pre."keyword where cate='size' and title='".$child_sizegroup_title."' limit 0,1");
$child_sizegroup_id=$tmp["id"];
}else{
$child_sizegroup_id=0;
}
//导出数据
$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].",";
}else{
}
}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).") ";
$file_name="detail_".date("YmdHis");
$xh_ms=get_set("xh_ms");
$data=get_order_by_client($con);
output_excel($file_name,$data);
exit;
?>