7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2561 lines
104 KiB
PHP
2561 lines
104 KiB
PHP
<?php
|
|
//-------------------------------表报分析-界面
|
|
header("Content-type: text/html; charset=utf-8");
|
|
$json_data="{";
|
|
if(THIS_IN!="edt_ipad")
|
|
exit("错误的访问!");
|
|
$uid=check_cookie_jxs();
|
|
$msg_client=get_db_msg("select * from ".$table_pre."client where id='".$uid."'");
|
|
$is_brand=is_brand();
|
|
$zk_type=get_set("zk_type");
|
|
$zb_type=get_set("zb_type");
|
|
$arr_zb_type=explode(",",$zb_type);
|
|
$is_spk=get_set("is_spk");
|
|
|
|
$json_data.="\"uid\":\"".$uid."\",";
|
|
$json_data.="\"face\":\"".$msg_client["face"]."\",";
|
|
//$json_data.="\"cate\":\"".$cate."\",";
|
|
$json_data.="\"cate\":\"".str_replace('&','%26',$cate)."\",";
|
|
|
|
//订货会标记选项
|
|
$tmp_order_flag="";
|
|
$con_f=$con_f1=$con_f2="";
|
|
foreach($arr_sys_order_flag as $k => $v){
|
|
$tmp_order_flag.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},";
|
|
}
|
|
if(count($arr_sys_order_flag)>1){
|
|
$tmp_order_flag.="{\"no\":\"all\",\"title\":\"所有订单\"},";
|
|
$json_data.="\"show_key\":\"y\",";
|
|
|
|
$tmp_order_flag=deel_end($tmp_order_flag);
|
|
if($s_key){
|
|
$selectf=$s_key;
|
|
}else{
|
|
$selectf=$_key;
|
|
}
|
|
$str_json="\"select_order_flag\":{\"no\":\"s_key\",\"title\":\"订货会标记\",\"value\":\"".$selectf."\",\"op\":[".$tmp_order_flag."]},";
|
|
|
|
$json_data.=$str_json;
|
|
|
|
if($s_key){
|
|
if($s_key=="all"){
|
|
$con_f=$con_f1=$con_f2="";
|
|
}else{
|
|
$con_f=" and _key='".$s_key."'";
|
|
$con_f1=" and a._key='".$s_key."'";
|
|
$con_f2=" and b._key='".$s_key."'";
|
|
}
|
|
}
|
|
}
|
|
|
|
switch($cate){
|
|
case "openDetail":
|
|
$s_key=$s_key?$s_key:$_key;
|
|
$con_u_tmp="";
|
|
if($s_username){
|
|
//检查是否存在
|
|
$m_client=get_db_msg("select id,face,path,username from ".$table_pre."client where username='".$s_username."'");
|
|
//
|
|
if($m_client["id"]){
|
|
if($m_client["face"]=="4"){
|
|
$con_u_tmp.=" and (uid='".$m_client["id"]."') ";
|
|
}else{
|
|
$con_u_tmp.=" and (upath='".$m_client["path"]."-".$m_client["id"]."' or upath like '".$m_client["path"]."-".$m_client["id"]."-%') ";
|
|
}
|
|
}else{
|
|
$con_u_tmp.=" and (uid='0') ";
|
|
}
|
|
}else{
|
|
if($msg_client["face"]=="1"){
|
|
|
|
}else{
|
|
if($msg_client["face"]=="2"){
|
|
$con_u_tmp.=get_qj_ucon_all($msg_client["charge_path_real"]);
|
|
}else{
|
|
$con_u_tmp.=" and (upath='".$msg_client["path"]."-".$msg_client["id"]."' or upath like '".$msg_client["path"]."-".$msg_client["id"]."-%') ";
|
|
}
|
|
}
|
|
}
|
|
//
|
|
$json_data.="\"code\":0,\"msg\":\"\",\"count\":\"1000\",\"data\":[";
|
|
$str_tmp="";
|
|
$q="select iid,color,num from (select sum(num) 'num',iid,color from ".$table_pre."order where _key='".$s_key."' and ka<>'y'".$con_u_tmp." group by iid,color) as t1 where num='".$s_num."'";
|
|
//echo $q."<br>";
|
|
$r=$db->query($q);
|
|
$count=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$list=$count+1;
|
|
$m_kh=get_db_msg("select no,xh from ".$table_pre."kh where id='".$m["iid"]."'");
|
|
$str_tmp.="{";
|
|
$str_tmp.="\"list\":\"".$list."\",";
|
|
$str_tmp.="\"xh\":\"".get_kh_xh($m_kh,$m["color"])."\",";
|
|
$str_tmp.="\"kh\":\"".$m_kh["no"]."\",";
|
|
$str_tmp.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\"";
|
|
$str_tmp.="},";
|
|
$count++;
|
|
}
|
|
$json_data.=substr($str_tmp,0,-1)."],";
|
|
break;
|
|
case "client":
|
|
$s_group_by_default="dd";
|
|
//判断是否有区域
|
|
$check_qy=get_db_msg("select count(*) 'num' from ".$table_pre."client where face='9'");
|
|
if($check_qy["num"]>0){
|
|
$arr_group_by["qy"]=d_translate("qy");
|
|
}
|
|
//判断是否有代理
|
|
$check_dl=get_db_msg("select count(*) 'num' from ".$table_pre."client where face='3'");
|
|
if($check_dl["num"]>0){
|
|
$arr_group_by["dl"]=d_translate("dl");
|
|
}
|
|
//判断是否有店铺属性
|
|
$check_dpsx=get_db_msg("select count(distinct dpsx) 'num' from ".$table_pre."client where face='4' and dpsx<>''");
|
|
if($check_dpsx["num"]>0){
|
|
$arr_group_by["dpsx"]="店铺属性";
|
|
}
|
|
//判断是否有店铺等级
|
|
$check_dj=get_db_msg("select count(distinct dj) 'num' from ".$table_pre."client where face='4' and dj<>''");
|
|
if($check_dj["num"]>0){
|
|
$arr_group_by["dj"]="店铺等级";
|
|
}
|
|
$arr_group_by["dd"]="店铺";
|
|
|
|
//------------------------二维报表
|
|
//区域
|
|
if($check_qy["num"]>0 && $check_dl["num"]>0){
|
|
$arr_group_by["qy|dl"]=d_translate("qy")."-".d_translate("dl");
|
|
}
|
|
if($check_qy["num"]>0){
|
|
$arr_group_by["qy|dd"]=d_translate("qy")."-店铺";
|
|
}
|
|
if($check_dpsx["num"]>0 && $check_qy["num"]>0){
|
|
$arr_group_by["qy|dpsx"]=d_translate("qy")."-属性";
|
|
}
|
|
if($check_dj["num"]>0 && $check_qy["num"]>0){
|
|
$arr_group_by["qy|dj"]=d_translate("qy")."-等级";
|
|
}
|
|
//代理
|
|
if($check_dl["num"]>0){
|
|
$arr_group_by["dl|dd"]=d_translate("dl")."-店铺";
|
|
}
|
|
if($check_dpsx["num"]>0 && $check_dl["num"]>0){
|
|
$arr_group_by["dl|dpsx"]=d_translate("dl")."-属性";
|
|
}
|
|
if($check_dj["num"]>0 && $check_dl["num"]>0){
|
|
$arr_group_by["dl|dj"]=d_translate("dl")."-等级";
|
|
}
|
|
//属性
|
|
if($check_dpsx["num"]>0){
|
|
$arr_group_by["dpsx|dd"]="属性-店铺";
|
|
}
|
|
//等级
|
|
if($check_dj["num"]>0){
|
|
$arr_group_by["dj|dd"]="等级-店铺";
|
|
}
|
|
|
|
//----默认
|
|
if($check_dj["num"]>0)
|
|
$s_group_by_default="dj";
|
|
if($check_dpsx["num"]>0)
|
|
$s_group_by_default="dpsx";
|
|
if($check_dl["num"]>0)
|
|
$s_group_by_default="dl";
|
|
if($check_qy["num"]>0)
|
|
$s_group_by_default="qy";
|
|
$s_group_by=$s_group_by?$s_group_by:$s_group_by_default;
|
|
|
|
if($is_brand=="y"){
|
|
$str_brand="";
|
|
$r=$db->query("select * from ".$table_pre."keyword where cate='brand' order by no");
|
|
while($m=$db->fetch_array($r)){
|
|
$str_brand.="{\"no\":\"".$m["no"]."\",\"title\":\"".$m["no"]."(".$m["title"].")\"},";
|
|
}
|
|
$str_brand=deel_end($str_brand);
|
|
$json_data.="\"select_brand\":{\"no\":\"s_brand\",\"title\":\"所有".get_cate_title_no("arr_select","brand")."\",\"value\":\"".$s_brand."\",\"op\":[".$str_brand."]},";
|
|
$json_data.="\"show_brand\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_brand\":\"n\",";
|
|
}
|
|
|
|
$str_group_by="";
|
|
foreach($arr_group_by as $k1 => $v1){
|
|
$str_group_by.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\"},";
|
|
}
|
|
$str_group_by=deel_end($str_group_by);
|
|
$json_data.="\"select_group_by\":{\"no\":\"s_group_by\",\"title\":\"报表分组\",\"value\":\"".$s_group_by."\",\"op\":[".$str_group_by."]},";
|
|
|
|
if($s_group_by=="dd"){
|
|
$json_data.="\"show_dd\":\"y\",";
|
|
$json_data.="\"s_username\":\"".$s_username."\",";
|
|
|
|
$str_is_checked="";
|
|
foreach($arr_yn as $k => $v){
|
|
$str_is_checked.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},";
|
|
}
|
|
$str_is_checked=deel_end($str_is_checked);
|
|
$json_data.="\"select_is_checked\":{\"no\":\"s_is_checked\",\"title\":\"已确认\",\"value\":\"".$s_is_checked."\",\"op\":[".$str_is_checked."]},";
|
|
|
|
if($check_dl["num"]>0){
|
|
//取得区域过滤
|
|
$q1="select * from ".$table_pre."client where face='9' order by ord";
|
|
$r1=$db->query($q1);
|
|
$str_qy="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$str_qy.="{\"no\":\"".$m1["path"]."-".$m1["id"]."\",\"title\":\"".$m1["title"]."\"},";
|
|
}
|
|
$str_qy=deel_end($str_qy);
|
|
$json_data.="\"select_path_qy\":{\"no\":\"s_path_qy\",\"title\":\"区域\",\"value\":\"".$s_path_qy."\",\"op\":[".$str_qy."]},";
|
|
$json_data.="\"show_path_qy\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_path_qy\":\"n\",";
|
|
}
|
|
|
|
if($check_dl["num"]>0){
|
|
$con1="";
|
|
if($s_path_qy)
|
|
$con1.=" and (path='".$s_path_qy."' or path like '".$s_path_qy."-%')";
|
|
//取得代理过滤
|
|
$q1="select * from ".$table_pre."client where face='3'".$con1." order by ord";
|
|
$r1=$db->query($q1);
|
|
$str_dl="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$str_dl.="{\"no\":\"".$m1["path"]."-".$m1["id"]."\",\"title\":\"".$m1["title"]."\"},";
|
|
}
|
|
$str_dl=deel_end($str_dl);
|
|
$json_data.="\"select_path_dl\":{\"no\":\"s_path_dl\",\"title\":\"代理\",\"value\":\"".$s_path_dl."\",\"op\":[".$str_dl."]},";
|
|
$json_data.="\"show_path_dl\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_path_dl\":\"n\",";
|
|
}
|
|
|
|
if($check_dpsx["num"]>0){
|
|
//取得店铺属性
|
|
$q1="select dpsx 'title' from ".$table_pre."client where dpsx<>'' group by dpsx order by dpsx";
|
|
$r1=$db->query($q1);
|
|
$str_dpsx="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$str_dpsx.="{\"no\":\"".$m1["title"]."\",\"title\":\"".$m1["title"]."\"},";
|
|
}
|
|
$str_dpsx=deel_end($str_dpsx);
|
|
$json_data.="\"select_dpsx\":{\"no\":\"s_dpsx\",\"title\":\"店铺属性\",\"value\":\"".$s_dpsx."\",\"op\":[".$str_dpsx."]},";
|
|
$json_data.="\"show_dpsx\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_dpsx\":\"n\",";
|
|
}
|
|
|
|
if($check_dj["num"]>0){
|
|
//取得店铺等级
|
|
$q1="select dj 'title' from ".$table_pre."client where dj<>'' group by dj order by dj";
|
|
$r1=$db->query($q1);
|
|
$str_dj="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$str_dj.="{\"no\":\"".$m1["title"]."\",\"title\":\"".$m1["title"]."\"},";
|
|
}
|
|
$str_dj=deel_end($str_dj);
|
|
$json_data.="\"select_dj\":{\"no\":\"s_dj\",\"title\":\"店铺等级\",\"value\":\"".$s_dj."\",\"op\":[".$str_dj."]},";
|
|
$json_data.="\"show_dj\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_dj\":\"n\",";
|
|
}
|
|
}else{
|
|
$json_data.="\"show_dd\":\"n\",";
|
|
}
|
|
|
|
$arr_zb_type=explode(",",$zb_type);
|
|
$check_md=get_db_msg("select count(*) 'num' from ".$table_pre."kh_md");
|
|
//是否显示吊牌金额
|
|
if($zk_type || $check_md["num"]>0)
|
|
$show_jsje="y";
|
|
else
|
|
$show_jsje="n";
|
|
$s_order=$s_order?$s_order:"js";
|
|
if($is_spk=="y")
|
|
$con_spk=" and is_sp<>'y'";
|
|
else
|
|
$con_spk="";
|
|
if($is_brand=="y" && $s_brand)
|
|
$con_brand=" and brand='".$s_brand."'";
|
|
else
|
|
$con_brand="";
|
|
$arr_group_by1=explode("|",$s_group_by);
|
|
$arr_face1=array("dl"=>"3","qy"=>"9","dd"=>"4");
|
|
if(count($arr_group_by1)>1){
|
|
//---------------------------------二维报表
|
|
$json_data.="\"bbtype\":2,";
|
|
$s_group_by1=$arr_group_by1[0];
|
|
$s_group_by2=$arr_group_by1[1];
|
|
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"group_by1\",\"title\":\"".get_main_value($arr_group_by,$s_group_by1)."\"},";
|
|
$thead_str.="{\"zd\":\"group_by2\",\"title\":\"".get_main_value($arr_group_by,$s_group_by2)."\"},";
|
|
$thead_str.="{\"zd\":\"sl\",\"title\":\"数量\"},";
|
|
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\"},";
|
|
if($show_jsje=="y")
|
|
$thead_str.="{\"zd\":\"jsje\",\"title\":\"结算金额\"},";
|
|
if(in_array("js",$arr_zb_type)){
|
|
$thead_str.="{\"zd\":\"slzb\",\"title\":\"件数指标\"},";
|
|
$thead_str.="{\"zd\":\"slwcl\",\"title\":\"件数完成率\"},";
|
|
}
|
|
if(in_array("je",$arr_zb_type)){
|
|
$thead_str.="{\"zd\":\"jezb\",\"title\":\"金额指标\"},";
|
|
$thead_str.="{\"zd\":\"jewcl\",\"title\":\"金额完成率\"},";
|
|
}
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
|
|
//--取得face
|
|
$f1=get_main_value($arr_face1,$s_group_by1);
|
|
$f2=get_main_value($arr_face1,$s_group_by2);
|
|
|
|
//--取得查询语句
|
|
if($s_group_by1=="dj" || $s_group_by1=="dpsx"){
|
|
$q="select c.".$s_group_by1." 'title',sum(o.num) 'js',sum(o.je) 'je',sum(o.jsje) 'jsje' from ".$table_pre."client c left join (select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',uid,ka,is_sp,brand from ".$table_pre."order where ka<>'y' ".$con_brand.$con_spk.$con_f." group by uid) o on (o.uid=c.id and o.ka<>'y') where c.face='4' group by c.".$s_group_by1." order by c.".$s_group_by1;
|
|
}else{
|
|
$flag_dl=($s_group_by1=="dl" || $s_group_by1=="qy")?"_dl":"";
|
|
if($s_group_by=="dd"){
|
|
$sql_group_by="o.uid";
|
|
$sql_group_by1="uid";
|
|
}else{
|
|
$sql_group_by="o.".$s_group_by1;
|
|
$sql_group_by1=$s_group_by1;
|
|
}
|
|
$q="select c.id 'id', c.path 'path',c.username 'username',c.title 'title',sum(o.num) 'js',sum(o.je) 'je',sum(o.jsje".$flag_dl.") 'jsje' from ".$table_pre."client c left join (select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',sum(jsje_dl) 'jsje_dl',uid,ka,is_sp,brand,dl,qy from ".$table_pre."order where ka<>'y' ".$con_brand.$con_spk.$con_f." group by ".$sql_group_by1.") o on (c.id=o.".$s_group_by1.") where c.face=".$f1." group by c.id order by c.id";
|
|
}
|
|
$r=$db->query($q);
|
|
$count=$total_js=$total_je=$total_jsje=$total_zb=$total_zb_js=0;
|
|
while($m=$db->fetch_array($r)){
|
|
if($s_group_by1=="qy" || $s_group_by1=="dl"){
|
|
$title1=$m["title"]."(".$m["username"].")";
|
|
$tmp_id=$m["path"]."-".$m["id"];
|
|
}else if($s_group_by1=="dpsx" || $s_group_by1=="dj"){
|
|
$title1=$m["title"];
|
|
$tmp_id=$m["title"];
|
|
}else{
|
|
$title1=$m["title"]."(".$m["username"].")";
|
|
$tmp_id=$m["path"]."-".$m["id"];
|
|
}
|
|
//--取得第二维查询语句
|
|
if($s_group_by1=="dj" || $s_group_by1=="dpsx")
|
|
$con1=" and c.".$s_group_by1."='".$m["title"]."'";
|
|
else
|
|
$con1=" and (c.path='".$m["path"]."-".$m["id"]."' or c.path like '".$m["path"]."-".$m["id"]."-%')";
|
|
if($s_group_by2=="dj" || $s_group_by2=="dpsx"){
|
|
$q2="select c.".$s_group_by2." 'title',sum(o.num) 'js',sum(o.je) 'je',sum(o.jsje) 'jsje',sum(o.jsje_dl) 'jsje_dl' from ".$table_pre."client c left join (select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',sum(jsje_dl) 'jsje_dl',uid,ka,is_sp,brand from ".$table_pre."order where ka<>'y'".$con_brand.$con_spk.$con_f." group by uid) o on (c.id=o.uid) where c.face='4' ".$con1." group by c.".$s_group_by2." order by je desc";
|
|
}else{
|
|
$flag_dl=($s_group_by2=="dl" || $s_group_by2=="qy")?"_dl":"";
|
|
if($s_group_by2=="dd"){
|
|
$sql_join="(c.id=o.uid)";
|
|
$sql_group_by1="uid";
|
|
}else{
|
|
$sql_join="(c.id=o.".$s_group_by2.")";
|
|
$sql_group_by1=$s_group_by2;
|
|
}
|
|
$q2="select c.id 'id', c.path 'path',c.username 'username',c.title 'title',sum(o.num) 'js',sum(o.je) 'je',sum(o.jsje".$flag_dl.") 'jsje' from ".$table_pre."client c left join (select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',sum(jsje_dl) 'jsje_dl',uid,ka,is_sp,brand,dl,qy from ".$table_pre."order where ka<>'y'".$con_brand.$con_spk.$con_f." group by ".$sql_group_by1.") o on ".$sql_join." where c.face=".$f2." ".$con1." group by c.id order by je desc";
|
|
}
|
|
|
|
$r2=$db->query($q2);
|
|
$xj_js=$xj_je=$xj_jsje=0;
|
|
while($m2=$db->fetch_array($r2)){
|
|
if($s_group_by2=="qy" || $s_group_by2=="dl"){
|
|
$title2=$m2["title"]."(".$m2["username"].")";
|
|
$tmp_id2=$m["id"]."-".$m2["id"];
|
|
}else if($s_group_by2=="dpsx" || $s_group_by2=="dj"){
|
|
$title2=$m2["title"];
|
|
$tmp_id2=$m["title"]."-".$m2["title"];
|
|
}else{
|
|
$title2=$m2["title"]."(".$m2["username"].")";
|
|
$tmp_id2=$m["id"]."-".$m2["id"];
|
|
}
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"xj\":\"n\",";
|
|
$tbody_str2.="\"group_by1\":\"".$title1."\",";
|
|
$tbody_str2.="\"group_by2\":\"".$title2."\",";
|
|
$tbody_str2.="\"sl\":\"".deel_01($m2["js"])."\",";
|
|
$tbody_str2.="\"je\":\"".deel_je_show(deel_01($m2["je"]))."\",";
|
|
if($show_jsje=="y")
|
|
$tbody_str2.="\"jsje\":\"".deel_je_show(deel_01($m2["jsje"]))."\",";
|
|
|
|
//-----取得指标
|
|
if($is_brand=="y"){
|
|
$tmp_sql=$tmp_sql_xj=$s_brand?" and a.brand='".$s_brand."'":"";
|
|
if($s_group_by1=="dpsx" || $s_group_by1=="dj"){
|
|
$tmp_sql_xj.=" and c.".$s_group_by1."='".$m["title"]."' and c.face='4'";
|
|
}else{
|
|
$tmp_sql_xj.=" and c.id='".$m["id"]."'";
|
|
}
|
|
if($s_group_by2=="dpsx" || $s_group_by2=="dj"){
|
|
$tmp_sql.=" and c.".$s_group_by2."='".$m2["title"]."' and c.face='4'";
|
|
}else{
|
|
$tmp_sql.=" and c.id='".$m2["id"]."'";
|
|
}
|
|
$tmp=get_db_msg("select sum(a.zb) 'zb',sum(a.zb_js) 'zb_js' from ".$table_pre."client_brand a,".$table_pre."client c where c.id=a.cid ".$tmp_sql);
|
|
}else{
|
|
$tmp_sql=$tmp_sql2=$tmp_sql_xj="";
|
|
if($s_group_by1=="dpsx" || $s_group_by1=="dj"){
|
|
$tmp_sql_xj.=" and ".$s_group_by1."='".$m["title"]."'";
|
|
$tmp_sql2=" and ".$s_group_by1."='".$m["title"]."'";
|
|
}else if($s_group_by1=="qy" || $s_group_by1=="dl"){
|
|
$tmp_sql_xj.=" and (path like '".$m["path"]."-".$m["id"]."-%' or path='".$m["path"]."-".$m["id"]."')";
|
|
$tmp_sql2=" and (path like '".$m["path"]."-".$m["id"]."-%' or path='".$m["path"]."-".$m["id"]."')";
|
|
}else{
|
|
$tmp_sql_xj.=" and id='".$m["id"]."'";
|
|
$tmp_sql2=" and id='".$m["id"]."'";
|
|
}
|
|
if($s_group_by2=="dpsx" || $s_group_by2=="dj"){
|
|
$tmp_sql.=$tmp_sql2." and ".$s_group_by2."='".$m2["title"]."'";
|
|
$tmp_sql_xj.=" and face='4'";
|
|
}else if($s_group_by2=="qy"){
|
|
$tmp_sql.=$tmp_sql2." and (path like '".$m2["path"]."-".$m2["id"]."-%' or path='".$m2["path"]."-".$m2["id"]."')";
|
|
$tmp_sql_xj.=" and face='9'";
|
|
}else if($s_group_by2=="dl"){
|
|
$tmp_sql.=$tmp_sql2." and (path like '".$m2["path"]."-".$m2["id"]."-%' or path='".$m2["path"]."-".$m2["id"]."')";
|
|
$tmp_sql_xj.=" and face='3'";
|
|
}else{
|
|
$tmp_sql.=$tmp_sql2." and id='".$m2["id"]."'";
|
|
$tmp_sql_xj.=" and face='4'";
|
|
}
|
|
//
|
|
$tmp=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client where id>0 ".$tmp_sql);
|
|
}
|
|
|
|
$tmp_zb=$tmp["zb"]*10000;
|
|
$tmp_zb_js=$tmp["zb_js"];
|
|
$wcl_js=$wcl_je="";
|
|
if(in_array("js",$arr_zb_type)){
|
|
$wcl_js=deel_bfb1($m2["js"],$tmp_zb_js,1);
|
|
$total_zb_js+=$tmp_zb_js;
|
|
$tbody_str2.="\"slzb\":\"".deel_01($tmp_zb_js)."\",";
|
|
$tbody_str2.="\"slwcl\":\"".$wcl_js."\",";
|
|
}
|
|
if(in_array("je",$arr_zb_type)){
|
|
$wcl_je=deel_bfb1($m2["jsje"],$tmp_zb,1);
|
|
$tbody_str2.="\"jezb\":\"".deel_je_show(deel_01(deel_num($tmp_zb)))."\",";
|
|
$tbody_str2.="\"jewcl\":\"".$wcl_je."\",";
|
|
$total_zb+=$tmp_zb;
|
|
}
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
|
|
$xj_js+=$m2["js"];
|
|
$xj_je+=$m2["je"];
|
|
$xj_jsje+=$m2["jsje"];
|
|
//
|
|
$total_js+=$m2["js"];
|
|
$total_je+=$m2["je"];
|
|
$total_jsje+=$m2["jsje"];
|
|
|
|
}
|
|
if($is_brand=="y"){
|
|
$tmp=get_db_msg("select sum(a.zb) 'zb',sum(a.zb_js) 'zb_js' from ".$table_pre."client_brand a,".$table_pre."client c where c.id=a.cid ".$tmp_sql_xj);
|
|
}else{
|
|
$tmp=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client where id>0 ".$tmp_sql_xj);
|
|
//echo "select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client where id>0 ".$tmp_sql_xj."<br>";
|
|
}
|
|
$xj_zb=$tmp["zb"]*10000;
|
|
$xj_zb_js=$tmp["zb_js"];
|
|
|
|
$tbody_str3="";
|
|
$tbody_str3.="\"xj\":\"y\",";
|
|
$tbody_str3.="\"group_by1\":\"\",";
|
|
$tbody_str3.="\"group_by2\":\"小计\",";
|
|
$tbody_str3.="\"sl\":\"".$xj_js."\",";
|
|
$tbody_str3.="\"je\":\"".deel_je_show($xj_je)."\",";
|
|
if($show_jsje=="y")
|
|
$tbody_str3.="\"jsje\":\"".deel_je_show($xj_jsje)."\",";
|
|
|
|
if(in_array("js",$arr_zb_type)){
|
|
$wcl1=deel_bfb1($xj_js,$xj_zb_js,1);
|
|
$tbody_str3.="\"slzb\":\"".$xj_zb_js."\",";
|
|
$tbody_str3.="\"slwcl\":\"".$wcl1."\",";
|
|
}
|
|
if(in_array("je",$arr_zb_type)){
|
|
$wcl1=deel_bfb1($xj_jsje,$xj_zb,1);
|
|
$tbody_str3.="\"jezb\":\"".deel_je_show($xj_zb)."\",";
|
|
$tbody_str3.="\"jewcl\":\"".$wcl1."\",";
|
|
}
|
|
$tbody_str.="{".substr($tbody_str3,0,-1)."},";
|
|
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//计算合计指标
|
|
if($is_brand=="y"){
|
|
if($s_brand)
|
|
$con_brand1=" and b.brand='".$s_brand."'";
|
|
else
|
|
$con_brand1="";
|
|
//首先合计区域
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9");
|
|
if($tmp["num"]>0){
|
|
$msg_zb_total=get_db_msg("select sum(b.zb_js) 'zb_js',sum(b.zb) 'zb' from ".$table_pre."client a,".$table_pre."client_brand b where a.id=b.cid and a.face=9".$con_brand1);
|
|
}else{
|
|
//没有区域,则合计代理
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3");
|
|
if($tmp["num"]>0){
|
|
$msg_zb_total=get_db_msg("select sum(b.zb_js) 'zb_js',sum(b.zb) 'zb' from ".$table_pre."client a,".$table_pre."client_brand b where a.id=b.cid and a.face=3".$con_brand1);
|
|
}else{
|
|
//区域,代理都没有,合计店铺
|
|
$msg_zb_total=get_db_msg("select sum(b.zb_js) 'zb_js',sum(b.zb) 'zb' from ".$table_pre."client a,".$table_pre."client_brand b where a.id=b.cid and face=4".$con_brand1);
|
|
}
|
|
}
|
|
}else{
|
|
//首先合计区域
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9");
|
|
if($tmp["num"]>0){
|
|
$msg_zb_total=get_db_msg("select sum(zb_js) 'zb_js',sum(zb) 'zb' from ".$table_pre."client where face=9");
|
|
}else{
|
|
//没有区域,则合计代理
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3");
|
|
if($tmp["num"]>0){
|
|
$msg_zb_total=get_db_msg("select sum(zb_js) 'zb_js',sum(zb) 'zb' from ".$table_pre."client where face=3");
|
|
}else{
|
|
//区域,代理都没有,合计店铺
|
|
$msg_zb_total=get_db_msg("select sum(zb_js) 'zb_js',sum(zb) 'zb' from ".$table_pre."client where face=4");
|
|
}
|
|
}
|
|
}
|
|
$total_zb_js=$msg_zb_total["zb_js"];
|
|
$total_zb=$msg_zb_total["zb"]*10000;
|
|
|
|
$tdnum=2;
|
|
$strfoot="";
|
|
$strfoot.="\"tdnum\":\"".$tdnum."\",";
|
|
$strfoot.="\"sl\":\"".$total_js."\",";
|
|
$strfoot.="\"je\":\"".deel_je_show($total_je)."\",";
|
|
|
|
//合计结算金额
|
|
if($show_jsje=="y")
|
|
$strfoot.="\"jsje\":\"".deel_je_show($total_jsje)."\",";
|
|
//件数指标
|
|
if(in_array("js",$arr_zb_type)){
|
|
$wcl1=deel_bfb1($total_js,$total_zb_js,1);
|
|
$strfoot.="\"slzb\":\"".$total_zb_js."\",";
|
|
$strfoot.="\"slwcl\":\"".$wcl1."\",";
|
|
}
|
|
//金额指标
|
|
if(in_array("je",$arr_zb_type)){
|
|
$wcl1=deel_bfb1($total_jsje,$total_zb,1);
|
|
$strfoot.="\"jezb\":\"".deel_je_show($total_zb)."\",";
|
|
$strfoot.="\"jewcl\":\"".$wcl1."\",";
|
|
}
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
}else{
|
|
//---------------------------------一维报表
|
|
$json_data.="\"bbtype\":1,";
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},";
|
|
$thead_str.="{\"zd\":\"group_by\",\"title\":\"".get_main_value($arr_group_by,$s_group_by)."\"},";
|
|
$thead_str.="{\"zd\":\"sl\",\"title\":\"数量\"},";
|
|
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\"},";
|
|
if($show_jsje=="y")
|
|
$thead_str.="{\"zd\":\"jsje\",\"title\":\"结算金额\"},";
|
|
if(in_array("js",$arr_zb_type)){
|
|
$thead_str.="{\"zd\":\"slzb\",\"title\":\"件数指标\"},";
|
|
$thead_str.="{\"zd\":\"slwcl\",\"title\":\"件数完成率\"},";
|
|
}
|
|
if(in_array("je",$arr_zb_type)){
|
|
$thead_str.="{\"zd\":\"jezb\",\"title\":\"金额指标\"},";
|
|
$thead_str.="{\"zd\":\"jewcl\",\"title\":\"金额完成率\"},";
|
|
}
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
|
|
|
|
//--取得face
|
|
$f1=get_main_value($arr_face1,$s_group_by);
|
|
//--取得查询语句
|
|
if($s_group_by=="dj" || $s_group_by=="dpsx"){
|
|
$q="select c.".$s_group_by." 'title',sum(o.num) 'js',sum(o.je) 'je',sum(o.jsje) 'jsje' from ".$table_pre."client c left join (select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',sum(jsje_dl) 'jsje_dl',uid,ka,is_sp,brand from ".$table_pre."order where ka<>'y'".$con_brand.$con_spk.$con_f." group by uid) o on (o.uid=c.id) where c.face='4' group by c.".$s_group_by." order by ".$s_order." desc";
|
|
}else{
|
|
if($s_group_by=="dd"){
|
|
$con_is_checked="";
|
|
if($s_is_checked=="y"){
|
|
$con_is_checked=" and c.is_checked='y'";
|
|
}else if($s_is_checked=="n"){
|
|
$con_is_checked=" and c.is_checked<>'y'";
|
|
}
|
|
$con_path="";
|
|
if(trim($s_path_qy)){
|
|
$con_path.=" and (c.path='".$s_path_qy."' or c.path like '".$s_path_qy."-%') ";
|
|
}
|
|
if(trim($s_path_dl)){
|
|
$con_path.=" and (c.path='".$s_path_dl."' or c.path like '".$s_path_dl."-%') ";
|
|
}
|
|
if(trim($s_username)){
|
|
$con_path.=" and c.username like '%".$s_username."%' ";
|
|
}
|
|
$con_dpsx="";
|
|
if(trim($s_dpsx)){
|
|
$con_dpsx=" and c.dpsx='".$s_dpsx."' ";
|
|
}
|
|
$con_dj="";
|
|
if(trim($s_dj)){
|
|
$con_dj=" and c.dj='".$s_dj."' ";
|
|
}
|
|
$sql_join=" on (c.id=o.uid)";
|
|
$sql_group_by1="uid";
|
|
}else{
|
|
$con_dj=$con_dpsx=$con_path=$con_is_checked="";
|
|
$sql_join=" on (c.id=o.".$s_group_by.")";
|
|
$sql_group_by1=$s_group_by;
|
|
}
|
|
$flag_dl=($s_group_by=="dl" || $s_group_by=="qy")?"_dl":"";
|
|
$q="select c.id 'id', c.path 'path',c.username 'username',c.title 'title',sum(o.num) 'js',sum(o.je) 'je',sum(o.jsje".$flag_dl.") 'jsje' from ".$table_pre."client c left join (select sum(num) 'num',sum(je) 'je',sum(jsje) 'jsje',sum(jsje_dl) 'jsje_dl',uid,ka,is_sp,brand,dl,qy from ".$table_pre."order where ka<>'y'".$con_brand.$con_spk.$con_f." group by ".$sql_group_by1.") o ".$sql_join." where c.face='".$f1."' ".$con_is_checked.$con_path.$con_dpsx.$con_dj." group by c.id order by ".$s_order." desc";
|
|
}
|
|
$count=0;
|
|
$total_js=$total_je=$total_jsje=$total_zb=$total_zb_js=0;
|
|
$tbody_str="";
|
|
$r=$db->query($q);
|
|
while($m=$db->fetch_array($r)){
|
|
$list=$count+1;
|
|
|
|
if($s_group_by=="qy" || $s_group_by=="dl"){
|
|
$title1=$m["title"]."(".$m["username"].")";
|
|
$tmp_id=$m["path"]."-".$m["id"];
|
|
}else if($s_group_by=="dpsx" || $s_group_by=="dj"){
|
|
$title1=$m["title"];
|
|
$tmp_id=$m["title"];
|
|
}else{
|
|
$title1=$m["title"]."(".$m["username"].")";
|
|
$tmp_id=$m["path"]."-".$m["id"];
|
|
}
|
|
|
|
//-----取得指标
|
|
if($is_brand=="y"){
|
|
$tmp_sql=$s_brand?" and a.brand='".$s_brand."'":"";
|
|
if($s_group_by=="dpsx" || $s_group_by=="dj"){
|
|
$state_sql="";
|
|
$tmp_sql.=" and c.".$s_group_by."='".$m["title"]."'";
|
|
}else{
|
|
$state_sql=",a.is_jd 'is_jd',a.is_checked 'is_checked'";
|
|
$tmp_sql.=" and c.id='".$m["id"]."'";
|
|
}
|
|
$tmp=get_db_msg("select sum(a.zb) 'zb',sum(a.zb_js) 'zb_js'".$state_sql." from ".$table_pre."client_brand a,".$table_pre."client c where c.id=a.cid ".$tmp_sql." group by c.id");
|
|
}else{
|
|
if($s_group_by=="dpsx" || $s_group_by=="dj"){
|
|
$tmp=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client where ".$s_group_by."='".$m["title"]."' and face='4'");
|
|
}else{
|
|
$tmp=get_db_msg("select zb,zb_js,is_checked,is_jd from ".$table_pre."client where id='".$m["id"]."'");
|
|
}
|
|
}
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"ct\":\"".$list."\",";
|
|
$tbody_str2.="\"group_by\":\"".$title1."\",";
|
|
$tbody_str2.="\"sl\":\"".deel_01($m["js"])."\",";
|
|
$tbody_str2.="\"je\":\"".deel_je_show(deel_01($m["je"]))."\",";
|
|
if($show_jsje=="y")
|
|
$tbody_str2.="\"jsje\":\"".deel_je_show(deel_01($m["jsje"]))."\",";
|
|
$tmp_zb=$tmp["zb"]*10000;
|
|
$tmp_zb_js=$tmp["zb_js"];
|
|
//----
|
|
$total_zb+=$tmp_zb;
|
|
$total_zb_js+=$tmp_zb_js;
|
|
$wcl="";
|
|
if(in_array("js",$arr_zb_type)){
|
|
$wcl=deel_bfb1($m["js"],$tmp_zb_js,1);
|
|
$tbody_str2.="\"slzb\":\"".deel_01($tmp_zb_js)."\",";
|
|
$tbody_str2.="\"slwcl\":\"".$wcl."\",";
|
|
}
|
|
if(in_array("je",$arr_zb_type)){
|
|
$wcl=deel_bfb1($m["jsje"],$tmp_zb,1);
|
|
$tbody_str2.="\"jezb\":\"".deel_je_show(deel_01($tmp_zb))."\",";
|
|
$tbody_str2.="\"jewcl\":\"".$wcl."\",";
|
|
}
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$total_js+=$m["js"];
|
|
$total_je+=$m["je"];
|
|
$total_jsje+=$m["jsje"];
|
|
$count++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$tdnum=2;
|
|
$strfoot="";
|
|
$strfoot.="\"tdnum\":\"".$tdnum."\",";
|
|
$strfoot.="\"sl\":\"".$total_js."\",";
|
|
$strfoot.="\"je\":\"".$total_je."\",";
|
|
|
|
//合计结算金额
|
|
if($show_jsje=="y")
|
|
$strfoot.="\"jsje\":\"".deel_je_show($total_jsje)."\",";
|
|
//件数指标
|
|
if(in_array("js",$arr_zb_type)){
|
|
$wcl1=deel_bfb1($total_js,$total_zb_js,1);
|
|
$strfoot.="\"slzb\":\"".$total_zb_js."\",";
|
|
$strfoot.="\"slwcl\":\"".$wcl1."\",";
|
|
}
|
|
//金额指标
|
|
if(in_array("je",$arr_zb_type)){
|
|
$wcl1=deel_bfb1($total_jsje,$total_zb,1);
|
|
$strfoot.="\"jezb\":\"".deel_je_show($total_zb)."\",";
|
|
$strfoot.="\"jewcl\":\"".$wcl1."\",";
|
|
}
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
}
|
|
break;
|
|
case "ks":
|
|
if($is_brand=="y"){
|
|
$str_brand="";
|
|
$r=$db->query("select * from ".$table_pre."keyword where cate='brand' order by no");
|
|
while($m=$db->fetch_array($r)){
|
|
$str_brand.="{\"no\":\"".$m["no"]."\",\"title\":\"".$m["no"]."(".$m["title"].")\"},";
|
|
}
|
|
$str_brand=deel_end($str_brand);
|
|
$json_data.="\"select_brand\":{\"no\":\"s_brand\",\"title\":\"所有".get_cate_title_no("arr_select","brand")."\",\"value\":\"".$s_brand."\",\"op\":[".$str_brand."]},";
|
|
$json_data.="\"show_brand\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_brand\":\"n\",";
|
|
}
|
|
|
|
//
|
|
if($is_spk=="y"){
|
|
$json_data.="\"show_spk\":\"y\",";
|
|
$arr_is_sp=array("n"=>"否","y"=>"是");
|
|
$tmp_is_sp="";
|
|
foreach($arr_is_sp as $k => $v){
|
|
$tmp_is_sp.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},";
|
|
}
|
|
$tmp_is_sp=deel_end($tmp_is_sp);
|
|
$json_data.="\"select_is_sp\":{\"no\":\"s_is_sp\",\"title\":\"显示".d_translate("spk")."\",\"value\":\"".$s_is_sp."\",\"op\":[".$tmp_is_sp."]},";
|
|
}else{
|
|
$json_data.="\"show_spk\":\"n\",";
|
|
}
|
|
|
|
|
|
//取得表头标题
|
|
$s_group_by_default="category";
|
|
$s_group_by=$s_group_by?$s_group_by:$s_group_by_default;
|
|
$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"]."分析";
|
|
}
|
|
$arr_group_by_title["size"]="尺码分析";
|
|
$arr_group_by_title["color"]="颜色分析";
|
|
$arr_group_by_title["ks_size"]="款色深度分析";
|
|
if(is_array($sys_bb_cate)){
|
|
//------定制报表显示
|
|
for($i=0;$i<count($sys_bb_cate);$i++){
|
|
$arr1=explode("&",$sys_bb_cate[$i]);
|
|
if(count($arr1)>1){
|
|
$s_group_by_title=str_replace("分析","",get_main_value($arr_group_by_title,$arr1[0]))."-".get_main_value($arr_group_by_title,$arr1[1]);
|
|
}else{
|
|
$s_group_by_title=get_main_value($arr_group_by_title,$arr1[0]);
|
|
}
|
|
$arr_group_by[$sys_bb_cate[$i]]=$s_group_by_title;
|
|
}
|
|
}else{
|
|
//------默认报表显示
|
|
for($i=0;$i<count($arr_select_no);$i++){
|
|
$arr_group_by[$arr_select_no[$i]]=$arr_select_title[$i]."分析";
|
|
}
|
|
//颜色
|
|
$arr_group_by["color"]="颜色分析";
|
|
//尺码
|
|
$arr_group_by["size"]="尺码分析";
|
|
//款色深度
|
|
$arr_group_by["ks_size"]="款色深度分析";
|
|
}
|
|
$str_bb="";
|
|
foreach($arr_group_by as $k=>$v){
|
|
$k1=str_replace("&","|",$k);
|
|
$str_bb.="{\"no\":\"".$k1."\",\"title\":\"按".$v."分组\"},";
|
|
}
|
|
$str_bb=deel_end($str_bb);
|
|
$json_data.="\"select_bb\":{\"no\":\"s_group_by\",\"title\":\"所有\",\"value\":\"".$s_group_by."\",\"op\":[".$str_bb."]},";
|
|
|
|
//-----------
|
|
$op_client="";
|
|
$r=$db->query("select * from ".$table_pre."client where face='3' or face='4' or face='9' order by concat(path,'-',id)");
|
|
while($m=$db->fetch_array($r)){
|
|
$op_client.="{\"no\":\"".$m["id"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
$op_client=deel_end($op_client);
|
|
$json_data.="\"select_client\":{\"no\":\"s_uid\",\"title\":\"所有客户\",\"value\":\"".$s_uid."\",\"op\":[".$op_client."]},";
|
|
|
|
//------------------条件
|
|
$s_key=$s_key?$s_key:$_key;
|
|
$s_ka=$s_ka?$s_ka:"n";
|
|
$con=$con1="";
|
|
if($s_uid){
|
|
$m1=get_db_msg("select * from ".$table_pre."client where id='".$s_uid."'");
|
|
if($m1["face"]=="4"){
|
|
$con.=" and uid='".$s_uid."'";
|
|
}else{
|
|
$con.=" and (upath='".$m1["path"]."-".$m1["id"]."' or upath like '".$m1["path"]."-".$m1["id"]."-%')";
|
|
}
|
|
$s_username=$m1["username"];
|
|
}else{
|
|
$s_username="";
|
|
}
|
|
$json_data.="\"s_username\":\"".$s_username."\",";
|
|
if($s_is_sp){
|
|
$con.=" and is_sp='".$s_is_sp."' ";
|
|
$con1.=" and is_sp='".$s_is_sp."' ";
|
|
}
|
|
if($s_ka){
|
|
if($s_ka=="n"){
|
|
$con.=" and ka<>'y'";
|
|
$con1.=" and ka<>'y'";
|
|
}else if($s_ka=="y"){
|
|
$con.=" and ka='y'";
|
|
$con1.=" and ka='y'";
|
|
}
|
|
}
|
|
if($is_brand && $s_brand){
|
|
$con.=" and brand='".$s_brand."' ";
|
|
$con1.=" and brand='".$s_brand."' ";
|
|
}
|
|
$arr_group_by=explode("|",$s_group_by);
|
|
if(count($arr_group_by)==1){
|
|
//-------------------------------------------------------一维报表
|
|
$json_data.="\"bbcode\":1,";
|
|
if($s_group_by=="ks_size"){
|
|
$json_data.="\"bbtype\":\"ks_size\",";
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"件数\"},";
|
|
$thead_str.="{\"zd\":\"kss\",\"title\":\"款色数\"},";
|
|
$thead_str.="{\"zd\":\"zb\",\"title\":\"占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
|
|
//取得已订款色数
|
|
$tmp=get_db_msg("select count(distinct iid,color) 'num' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_kss=$tmp["num"];
|
|
|
|
//--------------------------------正体start
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
$tbody_str="";
|
|
$q="select sum(num)/count(distinct iid,color) 'num',count(distinct iid,color) 'kss' from (select sum(num) 'num',iid,color from ".$table_pre."order where id>0".$con.$con_f." group by iid,color) as t1 group by num order by num";
|
|
$r=$db->query($q);
|
|
$count=0;
|
|
$l=0;
|
|
while($m=$db->fetch_array($r)){
|
|
//
|
|
$tb_data_x.=deel_num($m["num"])."件,";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($m["kss"],$total_kss)).",";
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"js\":\"".deel_num($m["num"])."\",";
|
|
$tbody_str2.="\"kss\":\"".$m["kss"]."\",";
|
|
$tbody_str2.="\"zb\":\"".deel_bfb($m["kss"],$total_kss)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
$l+=$m["num"]*$m["kss"];
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
//--------------------------------正体end
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"tal_js\":\"合计(".$l.")\",";
|
|
$strfoot.="\"tal_kss\":\"".$total_kss."\",";
|
|
$strfoot.="\"tal_zb\":\"100%\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else if($s_group_by=="size"){
|
|
$json_data.="\"bbtype\":\"size\",";
|
|
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"size_group\",\"title\":\"尺码组\"},";
|
|
$thead_str.="{\"zd\":\"size\",\"title\":\"".get_main_value($arr_group_by_title,$s_group_by)."\"},";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"已订件数\"},";
|
|
$thead_str.="{\"zd\":\"jszb\",\"title\":\"件数占比\"},";
|
|
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\"},";
|
|
$thead_str.="{\"zd\":\"jezb\",\"title\":\"金额占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
//--------------------------------正体start
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
//
|
|
$tbody_str="";
|
|
$q1="select * from ".$table_pre."keyword where cate='size' order by ord";
|
|
$r1=$db->query($q1);
|
|
$count=$total_num=0;
|
|
$l=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$q="select * from ".$table_pre."size where iid='".$m1["id"]."' order by iid,no";
|
|
$r=$db->query($q);
|
|
//
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and size_group_id='".$m1["id"]."'".$con.$con_f);
|
|
$xj_yd_js=$tmp["num"];
|
|
$xj_yd_je=$tmp["je"];
|
|
while($m=$db->fetch_array($r)){
|
|
$arr1=get_num_je_size($m["no"],$m["iid"]);
|
|
$total_num+=$arr1[0];
|
|
$total_money+=$arr1[1];
|
|
$_tcontent[$count]="<tr><td bgcolor=\"".$bg."\">".$m1["title"]."</td><td bgcolor=\"".$bg."\">".$m["title"]."</td><td bgcolor=\"".$bg."\"align=\"right\">".$arr1[0]."</td><td bgcolor=\"".$bg."\"align=\"right\">".deel_bfb($arr1[0],$xj_yd_js)."</td><td bgcolor=\"".$bg."\"align=\"right\">".$arr1[1]."</td><td bgcolor=\"".$bg."\"align=\"right\">".deel_bfb($arr1[1],$xj_yd_je)."</td></tr>";
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group\":\"".$m1["title"]."\",";
|
|
$tbody_str2.="\"size\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"js\":\"".$arr1[0]."\",";
|
|
$tbody_str2.="\"jszb\":\"".deel_bfb($arr1[0],$total_yd_js)."\",";
|
|
$tbody_str2.="\"je\":\"".$arr1[1]."\",";
|
|
$tbody_str2.="\"jezb\":\"".deel_bfb($arr1[1],$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($arr1[0],$total_yd_js)).",";
|
|
}
|
|
$l++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
//--------------------------------正体end
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"\",";
|
|
$strfoot.="\"size\":\"\",";
|
|
$strfoot.="\"js\":\"".$total_num."\",";
|
|
$strfoot.="\"jszb\":\"\",";
|
|
$strfoot.="\"je\":\"".$total_money."\",";
|
|
$strfoot.="\"jezb\":\"\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else if($s_group_by=="color"){
|
|
$json_data.="\"bbtype\":\"color\",";
|
|
|
|
//取得总款数
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where no<>''".$con1);
|
|
$total_ks=$tmp["num"];
|
|
//取得总款色数
|
|
$total_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where no<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if($s_ka=="y"){
|
|
if(in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}else{
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
}
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款色数
|
|
$tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_sku=$tmp1["num"];
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
//
|
|
$tbody_str="";
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by."' order by no";
|
|
$r=$db->query($q);
|
|
$count=$total_num=$total_money=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$list=$count+1;
|
|
//取得数量
|
|
$m1=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$total_num+=$m1["num"];
|
|
$total_money+=$m1["je"];
|
|
//取得款色
|
|
$tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_sku=$tmp["num"];
|
|
$tmp_z_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where no<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$tmp1=explode(",",$m2["color"]);
|
|
$tmp2=explode(",",$m2["color_ka"]);
|
|
if(in_array($m["no"],$tmp1) && !in_array($m["no"],$tmp2)){
|
|
$tmp_z_sku++;
|
|
}
|
|
}
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$tmp_z_sku."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_z_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$tmp_yd_sku."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($m1["num"])."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($m1["num"],$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($m1["je"])."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($m1["je"],$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($m1["num"],$total_yd_js)).",";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_sku."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".$total_yd_sku."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".$total_num."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".$total_money."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else if($s_group_by=="sx"){
|
|
$json_data.="\"bbtype\":\"sx\",";
|
|
|
|
//取得总款色数
|
|
$total_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where no<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if($s_ka=="y"){
|
|
if(in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}else{
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
}
|
|
//取得已订总件数和金额
|
|
$q="select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f;
|
|
$tmp=get_db_msg($q);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款色数
|
|
$tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_sku=$tmp1["num"];
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
//
|
|
$tbody_str="";
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by."' 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 * from ".$table_pre."sx where no='".$m["no"]."'");
|
|
$arr_color=explode(",",$tmp["_v"]);
|
|
$n1=0;
|
|
for($i1=0;$i1<count($arr_color);$i1++){
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$arr_color[$i1].",%'".$con1);
|
|
$n1+=$tmp["num"];
|
|
}
|
|
$tmp_sku=$n1;
|
|
//取得款色
|
|
$tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_sku=$tmp["num"];
|
|
//取得数量
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_js=$tmp["num"];
|
|
$tmp_yd_je=$tmp["je"];
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".deel_01($tmp_sku)."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".deel_01($tmp_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($tmp_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($tmp_yd_js,$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($tmp_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($tmp_yd_je,$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
|
|
$count++;
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($tmp_yd_js,$total_yd_js)).",";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_sku."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".$total_yd_sku."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".$total_yd_js."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".$total_yd_je."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else{
|
|
$json_data.="\"bbtype\":\"other\",";
|
|
$json_data.="\"bb_group_by\":\"".get_main_value($arr_group_by_title,$s_group_by)."\",";
|
|
//取得总款数
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by."<>''".$con1);
|
|
$total_ks=$tmp["num"];
|
|
//取得总款色数
|
|
$total_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by."<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
//取得总均价
|
|
$tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by."<>''".$con1);
|
|
$price_jj=keep_float($tmp["jj"],1);
|
|
//取得已订总件数和金额
|
|
$q="select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f;
|
|
$tmp=get_db_msg($q);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款数
|
|
$tmp1=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_ks=$tmp1["num"];
|
|
//取得已订总款色数
|
|
$tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_sku=$tmp1["num"];
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
//
|
|
$tbody_str="";
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by."' 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_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_ks=$tmp["num"];
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by."='".$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_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_sku=$tmp["num"];
|
|
$tmp_z_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by."='".$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' from ".$table_pre."order where id>0 and ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_js=$tmp["num"];
|
|
$tmp_yd_je=$tmp["je"];
|
|
if($tmp_z_ks>0){
|
|
//取得均价
|
|
$tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by."='".$m["no"]."'".$con1);
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"jjprice\":\"".keep_float($tmp["jj"],1)."\",";
|
|
$tbody_str2.="\"sj_kh\":\"".$tmp_z_ks."\",";
|
|
$tbody_str2.="\"sj_khzb\":\"".deel_bfb($tmp_z_ks,$total_ks)."\",";
|
|
$tbody_str2.="\"yd_kh\":\"".$tmp_yd_ks."\",";
|
|
$tbody_str2.="\"yd_khzb\":\"".deel_bfb($tmp_yd_ks,$total_yd_ks)."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$tmp_z_sku."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_z_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$tmp_yd_sku."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($tmp_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($tmp_yd_js,$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($tmp_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($tmp_yd_je,$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
|
|
$count++;
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($tmp_yd_js,$total_yd_js)).",";
|
|
}
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"jjprice\":\"".$price_jj."\",";
|
|
$strfoot.="\"sj_kh\":\"".$total_ks."\",";
|
|
$strfoot.="\"sj_khzb\":\"\",";
|
|
$strfoot.="\"yd_kh\":\"".$total_yd_ks."\",";
|
|
$strfoot.="\"yd_khzb\":\"\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_sku."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".$total_yd_sku."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".$total_yd_js."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".$total_yd_je."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
}
|
|
//图
|
|
$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."\",";
|
|
}else{
|
|
//-------------------------------------------------------二维报表
|
|
$json_data.="\"bbcode\":2,";
|
|
$s_group_by1=$arr_group_by[0];
|
|
$s_group_by2=$arr_group_by[1];
|
|
|
|
if($s_group_by2=="size"){
|
|
//---------------------第二条件为尺码
|
|
$json_data.="\"bbtype\":\"size\",";
|
|
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"size_group1\",\"title\":\"".get_main_value($arr_group_by_title,$s_group_by1)."\"},";
|
|
$thead_str.="{\"zd\":\"size_group2\",\"title\":\"尺码\"},";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"已订件数\"},";
|
|
$thead_str.="{\"zd\":\"jszb\",\"title\":\"件数占比\"},";
|
|
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\"},";
|
|
$thead_str.="{\"zd\":\"jezb\",\"title\":\"金额占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
|
|
$q1="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by ord";
|
|
$r1=$db->query($q1);
|
|
$count=$total_num=0;
|
|
$l=0;
|
|
$tbody_str="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$tmp=get_db_msg("select size_group from ".$table_pre."kh where ".$s_group_by1."='".$m1["no"]."' limit 0,1");
|
|
$q="select * from ".$table_pre."size where iid='".$tmp["size_group"]."' order by iid,no";
|
|
$r=$db->query($q);
|
|
//
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m1["no"]."'".$con.$con_f);
|
|
$xj_yd_js=$tmp["num"];
|
|
$xj_yd_je=$tmp["je"];
|
|
while($m=$db->fetch_array($r)){
|
|
$arr1=get_num_je_size_category($m["no"],$s_group_by1,$m1["no"]);
|
|
$total_num+=$arr1[0];
|
|
$total_money+=$arr1[1];
|
|
if($arr1[0]>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group1\":\"".$m1["title"]."\",";
|
|
$tbody_str2.="\"size_group2\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"js\":\"".$arr1[0]."\",";
|
|
$tbody_str2.="\"jszb\":\"".deel_bfb($arr1[0],$xj_yd_js)."\",";
|
|
$tbody_str2.="\"je\":\"".$arr1[1]."\",";
|
|
$tbody_str2.="\"jezb\":\"".deel_bfb($arr1[1],$xj_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
$l++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"js\":\"".$total_num."\",";
|
|
$strfoot.="\"jszb\":\"\",";
|
|
$strfoot.="\"je\":\"".$total_money."\",";
|
|
$strfoot.="\"jezb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
|
|
}else if($s_group_by2=="ks_size"){
|
|
//---------------------第二条件为款色深度
|
|
$json_data.="\"bbtype\":\"ks_size\",";
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"size_group\",\"title\":\"".get_main_value($arr_group_by_title,$s_group_by1)."\"},";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"件数\"},";
|
|
$thead_str.="{\"zd\":\"kss\",\"title\":\"款色数\"},";
|
|
$thead_str.="{\"zd\":\"zb\",\"title\":\"占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
|
|
$q1="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by ord";
|
|
$r1=$db->query($q1);
|
|
$count=$total_js=$total_kss=0;
|
|
$l=0;
|
|
$tbody_str="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$q="select sum(num)/count(distinct iid,color) 'num',count(distinct iid,color) 'kss' from ".$table_pre."order where ".$s_group_by1."='".$m1["no"]."'".$con.$con_f." group by num order by num";
|
|
$r=$db->query($q);
|
|
//取得数据
|
|
$xj_js=$xj_kss=0;
|
|
$arr_data=array();
|
|
$k=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$arr_data[deel_num($m["num"])]=$m["kss"];
|
|
$xj_js+=$m["num"]*$m["kss"];
|
|
$xj_kss+=$m["kss"];
|
|
$total_kss+=$m["kss"];
|
|
$total_js+=$m["num"]*$m["kss"];
|
|
$k++;
|
|
}
|
|
//
|
|
foreach($arr_data as $num1 => $kss1){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"n\",";
|
|
$tbody_str2.="\"size_group\":\"".$m1["title"]."\",";
|
|
$tbody_str2.="\"js\":\"".$num1."\",";
|
|
$tbody_str2.="\"kss\":\"".$kss1."\",";
|
|
$tbody_str2.="\"zb\":\"".deel_bfb($kss1,$xj_kss)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
//小计
|
|
if($k>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"y\",";
|
|
$tbody_str2.="\"size_group\":\"".$m1["title"]."小计\",";
|
|
$tbody_str2.="\"js\":\"".$xj_js."\",";
|
|
$tbody_str2.="\"kss\":\"".$xj_kss."\",";
|
|
$tbody_str2.="\"zb\":\"100%\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"js\":\"".$total_js."\",";
|
|
$strfoot.="\"kss\":\"".$total_kss."\",";
|
|
$strfoot.="\"zb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
|
|
}else{
|
|
//---------------------其他二维报表
|
|
$json_data.="\"bbtype\":\"other\",";
|
|
|
|
//--------------------------------表头start
|
|
$json_data.="\"group_by1\":\"".get_main_value($arr_group_by_title,$s_group_by1)."\",";
|
|
$json_data.="\"group_by2\":\"".get_main_value($arr_group_by_title,$s_group_by2)."\",";
|
|
if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){
|
|
$json_data.="\"thead_ts\":\"y\",";
|
|
}else{
|
|
$json_data.="\"thead_ts\":\"n\",";
|
|
}
|
|
//--------------------------------表头end
|
|
|
|
$con2="";
|
|
if($s_group_by1!="sx")
|
|
$con2.=" and ".$s_group_by1."<>''";
|
|
if($s_group_by2!="sx")
|
|
$con2.=" and ".$s_group_by2."<>''";
|
|
|
|
//取得总款数
|
|
$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<count($arr1);$i1++){
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
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 no<>'' ".$con2.$con1);
|
|
$price_jj=keep_float($tmp["jj"],1);
|
|
}
|
|
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款数
|
|
$tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con.$con_f);
|
|
$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.$con_f);
|
|
$total_yd_sku=$tmp["num"];
|
|
|
|
$tbody_str="";
|
|
$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;$i1<count($arr_color);$i1++){
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$arr_color[$i1].",%'".$con11.$con1);
|
|
$n1+=$tmp["num"];
|
|
}
|
|
$xj_z_sku=$n1;
|
|
}else{
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."'".$con11.$con1);
|
|
$xj_z_ks=$tmp["num"];
|
|
//取得小计设计款色数
|
|
$xj_z_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."'".$con11.$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$xj_z_sku++;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by2."' order by no";
|
|
//echo $q."<br>";
|
|
$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.$con_f);
|
|
$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.$con_f);
|
|
$xj_yd_sku=$tmp["num"];
|
|
//取得已订小计件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' ".$con.$con_f);
|
|
$xj_yd_js=$tmp["num"];
|
|
$xj_yd_je=$tmp["je"];
|
|
//
|
|
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.$con_f);
|
|
$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.$con_f);
|
|
$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<count($arr_color);$i1++){
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ka<>'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' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_js=$tmp["num"];
|
|
$tmp_yd_je=$tmp["je"];
|
|
//
|
|
if($tmp_z_sku>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"n\",";
|
|
$tbody_str2.="\"group_by1\":\"".$m4["title"]."\",";
|
|
$tbody_str2.="\"group_by2\":\"".$m["title"]."\",";
|
|
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);
|
|
$tbody_str2.="\"jjprice\":\"".keep_float($tmp["jj"],1)."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$tmp_z_ks."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_z_ks,$xj_z_ks)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$tmp_yd_ks."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_ks,$xj_yd_ks)."\",";
|
|
}
|
|
$tbody_str2.="\"sj_kss\":\"".$tmp_z_sku."\",";
|
|
$tbody_str2.="\"sj_ksszb\":\"".deel_bfb($tmp_z_sku,$xj_z_sku)."\",";
|
|
$tbody_str2.="\"yd_kss\":\"".$tmp_yd_sku."\",";
|
|
$tbody_str2.="\"yd_ksszb\":\"".deel_bfb($tmp_yd_sku,$xj_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($tmp_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($tmp_yd_js,$xj_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($tmp_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($tmp_yd_je,$xj_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
if($xj_z_sku>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"y\",";
|
|
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);
|
|
$tbody_str2.="\"jjprice\":\"".keep_float($tmp["jj"],1)."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$xj_z_ks."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($xj_z_ks,$total_ks)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$xj_yd_ks."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($xj_yd_ks,$total_yd_ks)."\",";
|
|
}
|
|
$tbody_str2.="\"sj_kss\":\"".$xj_z_sku."\",";
|
|
$tbody_str2.="\"sj_ksszb\":\"".deel_bfb($xj_z_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_kss\":\"".$xj_yd_sku."\",";
|
|
$tbody_str2.="\"yd_ksszb\":\"".deel_bfb($xj_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_num($xj_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($xj_yd_js,$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_num($xj_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($xj_yd_je,$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$strfoot="";
|
|
if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){
|
|
$strfoot.="\"jjprice\":\"".$price_jj."\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_ks."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".deel_num($total_yd_ks)."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
}
|
|
$strfoot.="\"sj_kss\":\"".deel_num($total_sku)."\",";
|
|
$strfoot.="\"sj_ksszb\":\"\",";
|
|
$strfoot.="\"yd_kss\":\"".deel_num($total_yd_sku)."\",";
|
|
$strfoot.="\"yd_ksszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".deel_num($total_yd_js)."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".deel_num($total_yd_je)."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
}
|
|
}
|
|
break;
|
|
case "plugin":
|
|
//记录访问日志
|
|
if($_filename)
|
|
$db->query("insert into ".$table_pre."bb_log(username,bb,add_date) values ('".$msg_client["username"]."','".$_filename."',now())");
|
|
$json_data.="\"src\":\"../plugin/client_bb/".$_filename.".php\",";
|
|
break;
|
|
default:
|
|
//记录访问日志
|
|
if($cate)
|
|
$db->query("insert into ".$table_pre."bb_log(username,bb,add_date) values ('".$msg_client["username"]."','".$cate."',now())");
|
|
$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"]."分析";
|
|
}
|
|
$arr_group_by_title["size"]="尺码分析";
|
|
$arr_group_by_title["color"]="颜色分析";
|
|
$arr_group_by_title["ks_size"]="款色深度分析";
|
|
if(is_array($sys_bb_cate)){
|
|
//------定制报表显示
|
|
for($i=0;$i<count($sys_bb_cate);$i++){
|
|
$arr1=explode("&",$sys_bb_cate[$i]);
|
|
if(count($arr1)>1){
|
|
$s_group_by_title=str_replace("分析","",get_main_value($arr_group_by_title,$arr1[0]))."-".get_main_value($arr_group_by_title,$arr1[1]);
|
|
}else{
|
|
$s_group_by_title=get_main_value($arr_group_by_title,$arr1[0]);
|
|
}
|
|
}
|
|
}
|
|
//------------------条件
|
|
$s_key=$s_key?$s_key:$_key;
|
|
$s_ka=$s_ka?$s_ka:"n";
|
|
|
|
$con=$con1="";
|
|
if($s_uid){
|
|
$m1=get_db_msg("select * from ".$table_pre."client where id='".$s_uid."'");
|
|
if($m1["face"]=="4"){
|
|
$con.=" and uid='".$s_uid."'";
|
|
}else{
|
|
$con.=" and (upath='".$m1["path"]."-".$m1["id"]."' or upath like '".$m1["path"]."-".$m1["id"]."-%')";
|
|
}
|
|
$s_username=$m1["username"];
|
|
}else{
|
|
if($msg_client["face"]!="1"){
|
|
if($msg_client["face"]=="2"){
|
|
$qjarr=explode(",",$msg_client["charge_uid"]);
|
|
if(is_array($qjarr)){
|
|
$con.=" and uid in (".$msg_client["charge_uid"].") ";
|
|
}else{
|
|
$con.=" and uid='0' ";
|
|
}
|
|
}else{
|
|
$con.=" and (upath='".$msg_client["path"]."-".$msg_client["id"]."' or upath like '".$msg_client["path"]."-".$msg_client["id"]."-%')";
|
|
}
|
|
}
|
|
$s_username="";
|
|
}
|
|
$json_data.="\"s_username\":\"".$s_username."\",";
|
|
|
|
|
|
if($msg_client["face"]!="4"){
|
|
$json_data.="\"is_tjshow\":\"y\",";
|
|
if($msg_client["face"]=="1"){
|
|
//-----------
|
|
$op_client="";
|
|
$r=$db->query("select * from ".$table_pre."client where face='3' or face='4' or face='9' order by concat(path,'-',id)");
|
|
while($m=$db->fetch_array($r)){
|
|
$op_client.="{\"no\":\"".$m["id"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
$op_client=deel_end($op_client);
|
|
$json_data.="\"select_client\":{\"no\":\"s_uid\",\"title\":\"所有客户\",\"value\":\"".$s_uid."\",\"op\":[".$op_client."]},";
|
|
}else if($msg_client["face"]=="2"){
|
|
$str_c="";
|
|
if($msg_client["charge_path"]){
|
|
$str_path="";
|
|
$path_arr=explode(',',$msg_client["charge_path"]);
|
|
for($i=0;$i<count($path_arr);$i++){
|
|
$str_path.="'".$path_arr[$i]."',";
|
|
}
|
|
if($str_path)
|
|
$str_path=substr($str_path,0,-1);
|
|
$str_c.=" where concat(path,'-',id) in (".$str_path.")";
|
|
}else{
|
|
$str_c.=" where id=0 ";
|
|
}
|
|
//-----------
|
|
$op_client="";
|
|
$r=$db->query("select * from ".$table_pre."client ".$str_c);
|
|
while($m=$db->fetch_array($r)){
|
|
$op_client.="{\"no\":\"".$m["id"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
$op_client=deel_end($op_client);
|
|
$json_data.="\"select_client\":{\"no\":\"s_uid\",\"title\":\"所有客户\",\"value\":\"".$s_uid."\",\"op\":[".$op_client."]},";
|
|
}else if($msg_client["face"]=="3"){
|
|
//-----------
|
|
$op_client="";
|
|
$r=$db->query("select * from ".$table_pre."client where path='".$msg_client["path"]."-".$msg_client["id"]."' or path like '".$msg_client["path"]."-".$msg_client["id"]."-%'");
|
|
while($m=$db->fetch_array($r)){
|
|
$op_client.="{\"no\":\"".$m["id"]."\",\"title\":\"".$m["title"]."(".$m["username"].")\"},";
|
|
}
|
|
$op_client=deel_end($op_client);
|
|
$json_data.="\"select_client\":{\"no\":\"s_uid\",\"title\":\"所有客户\",\"value\":\"".$s_uid."\",\"op\":[".$op_client."]},";
|
|
|
|
}
|
|
}else{
|
|
$json_data.="\"is_tjshow\":\"n\",";
|
|
}
|
|
|
|
if($is_brand=="y"){
|
|
$str_brand="";
|
|
$r=$db->query("select * from ".$table_pre."keyword where cate='brand' order by no");
|
|
while($m=$db->fetch_array($r)){
|
|
$str_brand.="{\"no\":\"".$m["no"]."\",\"title\":\"".$m["no"]."(".$m["title"].")\"},";
|
|
}
|
|
$str_brand=deel_end($str_brand);
|
|
$json_data.="\"select_brand\":{\"no\":\"s_brand\",\"title\":\"所有".get_cate_title_no("arr_select","brand")."\",\"value\":\"".$s_brand."\",\"op\":[".$str_brand."]},";
|
|
$json_data.="\"show_brand\":\"y\",";
|
|
}else{
|
|
$json_data.="\"show_brand\":\"n\",";
|
|
}
|
|
|
|
if($is_spk=="y"){
|
|
$json_data.="\"show_spk\":\"y\",";
|
|
$arr_is_sp=array("n"=>"否","y"=>"是");
|
|
$tmp_is_sp="";
|
|
foreach($arr_is_sp as $k => $v){
|
|
$tmp_is_sp.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},";
|
|
}
|
|
$tmp_is_sp=deel_end($tmp_is_sp);
|
|
$json_data.="\"select_is_sp\":{\"no\":\"s_is_sp\",\"title\":\"显示".d_translate("spk")."\",\"value\":\"".$s_is_sp."\",\"op\":[".$tmp_is_sp."]},";
|
|
}else{
|
|
$json_data.="\"show_spk\":\"n\",";
|
|
}
|
|
|
|
if($s_is_sp){
|
|
$con.=" and is_sp='".$s_is_sp."' ";
|
|
$con1.=" and is_sp='".$s_is_sp."' ";
|
|
}
|
|
|
|
if($s_brand){
|
|
$con.=" and brand='".$s_brand."'";
|
|
$con1.=" and brand='".$s_brand."'";
|
|
}
|
|
if($s_ka){
|
|
if($s_ka=="n"){
|
|
$con.=" and ka<>'y'";
|
|
$con1.=" and ka<>'y'";
|
|
}else if($s_ka=="y"){
|
|
$con.=" and ka='y'";
|
|
$con1.=" and ka='y'";
|
|
}
|
|
}
|
|
$arr_group_by=explode("&",$cate);
|
|
if(count($arr_group_by)==1){
|
|
$s_group_by=$arr_group_by[0];
|
|
//-------------------------------------------------------一维报表
|
|
$json_data.="\"bbcode\":1,";
|
|
if($s_group_by=="ks_size"){
|
|
$json_data.="\"bbtype\":\"ks_size\",";
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"件数\"},";
|
|
$thead_str.="{\"zd\":\"kss\",\"title\":\"款色数\"},";
|
|
$thead_str.="{\"zd\":\"zb\",\"title\":\"占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
|
|
//取得已订款色数
|
|
$tmp=get_db_msg("select count(distinct iid,color) 'num' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_kss=$tmp["num"];
|
|
|
|
//--------------------------------正体start
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
$tbody_str="";
|
|
$q="select sum(num)/count(distinct iid,color) 'num',count(distinct iid,color) 'kss' from (select sum(num) 'num',iid,color from ".$table_pre."order where id>0".$con.$con_f." group by iid,color) as t1 group by num order by num";
|
|
$r=$db->query($q);
|
|
$count=0;
|
|
$l=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$tb_data_x.=deel_num($m["num"])."件,";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($m["kss"],$total_kss)).",";
|
|
//
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"js\":\"".deel_num($m["num"])."\",";
|
|
$tbody_str2.="\"kss\":\"".$m["kss"]."\",";
|
|
$tbody_str2.="\"zb\":\"".deel_bfb($m["kss"],$total_kss)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
$l+=$m["num"]*$m["kss"];
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
//--------------------------------正体end
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"tal_js\":\"合计(".$l.")\",";
|
|
$strfoot.="\"tal_kss\":\"".$total_kss."\",";
|
|
$strfoot.="\"tal_zb\":\"100%\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
|
|
}else if($s_group_by=="size"){
|
|
$json_data.="\"bbtype\":\"size\",";
|
|
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"size_group\",\"title\":\"尺码组\"},";
|
|
$thead_str.="{\"zd\":\"size\",\"title\":\"".get_main_value($arr_group_by_title,$s_group_by)."\"},";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"已订件数\"},";
|
|
$thead_str.="{\"zd\":\"jszb\",\"title\":\"件数占比\"},";
|
|
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\"},";
|
|
$thead_str.="{\"zd\":\"jezb\",\"title\":\"金额占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
//--------------------------------正体start
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
//
|
|
$tbody_str="";
|
|
$q1="select * from ".$table_pre."keyword where cate='size' order by ord";
|
|
$r1=$db->query($q1);
|
|
$count=$total_num=0;
|
|
$l=0;
|
|
while($m1=$db->fetch_array($r1)){
|
|
$q="select * from ".$table_pre."size where iid='".$m1["id"]."' order by iid,no";
|
|
$r=$db->query($q);
|
|
//
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and size_group_id='".$m1["id"]."'".$con.$con_f);
|
|
$xj_yd_js=$tmp["num"];
|
|
$xj_yd_je=$tmp["je"];
|
|
while($m=$db->fetch_array($r)){
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($arr1[0],$total_yd_js)).",";
|
|
//
|
|
$arr1=get_num_je_size($m["no"],$m["iid"]);
|
|
$total_num+=$arr1[0];
|
|
$total_money+=$arr1[1];
|
|
$_tcontent[$count]="<tr><td bgcolor=\"".$bg."\">".$m1["title"]."</td><td bgcolor=\"".$bg."\">".$m["title"]."</td><td bgcolor=\"".$bg."\"align=\"right\">".$arr1[0]."</td><td bgcolor=\"".$bg."\"align=\"right\">".deel_bfb($arr1[0],$xj_yd_js)."</td><td bgcolor=\"".$bg."\"align=\"right\">".$arr1[1]."</td><td bgcolor=\"".$bg."\"align=\"right\">".deel_bfb($arr1[1],$xj_yd_je)."</td></tr>";
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group\":\"".$m1["title"]."\",";
|
|
$tbody_str2.="\"size\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"js\":\"".$arr1[0]."\",";
|
|
$tbody_str2.="\"jszb\":\"".deel_bfb($arr1[0],$total_yd_js)."\",";
|
|
$tbody_str2.="\"je\":\"".$arr1[1]."\",";
|
|
$tbody_str2.="\"jezb\":\"".deel_bfb($arr1[1],$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
$l++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
//--------------------------------正体end
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"\",";
|
|
$strfoot.="\"size\":\"\",";
|
|
$strfoot.="\"js\":\"".$total_num."\",";
|
|
$strfoot.="\"jszb\":\"\",";
|
|
$strfoot.="\"je\":\"".$total_money."\",";
|
|
$strfoot.="\"jezb\":\"\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else if($s_group_by=="color"){
|
|
$json_data.="\"bbtype\":\"color\",";
|
|
|
|
//取得总款数
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where no<>''".$con1);
|
|
$total_ks=$tmp["num"];
|
|
//取得总款色数
|
|
$total_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where no<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if($s_ka=="y"){
|
|
if(in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}else{
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
}
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款色数
|
|
$tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_sku=$tmp1["num"];
|
|
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
|
|
//
|
|
$tbody_str="";
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by."' order by no";
|
|
$r=$db->query($q);
|
|
$count=$total_num=$total_money=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$list=$count+1;
|
|
//取得数量
|
|
$m1=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$total_num+=$m1["num"];
|
|
$total_money+=$m1["je"];
|
|
//取得款色
|
|
$tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_sku=$tmp["num"];
|
|
$tmp_z_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where no<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$tmp1=explode(",",$m2["color"]);
|
|
$tmp2=explode(",",$m2["color_ka"]);
|
|
if(in_array($m["no"],$tmp1) && !in_array($m["no"],$tmp2)){
|
|
$tmp_z_sku++;
|
|
}
|
|
}
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($m1["num"],$total_yd_js)).",";
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group_bm\":\"".$m["no"]."\",";
|
|
$tbody_str2.="\"size_group\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$tmp_z_sku."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_z_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$tmp_yd_sku."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($m1["num"])."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($m1["num"],$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($m1["je"])."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($m1["je"],$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_sku."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".$total_yd_sku."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".$total_num."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".$total_money."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else if($s_group_by=="sx"){
|
|
$json_data.="\"bbtype\":\"sx\",";
|
|
|
|
//取得总款色数
|
|
$total_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where no<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if($s_ka=="y"){
|
|
if(in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}else{
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
}
|
|
//取得已订总件数和金额
|
|
$q="select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f;
|
|
$tmp=get_db_msg($q);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款色数
|
|
$tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_sku=$tmp1["num"];
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
$tbody_str="";
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by."' 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 * from ".$table_pre."sx where no='".$m["no"]."'");
|
|
$arr_color=explode(",",$tmp["_v"]);
|
|
$n1=0;
|
|
for($i1=0;$i1<count($arr_color);$i1++){
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$arr_color[$i1].",%'".$con1);
|
|
$n1+=$tmp["num"];
|
|
}
|
|
$tmp_sku=$n1;
|
|
//取得款色
|
|
$tmp=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_sku=$tmp["num"];
|
|
//取得数量
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_js=$tmp["num"];
|
|
$tmp_yd_je=$tmp["je"];
|
|
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($tmp_yd_js,$total_yd_js)).",";
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".deel_01($tmp_sku)."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".deel_01($tmp_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($tmp_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($tmp_yd_js,$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($tmp_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($tmp_yd_je,$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
|
|
$count++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
//--------------------------------合计start
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_sku."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".$total_yd_sku."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".$total_yd_js."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".$total_yd_je."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
//--------------------------------合计end
|
|
}else{
|
|
$json_data.="\"bbtype\":\"other\",";
|
|
$json_data.="\"bbcate\":\"".$cate."\",";
|
|
$json_data.="\"bb_group_by\":\"".get_main_value($arr_group_by_title,$s_group_by)."\",";
|
|
//取得总款数
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by."<>''".$con1);
|
|
$total_ks=$tmp["num"];
|
|
//取得总款色数
|
|
$total_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by."<>''".$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
//取得总均价
|
|
$tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by."<>''".$con1);
|
|
$price_jj=keep_float($tmp["jj"],1);
|
|
//取得已订总件数和金额
|
|
$q="select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f;
|
|
$tmp=get_db_msg($q);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款数
|
|
$tmp1=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_ks=$tmp1["num"];
|
|
//取得已订总款色数
|
|
$tmp1=get_db_msg("select count(distinct no,color) 'num' from ".$table_pre."order where ".$s_group_by."<>'' ".$con.$con_f);
|
|
$total_yd_sku=$tmp1["num"];
|
|
//
|
|
$tb_data_x="";
|
|
$tb_data_y=",";
|
|
//
|
|
$tbody_str="";
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by."' 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_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_ks=$tmp["num"];
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by."='".$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_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_sku=$tmp["num"];
|
|
$tmp_z_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by."='".$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' from ".$table_pre."order where id>0 and ".$s_group_by."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_js=$tmp["num"];
|
|
$tmp_yd_je=$tmp["je"];
|
|
if($tmp_z_ks>0){
|
|
//取得均价
|
|
$tmp=get_db_msg("select sum(price)/count(*) 'jj' from ".$table_pre."kh where ".$s_group_by."='".$m["no"]."'".$con1);
|
|
|
|
//
|
|
$tb_data_x.=$m["title"].",";
|
|
$tb_data_y.=str_replace("%","",deel_bfb($tmp_yd_js,$total_yd_js)).",";
|
|
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group_bm\":\"".$m["no"]."\",";
|
|
$tbody_str2.="\"size_group\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"jjprice\":\"".keep_float($tmp["jj"],1)."\",";
|
|
$tbody_str2.="\"sj_kh\":\"".$tmp_z_ks."\",";
|
|
$tbody_str2.="\"sj_khzb\":\"".deel_bfb($tmp_z_ks,$total_ks)."\",";
|
|
$tbody_str2.="\"yd_kh\":\"".$tmp_yd_ks."\",";
|
|
$tbody_str2.="\"yd_khzb\":\"".deel_bfb($tmp_yd_ks,$total_yd_ks)."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$tmp_z_sku."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_z_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$tmp_yd_sku."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($tmp_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($tmp_yd_js,$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($tmp_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($tmp_yd_je,$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
|
|
$count++;
|
|
}
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"jjprice\":\"".$price_jj."\",";
|
|
$strfoot.="\"sj_kh\":\"".$total_ks."\",";
|
|
$strfoot.="\"sj_khzb\":\"\",";
|
|
$strfoot.="\"yd_kh\":\"".$total_yd_ks."\",";
|
|
$strfoot.="\"yd_khzb\":\"\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_sku."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".$total_yd_sku."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".$total_yd_js."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".$total_yd_je."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
}
|
|
//图
|
|
$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."\",";
|
|
}else{
|
|
//-------------------------------------------------------二维报表
|
|
$json_data.="\"bbcode\":2,";
|
|
$s_group_by1=$arr_group_by[0];
|
|
$s_group_by2=$arr_group_by[1];
|
|
|
|
if($s_group_by2=="size"){
|
|
//---------------------第二条件为尺码
|
|
$json_data.="\"bbtype\":\"size\",";
|
|
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"size_group1\",\"title\":\"".get_main_value($arr_group_by_title,$s_group_by1)."\"},";
|
|
$thead_str.="{\"zd\":\"size_group2\",\"title\":\"尺码\"},";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"已订件数\"},";
|
|
$thead_str.="{\"zd\":\"jszb\",\"title\":\"件数占比\"},";
|
|
$thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\"},";
|
|
$thead_str.="{\"zd\":\"jezb\",\"title\":\"金额占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
|
|
$q1="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by ord";
|
|
$r1=$db->query($q1);
|
|
$count=$total_num=0;
|
|
$l=0;
|
|
$tbody_str="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$tmp=get_db_msg("select size_group from ".$table_pre."kh where ".$s_group_by1."='".$m1["no"]."' limit 0,1");
|
|
$q="select * from ".$table_pre."size where iid='".$tmp["size_group"]."' order by iid,no";
|
|
$r=$db->query($q);
|
|
//
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m1["no"]."'".$con.$con_f);
|
|
$xj_yd_js=$tmp["num"];
|
|
$xj_yd_je=$tmp["je"];
|
|
while($m=$db->fetch_array($r)){
|
|
$arr1=get_num_je_size_category($m["no"],$s_group_by1,$m1["no"]);
|
|
$total_num+=$arr1[0];
|
|
$total_money+=$arr1[1];
|
|
if($arr1[0]>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"size_group1\":\"".$m1["title"]."\",";
|
|
$tbody_str2.="\"size_group2\":\"".$m["title"]."\",";
|
|
$tbody_str2.="\"js\":\"".$arr1[0]."\",";
|
|
$tbody_str2.="\"jszb\":\"".deel_bfb($arr1[0],$xj_yd_js)."\",";
|
|
$tbody_str2.="\"je\":\"".$arr1[1]."\",";
|
|
$tbody_str2.="\"jezb\":\"".deel_bfb($arr1[1],$xj_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
$l++;
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"js\":\"".$total_num."\",";
|
|
$strfoot.="\"jszb\":\"\",";
|
|
$strfoot.="\"je\":\"".$total_money."\",";
|
|
$strfoot.="\"jezb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
|
|
}else if($s_group_by2=="ks_size"){
|
|
//---------------------第二条件为款色深度
|
|
$json_data.="\"bbtype\":\"ks_size\",";
|
|
//--------------------------------表头start
|
|
$thead_str="";
|
|
$thead_str.="{\"zd\":\"size_group\",\"title\":\"".get_main_value($arr_group_by_title,$s_group_by1)."\"},";
|
|
$thead_str.="{\"zd\":\"js\",\"title\":\"件数\"},";
|
|
$thead_str.="{\"zd\":\"kss\",\"title\":\"款色数\"},";
|
|
$thead_str.="{\"zd\":\"zb\",\"title\":\"占比\"},";
|
|
$json_data.="\"thead_str\":[".substr($thead_str,0,-1)."],";
|
|
//--------------------------------表头end
|
|
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where id>0".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
|
|
$q1="select * from ".$table_pre."keyword where cate='".$s_group_by1."' order by ord";
|
|
$r1=$db->query($q1);
|
|
$count=$total_js=$total_kss=0;
|
|
$l=0;
|
|
$tbody_str="";
|
|
while($m1=$db->fetch_array($r1)){
|
|
$q="select sum(num)/count(distinct iid,color) 'num',count(distinct iid,color) 'kss' from ".$table_pre."order where ".$s_group_by1."='".$m1["no"]."'".$con.$con_f." group by num order by num";
|
|
$r=$db->query($q);
|
|
//取得数据
|
|
$xj_js=$xj_kss=0;
|
|
$arr_data=array();
|
|
$k=0;
|
|
while($m=$db->fetch_array($r)){
|
|
$arr_data[deel_num($m["num"])]=$m["kss"];
|
|
$xj_js+=$m["num"]*$m["kss"];
|
|
$xj_kss+=$m["kss"];
|
|
$total_kss+=$m["kss"];
|
|
$total_js+=$m["num"]*$m["kss"];
|
|
$k++;
|
|
}
|
|
//
|
|
foreach($arr_data as $num1 => $kss1){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"n\",";
|
|
$tbody_str2.="\"size_group\":\"".$m1["title"]."\",";
|
|
$tbody_str2.="\"js\":\"".$num1."\",";
|
|
$tbody_str2.="\"kss\":\"".$kss1."\",";
|
|
$tbody_str2.="\"zb\":\"".deel_bfb($kss1,$xj_kss)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
//小计
|
|
if($k>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"y\",";
|
|
$tbody_str2.="\"size_group\":\"".$m1["title"]."小计\",";
|
|
$tbody_str2.="\"js\":\"".$xj_js."\",";
|
|
$tbody_str2.="\"kss\":\"".$xj_kss."\",";
|
|
$tbody_str2.="\"zb\":\"100%\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
|
|
$strfoot="";
|
|
$strfoot.="\"size_group\":\"合计\",";
|
|
$strfoot.="\"js\":\"".$total_js."\",";
|
|
$strfoot.="\"kss\":\"".$total_kss."\",";
|
|
$strfoot.="\"zb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
|
|
}else{
|
|
//---------------------其他二维报表
|
|
$json_data.="\"bbtype\":\"other\",";
|
|
|
|
//--------------------------------表头start
|
|
$json_data.="\"group_by1\":\"".get_main_value($arr_group_by_title,$s_group_by1)."\",";
|
|
$json_data.="\"group_by2\":\"".get_main_value($arr_group_by_title,$s_group_by2)."\",";
|
|
if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){
|
|
$json_data.="\"thead_ts\":\"y\",";
|
|
}else{
|
|
$json_data.="\"thead_ts\":\"n\",";
|
|
}
|
|
//--------------------------------表头end
|
|
|
|
$con2="";
|
|
if($s_group_by1!="sx")
|
|
$con2.=" and ".$s_group_by1."<>''";
|
|
if($s_group_by2!="sx")
|
|
$con2.=" and ".$s_group_by2."<>''";
|
|
|
|
//取得总款数
|
|
$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<count($arr1);$i1++){
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$total_sku++;
|
|
}
|
|
}
|
|
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 no<>'' ".$con2.$con1);
|
|
$price_jj=keep_float($tmp["jj"],1);
|
|
}
|
|
|
|
//取得已订总件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con.$con_f);
|
|
$total_yd_js=$tmp["num"];
|
|
$total_yd_je=$tmp["je"];
|
|
//取得已订总款数
|
|
$tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con.$con_f);
|
|
$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.$con_f);
|
|
$total_yd_sku=$tmp["num"];
|
|
|
|
$tbody_str="";
|
|
$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;$i1<count($arr_color);$i1++){
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where concat(',',color,',') like '%,".$arr_color[$i1].",%'".$con11.$con1);
|
|
$n1+=$tmp["num"];
|
|
}
|
|
$xj_z_sku=$n1;
|
|
}else{
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."'".$con11.$con1);
|
|
$xj_z_ks=$tmp["num"];
|
|
//取得小计设计款色数
|
|
$xj_z_sku=0;
|
|
$q2="select no,color,color_ka from ".$table_pre."kh where ".$s_group_by1."='".$m4["no"]."'".$con11.$con1;
|
|
$r2=$db->query($q2);
|
|
while($m2=$db->fetch_array($r2)){
|
|
$arr1=explode(",",$m2["color"]);
|
|
$arr2=explode(",",$m2["color_ka"]);
|
|
for($i1=0;$i1<count($arr1);$i1++){
|
|
if(!in_array($arr1[$i1],$arr2))
|
|
$xj_z_sku++;
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
$q="select * from ".$table_pre."keyword where cate='".$s_group_by2."' order by no";
|
|
//echo $q."<br>";
|
|
$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.$con_f);
|
|
$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.$con_f);
|
|
$xj_yd_sku=$tmp["num"];
|
|
//取得已订小计件数和金额
|
|
$tmp=get_db_msg("select sum(num) 'num',sum(je) 'je' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by1."<>'' and ".$s_group_by2."<>'' ".$con.$con_f);
|
|
$xj_yd_js=$tmp["num"];
|
|
$xj_yd_je=$tmp["je"];
|
|
//
|
|
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.$con_f);
|
|
$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.$con_f);
|
|
$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<count($arr_color);$i1++){
|
|
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ka<>'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' from ".$table_pre."order where id>0 and ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."='".$m["no"]."'".$con.$con_f);
|
|
$tmp_yd_js=$tmp["num"];
|
|
$tmp_yd_je=$tmp["je"];
|
|
//
|
|
if($tmp_z_sku>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"n\",";
|
|
$tbody_str2.="\"group_by1\":\"".$m4["title"]."\",";
|
|
$tbody_str2.="\"group_by2\":\"".$m["title"]."\",";
|
|
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);
|
|
$tbody_str2.="\"jjprice\":\"".keep_float($tmp["jj"],1)."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$tmp_z_ks."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($tmp_z_ks,$xj_z_ks)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$tmp_yd_ks."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($tmp_yd_ks,$xj_yd_ks)."\",";
|
|
}
|
|
$tbody_str2.="\"sj_kss\":\"".$tmp_z_sku."\",";
|
|
$tbody_str2.="\"sj_ksszb\":\"".deel_bfb($tmp_z_sku,$xj_z_sku)."\",";
|
|
$tbody_str2.="\"yd_kss\":\"".$tmp_yd_sku."\",";
|
|
$tbody_str2.="\"yd_ksszb\":\"".deel_bfb($tmp_yd_sku,$xj_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_01($tmp_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($tmp_yd_js,$xj_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_01($tmp_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($tmp_yd_je,$xj_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
if($xj_z_sku>0){
|
|
$tbody_str2="";
|
|
$tbody_str2.="\"isxj\":\"y\",";
|
|
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);
|
|
$tbody_str2.="\"jjprice\":\"".keep_float($tmp["jj"],1)."\",";
|
|
$tbody_str2.="\"sj_ks\":\"".$xj_z_ks."\",";
|
|
$tbody_str2.="\"sj_kszb\":\"".deel_bfb($xj_z_ks,$total_ks)."\",";
|
|
$tbody_str2.="\"yd_ks\":\"".$xj_yd_ks."\",";
|
|
$tbody_str2.="\"yd_kszb\":\"".deel_bfb($xj_yd_ks,$total_yd_ks)."\",";
|
|
}
|
|
$tbody_str2.="\"sj_kss\":\"".$xj_z_sku."\",";
|
|
$tbody_str2.="\"sj_ksszb\":\"".deel_bfb($xj_z_sku,$total_sku)."\",";
|
|
$tbody_str2.="\"yd_kss\":\"".$xj_yd_sku."\",";
|
|
$tbody_str2.="\"yd_ksszb\":\"".deel_bfb($xj_yd_sku,$total_yd_sku)."\",";
|
|
$tbody_str2.="\"yd_js\":\"".deel_num($xj_yd_js)."\",";
|
|
$tbody_str2.="\"yd_jszb\":\"".deel_bfb($xj_yd_js,$total_yd_js)."\",";
|
|
$tbody_str2.="\"yd_je\":\"".deel_num($xj_yd_je)."\",";
|
|
$tbody_str2.="\"yd_jezb\":\"".deel_bfb($xj_yd_je,$total_yd_je)."\",";
|
|
$tbody_str.="{".substr($tbody_str2,0,-1)."},";
|
|
$count++;
|
|
}
|
|
}
|
|
$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],";
|
|
$strfoot="";
|
|
if($s_group_by1!="sx" && $s_group_by2!="sx" && $s_group_by1!="color" && $s_group_by2!="color"){
|
|
$strfoot.="\"jjprice\":\"".$price_jj."\",";
|
|
$strfoot.="\"sj_ks\":\"".$total_ks."\",";
|
|
$strfoot.="\"sj_kszb\":\"\",";
|
|
$strfoot.="\"yd_ks\":\"".deel_num($total_yd_ks)."\",";
|
|
$strfoot.="\"yd_kszb\":\"\",";
|
|
}
|
|
$strfoot.="\"sj_kss\":\"".deel_num($total_sku)."\",";
|
|
$strfoot.="\"sj_ksszb\":\"\",";
|
|
$strfoot.="\"yd_kss\":\"".deel_num($total_yd_sku)."\",";
|
|
$strfoot.="\"yd_ksszb\":\"\",";
|
|
$strfoot.="\"yd_js\":\"".deel_num($total_yd_js)."\",";
|
|
$strfoot.="\"yd_jszb\":\"\",";
|
|
$strfoot.="\"yd_je\":\"".deel_num($total_yd_je)."\",";
|
|
$strfoot.="\"yd_jezb\":\"\",";
|
|
|
|
$json_data.="\"tfoot_str\":{".substr($strfoot,0,-1)."},";
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
$json_data=substr($json_data,0,-1)."}";
|
|
echo $json_data;
|
|
?>
|