订单打印->明细导出 function get_order_by_client($u_sql){ global $table_pre,$db; $_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]=""; 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.=""; //取得定制选项 $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.=""; $num_dz++; } $_tbody.="".$size_tr[0].""; for($i=1;$i<$num_size_group;$i++){ $_tbody.="".$size_tr[$i].""; } $sql_con="where ka<>'y'".$u_sql; $q="select * from ".$table_pre."order ".$sql_con." order by uid,no,color"; //echo $q."
"; $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.=""; } if($num>0){ $money=$num*$m1["price"]; $total_num+=$num; $total_money+=$money; $_tbody.=""; //取得定制选项 $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.=""; else $_tbody.=""; } $_tbody.="".$td_size1.""; $count++; } } $_tbody.=""; $_tbody.="
".$t."
区域代理客户名称客户代码款号".get_cate_title_no("arr_select",$m["no"])."单价颜色颜色代码小计金额(元)
".$m["num_".$arr_size_merged[$k]]."
".$qy."".$dl."".$m3["title"]."".$m3["username"]."".$m1["no"]."".$m1[$m4["no"]]."".get_cate_title_no($m4["no"],$m1[$m4["no"]])."".$m1["price"]."".get_cate_title_no("color",$m["color"])."".$m["color"]."".$num."".$money."
合计".deel_td($total_num)."".deel_td($total_money)."
"; 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".$arr_username[$i]."(未确认),"; }else{ $confirm_str.="".$arr_username[$i]."(已确认),"; } }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; ?>