"; //-------------------处理尺码表头 //取得合并尺码 $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"]:" "; $size_tr[$num_size_group].=""; } $num_size_group++; } //-------------------/处理尺码表头结束 $_tbody.=""; if($xh_ms=="1") $_tbody.=""; $_tbody.=""; $_tbody.=""; //取得定制选项 $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.=""; $arr_zd[$m["no"]]=$m["title"]; $num_dz++; } if($is_gg!="y") $_tbody.=""; if($xh_ms=="2") $_tbody.=""; $_tbody.=""; if($bx_sizegroup_id>0) $_tbody.=""; else if($child_sizegroup_id>0) $_tbody.=""; if($is_gg=="y") $_tbody.=""; else if($is_gg=="b") $_tbody.=""; $_tbody.=$size_tr[0].""; if(trim($zk_type) || $check_md["num"]>0) $_tbody.=""; $_tbody.=""; for($i=1;$i<$num_size_group;$i++){ $_tbody.="".$size_tr[$i].""; } $sql_con="where (upath='".$upath."' or upath like '".$upath."-%') and ka<>'y'"; if($show_wd=="n"){ //-------不显示未订款 $q="select iid,no,price from ".$table_pre."order ".$sql_con." group by no order by bc,no"; //echo $q."
"; $r=$db->query($q); $total_num=$total_money=$total_money_zk=0; $count=0; $arr_kh=$arr_kh_color=array(); while($m=$db->fetch_array($r)){ $bg=($count%2)?"#ffffff":"#f0f0f0"; $m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'"); $price_zk=get_price_zk($m1["id"],$m_client["id"]); //取得颜色,杯型 $q2="select iid,color,bx,".get_size_sql("sum1").",sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',price from ".$table_pre."order ".$sql_con." and no='".$m["no"]."' group by color,bx order by color,bx"; //echo $q2."
"; $r2=$db->query($q2); // $j=0; $je1=$jsje1=$num1=0; while($m2=$db->fetch_array($r2)){ $td_size1=""; for($k=0;$k<$num_size_total;$k++){ $tmp_num=$m2["num_".$arr_size_merged[$k]]; //计算尺码合计 $v11="hj_num_".$k; $$v11+=$tmp_num; // $td_size1.=""; } if($m2["num"]>0){ $arr_kh_color[$count][$j]=""; if($xh_ms=="2") $arr_kh_color[$count][$j]=""; $arr_kh_color[$count][$j].=""; //if($bx_sizegroup_id>0) if($bx_sizegroup_id>0 || $child_sizegroup_id>0) $arr_kh_color[$count][$j].=""; if($is_gg=="y"){ //取得规格价格 $tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m2["iid"]."' and color='".$m2["color"]."' and gg='".$m2["bx"]."'"); $arr_kh_color[$count][$j].=""; }else if($is_gg=="b"){ $arr_kh_color[$count][$j].=""; } $arr_kh_color[$count][$j].=$td_size1; $j++; } $num1+=$m2["num"]; $je1+=$m2["je"]; $jsje1+=$m2["jsje"]; } $total_num+=$num1; $total_money+=$je1; $total_money_zk+=$jsje1; // if($num1>0){ $arr_kh[$count]["id"]=$m1["id"]; $arr_kh[$count]["no"]=$m1["no"]; $arr_kh[$count]["title"]=$m1["title"]; if($xh_ms=="1"){ $xh=get_kh_xh($m1); $arr_kh[$count]["xh"]=$xh; } $arr_kh[$count]["title"]=$m1["title"]; foreach($arr_zd as $k1 => $v1){ if($k1!="zd1" && $k1!="zd2" && $k1!="zd3") $arr_kh[$count][$k1]=get_cate_title_no($k1,$m1[$k1]); else $arr_kh[$count][$k1]=$m1[$k1]; } $arr_kh[$count]["num"]=$num1; $arr_kh[$count]["price"]=$m["price"]; $arr_kh[$count]["je"]=$je1; $arr_kh[$count]["jsje"]=$jsje1; $count++; } } //组合输出内容 $count=0; for($i=0;$i $v1){ $tmp_zd.=""; } $_tbody.=""; if($xh_ms=="1") $_tbody.=""; $_tbody.="".$tmp_zd; if($is_gg!="y") $_tbody.=""; $_tbody.=$arr_kh_color[$i][$j].""; if(trim($zk_type) || $check_md["num"]>0) $_tbody.=""; $_tbody.=""; }else{ $_tbody.="".$arr_kh_color[$i][$j].""; } $count++; } } }else{ //-------显示未订款,不合并款号 //取得订单表数据 $arr_order=array(); $q="select iid,color,bx,jsje/num 'price',sum(num) 'num',".get_size_sql("sum1").",sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order ".$sql_con." group by iid,color,bx"; //echo $q."
"; $r=$db->query($q); $total_num=$total_money=$total_money_zk=0; $count=0; $arr_kh=$arr_kh_color=array(); while($m=$db->fetch_array($r)){ $arr_order[$m["iid"]][$m["color"]][$m["bx"]]=$m; } // //print_r($arr_order); // $arr_data=array(); $q="select id,no,color,color_ka,size from ".$table_pre."kh where ka<>'y' order by no"; $r=$db->query($q); $i=0; $count=0; while($m=$db->fetch_array($r)){ //取得bx,size $arr_bx_size=array(); $check_bx=get_db_msg("select count(*) 'num' from ".$table_pre."size_bx where no='".$m["no"]."'"); if($check_bx["num"]>0){ $q1="select no,bx,size from ".$table_pre."size_bx where no='".$m["no"]."'"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_bx_size[$m1["bx"]]=$m1["size"]; } }else{ $arr_bx_size[""]=$m["size"]; } $arr_color=explode(",",$m["color"]); $arr_color_ka=explode(",",$m["color_ka"]); for($j=0;$j $size1){ $arr_data[$count]["iid"]=$m["id"]; $arr_data[$count]["color"]=$arr_color[$j]; $arr_data[$count]["bx"]=$bx1; $arr_size1=explode(",",$size1); for($k=0;$k"; $tmp_zd=""; foreach($arr_zd as $k1 => $v1){ if($k1!="zd1" && $k1!="zd2" && $k1!="zd3") $tmp1=get_cate_title_no($k1,$msg_kh[$k1]); else $tmp1=$msg_kh[$k1]; $tmp_zd.=""; } $_tbody.="".$tmp_zd; if($is_gg!="y") $_tbody.=""; $_tbody.=""; $_tbody.=""; if($bx_sizegroup_id>0) $arr_kh_color[$count][$j].=""; if($is_gg=="y"){ //取得规格价格 $tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$arr_data[$i]["iid"]."' and color='".$arr_data[$i]["color"]."' and gg='".$arr_data[$i]["bx"]."'"); $_tbody.=""; }else if($is_gg=="b"){ $arr_kh_color[$count][$j].=""; } if($bx_sizegroup_id>0 || $child_sizegroup_id>0) $_tbody.=""; //尺码 for($k=0;$k<$num_size_total;$k++){ $v1="hj_num_".$k; $$v1+=$arr_data[$i]["num_".$arr_size_merged[$k]]; $_tbody.=""; } $_tbody.=""; $_tbody.=""; if(trim($zk_type) || $check_md["num"]>0) $_tbody.=""; $_tbody.=""; $total_num+=$arr_data[$i]["num"]; $total_money+=$arr_data[$i]["je"]; $total_money_zk+=$arr_data[$i]["jsje"]; } } $tmp_zd_je=""; if(trim($zk_type) || $check_md["num"]>0){ $tmp_zd_je.=""; } $td_size1=""; for($k=0;$k<$num_size_total;$k++){ $v1="hj_num_".$k; $td_size1.=""; } if($bx_sizegroup_id>0 || $child_sizegroup_id>0) $colspan1=count($arr_zd)+7; else $colspan1=count($arr_zd)+6; if($is_gg=="y") $colspan1++; else if($is_gg=="b") $colspan1++; $_tbody.="".$td_size1."".$tmp_zd_je.""; $_tbody.="
".$t."
序号款号款式名".get_cate_title_no("arr_select",$m["no"])."吊牌价序号颜色名称颜色代码杯型款型".d_translate("gg")."".get_main_value($sys_gg_zd,"price")."".d_translate("gg")."小计吊牌金额结算金额
".deel_td(deel_0($tmp_num))."".get_kh_xh($m1,$m2["color"])."".get_cate_title_no("color",$m2["color"])."".$m2["color"]."".deel_td($m2["bx"])."".deel_td(get_gg_title($m2["bx"]))."".deel_td($tmp["price"])."".deel_td(get_gg_title($m2["bx"]))."".deel_td($arr_kh[$i][$k1])."
".$arr_kh[$i]["xh"]."".$arr_kh[$i]["no"]."".$arr_kh[$i]["title"]."".$arr_kh[$i]["price"]."".$arr_kh[$i]["num"]."".deel_num($arr_kh[$i]["je"])."".deel_num($arr_kh[$i]["jsje"])."
".deel_td($tmp1)."".$msg_kh["no"]."".$msg_kh["title"]."".deel_num(keep_float($arr_data[$i]["price"],1))."".get_cate_title_no("color",$arr_data[$i]["color"])."".$arr_data[$i]["color"]."".deel_td($m2["bx"])."".deel_td(get_gg_title($arr_data[$i]["bx"]))."".deel_td($tmp["price"])."".deel_td(get_gg_title($arr_data[$i]["bx"]))."".$m["bx"]."".deel_0(deel_num($arr_data[$i]["num_".$arr_size_merged[$k]]))."".deel_0(deel_num($arr_data[$i]["num"]))."".deel_0(deel_num($arr_data[$i]["je"]))."".deel_num($arr_data[$i]["jsje"])."
".$total_money."".keep_float($total_money_zk,2)."".deel_td($$v1)."
合计".$total_num."
"; return $_tbody; } require "../config.php"; include "../../tmpl/config.php"; require THIS_FILE_ROOT."/include/function.php"; require THIS_FILE_ROOT."/include/db_mysql.php"; //require THIS_FILE_ROOT."/include/page.class.php"; error_reporting(E_ERROR | E_WARNING | E_PARSE); header("Content-type: text/html; charset=utf-8"); //-------------------------------mysql connect $db=new DB_Sql; $db->connect($dbhost,$dbuser,$dbpw,$dbname,"p"); $sub=$_GET["sub"]; $id=$_GET["id"]; $list=$_GET["list"]?$_GET["list"]:1; $is_dir=$_GET["is_dir"]?$_GET["is_dir"]:"n"; $show_wd=$_GET["show_wd"]?$_GET["show_wd"]:"n"; if($sub=="y"){ // $xh_ms=get_set("xh_ms"); $check_md=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md"); //文胸 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; } $zk_type=get_set("zk_type"); // $sys_size_num=get_max_size_num(); $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face>'2'"); $total=$tmp["num"]; if(!$id){ // $tmp=get_db_msg("select min(id) 'id' from ".$table_pre."client where face>'2'"); $this_id=$tmp["id"]; }else{ $tmp=get_db_msg("select min(id) 'id' from ".$table_pre."client where face>'2' and id>'".$id."'"); $this_id=$tmp["id"]; } $m=get_db_msg("select * from ".$table_pre."client where id='".$this_id."'"); $upath=$m["path"]."-".$m["id"]; //检查是否有订单 $q1="select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where (upath='".$upath."' or upath like '".$upath."-%') and ka<>'y'"; $tmp=get_db_msg($q1); if($tmp["num"]>0){ //echo $q."
"; $content=get_order_by_client($upath); $file_name="订单明细_".get_main_value($arr_client_face,$m["face"])."_".$m["title"]."_".$m["username"].".xls"; if($is_dir=="y"){ //建立目录结构 $dir1=""; $arr_path=explode("-",$m["path"]); for($j=0;$j0){ $m1=get_db_msg("select title from ".$table_pre."client where id='".$arr_path[$j]."'"); //$dir.="/".$m1["title"]; $dir1.="/".$m1["title"]; $dir=iconv("utf-8","gb2312",$dir1); make_dir("xls".$dir); } } }else{ $dir="/"; } $file_name=iconv("utf-8","gb2312",$file_name); write_file("xls".$dir,$file_name,$content); $file_name=iconv("gb2312","utf-8",$file_name); $list++; echo $list."/".$total.":".$file_name.",输出完成,暂停
"; } $url=$_SERVER[PHP_SELF]."?sub=y&id=".$this_id."&list=".$list."&is_dir=".$is_dir."&show_wd=".$show_wd; //取得最大id $tmp=get_db_msg("select max(id) 'id' from ".$table_pre."client where face>'2'"); $db->close(); if($id<$tmp["id"]){ // url_redirect($url); }else{ echo $total."个客户订单输出完成(包含无订单的客户),位于admin/debug/xls/下面,请手动下载!"; } exit; }else{ $is_dir=$is_dir?$is_dir:"n"; $arr_is_dir=array("n"=>"同一个目录","y"=>"按照客户结构列出目录"); } ?> 导出每个客户的订单明细
"; } ?>
导出每个客户的订单明细
文件目录方式
".$msg."