7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
1185 lines
49 KiB
PHP
1185 lines
49 KiB
PHP
<?php
|
||
//-------------------------------删除款设置
|
||
//http://localhost/new1/admin/?_m=kh_ka&_a=view_order&id=2&s_group_by=1
|
||
header("Content-type: text/html; charset=utf-8");
|
||
if(THIS_IN!="edt_admin")
|
||
exit("错误的访问!");
|
||
$db=_mysql_connect();
|
||
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
|
||
//---------priv
|
||
$priv=return_priv($_m,$msg_login_user["priv"]);
|
||
$sys_size_num=get_max_size_num();
|
||
$json_data="{";
|
||
if($priv[0]=="n"){
|
||
//没有操作权限
|
||
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
|
||
}else{
|
||
//取得选项
|
||
$arr_select_no=$arr_select_no1=array();
|
||
$arr_select_title=$arr_select_title1=array();
|
||
$q="select no,title 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)){
|
||
if($m["no"]!="zd1" && $m["no"]!="zd2" && $m["no"]!="zd3"){
|
||
$arr_select_no1[]=$m["no"];
|
||
$arr_select_title1[]=$m["title"];
|
||
if($m["no"]!="designer"){
|
||
$arr_select_no2[]=$m["no"];
|
||
$arr_select_title2[]=$m["title"];
|
||
}
|
||
}
|
||
$arr_select_no[]=$m["no"];
|
||
$arr_select_title[]=$m["title"];
|
||
}
|
||
//杯型参数
|
||
if($is_gg=="n"){
|
||
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;
|
||
}
|
||
}
|
||
$json_data.="\"uid\":".$uid.",";
|
||
//有权限
|
||
switch($_a){
|
||
case "view_order":
|
||
$s_group_by=$s_group_by?$s_group_by:"4";
|
||
$arr_group_by=array("4"=>"客户","3"=>"代理","9"=>"区域","1"=>"明细");
|
||
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
|
||
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
||
$pic_big=get_kh_picture_big($msg["no"],$msg["main_pic"],$msg["color"]);
|
||
$pic1=out_good_pic($pic,200,200,'border=0');
|
||
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
|
||
$json_data.="\"pic_src\":\"".$pic."\",\"pic_w\":\"".$arr_pic_set[0]."\",\"pic_h\":\"".$arr_pic_set[1]."\",\"xhno\":\"".$msg["xh"]."#".$msg["no"]."\",";
|
||
$content="<table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" bgcolor=\"#ffffff\"><form name=\"form1\" action=\"".$_SERVER["PHP_SELF"]."\"><input type=\"hidden\" name=\"id\" value=\"".$id."\"><input type=\"hidden\" name=\"_cid\" value=\"".$_cid."\"><input type=\"hidden\" name=\"_m\" value=\"".$_m."\"><input type=\"hidden\" name=\"_a\" value=\"".$_a."\"><tr><td bgcolor=\"#ffffff\" align=\"center\"><a href=\"".$pic_big."\" target=\"_blank\">".$pic1."</a></td></tr><tr><td bgcolor=\"#ffffff\" align=\"center\">".$msg["xh"]."#".$msg["no"]."</td></tr>";
|
||
$content.="<tr><td>";
|
||
foreach($arr_group_by as $k1 => $v1){
|
||
$sty=($k1==$s_group_by)?"font-weight:bold;border:1px solid #333333;padding:6px;":"font-weight:normal;border:1px solid #cccccc;padding:4px;";
|
||
$content.="<a href=\"".$_SERVER[PHP_SELF]."?_cid=".$_cid."&_m=".$_m."&_a=".$_a."&id=".$id."&color=".$color."&s_group_by=".$k1."\"><span style=\"".$sty."\">".$v1."</span></a> ";
|
||
}
|
||
$content.="<input type=\"button\" value=\" 刷 新 \" class=\"btn_black\" onclick=\"window.location.reload();\"> <input type=\"button\" value=\" 后 退 \" class=\"btn_black\" onclick=\"history.back();\"></td></tr>";
|
||
$content.="<tr><td bgcolor=\"#ffffff\"><table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"4\" cellspacing=\"1\" bgcolor=\"#cccccc\">";
|
||
$sql_con="iid='".$id."' and ";
|
||
if($color)
|
||
$sql_con.="color='".$color."' and ";
|
||
$sql_con=substr($sql_con,0,-4);
|
||
$json_data1=$json_data2=$json_data3="";
|
||
if($s_group_by=="1"){
|
||
//------------------------明细
|
||
//表头
|
||
$content.="<tr><td bgcolor=\"#f0f0f0\">客户</td><td bgcolor=\"#f0f0f0\">颜色</td>";
|
||
|
||
$json_data1.="\"客户\",\"颜色\",";
|
||
if($is_gg=="y")
|
||
$content.="<td bgcolor=\"#f0f0f0\">".d_translate("gg")."</td>";
|
||
if($bx_sizegroup_id==$msg["size_group"]){
|
||
$content.="<td bgcolor=\"#f0f0f0\" width=\"30\">杯型</td>";
|
||
$json_data1.="\"杯型\",";
|
||
//
|
||
$size_str="";
|
||
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$size_str.=$m1["no"].",";
|
||
}
|
||
if($size_str)
|
||
$size_str=substr($size_str,0,-1);
|
||
$size=explode(",",$size_str);
|
||
}else{
|
||
$size=explode(",",$msg["size"]);
|
||
}
|
||
$tmp1=explode(",",$msg["color"]);
|
||
for($l=0;$l<count($size);$l++){
|
||
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
||
$content.="<td bgcolor=\"#f0f0f0\">".$tmp3["title"]."</td>";
|
||
$json_data1.="\"".$tmp3["title"]."\",";
|
||
|
||
}
|
||
$content.="<td bgcolor=\"#f0f0f0\">小计</td><td bgcolor=\"#f0f0f0\">订单时间</td></tr>";
|
||
$json_data1.="\"小计\",\"订单时间\"";
|
||
$q="select * from ".$table_pre."order where ".$sql_con." and _key='".$_key."' order by uid,add_date";
|
||
$r=$db->query($q);
|
||
$hj=0;
|
||
while($m=$db->fetch_array($r)){
|
||
$tmp=get_db_msg("select * from ".$table_pre."client where id='".$m["uid"]."'");
|
||
$content.="<tr><td bgcolor=\"#ffffff\">".$tmp["title"]."(".$tmp["username"].")</td>";
|
||
$json_data2.="\"".$tmp["title"]."(".$tmp["username"].")\",";
|
||
$content.="<td bgcolor=\"#ffffff\">".$m["color"]."-".get_cate_title_no("color",$m["color"])."</td>";
|
||
$json_data2.="\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\",";
|
||
if($bx_sizegroup_id==$msg["size_group"]){
|
||
$content.="<td bgcolor=\"#ffffff\" align=\"center\">".$m["bx"]."</td>";
|
||
$json_data2.="\"".$m["bx"]."\",";
|
||
}
|
||
if($is_gg=="y"){
|
||
$content.="<td bgcolor=\"#ffffff\" align=\"center\">".get_gg_title($m["bx"])."</td>";
|
||
$json_data2.="\"".get_gg_title($m["bx"])."\",";
|
||
}
|
||
//尺码列表
|
||
$xj=0;
|
||
for($l=0;$l<count($size);$l++){
|
||
$xj+=$m["num_".$size[$l]];
|
||
$hj+=$m["num_".$size[$l]];
|
||
//尺码合计
|
||
$v1="hj_".$size[$l];
|
||
$$v1+=$m["num_".$size[$l]];
|
||
$content.="<td bgcolor=\"#ffffff\">".$m["num_".$size[$l]]."</td>";
|
||
$json_data2.="\"".$m["num_".$size[$l]]."\",";
|
||
}
|
||
$content.="<td bgcolor=\"#ffffff\">".$xj."</td><td bgcolor=\"#ffffff\">".date("d日 H点i分",$m["add_date"])."</td></tr>";
|
||
$json_data2.="\"".date("d日 H点i分",$m["add_date"])."\"";
|
||
}
|
||
//合计
|
||
$hj_colspan=($bx_sizegroup_id==$msg["size_group"])?3:2;
|
||
if($is_gg=="y")
|
||
$hj_colspan++;
|
||
$content.="<tr><td bgcolor=\"#ffffff\" colspan=\"".($hj_colspan)."\" align=\"right\">合计</td>";
|
||
for($l=0;$l<count($size);$l++){
|
||
$v1="hj_".$size[$l];
|
||
$content.="<td bgcolor=\"#ffffff\">".$$v1."</td>";
|
||
$json_data3.="\"".$$v1."\",";
|
||
}
|
||
$json_data3.="\"".$hj."\",\"\"";
|
||
$content.="<td bgcolor=\"#ffffff\">".$hj."</td><td bgcolor=\"#ffffff\"> </td></tr>";
|
||
}else{
|
||
//------------------------客户、代理、区域
|
||
$arr_show_log_hd=array("23"=>"加量","22"=>"减量","24"=>"删单");
|
||
//取得数组
|
||
$arr1=array();
|
||
$q="select * from ".$table_pre."client where face='".$s_group_by."'";
|
||
$r=$db->query($q);
|
||
while($m=$db->fetch_array($r)){
|
||
if($s_group_by=="4"){
|
||
$tmp_sql=" and uid='".$m["id"]."'";
|
||
}else{
|
||
$p=$m["path"]."-".$m["id"];
|
||
$tmp_sql=" and upath like '".$p."-%'";
|
||
}
|
||
$tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where ".$sql_con.$tmp_sql);
|
||
if($tmp["num"]>0)
|
||
$arr1[$m["id"]]=$tmp["num"];
|
||
}
|
||
arsort($arr1);
|
||
if($bx_sizegroup_id==$msg["size_group"]){
|
||
//
|
||
$size_str="";
|
||
$r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$size_str.=$m1["no"].",";
|
||
}
|
||
if($size_str)
|
||
$size_str=substr($size_str,0,-1);
|
||
$size=explode(",",$size_str);
|
||
}else{
|
||
$size=explode(",",$msg["size"]);
|
||
}
|
||
//表头
|
||
$content.="<tr><td bgcolor=\"#f0f0f0\" width=\"40\">序号</td><td bgcolor=\"#f0f0f0\">客户</td>";
|
||
if($s_group_by=="4"){
|
||
//
|
||
foreach($arr_show_log_hd as $k1 => $v1){
|
||
$content.="<td bgcolor=\"#f0f0f0\" width=\"30\">".$v1."<br>次数</td>";
|
||
}
|
||
}
|
||
for($l=0;$l<count($size);$l++){
|
||
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
||
$content.="<td bgcolor=\"#f0f0f0\">".$tmp3["title"]."</td>";
|
||
}
|
||
$content.="<td bgcolor=\"#f0f0f0\">小计</td></tr>";
|
||
//
|
||
$hj=0;
|
||
$list=1;
|
||
foreach($arr1 as $id1 => $num1){
|
||
$hj+=$num1;
|
||
$m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'");
|
||
if($s_group_by=="4"){
|
||
$tmp_sql=" and uid='".$m["id"]."'";
|
||
}else{
|
||
$p=$m["path"]."-".$m["id"];
|
||
$tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')";
|
||
}
|
||
$tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$sql_con.$tmp_sql." and _key='".$_key."'");
|
||
$content.="<tr><td bgcolor=\"#ffffff\">".$list."</td><td bgcolor=\"#ffffff\">".$m["title"]."(".$m["username"].")</td>";
|
||
if($s_group_by=="4"){
|
||
foreach($arr_show_log_hd as $k1 => $v1){
|
||
//加单次数
|
||
$t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and action='".$k1."'");
|
||
$content.="<td bgcolor=\"#ffffff\">".$t1["num"]."</td>";
|
||
}
|
||
}
|
||
for($l=0;$l<count($size);$l++){
|
||
$content.="<td bgcolor=\"#ffffff\">".$tmp["num_".$size[$l]]."</td>";
|
||
//尺码合计
|
||
$v1="hj_".$size[$l];
|
||
$$v1+=$tmp["num_".$size[$l]];
|
||
}
|
||
$content.="<td bgcolor=\"#ffffff\">".$num1."</td>";
|
||
$list++;
|
||
}
|
||
//合计
|
||
$hj_colspan=($s_group_by=="4")?5:2;
|
||
$content.="<tr><td bgcolor=\"#ffffff\" align=\"right\" colspan=\"".$hj_colspan."\">合计</td>";
|
||
for($l=0;$l<count($size);$l++){
|
||
$v1="hj_".$size[$l];
|
||
$content.="<td bgcolor=\"#ffffff\">".$$v1."</td>";
|
||
}
|
||
$content.="<td bgcolor=\"#ffffff\">".$hj."</td></tr>";
|
||
}
|
||
$json_data.="\"hj_cos\":\"".$hj_colspan."\",\"size\":[".$json_data1."],\"mx\":[".$json_data2."],\"hj\":[".$json_data3."],";
|
||
$content.="</table></td></tr></table>";
|
||
break;
|
||
case "ka" :
|
||
if(is_array($id))
|
||
$arr_id=$id;
|
||
else
|
||
$arr_id=explode(",",$id);
|
||
$num=count($arr_id);
|
||
if($num==0)
|
||
alert_and_back("请至少选择一条记录!");
|
||
for($i=0;$i<$num;$i++){
|
||
if($arr_id[$i]>0){
|
||
$tmp=get_db_msg("select no from ".$table_pre."kh where id='".$arr_id[$i]."'");
|
||
//
|
||
$db->query("update ".$table_pre."kh set ka='y' where id='".$arr_id[$i]."'");
|
||
$db->query("update ".$table_pre."kh set color_ka=color where id='".$arr_id[$i]."'");
|
||
$db->query("update ".$table_pre."kh_color set ka='y' where iid='".$arr_id[$i]."'");
|
||
$db->query("update ".$table_pre."order set ka='y' where iid='".$arr_id[$i]."' and _key='".$_key."'");
|
||
$lid.=$tmp["no"].", ";
|
||
}
|
||
}
|
||
$lid=substr($lid,0,-2);
|
||
set_order_total_all();
|
||
set_log("设为删除款",$lid);
|
||
if($r_url)
|
||
url_redirect(urldecode($r_url));
|
||
else
|
||
echo "ok";
|
||
break;
|
||
case "ka_qx" :
|
||
if(is_array($id))
|
||
$arr_id=$id;
|
||
else
|
||
$arr_id=explode(",",$id);
|
||
$num=count($arr_id);
|
||
if($num==0)
|
||
alert_and_back("请至少选择一条记录!");
|
||
for($i=0;$i<$num;$i++){
|
||
if($arr_id[$i]>0){
|
||
$tmp=get_db_msg("select no from ".$table_pre."kh where id='".$arr_id[$i]."'");
|
||
//
|
||
$db->query("update ".$table_pre."kh set ka='n' where id='".$arr_id[$i]."'");
|
||
$db->query("update ".$table_pre."kh_color set ka='n' where iid='".$arr_id[$i]."'");
|
||
$db->query("update ".$table_pre."kh set color_ka='' where id='".$arr_id[$i]."'");
|
||
$db->query("update ".$table_pre."order set ka='n' where iid='".$arr_id[$i]."' and _key='".$_key."'");
|
||
$lid.=$tmp["no"].", ";
|
||
}
|
||
}
|
||
set_order_total_all();
|
||
$lid=substr($lid,0,-2);
|
||
set_log("取消删除款",$lid);
|
||
if($r_url)
|
||
url_redirect(urldecode($r_url));
|
||
else
|
||
echo "ok";
|
||
break;
|
||
case "color_ka":
|
||
$msg_kh=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
|
||
if($msg_kh["color_ka"])
|
||
$color_ka=$msg_kh["color_ka"].",".$color;
|
||
else
|
||
$color_ka=$color;
|
||
$q="update ".$table_pre."kh set color_ka='".$color_ka."' where id='".$id."'";
|
||
$db->query($q);
|
||
//
|
||
//恢复删除款
|
||
$arr1=explode(",",$msg_kh["color"]);
|
||
$arr2=explode(",",$color_ka);
|
||
if(count($arr1)==count($arr2))
|
||
$db->query("update ".$table_pre."kh set ka='y' where id='".$id."'");
|
||
//
|
||
//设置款色表
|
||
$db->query("update ".$table_pre."kh_color set ka='y' where iid='".$id."' and color='".$color."'");
|
||
//设置订货表
|
||
$db->query("update ".$table_pre."order set ka='y' where iid='".$id."' and color='".$color."' and _key='".$_key."'");
|
||
set_order_total_all();
|
||
set_log("删除颜色",$msg_kh["no"]."|".$color);
|
||
echo "ok";
|
||
//url_redirect(urldecode($r_url));
|
||
break;
|
||
case "color_ka_qx":
|
||
$msg_kh=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
|
||
$tmp=explode(",",$msg_kh["color_ka"]);
|
||
$ka_color="";
|
||
for($i=0;$i<count($tmp);$i++){
|
||
if($tmp[$i]!=$color)
|
||
$ka_color.=$tmp[$i].",";
|
||
}
|
||
if($ka_color)
|
||
$ka_color=substr($ka_color,0,-1);
|
||
$q="update ".$table_pre."kh set color_ka='".$ka_color."' where id='".$id."'";
|
||
$db->query($q);
|
||
//恢复删除款
|
||
$db->query("update ".$table_pre."kh set ka='n' where id='".$id."'");
|
||
//设置款色表
|
||
$db->query("update ".$table_pre."kh_color set ka='n' where iid='".$id."' and color='".$color."'");
|
||
//设置订货表
|
||
$db->query("update ".$table_pre."order set ka='n' where iid='".$id."' and color='".$color."' and _key='".$_key."'");
|
||
set_order_total_all();
|
||
//
|
||
set_log("取消删除颜色",$msg_kh["no"]."|".$color);
|
||
echo "ok";
|
||
//url_redirect(urldecode($r_url));
|
||
break;
|
||
case "export":
|
||
//-------------------处理尺码表头
|
||
//取得合并尺码
|
||
$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;
|
||
}
|
||
$_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;'>";
|
||
//-------------------/处理尺码表头结束
|
||
$_tbody.="<tr><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><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++;
|
||
}
|
||
$_tbody.="<td rowspan=\"".$num_size_group."\">吊牌价</td><td rowspan=\"".$num_size_group."\">颜色名称</td><td rowspan=\"".$num_size_group."\">颜色代码</td>";
|
||
if($bx_sizegroup_id>0)
|
||
$_tbody.="<td rowspan=\"".$num_size_group."\">杯型</td>";
|
||
if($is_gg=="y")
|
||
$_tbody.="<td rowspan=\"".$num_size_group."\">".d_translate("gg")."</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 where ka='y' and _key='".$_key."' order by uid,no,color";
|
||
//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 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>".$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>";
|
||
//取得定制选项
|
||
$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>".$m[$m2["no"]]."</td>";
|
||
else
|
||
$_tbody.="<td>".get_cate_title_no($m2["no"],$m[$m2["no"]])."</td>";
|
||
}
|
||
$_tbody.="<td>".$m["price"]."</td><td>".get_cate_title_no("color",$m["color"])."</td><td>".$m["color"]."</td>";
|
||
if($bx_sizegroup_id>0)
|
||
$_tbody.="<td>".$m["bx"]."</td>";
|
||
if($is_gg=="y")
|
||
$_tbody.="<td>".get_gg_title($m["bx"])."</td>";
|
||
$_tbody.=$td_size1."<td>".$num."</td><td>".$m["je"]."</td><td>".$m["jsje"]."</td></tr>";
|
||
$count++;
|
||
}
|
||
$_tbody.="</table></body></html>";
|
||
$content_str=$_tbody;
|
||
$filename="ka_".date("YmdHi").".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.'"');
|
||
echo $content_str;
|
||
break;
|
||
case "detail":
|
||
//可选择字段
|
||
$arr_zd=array(
|
||
"xh"=>"序号",
|
||
"price"=>"价格",
|
||
"title"=>"款式名"
|
||
);
|
||
for($i=0;$i<count($arr_select_no1);$i++){
|
||
$arr_zd[$arr_select_no1[$i]]=$arr_select_title1[$i];
|
||
}
|
||
//-------------------处理尺码表头
|
||
//取得合并尺码
|
||
$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 bgcolor=\"#f0f0f0\" align=\"center\" width=\"5%\">".$t."</td>";
|
||
$size_tr[$num_size_group].="{\"zd\":\"num_".$i."\",\"title\":\"".$t."\",\"is_size\":\"y\"},";
|
||
}
|
||
$arr_size_merged[]=$m1["no"];
|
||
$num_size_group++;
|
||
}
|
||
//-------------------/处理尺码表头结束
|
||
$s_zd=$s_zd?$s_zd:"price";
|
||
$sql_con="";
|
||
$search_content="";
|
||
//字段
|
||
$zd="";
|
||
$zd1="";
|
||
$i=0;
|
||
$arrzd=array();
|
||
$arrzd=explode(",",$s_zd);
|
||
$zd_ct=0;
|
||
foreach($arr_zd as $k1 => $v1){
|
||
$zd.="<input type=\"checkbox\" name=\"s_zd[]\" value=\"".$k1."\" id=\"zd_".$k1."\"";
|
||
$zd1.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",";
|
||
if(in_array($k1,$arrzd)){
|
||
$zd.=" checked";
|
||
$zd1.="\"sign\":\"y\"";
|
||
$zd_ct++;
|
||
}else
|
||
$zd1.="\"sign\":\"n\"";
|
||
$zd1.="},";
|
||
$zd.="><label for=\"zd_".$k1."\">".$v1."</label>";
|
||
}
|
||
$json_data.="\"th_zd\":[".substr($zd1,0,-1)."],";
|
||
$search_content.="显示列:".$zd;
|
||
//$search_content.="<input type=submit value=\"提 交\" class=\"btn_act\"> ";
|
||
$search_content.="<input type=button value=\"导出明细\" class=\"btn_act\" onclick=\"dexport();\"> ";
|
||
//-----------------------/search
|
||
//-----------------------tab
|
||
|
||
//-----------------------/tab
|
||
$json_data.="\"thead_str_group\":\"".$num_size_group."\",";
|
||
$th_zd="";
|
||
for($i=0;$i<count($s_zd);$i++){
|
||
$th_zd.="<td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">".get_main_value($arr_zd,$s_zd[$i])."</td>";
|
||
}
|
||
$thead_str="";
|
||
$thead_str.="{\"zd\":\"no\",\"title\":\"款号\",\"is_size\":\"n\"},";
|
||
$colnum=0;
|
||
foreach($arr_zd as $k1 => $v1){
|
||
if(in_array($k1,$arrzd)){
|
||
$thead_str.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\",\"is_size\":\"n\"},";
|
||
$colnum++;
|
||
}
|
||
}
|
||
$thead_str.="{\"zd\":\"color_title\",\"title\":\"颜色名称\",\"is_size\":\"n\"},";
|
||
$thead_str.="{\"zd\":\"color\",\"title\":\"颜色代码\",\"is_size\":\"n\"},";
|
||
if($bx_sizegroup_id>0){
|
||
$thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\",\"is_size\":\"n\"},";
|
||
}
|
||
if($is_gg=="y"){
|
||
$thead_str.="{\"zd\":\"gg\",\"title\":\"".d_translate("gg")."\",\"is_size\":\"n\"},";
|
||
//$thead_str.="{\"zd\":\"ggprice\",\"title\":\"".get_main_value($sys_gg_zd,"price")."\",\"is_size\":\"n\"},";
|
||
}
|
||
|
||
$thead_str.=$size_tr[0];
|
||
$thead_str.="{\"zd\":\"js\",\"title\":\"小计\",\"is_size\":\"n\"},";
|
||
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\",\"is_size\":\"n\"}";
|
||
$thead_str2="\"0\":[".$thead_str."],";
|
||
for($i=1;$i<$num_size_group;$i++){
|
||
$thead_str2.="\"".$i."\":[".substr($size_tr[$i],0,-1)."],";
|
||
}
|
||
$json_data.="\"thead_str\":{".substr($thead_str2,0,-1)."},";
|
||
$_tbody="<tr><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">次序</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">款号</td>".$th_zd."<td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">颜色</td><td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">颜色代码</td>";
|
||
if($bx_sizegroup_id>0)
|
||
$_tbody.="<td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\" width=\"30\">杯型</td>";
|
||
if($is_gg=="y")
|
||
$_tbody.="<td rowspan=\"".$num_size_group."\" bgcolor=\"#f0f0f0\" align=\"center\">".d_translate("gg")."</td>";
|
||
$_tbody.=$size_tr[0]."<td rowspan=\"".$num_size_group."\" width=\"40\" bgcolor=\"#f0f0f0\" align=\"center\">小计</td><td rowspan=\"".$num_size_group."\" width=\"80\" bgcolor=\"#f0f0f0\" align=\"center\">金额</td></tr>";
|
||
for($i=1;$i<$num_size_group;$i++){
|
||
$_tbody.="<tr>".$size_tr[$i]."</tr>";
|
||
}
|
||
$q="select * from ".$table_pre."kh where ka='y' or (ka<>'y' and color_ka<>'') order by xh";
|
||
//echo $q."<br>";
|
||
$r=$db->query($q);
|
||
$count=0;
|
||
$l=0;
|
||
$_tcontent=array();
|
||
$total_num=$total_money=0;
|
||
$list_kh=$list_color=0;
|
||
$list=1;
|
||
while($m=$db->fetch_array($r)){
|
||
//取得杯型
|
||
$arrBx=array();
|
||
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$m["no"]."' order by bx");
|
||
$i1=0;
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arrBx[$i1][]=$m1["bx"];
|
||
$arrBx[$i1][]=$m1["size"];
|
||
$i1++;
|
||
}
|
||
if(count($arrBx)==0){
|
||
$arrBx[0][0]="";
|
||
$arrBx[0][1]=$m["size"];
|
||
}
|
||
$bg=($l%2)?"#f0f0f0":"#ffffff";
|
||
//
|
||
$tmp_zd="";
|
||
for($i=0;$i<count($s_zd);$i++){
|
||
$tmp_zd.="<td bgcolor=\"".$bg."\">";
|
||
$tmp_zd.=($s_zd=="title" || $s_zd=="price" || $s_zd=="xh")?deel_td($m[$s_zd[$i]]):deel_td(get_cate_title_no($s_zd[$i],$m[$s_zd[$i]]));
|
||
$tmp_zd.="</td>";
|
||
}
|
||
//取得颜色
|
||
$arr_color=($m["ka"]=="y")?explode(",",$m["color"]):explode(",",$m["color_ka"]);
|
||
$num1=count($arr_color);
|
||
//有多种颜色
|
||
for($j=0;$j<count($arr_color);$j++){
|
||
for($i1=0;$i1<count($arrBx);$i1++){
|
||
$tbody_str.="{";
|
||
$num=0;
|
||
$td_size1="";
|
||
$xj_je=$xj_js=0;
|
||
for($k=0;$k<$num_size_total;$k++){
|
||
$k1=$k+1;
|
||
$tmp=get_db_msg("select sum(num_".$k1.") 'num' from ".$table_pre."order where iid='".$m["id"]."' and ka='y' and color='".$arr_color[$j]."' and _key='".$_key."'");
|
||
$td_size1.="<td bgcolor=\"".$bg."\">".add_0($tmp["num"])."</td>";
|
||
$xixi=$tmp["num"];
|
||
if(!$xixi) $xixi="";
|
||
$tbody_str.="\"num_".$k1."\":\"".$xixi."\",";
|
||
$xj_js+=$tmp["num"];
|
||
$xj_je+=$tmp["num"]*$m["price"];
|
||
}
|
||
$total_num+=$xj_js;
|
||
$total_money+=$xj_je;
|
||
$tbody_str2="";
|
||
foreach($arr_zd as $k1 => $v1){
|
||
if(in_array($k1,$arrzd)){
|
||
if($k1=="title" || $k1=="price"){
|
||
$tbody_str2.="\"".$k1."\":\"".deel_td($m[$k1])."\",";
|
||
}else if($k1=="xh"){
|
||
$tbody_str2.="\"".$k1."\":\"".get_kh_xh($m1)."\",";
|
||
}else{
|
||
$tbody_str2.="\"".$k1."\":\"".deel_td(get_cate_title_no($k1,$m[$k1]))."\",";
|
||
}
|
||
}
|
||
}
|
||
$tbody_str.="\"no\":\"".$m["no"]."\",";
|
||
$tbody_str.=$tbody_str2;
|
||
$tbody_str.="\"color_title\":\"".deel_td(get_cate_title_no("color",$arr_color[$j]))."\",";
|
||
$tbody_str.="\"color\":\"".deel_td($arr_color[$j])."\",";
|
||
if($bx_sizegroup_id>0){
|
||
$tbody_str.="\"bx\":\"".deel_td($m["bx"])."\",";
|
||
}
|
||
if($is_gg=="y"){
|
||
//取得规格价格
|
||
$tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m2["iid"]."' and gg='".$m2["bx"]."'");
|
||
$tbody_str.="\"gg\":\"".deel_td(get_gg_title($arrBx[$i1][0]))."\",";
|
||
//$tbody_str.="\"ggprice\":\"".deel_td($tmp["price"])."\",";
|
||
}
|
||
$tbody_str.="\"js\":\"".add_0($xj_js)."\",";
|
||
$tbody_str.="\"je\":\"".add_0($xj_je)."\"";
|
||
$tbody_str.="},";
|
||
|
||
$_tcontent[$count].="<tr height=\"25\"><td bgcolor=\"".$bg."\">".$list."</td><td bgcolor=\"".$bg."\">".$m["no"]."</td>".$tmp_zd."<td bgcolor=\"".$bg."\">".deel_td(get_cate_title_no("color",$arr_color[$j]))."</td><td bgcolor=\"".$bg."\">".deel_td($arr_color[$j])."</td>";
|
||
if($is_gg=="y")
|
||
$_tcontent[$count].="<td bgcolor=\"".$bg."\" align=\"center\">".deel_td(get_gg_title($arrBx[$i1][0]))."</td>";
|
||
if($bx_sizegroup_id>0)
|
||
$_tcontent[$count].="<td bgcolor=\"".$bg."\" align=\"center\">".deel_td($arrBx[$i1][0])."</td>";
|
||
$_tcontent[$count].=$td_size1."<td bgcolor=\"".$bg."\">".add_0($xj_js)."</td><td bgcolor=\"".$bg."\">".add_0($xj_je)."</td></tr>";
|
||
$count++;
|
||
$list++;
|
||
}
|
||
$list_color++;
|
||
}
|
||
$list_kh++;
|
||
|
||
$l++;
|
||
}
|
||
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
||
$td_size1="";
|
||
$tfoot_str2="";
|
||
for($k=0;$k<$num_size_total;$k++){
|
||
$k1=$k+1;
|
||
$tmp=get_db_msg("select sum(num_".$k1.") 'num' from ".$table_pre."order where ka='y' and _key='".$_key."'");
|
||
$td_size1.="<td bgcolor=\"".$bg."\">".add_0($tmp["num"])."</td>";
|
||
$haha=add_0($tmp["num"]);
|
||
if(!$haha)
|
||
$haha="";
|
||
$tfoot_str2.="\"num_".$k1."\":\"".$haha."\",";
|
||
}
|
||
$th_zd="";
|
||
for($i=0;$i<count($s_zd);$i++){
|
||
$th_zd.="<td bgcolor=\"".$bg."\" align=\"right\"> </td>";
|
||
}
|
||
$_tcontent[$count].="<tr height=\"25\"><td bgcolor=\"".$bg."\" align=\"right\">合计</td><td bgcolor=\"".$bg."\" align=\"center\">".add_0($list_kh)."</td>".$th_zd."<td bgcolor=\"".$bg."\" align=\"center\">".add_0($list_color)."</td><td bgcolor=\"".$bg."\" align=\"right\"> </td>";
|
||
$hj_colspan=($bx_sizegroup_id>0)?4:3;
|
||
if($is_gg=="y")
|
||
$hj_colspan+=1;
|
||
|
||
$tdnum=$hj_colspan+$zd_ct;
|
||
|
||
|
||
$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",".$tfoot_str2."\"js\":\"".deel_td($total_num)."\",\"je\":\"".deel_td($total_money)."\"},";
|
||
|
||
if($is_sub)
|
||
$json_data.="\"issub\":\"y\",";
|
||
if($bx_sizegroup_id>0)
|
||
$_tcontent[$count].="<td bgcolor=\"".$bg."\"> </td>";
|
||
if($is_gg=="y")
|
||
$_tcontent[$count].="<td bgcolor=\"".$bg."\"> </td>";
|
||
$_tcontent[$count].=$td_size1."<td bgcolor=\"".$bg."\">".add_0($total_num)."</td><td bgcolor=\"".$bg."\">".add_0($total_money)."</td></tr>";
|
||
$_nav_.=" > 删除款订单明细表";
|
||
break;
|
||
default :
|
||
//
|
||
$content=array();
|
||
$s_order=$s_order?$s_order:"1";
|
||
$s_in_ph=$s_in_ph?$s_in_ph:"y";
|
||
$offset=$offset?$offset:"0";
|
||
$order=$order?$order:"xh";
|
||
$s_ms=$s_ms?$s_ms:"dk";
|
||
$sql_con="";
|
||
if($s_ka)
|
||
$sql_con.="ka='".$s_ka."' and ";
|
||
if($s_ka_color=="y")
|
||
$sql_con.="color_ka<>'' and ";
|
||
if($s_is_sp)
|
||
$sql_con.="is_sp='".$s_is_sp."' and ";
|
||
if($s_xh)
|
||
$sql_con.="xh='".$s_xh."' and ";
|
||
if($s_no)
|
||
$sql_con.="no like '%".$s_no."%' and ";
|
||
for($i=0;$i<count($arr_select_no1);$i++){
|
||
$v="s_".$arr_select_no1[$i];
|
||
if($$v)
|
||
$sql_con.=$arr_select_no1[$i]."='".$$v."' and ";
|
||
}
|
||
$tj_table="order";
|
||
if($sql_con)
|
||
$sql_con="where ".substr($sql_con,0,-4);
|
||
$sql_order=str_replace("!"," desc",$order);
|
||
//读取所有款号排名
|
||
$q="select sum(num) 'num' from ".$table_pre."order where _key='".$_key."' group by no order by num desc";
|
||
$r=$db->query($q);
|
||
$arr_kh_num_all=array();
|
||
while($m=$db->fetch_array($r)){
|
||
$arr_kh_num_all[]=$m["num"];
|
||
}
|
||
$arr_kh_num_all[]=0;
|
||
//读取相应款号和订单量数组
|
||
$q="select * from ".$table_pre."kh ".$sql_con;
|
||
//echo $q."<br>";
|
||
$r=$db->query($q);
|
||
$arr_kh_id=$arr_kh_num=$arr_kh=array();
|
||
$i=0;
|
||
while($m=$db->fetch_array($r)){
|
||
if($s_ms=="dk"){
|
||
//到款
|
||
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre.$tj_table." where iid='".$m["id"]."'");
|
||
$num=$tmp["num"]?$tmp["num"]:0;
|
||
$arr_kh[$i]["id"]=$m["id"];
|
||
$arr_kh[$i]["num"]=$num;
|
||
$arr_kh_id[$i]=$m["id"];
|
||
$arr_kh_num[$i]=$num;
|
||
$i++;
|
||
}else{
|
||
//到色
|
||
$arr_color=explode(",",$m["color"]);
|
||
for($j=0;$j<count($arr_color);$j++){
|
||
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre.$tj_table." where iid='".$m["id"]."' and color='".$arr_color[$j]."'");
|
||
$num=$tmp["num"]?$tmp["num"]:0;
|
||
$arr_kh[$i]["id"]=$m["id"].",".$arr_color[$j];
|
||
$arr_kh[$i]["num"]=$num;
|
||
$arr_kh_id[$i]=$m["id"].",".$arr_color[$j];
|
||
$arr_kh_num[$i]=$num;
|
||
$i++;
|
||
}
|
||
}
|
||
}
|
||
$total=count($arr_kh);
|
||
if($not_first=="y")
|
||
$s_pagesize=$s_pagesize?$s_pagesize:$total;
|
||
else
|
||
$s_pagesize=10;
|
||
if($s_order=="1")
|
||
array_multisort($arr_kh_num,SORT_ASC,$arr_kh_id,SORT_ASC,$arr_kh,SORT_ASC);
|
||
else
|
||
array_multisort($arr_kh_num,SORT_DESC,$arr_kh_id,SORT_DESC,$arr_kh,SORT_DESC);
|
||
//exit;
|
||
//取得款色排名数组
|
||
$arr_ks_pm=array();
|
||
$q1="select sum(num) 'num',iid,color from ".$table_pre.$tj_table." group by iid,color order by num desc";
|
||
$r1=$db->query($q1);
|
||
$i=0;
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arr_ks_pm[$i]=$m1["num"];
|
||
$i++;
|
||
}
|
||
//取得款类、色类排行数组
|
||
$arr_kl_ph=array();
|
||
$arr_sl_ph=array();
|
||
$q1="select * from ".$table_pre."keyword where cate='category'";
|
||
$r1=$db->query($q1);
|
||
while($m1=$db->fetch_array($r1)){
|
||
$q2="select sum(num) 'num' from ".$table_pre.$tj_table." where category='".$m1["no"]."' group by no,color order by num desc";
|
||
$r2=$db->query($q2);
|
||
$i=0;
|
||
while($m2=$db->fetch_array($r2)){
|
||
$arr_sl_pm[$m1["no"]][$i]=$m2["num"];
|
||
$i++;
|
||
}
|
||
//
|
||
$q2="select sum(num) 'num' from ".$table_pre.$tj_table." where category='".$m1["no"]."' group by no order by num desc";
|
||
$r2=$db->query($q2);
|
||
$i=0;
|
||
while($m2=$db->fetch_array($r2)){
|
||
$arr_kl_pm[$m1["no"]][$i]=$m2["num"];
|
||
$i++;
|
||
}
|
||
}
|
||
//取得定制选项
|
||
$select_dz="";
|
||
for($i=0;$i<count($arr_select_no1);$i++){
|
||
//取得选项
|
||
$tmp="";
|
||
$r1=$db->query("select no,title from ".$table_pre."keyword where cate='".$arr_select_no1[$i]."' order by no");
|
||
while($m1=$db->fetch_array($r1)){
|
||
$tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},";
|
||
}
|
||
$tmp=deel_end($tmp);
|
||
$var="s_".$arr_select_no1[$i];
|
||
$select_dz.="{\"no\":\"".$arr_select_no1[$i]."\",\"title\":\"".$arr_select_title1[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},";
|
||
}
|
||
$select_dz=deel_end($select_dz);
|
||
//-----------------------search
|
||
$search_content1="<input type=\"hidden\" name=\"not_first\" value=\"y\"><span style=\"font-family:黑体;padding-left:15px;font-size:14px;font-weight:bold;\">序号:</span> <input type=text name=\"s_xh\" style=\"width:150px\" onfocus=\"this.select()\" value=\"".$s_xh."\"> <br><br> <span style=\"font-family:黑体;padding-left:15px;font-size:14px;font-weight:bold;\">款号:</span> <input type=text name=\"s_no\" style=\"width:150px\" onfocus=\"this.select()\" value=\"".$s_no."\"> ";
|
||
//删除款
|
||
$search_content="<select name=\"s_ka\" class=\"slt_list\"><option value=''>-所有款-</option>".get_main_op(array("n"=>"不显示删除款","y"=>"显示删除款"),$s_ka)."</select> ";
|
||
//删除色
|
||
$search_content.="<select name=\"s_ka_color\" class=\"slt_list\"><option value=''>-所有款-</option>".get_main_op(array("y"=>"显示删除色"),$s_ka_color)."</select> ";
|
||
//饰品款
|
||
$search_content.="<select name=\"s_is_sp\" class=\"slt_list\"><option value=''>-显示饰品款-</option>".get_main_op(array("n"=>"否","y"=>"是"),$s_is_sp)."</select> ";
|
||
//选项
|
||
for($i=0;$i<count($arr_select_no1);$i++){
|
||
$v="s_".$arr_select_no1[$i];
|
||
$search_content.="<select name=\"s_".$arr_select_no1[$i]."\" class=\"slt_list\"><option value=''>-".$arr_select_title1[$i]."-</option>".op_select_cate1($arr_select_no1[$i],$$v)."</select> ";
|
||
}
|
||
//
|
||
$search_content.="<select name=\"s_order\" class=\"slt_list2\">".get_main_op(array("1"=>"后","2"=>"前"),$s_order)."</select> <input type=\"text\" name=\"s_pagesize\" value=\"".
|
||
$s_pagesize."\" style=\"width:40px\" onmouseover=\"this.select();\">名 ";
|
||
//排行款
|
||
//$search_content.="<select name=\"s_in_ph\">".get_main_op(array("y"=>"仅排行款","n"=>"所有款"),$s_in_ph)."</select> ";
|
||
$search_content.="<input type=submit value=\"搜索\" class=\"btn_act\">";
|
||
$search_form_hidden=array(
|
||
"_a"=>$_a
|
||
);
|
||
//-----------------------/search
|
||
$tmp_page_size=($s_pagesize=="")?$total:$s_pagesize;
|
||
//-----------------------act
|
||
$act="";
|
||
$act.="<input type=\"button\" value=\"批量设置删除款\" onclick=\"dcheckbox_act(".$tmp_page_size.",'ka','确认设置所选款为删除款吗?')\" class=\"btn_black2\">";
|
||
$act.="<input type=\"button\" value=\"批量取消删除款\" onclick=\"dcheckbox_act(".$tmp_page_size.",'ka_qx','确认取消设置所选款为删除款吗?')\" class=\"btn_black2\">";
|
||
$act.=" <input type=\"button\" value=\"删除款明细报表\" onclick=\"location.href='".$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."&_a=detail'\" class=\"btn_black2\">";
|
||
if($s_no || $s_xh)
|
||
$act.=" <a href=\"".$_SERVER[PHP_SELF]."?_m=".$_m."&_cid=".$_cid."&s_pagesize=".$s_pagesize."&s_order=".$s_order."\">显示全部</a>";
|
||
//-----------------------/act
|
||
//-----------------------tab
|
||
|
||
//-----------------------/tab
|
||
$r_url=$_SERVER[PHP_SELF]."?_cid=".$_cid."&_m=".$_m."&s_xh=".$s_xh."&s_no=".$s_no."&s_ka=".$s_ka."&s_ka_color=".$s_ka_color."&s_is_sp=".$s_is_sp."&s_pagesize=".$s_pagesize."&s_order=".$s_order;
|
||
for($i=0;$i<count($arr_select_no1);$i++){
|
||
$v="s_".$arr_select_no1[$i];
|
||
if($$v)
|
||
$r_url.="&s_".$arr_select_no1[$i]."=".$$v;
|
||
}
|
||
$form_hidden=array(
|
||
"r_url"=>urlencode($r_url)
|
||
);
|
||
$column=array(
|
||
"序号",
|
||
"订单/客户量",
|
||
"<input type=\"checkbox\" name=\"toggle\" onclick=\"checkAll(".$total.")\">款号/名".get_order_action("no",$order,$_SERVER[PHP_SELF],$tran_var)
|
||
);
|
||
$column_property=array("align=left width=40","align=center width=80","align=left");
|
||
for($count=0;$count<$tmp_page_size;$count++){
|
||
if($s_ms=="dk"){
|
||
//到款
|
||
$khid=$arr_kh[$count]["id"];
|
||
}else{
|
||
//到色
|
||
$arr_tmp=explode(",",$arr_kh[$count]["id"]);
|
||
$khid=$arr_tmp[0];
|
||
$this_color=$arr_tmp[1];
|
||
}
|
||
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$khid."'");
|
||
if($msg["id"]>0){
|
||
$list=$count+1;
|
||
$content[$count][]="\"bh\":\"".$list."\",\"id\":\"".$msg["id"]."\"";
|
||
$c=$msg["ka"]=="y"?"font_ka":"font_normal";
|
||
//
|
||
if($s_ms=="dk"){
|
||
//到款
|
||
$num_client=get_num_client($msg["id"],$uid);
|
||
}else{
|
||
//到色
|
||
$num_client=get_num_client_color($msg["id"],$this_color,$uid);
|
||
}
|
||
if($arr_kh[$count]["num"]>0){
|
||
$t_num="".$arr_kh[$count]["num"]."/".get_num_client($msg["id"],$uid)."";
|
||
}else{
|
||
$t_num="".$arr_kh[$count]["num"]."/".get_num_client($msg["id"],$uid)."";
|
||
}
|
||
$content[$count][]=$t_num;
|
||
if($s_ms=="dk"){
|
||
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
|
||
$pic_big=get_kh_picture_big($msg["no"],$msg["main_pic"],$msg["color"]);
|
||
}else{
|
||
$pic=get_kh_color_picture($msg["no"],$this_color);
|
||
$pic_big=get_kh_color_picture_big($msg["no"],$this_color);
|
||
}
|
||
$arr_pic_set=out_good_pic_set_arr($pic,120,120);
|
||
$pic1=out_good_pic($pic,80,80,'border=0');
|
||
$tmp1=explode(",",$msg["color"]);
|
||
$tmp2=explode(",",$msg["color_ka"]);
|
||
//取得杯型
|
||
$arrBx=array();
|
||
$arrBx[0][0]="";
|
||
$arrBx[0][1]=$msg["size"];
|
||
if($bx_sizegroup_id==$msg["size_group"]){
|
||
$arrBx=array();
|
||
$str_bx="";
|
||
$r1=$db->query("select * from ".$table_pre."size_bx where no='".$msg["no"]."' order by bx");
|
||
$i1=0;
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arrBx[$i1][]=$m1["bx"];
|
||
$arrBx[$i1][]=$m1["size"];
|
||
$i1++;
|
||
}
|
||
if(count($arrBx)==0){
|
||
$arrBx[0][0]="";
|
||
$arrBx[0][1]=$msg["size"];
|
||
}
|
||
$r3=$db->query("select * from ".$table_pre."size where iid='".$bx_sizegroup_id."' order by no");
|
||
$str_size_title="";
|
||
$str_size_title1="\"颜色\",\"杯型\",";
|
||
$size_str="";
|
||
while($m3=$db->fetch_array($r3)){
|
||
$str_size_title.="<td width=\"30\" bgcolor=\"#f0f0f0\">".$m3["title"]."</td>";
|
||
$str_size_title1.="\"".$m3["title"]."\",";
|
||
$size_str.=$m3["no"].",";
|
||
}
|
||
$size=explode(",",substr($size_str,0,-1));
|
||
}
|
||
//else if($msg["size_group"]==$child_sizegroup_id){
|
||
//}
|
||
else{
|
||
if($is_gg=="y"){
|
||
$arrBx=array();
|
||
$arrBx[0][0]="";
|
||
$r1=$db->query("select gg from ".$table_pre."kh_gg where iid='".$msg["id"]."' order by color,ord");
|
||
$i1=0;
|
||
while($m1=$db->fetch_array($r1)){
|
||
$arrBx[$i1][0]=$m1["gg"];
|
||
$i1++;
|
||
}
|
||
if(count($arrBx)==0){
|
||
$arrBx[0][0]="";
|
||
$arrBx[0][1]=$msg["size"];
|
||
}
|
||
|
||
$r3=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no");
|
||
$str_size_title="";
|
||
$str_size_title1="\"颜色\",\"规格\",";
|
||
$size_str="";
|
||
while($m3=$db->fetch_array($r3)){
|
||
$str_size_title.="<td width=\"30\" bgcolor=\"#f0f0f0\">".$m3["title"]."</td>";
|
||
$str_size_title1.="\"".$m3["title"]."\",";
|
||
$size_str.=$m3["no"].",";
|
||
}
|
||
$size=explode(",",substr($size_str,0,-1));
|
||
}
|
||
else{
|
||
$size=explode(",",$msg["size"]);
|
||
$str_size_title="";
|
||
$str_size_title1="\"颜色\",";
|
||
for($l=0;$l<count($size);$l++){
|
||
$tmp3=get_db_msg("select * from ".$table_pre."size where iid='".$msg["size_group"]."' and no='".$size[$l]."' limit 0,1");
|
||
$str_size_title.="<td width=\"30\" bgcolor=\"#f0f0f0\">".$tmp3["title"]."</td>";
|
||
$str_size_title1.="\"".$tmp3["title"]."\",";
|
||
}
|
||
}
|
||
}
|
||
$str_size_title1.="\"小计\", \"色总排名\",\"色类排名\",";
|
||
$color="";
|
||
$color1="";
|
||
$color_ka="";
|
||
$color_ka1="";
|
||
for($k=0;$k<count($tmp1);$k++){
|
||
//取得款色的定量
|
||
//$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre.$tj_table." where iid='".$msg["id"]."' and color='".$tmp1[$k]."' group by bx");
|
||
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre.$tj_table." where iid='".$msg["id"]."' and color='".$tmp1[$k]."' ");
|
||
$xj_num_color=$tmp["num"];
|
||
for($i1=0;$i1<count($arrBx);$i1++){
|
||
if(in_array($tmp1[$k],$tmp2)){
|
||
$st1="font_ka";
|
||
$ka_button="<input type=\"button\" class=\"btn_act\" value=\"取消删除颜色\" onclick=\"d_ka_color('color_ka_qx','".$msg["id"]."','".$tmp1[$k]."','".$msg["color"]."')\">";
|
||
}else{
|
||
$ka_button="<input type=\"button\" class=\"btn_act\" value=\"删除颜色\" onclick=\"d_ka_color('color_ka','".$msg["id"]."','".$tmp1[$k]."','".$msg["color"]."')\">";
|
||
$st1="font_normal";
|
||
}
|
||
$color_ka1.="[\"".$tmp1[$k]."\",\"".in_array($tmp1[$k],$tmp2)."\"],";
|
||
//尺码列表
|
||
//$size=explode(",",$arrBx[$i1][1]);
|
||
$str_size_num="";
|
||
$str_size_num1="";
|
||
$xj=0;
|
||
$tmp4=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where iid='".$msg["id"]."' and color='".$tmp1[$k]."' and bx='".$arrBx[$i1][0]."'");
|
||
for($l=0;$l<count($size);$l++){
|
||
//$tmp4=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where iid='".$msg["id"]."' and _key='".$_key."' and color='".$tmp1[$k]."' and bx='".$arrBx[$i1][0]."'");
|
||
$xj+=$tmp4["num_".$size[$l]];
|
||
$str_size_num.="<td bgcolor=\"#ffffff\">".$tmp4["num_".$size[$l]]."</td>";
|
||
$hehe=$tmp4["num_".$size[$l]];
|
||
if(!$hehe) $hehe="";
|
||
$str_size_num1.="\"".$hehe."\",";
|
||
}
|
||
if($xj_num_color>0){
|
||
$pm=get_main_key($arr_ks_pm,$xj_num_color)+1;
|
||
$slpm=(get_main_key($arr_sl_pm[$msg["category"]],$xj_num_color)+1)."/".count($arr_sl_pm[$msg["category"]]);
|
||
}else{
|
||
$pm="";
|
||
$slpm="";
|
||
}
|
||
$color1.="[";
|
||
if($i1==0){
|
||
$color.="<td bgcolor=\"#f0f0f0\" rowspan=\"".count($arrBx)."\"><span class=\"".$st1."\" id=\"color_".$msg["id"]."_".$tmp1[$k]."\">".$tmp1[$k]."-".get_cate_title_no("color",$tmp1[$k])."</span></td>";
|
||
$color1.="\"bxhb:".count($arrBx)."\",\"bxhb:".$tmp1[$k]."-".get_cate_title_no("color",$tmp1[$k])."\",";
|
||
$color_ka=$color_ka1;
|
||
}
|
||
if($i1!=0)
|
||
$color1.="\"\",";
|
||
if($bx_sizegroup_id==$msg["size_group"]){
|
||
$color.="<td bgcolor=\"#ffffff\">".$arrBx[$i1][0]."</td>";
|
||
$color1.="\"".$arrBx[$i1][0]."\",";
|
||
}
|
||
if($is_gg=="y"){
|
||
$color.="<td bgcolor=\"#ffffff\">".$arrBx[$i1][0]."</td>";
|
||
$color1.="\"".$arrBx[$i1][0]."\",";
|
||
}
|
||
if($is_gg=="b"){
|
||
$tmpgg=get_db_msg("select * from web_kh_gg_title where id='".$arrBx[$i1][0]."'");
|
||
$color.="<td bgcolor=\"#ffffff\">".$tmpgg["title"]."</td>";
|
||
$color1.="\"".$tmpgg["title"]."\",";
|
||
}
|
||
$color.=$str_size_num;
|
||
$color1.="".$str_size_num1."";
|
||
if($i1==0){
|
||
$color.="<td bgcolor=\"#ffffff\" rowspan=\"".count($arrBx)."\">".$xj_num_color."</td><td bgcolor=\"#ffffff\" rowspan=\"".count($arrBx)."\">".$pm."</td><td bgcolor=\"#ffffff\" rowspan=\"".count($arrBx)."\">".$slpm."</td><td bgcolor=\"#ffffff\" rowspan=\"".count($arrBx)."\"><div id=\"button_color_".$msg["id"]."_".$tmp1[$k]."\">".$ka_button."</div></td>";
|
||
$color1.="\"bxhb:".$xj_num_color."\",\"bxhb:".$pm."\",\"bxhb:".$slpm."\",\"bxhb:thisaaa:操作\",";
|
||
|
||
}
|
||
$color1="".substr($color1,0,-1)."],";
|
||
}
|
||
}
|
||
if($msg["ka"]=="y")
|
||
$button_ka="<input type=\"button\" class=\"btn_act\" value=\"取消删除款\" onclick=\"d_ka('ka_qx','".$msg["id"]."','".$msg["color"]."')\">";
|
||
else
|
||
$button_ka="<input type=\"button\" class=\"btn_act\" value=\"设为删除款\" onclick=\"d_ka('ka','".$msg["id"]."','".$msg["color"]."')\">";
|
||
$details="<table border=\"0\" cellspacing=\"1\" cellpadding=\"2\" style=\"background-color:#dddddd;\"><tr><td bgcolor=\"#f0f0f0\">颜色</td>";
|
||
if($bx_sizegroup_id==$msg["size_group"])
|
||
$details.="<td bgcolor=\"#f0f0f0\" width=\"30\">杯型</td>";
|
||
$details.=$str_size_title."<td bgcolor=\"#f0f0f0\">小计</td><td bgcolor=\"#f0f0f0\">色总<br>排名</td><td bgcolor=\"#f0f0f0\">色类<br>排名</td><td bgcolor=\"#f0f0f0\">操作</td></tr>".$color."</table>";
|
||
if($s_ms=="dk"){
|
||
$xj1=$arr_kh[$count]["num"];//款订量
|
||
$yph=get_kh_xh($msg);
|
||
}else{
|
||
$tmp=get_db_msg("select sum(num) 'num' from ".$table_pre."order where iid='".$khid."' group by iid");
|
||
$xj1=$tmp["num"];//款订量
|
||
$yph=get_kh_xh($msg,$this_color);
|
||
}
|
||
if($xj1>0)
|
||
$klpm=(get_main_key($arr_kl_pm[$msg["category"]],$xj1)+1)."/".count($arr_kl_pm[$msg["category"]]);
|
||
else
|
||
$klpm="";
|
||
//取得款总排名
|
||
if($this_color)
|
||
$color_title="<br>".$this_color."-".get_cate_title_no("color",$this_color);
|
||
$other_info="";
|
||
if($msg["category"])
|
||
$other_info.=" ".get_cate_title_no("category",$msg["category"]);
|
||
if($msg["category1"])
|
||
$other_info.=" ".get_cate_title_no("category1",$msg["category1"]);
|
||
if(trim($msg["title"]))
|
||
$other_info.=" ".trim($msg["title"]);
|
||
$content[$count][]="\"ka\":\"".$msg["ka"]."\",\"klpm\":\"".$klpm."\",\"kh\":\"".$msg["no"]."\",\"xh\":\"".$yph."\",\"kpm\":\"".(get_main_key1($arr_kh_num_all,$arr_kh[$count]["num"])+1)."\",\"colors\":\"".$this_color."\",\"other_info\":\" ".$other_info." ".$msg["price"]."元 款类排名 :".$klpm."\",\"pic_src\":\"".$pic."\",\"pic_name\":\"".$color_title."\",\"pic_w\":\"".$arr_pic_set[0]."\",\"pic_h\":\"".$arr_pic_set[1]."\"";
|
||
$content[$count][]="\"cm\":[".substr($str_size_title1,0,-1)."]";
|
||
$content[$count][]="\"color\":[".substr($color1,0,-1)."],\"color_ka\":[".substr($color_ka1,0,-1)."],\"msg_color\":\"".$msg["color"]."\"";
|
||
}
|
||
}
|
||
$json_data.="\"code\":0,\"ss_ms\":\"".$s_ms."\",\"ss_ka\":\"".$s_ka."\",\"ss_is_sp\":\"".$s_is_sp."\",\"ss_ka_color\":\"".$s_ka_color."\",\"ss_pagesize\":\"".$s_pagesize."\",\"ss_order\":\"".$s_order."\",\"select_dz\":[".$select_dz."],\"ss_xh\":\"".$s_xh."\",\"ss_no\":\"".$s_no."\",\"count\":".count($content).",\"data\":[";
|
||
foreach($content as $key=>$value){
|
||
$json_data1.="{".$value[0].",\"dingdan\":\"".$value[1]."\",".$value[2].",".$value[3].",".$value[4]."},";
|
||
}
|
||
$json_data.=substr($json_data1,0,-1)."],";
|
||
break;
|
||
}
|
||
}
|
||
$json_data=substr($json_data,0,-1)."}";
|
||
echo $json_data;
|
||
?>
|