query($sql_select); while($msg_select=$db->fetch_array($res_select)){ $str_op.="{\"no\":\"".$msg_select["no"]."\",\"title\":\"".$msg_select["title"]."\"},"; } $str_select.="{\"name\":\"".$arr_val."\",\"title\":\"".get_cate_title_no("arr_select",$arr_val)."\",\"value\":\"".$$arr_val."\",\"op\":[".substr($str_op,0,-1)."]},"; } } } $json_data.="\"select_report\":[".substr($str_select,0,-1)."],"; //end //-------------------------条件 //-------con为web_order //-------con1为web_kh $con=$con1=$con_dr=""; if($searh_select1!="s_ka" && $searh_select2!="s_ka" && $searh_select3!="s_ka"){ //没有删除款搜索时 $con.=" and ka<>'y' "; $con1.=" and ka<>'y' "; }else{ if($s_ka){ $con.=" and ka='".$s_ka."' "; $con1.=" and ka='".$s_ka."' "; } } if($searh_select1!="s_spk" && $searh_select2!="s_spk" && $searh_select3!="s_spk"){ //没有饰品款搜索时 $con.=" and is_sp<>'y' "; $con1.=" and is_sp<>'y' "; }else{ if($s_spk){ $con.=" and is_sp='".$s_spk."' "; $con1.=" and is_sp='".$s_spk."' "; } } if($s_key){ if($s_key=="all"){ $con.=""; }else{ $con.=" and _key='".$s_key."'"; } } //其他 for($i=0;$i"dr_zd1","dr_zd2"=>"dr_zd2","dr_zd3"=>"dr_zd3","dr_zd4"=>"dr_zd4","dr_zd5"=>"dr_zd5","dr_zd6"=>"dr_zd6","dr_zd7"=>"dr_zd7","dr_zd8"=>"dr_zd8"); $str_sql=""; foreach($arr_dr_zd as $k => $v){ if($$v){ $tmp=explode("_",$$v); if($tmp[1]=="文本"){ $str_sql.="".$v.","; }else{ $str_sql.="sum(".$v.") ".$v.","; } } } if($str_sql){ $str_sql=deel_end($str_sql); } if($zd1=="" || !$str_sql){ //请求数据有误 $content_data="
请先配置参数!
"; $json_data.="\"sys_bb_type\":\"report_null\","; }else{ //---------------------------------------一维报表 // $arr_group_by_title=array(); $r1=$db->query("select no,title from ".$table_pre."keyword where cate='arr_select'"); while($m1=$db->fetch_array($r1)){ $arr_group_by_title[$m1["no"]]=$m1["title"]; } // $s_group_by1=$zd1; $s_group_by2=$zd2; $s_group_by3=$zd3; $content_data=""; $content_data.=""; $content_data.=""; $sp=1; if($s_group_by2){ $content_data.=""; $sp++; } if($s_group_by3){ $content_data.=""; $sp++; } if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=""; $content_data.=""; $content_data.=""; $con2=""; if($s_group_by1!="sx" && $s_group_by1) $con2.=" and ".$s_group_by1."<>''"; if($s_group_by2!="sx" && $s_group_by2) $con2.=" and ".$s_group_by2."<>''"; if($s_group_by3!="sx" && $s_group_by3) $con2.=" and ".$s_group_by3."<>''"; if($zd3){ $json_data.="\"sys_bb_type\":\"report_2w\","; //取得总款数 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where no<>'' ".$con2.$con1); $total_ks=$tmp["num"]; //取得总款色数 $total_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where no<>'' ".$con2.$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $arr1=explode(",",$m2["color"]); $arr2=explode(",",$m2["color_ka"]); for($i1=0;$i1'' ".$con2.$con1); $price_jj=keep_float($tmp["jj"],1); } //取得已订总件数和金额 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' and ".$s_group_by3."<>'' ".$con); $total_yd_js=$tmp["num"]; $total_yd_je=$tmp["je"]; $total_yd_jsje=$tmp["jsje"]; //取得已订总款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' and ".$s_group_by3."<>'' ".$con); $total_yd_ks=$tmp["num"]; //取得已订总款色数 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' and ".$s_group_by3."<>'' ".$con); $total_yd_sku=$tmp["num"]; $total_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where id<>0 ".$con_dr); // $q4="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by no"; $r4=$db->query($q4); $count=$l=$total_num=$total_money=0; while($m4=$db->fetch_array($r4)){ $con11=($s_group_by2=="sx" || $s_group_by2=="color")?"":" and ".$s_group_by2."<>''"; if($s_group_by1=="color"){ $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$m4["no"].",%'".$con11.$con1); $xj_z_sku=$tmp["num"]; }else if($s_group_by1=="sx"){ //取得设计款色 $tmp=get_db_msg("select * from ".$table_pre."sx where no='".$m4["no"]."'"); $arr_color=explode(",",$tmp["_v"]); $n1=0; for($i1=0;$i1query($q2); while($m2=$db->fetch_array($r2)){ $arr1=explode(",",$m2["color"]); $arr2=explode(",",$m2["color_ka"]); for($i1=0;$i1"; $r=$db->query($q); $l=0; //取得已订小计款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con); $xj_yd_ks=$tmp["num"]; //取得已订小计款色数 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' ".$con); $xj_yd_sku=$tmp["num"]; //取得已订小计件数和金额 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' ".$con); $xj_yd_js=$tmp["num"]; $xj_yd_je=$tmp["je"]; $xj_yd_jsje=$tmp["jsje"]; $xj_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where zd1='".$m4["title"]."' ".$con_dr); // while($m=$db->fetch_array($r)){ //$list=$count+1; //$gtitle=get_cate_title_no($s_group_by,$m[$s_group_by]); // if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){ //取得款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con); $hj_yd_ks=$tmp["num"]; if($s_group_by1=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$m4["no"].",%' and ".$s_group_by2."='".$m["no"]."'".$con1); else if($s_group_by2=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and concat(',',color,',') like '%,".$m["no"].",%'".$con1); else $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con1); $hj_z_ks=$tmp["num"]; } //取得款色 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con); $hj_yd_sku=$tmp["num"]; if($s_group_by1=="sx" || $s_group_by2=="sx"){ if($s_group_by1=="sx"){ $con11=" no='".$m4["no"]."'"; $con12=$s_group_by2."='".$m["no"]."'"; }else{ $con11=" no='".$m["no"]."'"; $con12=$s_group_by1."='".$m4["no"]."'"; } //取得设计款色 $tmp=get_db_msg("select * from ".$table_pre."sx where ".$con11); $arr_color=explode(",",$tmp["_v"]); $n1=0; for($i1=0;$i1'y' and concat(',',color,',') like '%,".$arr_color[$i1].",%' and ".$con12); $n1+=$tmp["num"]; } $hj_z_sku=$n1; }else if($s_group_by1=="color" || $s_group_by2=="color"){ if($s_group_by1=="color"){ $con11=$m4["no"]; $con12=$s_group_by2."='".$m["no"]."'"; }else{ $con11=$m["no"]; $con12=$s_group_by1."='".$m4["no"]."'"; } //取得设计款色 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$con12." and concat(',',color,',') like '%,".$con11.",%'".$con1); $hj_z_sku=$tmp["num"]; }else{ $hj_z_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' ".$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $n1=count(explode(",",$m2["color"])); $n2=trim($m2["color_ka"])?count(explode(",",$m2["color_ka"])):0; $hj_z_sku+=$n1-$n2; } } $q1="select * from ".$table_pre."keyword where cate='".$s_group_by3."' order by no"; //echo $q1."
"; $r1=$db->query($q1); $l=0; //取得已订小计款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' and ".$s_group_by3."<>'' ".$con); $hj_yd_ks=$tmp["num"]; //取得已订小计款色数 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' and ".$s_group_by3."<>'' ".$con); $hj_yd_sku=$tmp["num"]; //取得已订小计件数和金额 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' and ".$s_group_by3."<>'' ".$con); $hj_yd_js=$tmp["num"]; $hj_yd_je=$tmp["je"]; $hj_yd_jsje=$tmp["jsje"]; $hj_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where zd1='".$m4["title"]."' and zd2='".$m["title"]."' ".$con_dr); // while($m1=$db->fetch_array($r1)){ if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ //取得款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'".$con); $tmp_yd_ks=$tmp["num"]; if($s_group_by1=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$m4["no"].",%' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'".$con1); else if($s_group_by2=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by3."='".$m1["no"]."' and concat(',',color,',') like '%,".$m["no"].",%'".$con1); else if($s_group_by3=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and concat(',',color,',') like '%,".$m1["no"].",%'".$con1); else $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'".$con1); $tmp_z_ks=$tmp["num"]; } //取得款色 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'".$con); $tmp_yd_sku=$tmp["num"]; if($s_group_by1=="sx" || $s_group_by2=="sx" || $s_group_by3=="sx"){ if($s_group_by1=="sx"){ $con11=" no='".$m4["no"]."'"; $con12=$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'"; }else if($s_group_by2=="sx"){ $con11=" no='".$m["no"]."'"; $con12=$s_group_by1."='".$m4["no"]."' and ".$s_group_by3."='".$m1["no"]."'"; }else{ $con11=" no='".$m1["no"]."'"; $con12=$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'"; } //取得设计款色 $tmp=get_db_msg("select * from ".$table_pre."sx where ".$con11); $arr_color=explode(",",$tmp["_v"]); $n1=0; for($i1=0;$i1'y' and concat(',',color,',') like '%,".$arr_color[$i1].",%' and ".$con12); $n1+=$tmp["num"]; } $tmp_z_sku=$n1; }else if($s_group_by1=="color" || $s_group_by2=="color" || $s_group_by3=="color"){ if($s_group_by1=="color"){ $con11=$m4["no"]; $con12=$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'"; }else if($s_group_by2=="color"){ $con11=$m["no"]; $con12=$s_group_by1."='".$m4["no"]."' and ".$s_group_by3."='".$m1["no"]."'"; }else{ $con11=$m1["no"]; $con12=$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'"; } //取得设计款色 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$con12." and concat(',',color,',') like '%,".$con11.",%'".$con1); $tmp_z_sku=$tmp["num"]; }else{ $tmp_z_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."' ".$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $n1=count(explode(",",$m2["color"])); $n2=trim($m2["color_ka"])?count(explode(",",$m2["color_ka"])):0; $tmp_z_sku+=$n1-$n2; } } //取得数量 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'".$con); $tmp_yd_js=$tmp["num"]; $tmp_yd_je=$tmp["je"]; $tmp_yd_jsje=$tmp["jsje"]; $tmp_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where id>0 and zd1='".$m4["title"]."' and zd2='".$m["title"]."' and zd3='".$m1["title"]."'".$con_dr); // if($tmp_z_sku>0){ $content_data.="
"; $content_data.=""; $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ //取得均价 $tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."='".$m1["no"]."'".$con1); $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $count++; } } if($hj_z_sku>0){ $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ //取得均价 $tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' and ".$s_group_by3."<>''".$con1); $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $count++; } } if($xj_z_sku>0){ $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ //取得均价 $tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."<>''".$con1); $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $count++; } } $content_data.=""; }else if($zd2){ $json_data.="\"sys_bb_type\":\"report_2w\","; //取得总款数 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where no<>'' ".$con2.$con1); $total_ks=$tmp["num"]; //取得总款色数 $total_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where no<>'' ".$con2.$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $arr1=explode(",",$m2["color"]); $arr2=explode(",",$m2["color_ka"]); for($i1=0;$i1'' ".$con2.$con1); $price_jj=keep_float($tmp["jj"],1); } //取得已订总件数和金额 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con); $total_yd_js=$tmp["num"]; $total_yd_je=$tmp["je"]; $total_yd_jsje=$tmp["jsje"]; //取得已订总款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con); $total_yd_ks=$tmp["num"]; //取得已订总款色数 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con); $total_yd_sku=$tmp["num"]; $total_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where id<>0 ".$con_dr); // $q4="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by no"; $r4=$db->query($q4); $count=$l=$total_num=$total_money=0; while($m4=$db->fetch_array($r4)){ $con11=($s_group_by2=="sx" || $s_group_by2=="color")?"":" and ".$s_group_by2."<>''"; if($s_group_by1=="color"){ $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$m4["no"].",%'".$con11.$con1); $xj_z_sku=$tmp["num"]; }else if($s_group_by1=="sx"){ //取得设计款色 $tmp=get_db_msg("select * from ".$table_pre."sx where no='".$m4["no"]."'"); $arr_color=explode(",",$tmp["_v"]); $n1=0; for($i1=0;$i1query($q2); while($m2=$db->fetch_array($r2)){ $arr1=explode(",",$m2["color"]); $arr2=explode(",",$m2["color_ka"]); for($i1=0;$i1"; $r=$db->query($q); $l=0; //取得已订小计款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con); $xj_yd_ks=$tmp["num"]; //取得已订小计款色数 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' ".$con); $xj_yd_sku=$tmp["num"]; //取得已订小计件数和金额 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' ".$con); $xj_yd_js=$tmp["num"]; $xj_yd_je=$tmp["je"]; $xj_yd_jsje=$tmp["jsje"]; $xj_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where zd1='".$m4["title"]."' ".$con_dr); // while($m=$db->fetch_array($r)){ $list=$count+1; $gtitle=get_cate_title_no($s_group_by,$m[$s_group_by]); // if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){ //取得款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con); $tmp_yd_ks=$tmp["num"]; if($s_group_by1=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$m4["no"].",%' and ".$s_group_by2."='".$m["no"]."'".$con1); else if($s_group_by2=="color") $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and concat(',',color,',') like '%,".$m["no"].",%'".$con1); else $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con1); $tmp_z_ks=$tmp["num"]; } //取得款色 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con); $tmp_yd_sku=$tmp["num"]; if($s_group_by1=="sx" || $s_group_by2=="sx"){ if($s_group_by1=="sx"){ $con11=" no='".$m4["no"]."'"; $con12=$s_group_by2."='".$m["no"]."'"; }else{ $con11=" no='".$m["no"]."'"; $con12=$s_group_by1."='".$m4["no"]."'"; } //取得设计款色 $tmp=get_db_msg("select * from ".$table_pre."sx where ".$con11); $arr_color=explode(",",$tmp["_v"]); $n1=0; for($i1=0;$i1'y' and concat(',',color,',') like '%,".$arr_color[$i1].",%' and ".$con12); $n1+=$tmp["num"]; } $tmp_z_sku=$n1; }else if($s_group_by1=="color" || $s_group_by2=="color"){ if($s_group_by1=="color"){ $con11=$m4["no"]; $con12=$s_group_by2."='".$m["no"]."'"; }else{ $con11=$m["no"]; $con12=$s_group_by1."='".$m4["no"]."'"; } //取得设计款色 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$con12." and concat(',',color,',') like '%,".$con11.",%'".$con1); $tmp_z_sku=$tmp["num"]; }else{ $tmp_z_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."' ".$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $n1=count(explode(",",$m2["color"])); $n2=trim($m2["color_ka"])?count(explode(",",$m2["color_ka"])):0; $tmp_z_sku+=$n1-$n2; } } //取得数量 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con); $tmp_yd_js=$tmp["num"]; $tmp_yd_je=$tmp["je"]; $tmp_yd_jsje=$tmp["jsje"]; $tmp_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where id>0 and zd1='".$m4["title"]."' and zd2='".$m["title"]."'".$con_dr); // if($tmp_z_sku>0){ $content_data.=""; $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){ //取得均价 $tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con1); $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $count++; } } if($xj_z_sku>0){ $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){ //取得均价 $tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."<>''".$con1); $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $count++; } } $content_data.=""; }else{ //取得总款数 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."<>''".$con1); $total_ks=$tmp["num"]; //取得总款色数 $total_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."<>''".$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $arr1=explode(",",$m2["color"]); $arr2=explode(",",$m2["color_ka"]); for($i1=0;$i1''".$con1); $price_jj=keep_float($tmp["jj"],1); //取得已订总件数和金额 $q="select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where ".$s_group_by1."<>'' ".$con; $tmp=get_db_msg($q); $total_yd_js=$tmp["num"]; $total_yd_je=$tmp["je"]; $total_yd_jsje=$tmp["jsje"]; //取得已订总款数 $tmp1=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by1."<>'' ".$con); $total_yd_ks=$tmp1["num"]; //取得已订总款色数 $tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by1."<>'' ".$con); $total_yd_sku=$tmp1["num"]; $total_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where id<>0 ".$con_dr); $json_data.="\"sys_bb_type\":\"report_1w\","; $tb_data_x=""; $tb_data_y=","; // $tbody_str=""; $q="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by no"; $r=$db->query($q); $count=$total_num=$total_money=0; while($m=$db->fetch_array($r)){ $list=$count+1; if($s_group_by=="color"){ $gtitle=get_cate_title_no("color",$m["color"]); }else{ $gtitle=get_cate_title_no($s_group_by,$m[$s_group_by]); } //------取得款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m["no"]."'".$con); $tmp_yd_ks=$tmp["num"]; $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m["no"]."'".$con1); $tmp_z_ks=$tmp["num"]; //取得款色 $tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m["no"]."'".$con); $tmp_yd_sku=$tmp["num"]; $tmp_z_sku=0; $q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."='".$m["no"]."'".$con1; $r2=$db->query($q2); while($m2=$db->fetch_array($r2)){ $n1=count(explode(",",$m2["color"])); $n2=trim($m2["color_ka"])?count(explode(",",$m2["color_ka"])):0; $tmp_z_sku+=$n1-$n2; } //取得数量 $tmp=get_db_msg("select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m["no"]."'".$con); $tmp_yd_js=$tmp["num"]; $tmp_yd_je=$tmp["je"]; $tmp_yd_jsje=$tmp["jsje"]; $tmp_dr=get_db_msg("select ".$str_sql." from ".$table_pre.$tbname." where id>0 and zd1='".$m4["title"]."' ".$con_dr); if($tmp_z_ks>0){ //取得均价 $tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by1."='".$m["no"]."'".$con1); // $tb_data_x.=$m["title"].","; $tb_data_y.=str_replace("%","",deel_bfb($tmp_yd_js,$total_yd_js)).","; if($msg_client["face"]=="4"){ $content_data.=""; }else{ $content_data.=""; } // $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $count++; } } $tb_data_y=deel_end($tb_data_y); $tb_data_x=deel_end($tb_data_x); $json_data.="\"chart_title\":\"\","; $json_data.="\"chart_type\":\"pie\","; $json_data.="\"chart_data_x\":\"".$tb_data_x."\","; $json_data.="\"chart_data_y\":\"".$tb_data_y."\","; $content_data.=""; } // $content_data.=""; $content_data.=""; $content_data.=""; if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by3!="sx" && $s_group_by1!="color" && $s_group_by2!="color" && $s_group_by3!="color"){ $content_data.=($head_zd1=="y")?"":""; $content_data.=($head_zd2=="y")?"":""; $content_data.=($head_zd3=="y")?"":""; } $content_data.=($head_zd4=="y")?"":""; $content_data.=($head_zd5=="y")?"":""; $content_data.=($head_zd6=="y")?"":""; $content_data.=($head_zd7=="y")?"":""; $content_data.=($head_zd8=="y")?"":""; $content_data.=($dr_zd1)?"":""; $content_data.=($dr_zd2)?"":""; $content_data.=($dr_zd3)?"":""; $content_data.=($dr_zd4)?"":""; $content_data.=($dr_zd5)?"":""; $content_data.=($dr_zd6)?"":""; $content_data.=($dr_zd7)?"":""; $content_data.=($dr_zd8)?"":""; $content_data.=""; $content_data.=""; $content_data.="
".get_main_value($arr_group_by_title,$s_group_by1)."".get_main_value($arr_group_by_title,$s_group_by2)."".get_main_value($arr_group_by_title,$s_group_by3)."均价设计款数已订款数设计款色已订款色已订件数吊牌金额结算金额".get_dr_title($dr_zd1)."".get_dr_title($dr_zd2)."".get_dr_title($dr_zd3)."".get_dr_title($dr_zd4)."".get_dr_title($dr_zd5)."".get_dr_title($dr_zd6)."".get_dr_title($dr_zd7)."".get_dr_title($dr_zd8)."
款数占比款数占比款数占比款数占比件数占比金额占比金额占比
".$m4["title"]."".$m["title"]."".$m1["title"]."".keep_float($tmp["jj"],1)."".$tmp_z_ks."".deel_bfb($tmp_z_ks,$hj_z_ks)."".$tmp_yd_ks."".deel_bfb($tmp_yd_ks,$hj_yd_ks)."".$tmp_z_sku."".deel_bfb($tmp_z_sku,$hj_z_sku)."".$tmp_yd_sku."".deel_bfb($tmp_yd_sku,$hj_yd_sku)."".deel_01(deel_num($tmp_yd_js))."".deel_bfb($tmp_yd_js,$hj_yd_js)."".deel_01(deel_num($tmp_yd_je))."".deel_bfb($tmp_yd_je,$hj_yd_je)."".deel_01(deel_num($tmp_yd_jsje))."".deel_bfb($tmp_yd_jsje,$hj_yd_jsje)."".deel_dr($dr_zd1,$tmp_dr["dr_zd1"])."".deel_dr($dr_zd2,$tmp_dr["dr_zd2"])."".deel_dr($dr_zd3,$tmp_dr["dr_zd3"])."".deel_dr($dr_zd4,$tmp_dr["dr_zd4"])."".deel_dr($dr_zd5,$tmp_dr["dr_zd5"])."".deel_dr($dr_zd6,$tmp_dr["dr_zd6"])."".deel_dr($dr_zd7,$tmp_dr["dr_zd7"])."".deel_dr($dr_zd8,$tmp_dr["dr_zd8"])."
".$m["title"]."小计".keep_float($tmp["jj"],1)."".$hj_z_ks."".deel_bfb($hj_z_ks,$total_ks)."".$hj_yd_ks."".deel_bfb($hj_yd_ks,$total_yd_ks)."".$hj_z_sku."".deel_bfb($hj_z_sku,$total_sku)."".$hj_yd_sku."".deel_bfb($hj_yd_sku,$total_yd_sku)."".deel_num($hj_yd_js)."".deel_bfb($hj_yd_js,$total_yd_js)."".deel_num($hj_yd_je)."".deel_bfb($hj_yd_je,$total_yd_je)."".deel_num($hj_yd_jsje)."".deel_bfb($hj_yd_jsje,$total_yd_jsje)."".deel_dr_hj($dr_zd1,$hj_dr["dr_zd1"])."".deel_dr_hj($dr_zd2,$hj_dr["dr_zd2"])."".deel_dr_hj($dr_zd3,$hj_dr["dr_zd3"])."".deel_dr_hj($dr_zd4,$hj_dr["dr_zd4"])."".deel_dr_hj($dr_zd5,$hj_dr["dr_zd5"])."".deel_dr_hj($dr_zd6,$hj_dr["dr_zd6"])."".deel_dr_hj($dr_zd7,$hj_dr["dr_zd7"])."".deel_dr_hj($dr_zd8,$hj_dr["dr_zd8"])."
".$m4["title"]."小计".keep_float($tmp["jj"],1)."".$xj_z_ks."".deel_bfb($xj_z_ks,$total_ks)."".$xj_yd_ks."".deel_bfb($xj_yd_ks,$total_yd_ks)."".$xj_z_sku."".deel_bfb($xj_z_sku,$total_sku)."".$xj_yd_sku."".deel_bfb($xj_yd_sku,$total_yd_sku)."".deel_num($xj_yd_js)."".deel_bfb($xj_yd_js,$total_yd_js)."".deel_num($xj_yd_je)."".deel_bfb($xj_yd_je,$total_yd_je)."".deel_num($xj_yd_jsje)."".deel_bfb($xj_yd_jsje,$total_yd_jsje)."".deel_dr_hj($dr_zd1,$xj_dr["dr_zd1"])."".deel_dr_hj($dr_zd2,$xj_dr["dr_zd2"])."".deel_dr_hj($dr_zd3,$xj_dr["dr_zd3"])."".deel_dr_hj($dr_zd4,$xj_dr["dr_zd4"])."".deel_dr_hj($dr_zd5,$xj_dr["dr_zd5"])."".deel_dr_hj($dr_zd6,$xj_dr["dr_zd6"])."".deel_dr_hj($dr_zd7,$xj_dr["dr_zd7"])."".deel_dr_hj($dr_zd8,$xj_dr["dr_zd8"])."
".$m4["title"]."".$m["title"]."".keep_float($tmp["jj"],1)."".$tmp_z_ks."".deel_bfb($tmp_z_ks,$xj_z_ks)."".$tmp_yd_ks."".deel_bfb($tmp_yd_ks,$xj_yd_ks)."".$tmp_z_sku."".deel_bfb($tmp_z_sku,$xj_z_sku)."".$tmp_yd_sku."".deel_bfb($tmp_yd_sku,$xj_yd_sku)."".deel_01(deel_num($tmp_yd_js))."".deel_bfb($tmp_yd_js,$xj_yd_js)."".deel_01(deel_num($tmp_yd_je))."".deel_bfb($tmp_yd_je,$xj_yd_je)."".deel_01(deel_num($tmp_yd_jsje))."".deel_bfb($tmp_yd_jsje,$xj_yd_jsje)."".deel_dr($dr_zd1,$tmp_dr["dr_zd1"])."".deel_dr($dr_zd2,$tmp_dr["dr_zd2"])."".deel_dr($dr_zd3,$tmp_dr["dr_zd3"])."".deel_dr($dr_zd4,$tmp_dr["dr_zd4"])."".deel_dr($dr_zd5,$tmp_dr["dr_zd5"])."".deel_dr($dr_zd6,$tmp_dr["dr_zd6"])."".deel_dr($dr_zd7,$tmp_dr["dr_zd7"])."".deel_dr($dr_zd8,$tmp_dr["dr_zd8"])."
小计".keep_float($tmp["jj"],1)."".$xj_z_ks."".deel_bfb($xj_z_ks,$total_ks)."".$xj_yd_ks."".deel_bfb($xj_yd_ks,$total_yd_ks)."".$xj_z_sku."".deel_bfb($xj_z_sku,$total_sku)."".$xj_yd_sku."".deel_bfb($xj_yd_sku,$total_yd_sku)."".deel_num($xj_yd_js)."".deel_bfb($xj_yd_js,$total_yd_js)."".deel_num($xj_yd_je)."".deel_bfb($xj_yd_je,$total_yd_je)."".deel_num($xj_yd_jsje)."".deel_bfb($xj_yd_jsje,$total_yd_jsje)."".deel_dr_hj($dr_zd1,$xj_dr["dr_zd1"])."".deel_dr_hj($dr_zd2,$xj_dr["dr_zd2"])."".deel_dr_hj($dr_zd3,$xj_dr["dr_zd3"])."".deel_dr_hj($dr_zd4,$xj_dr["dr_zd4"])."".deel_dr_hj($dr_zd5,$xj_dr["dr_zd5"])."".deel_dr_hj($dr_zd6,$xj_dr["dr_zd6"])."".deel_dr_hj($dr_zd7,$xj_dr["dr_zd7"])."".deel_dr_hj($dr_zd8,$xj_dr["dr_zd8"])."
".$m["title"]."
".$m["title"]."".keep_float($tmp["jj"],1)."".$tmp_z_ks."".deel_bfb($tmp_z_ks,$total_ks)."".$tmp_yd_ks."".deel_bfb($tmp_yd_ks,$total_yd_ks)."".$tmp_z_sku."".deel_bfb($tmp_z_sku,$total_sku)."".$tmp_yd_sku."".deel_bfb($tmp_yd_sku,$total_yd_sku)."".deel_01(deel_num($tmp_yd_js))."".deel_bfb($tmp_yd_js,$total_yd_js)."".deel_01(deel_num($tmp_yd_je))."".deel_bfb($tmp_yd_je,$total_yd_je)."".deel_01(deel_num($tmp_yd_jsje))."".deel_bfb($tmp_yd_jsje,$total_yd_jsje)."".deel_dr($dr_zd1,$tmp_dr["dr_zd1"])."".deel_dr($dr_zd2,$tmp_dr["dr_zd2"])."".deel_dr($dr_zd3,$tmp_dr["dr_zd3"])."".deel_dr($dr_zd4,$tmp_dr["dr_zd4"])."".deel_dr($dr_zd5,$tmp_dr["dr_zd5"])."".deel_dr($dr_zd6,$tmp_dr["dr_zd6"])."".deel_dr($dr_zd7,$tmp_dr["dr_zd7"])."".deel_dr($dr_zd8,$tmp_dr["dr_zd8"])."
合计".$price_jj."".$total_ks."".deel_num($total_yd_ks)."".deel_num($total_sku)."".deel_num($total_yd_sku)."".deel_num($total_yd_js)."".deel_num($total_yd_je)."".deel_num($total_yd_jsje)."".deel_dr_hj($dr_zd1,$total_dr["dr_zd1"])."".deel_dr_hj($dr_zd2,$total_dr["dr_zd2"])."".deel_dr_hj($dr_zd3,$total_dr["dr_zd3"])."".deel_dr_hj($dr_zd4,$total_dr["dr_zd4"])."".deel_dr_hj($dr_zd5,$total_dr["dr_zd5"])."".deel_dr_hj($dr_zd6,$total_dr["dr_zd6"])."".deel_dr_hj($dr_zd7,$total_dr["dr_zd7"])."".deel_dr_hj($dr_zd8,$total_dr["dr_zd8"])."
"; } $json_data.="\"table_html\":\"".$content_data."\","; function deel_dr($dr,$v){ $tmp=explode("_",$dr); if($tmp[1]=="百分比"){ $tmp1=$v*100; return $tmp1."%"; }else if($tmp[1]=="数字"){ return deel_num($v); }else{ return $v; } } function deel_dr_hj($dr,$v){ $tmp=explode("_",$dr); if($tmp[1]=="百分比"){ $tmp1=$v*100; return $tmp1."%"; }else if($tmp[1]=="数字"){ return deel_num($v); }else{ return ""; } } function get_dr_title($dr){ $tmp=explode("_",$dr); return $tmp[0]; } ?>