7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
341 lines
12 KiB
PHP
341 lines
12 KiB
PHP
<?php
|
|
//-------------------------------------------------------导出订单总表
|
|
function get_order_by_client($start,$end){
|
|
global $table_pre,$db,$bx_sizegroup_title,$child_sizegroup_title,$xh_ms,$is_gg,$sys_gg_zd,$sys_color_zd;
|
|
$_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"]:" ";
|
|
$size_tr[$num_size_group].="<td width=\"5%\">".$t."</td>";
|
|
}
|
|
$num_size_group++;
|
|
}
|
|
//文胸
|
|
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;
|
|
}
|
|
//-------------------/处理尺码表头结束
|
|
if($start==0){
|
|
$_tbody.="<tr><td rowspan=\"".$num_size_group."\">".d_translate("qy")."</td><td rowspan=\"".$num_size_group."\">".d_translate("dl")."</td><td rowspan=\"".$num_size_group."\">客户名称</td><td rowspan=\"".$num_size_group."\">客户代码</td><td rowspan=\"".$num_size_group."\">序号</td><td rowspan=\"".$num_size_group."\">款号</td><td rowspan=\"".$num_size_group."\">款式名</td>";
|
|
//取得定制选项
|
|
$q="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' order by ord";
|
|
$r=$db->query($q);
|
|
$num_dz=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">".get_cate_title_no("arr_select",$m["no"])."</td>";
|
|
$num_dz++;
|
|
}
|
|
//到色属性
|
|
if(count($sys_color_zd)>0){
|
|
foreach($sys_color_zd as $k1 => $v1){
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">".$v1."</td>";
|
|
}
|
|
}
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">吊牌价</td><td rowspan=\"".$num_size_group."\">颜色名称</td><td rowspan=\"".$num_size_group."\">颜色代码</td>";
|
|
if($is_gg=="y"){
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">".d_translate("gg")."</td>";
|
|
foreach($sys_gg_zd as $k1 => $v1){
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">".$v1."</td>";
|
|
}
|
|
}else if($is_gg=="b"){
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">".d_translate("gg")."</td>";
|
|
}
|
|
if($bx_sizegroup_id>0)
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">杯型</td>";
|
|
else if($child_sizegroup_id>0)
|
|
$_tbody.="<td rowspan=\"".$num_size_group."\">款型</td>";
|
|
$_tbody.=$size_tr[0]."<td rowspan=\"".$num_size_group."\" align=\"center\" bgcolor=\"#f0f0f0\">小计</td><td rowspan=\"".$num_size_group."\">吊牌金额</td><td rowspan=\"".$num_size_group."\">结算金额</td></tr>";
|
|
for($i=1;$i<$num_size_group;$i++){
|
|
$_tbody.="<tr>".$size_tr[$i]."</tr>";
|
|
}
|
|
}
|
|
$sql_con="where ka<>'y'";
|
|
$q="select * from ".$table_pre."order ".$sql_con." order by id limit ".$start.",".$end;
|
|
//echo $q."<br>";
|
|
$r=$db->query($q);
|
|
$count=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$list=$count+1;
|
|
$bg="#ffffff";
|
|
$m2=get_db_msg("select path,title,username from ".$table_pre."client where id='".$m["uid"]."'");
|
|
$msg_kh=get_db_msg("select no,xh,title,zd1,zd2,zd3 from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
$qy_id=get_qy_id($m2["path"]);
|
|
if($qy_id){
|
|
//取得区域
|
|
$tmp=get_db_msg("select title from ".$table_pre."client where id='".$qy_id."'");
|
|
$qy=$tmp["title"];
|
|
}else{
|
|
$qy="";
|
|
}
|
|
//取得代理
|
|
$dl_id=get_dl_id($m2["path"]);
|
|
if($dl_id){
|
|
$tmp=get_db_msg("select title from ".$table_pre."client where id='".$dl_id."'");
|
|
$dl=$tmp["title"];
|
|
}else{
|
|
$dl="";
|
|
}
|
|
$td_size1="";
|
|
$num=$money=0;
|
|
for($k=0;$k<$num_size_total;$k++){
|
|
$num+=$m["num_".$arr_size_merged[$k]];
|
|
$td_size1.="<td x:num>".$m["num_".$arr_size_merged[$k]]."</td>";
|
|
}
|
|
$_tbody.="<tr><td>".$qy."</td><td>".$dl."</td><td>".$m2["title"]."</td><td>".$m2["username"]."</td><td>".get_kh_xh($msg_kh,$m["color"])."</td><td>".$m["no"]."</td><td>".$msg_kh["title"]."</td>";
|
|
//取得定制选项
|
|
$q2="select * from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' order by ord";
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
if($m2["no"]=="zd1" || $m2["no"]=="zd2" || $m2["no"]=="zd3")
|
|
$_tbody.="<td>".$msg_kh[$m2["no"]]."</td>";
|
|
else
|
|
$_tbody.="<td>".get_cate_title_no($m2["no"],$m[$m2["no"]])."</td>";
|
|
}
|
|
//到色字段
|
|
if(count($sys_color_zd)>0){
|
|
$m_kh_color=get_db_msg("select * from ".$table_pre."kh_color where iid='".$m["iid"]."' and color='".$m["color"]."'");
|
|
foreach($sys_color_zd as $k1 => $v1){
|
|
$_tbody.="<td>".$m_kh_color[$k1]."</td>";
|
|
}
|
|
}
|
|
$_tbody.="<td x:num>".$m["price"]."</td><td>".get_cate_title_no("color",$m["color"])."</td><td>".$m["color"]."</td>";
|
|
if($is_gg=="y"){
|
|
$_tbody.="<td>".get_gg_title($m["bx"])."</td>";
|
|
$tmp1=get_db_msg("select * from ".$table_pre."kh_gg where iid='".$m["iid"]."' and color='".$m["color"]."' and gg='".$m["bx"]."'");
|
|
foreach($sys_gg_zd as $k1 => $v1){
|
|
$_tbody.="<td>".$tmp1[$k1]."</td>";
|
|
}
|
|
}else if($is_gg=="b"){
|
|
$_tbody.="<td>".get_gg_title($m["bx"])."</td>";
|
|
}
|
|
if($bx_sizegroup_id>0 || $child_sizegroup_id>0)
|
|
$_tbody.="<td>".$m["bx"]."</td>";
|
|
$_tbody.=$td_size1."<td x:num>".$num."</td><td x:num>".$m["je"]."</td><td x:num>".$m["jsje"]."</td></tr>";
|
|
$count++;
|
|
}
|
|
$_tbody.="</table></body></html>";
|
|
$db->close();
|
|
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");
|
|
$sys_size_num=get_max_size_num();
|
|
$sub=$_GET["sub"];
|
|
$step=$_GET["step"];
|
|
$list=$_GET["list"];
|
|
if($sub=="y"){
|
|
//定义每次导出的订单数量
|
|
$xh_ms=get_set("xh_ms");
|
|
$step=$step?$step:50000;
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."order where ka<>'y'");
|
|
$total_num=$tmp["num"];
|
|
$list=$_GET["list"]?$_GET["list"]:1;
|
|
$start=($list-1)*$step;
|
|
if($step*$list<$total_num){
|
|
$content=get_order_by_client($start,$step);
|
|
$file_name="DetailTotal-".$list.".xls";
|
|
$file_name=iconv("utf-8","gb2312",$file_name);
|
|
write_file("xls",$file_name,$content);
|
|
echo $list*$step."/".$total_num."条记录导出完成(".$file_name."),位于<a href='xls/'>admin/debug/xls</a>下面,请手动下载!";
|
|
$list++;
|
|
url_redirect($_SERVER[PHP_SELF]."?sub=y&list=".$list."&step=".$step);
|
|
}else{
|
|
$end=$total_num-($list-1)*$step;
|
|
$content=get_order_by_client($start,$end);
|
|
$file_name="DetailTotal-".$list.".xls";
|
|
$file_name=iconv("utf-8","gb2312",$file_name);
|
|
//$fp=fopen("中文订单明细.xls","w");
|
|
//fwrite($fp,$content);
|
|
write_file("xls",$file_name,$content);
|
|
echo $total_num."条记录导出完成(共".$list."个文件),位于<a href='xls/'>admin/debug/xls</a>下面,请手动下载!";
|
|
}
|
|
exit;
|
|
}else{
|
|
$step=50000;
|
|
}
|
|
?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>导出订单明细总表</title>
|
|
<style>
|
|
BODY{
|
|
font-family:宋体;FONT-SIZE:12px;margin:0px;padding:0px;
|
|
}
|
|
a,a:link,a:visited,a:active {
|
|
text-decoration:none;COLOR: #0000ff;FONT-SIZE:12px;
|
|
}
|
|
a:hover {
|
|
TEXT-DECORATION: underline;COLOR: #aaaa9f;FONT-SIZE:12px;
|
|
}
|
|
body,input,td,select,div,li,ul,textarea,form {
|
|
font-family:宋体;
|
|
FONT-SIZE:12px;
|
|
}
|
|
.wrong{
|
|
color:#ff0000;font-weight:bold;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<br />
|
|
<table width="80%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#cccccc">
|
|
<form name="form1" action="<?php echo $_SERVER[PHP_SELF]; ?>" method="get">
|
|
<input type="hidden" name="sub" value="y">
|
|
<tr>
|
|
<td align="center" bgcolor="#f0f0f0"><b>导出订单明细总表</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" bgcolor="#ffffff" style="line-height:25px;">单文件订单条数<input type="text" name="step" value="<?php echo $step; ?>" style="width:60px;">条 (如果执行超时,请减小条数)</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="center" bgcolor="#f0f0f0"><input type="submit" value=" 执 行 "></td>
|
|
</tr>
|
|
<?php
|
|
if($msg){
|
|
echo "<tr><td align=\"left\" bgcolor=\"#ffffff\" valign=\"top\" style=\"line-height:150%;\">".$msg."</td></tr>";
|
|
}
|
|
?>
|
|
</form>
|
|
</table>
|
|
</body>
|
|
</html>
|