close(); $db=new DB_Sql; $db->connect($dbhost_slave,$dbuser,$dbpw,$dbname); }else{ $db=_mysql_connect(); } $msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'"); //权限判断 $priv=return_priv($_m,$msg_login_user["priv"]); $arr_report=array("client"=>"按客户分析","gl"=>"订单概览","ks"=>"按款式分析","ph"=>"款号排行","ph_ks"=>"款色排行","detail"=>"订单明细报表","detail_fb"=>"款号订单分布","sql"=>"SQL查询"); //------插件报表读取 if(check_table_exist($table_pre."plugin")=="y"){ $check1=get_db_msg("select count(*) 'num' from ".$table_pre."plugin where cate='admin_bb'"); if($check1["num"]>0) $arr_report["plugin"]="定制报表"; } $_a=$_a?$_a:"client"; $is_multi_price=get_set("is_multi_price"); $sys_size_num=get_max_size_num(); $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="{"; if($priv[0]=="n"){ //没有操作权限 $json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],"; }else{ $json_data.="\"uid\":".$uid.","; $json_data.="\"s_a\":\"".$_a."\","; $str_tab=""; foreach($arr_report as $k1=>$v1){ $str_tab.="{\"_a\":\"".$k1."\",\"title\":\"".$v1."\"},"; } $str_tab=deel_end($str_tab); $json_data.="\"tab\":[".$str_tab."],"; // $tmp_order_flag=""; foreach($arr_sys_order_flag as $k => $v){ $tmp_order_flag.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } if($tmp_order_flag){ $tmp_order_flag.="{\"no\":\"all\",\"title\":\"所有订单\"},"; $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.="\"show_key\":\"y\","; } //取得选项 $arr_select_no=array(); $arr_select_title=array(); $q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' and no<>'zd1' and no<>'zd2' and no<>'zd3' order by ord"; $r=$db->query($q); while($m=$db->fetch_array($r)){ $arr_select_no[]=$m["no"]; $arr_select_title[]=$m["title"]; } //订货会标记选项 $json_data.=$str_json; $con_f=$con_f1=$con_f2=""; 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."'"; } } //-------------------------------------------- //可选择字段 $arr_zd["pic"]="图片"; $arr_zd["xh"]=d_translate("xh"); if($is_multi_price=="y"){ foreach($sys_multi_price as $k1 => $v1){ $arr_zd[$k1]=$v1; } $default_arr_zd=array("price1"); }else{ $arr_zd["price"]="吊牌价"; $default_arr_zd=array(); } $arr_zd["title"]="款式名"; // for($i=0;$i'y'".$con_u_tmp." group by iid,color) as t1 where num='".$s_num."'"; //echo $q."
"; $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 "openDetail2": $default_group_by=""; $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=9"); if($tmp["num"]>0){ $arr_group_by["9"]=d_translate("qy"); $default_group_by="9"; } $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client where face=3"); if($tmp["num"]>0){ $arr_group_by["3"]=d_translate("dl"); $default_group_by="3"; } $default_group_by=$default_group_by?$default_group_by:"4"; $arr_group_by["4"]="客户"; $arr_group_by["1"]="明细"; $s_group_by=$s_group_by?$s_group_by:$default_group_by; $msg=get_db_msg("select * from ".$table_pre."kh where no='".$kh."'"); if($color){ $pic=get_kh_color_picture($msg["no"],$color); }else{ $pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]); } $arr_pic_set=out_good_pic_set_arr($pic,200,200); $json_data.="\"kh\":\"".$msg["no"]."\","; $json_data.="\"color\":\"".$color."\","; $json_data.="\"pic\":\"".$pic."\","; $json_data.="\"pic_w\":\"".$arr_pic_set[0]."\","; $json_data.="\"pic_h\":\"".$arr_pic_set[1]."\","; $str_group_by=""; foreach($arr_group_by as $k1 => $v1){ $str_group_by.="{"; $str_group_by.="\"group_by_no\":\"".$k1."\","; $str_group_by.="\"group_by_title\":\"".$v1."\","; if($s_group_by==$k1){ $str_group_by.="\"group_by_sign\":\"y\""; }else{ $str_group_by.="\"group_by_sign\":\"n\""; } $str_group_by.="},"; } $json_data.="\"group_by\":[".substr($str_group_by,0,-1)."],"; $sql_con="no='".$kh."' and "; if($color) $sql_con.="color='".$color."' and "; $sql_con=substr($sql_con,0,-4); if($s_group_by=="1"){ $thead_str=""; $thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},"; $thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},"; $thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},"; if($bx_sizegroup_id==$msg["size_group"]){ $thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\"},"; // $size_str=""; $r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no"); while($m1=$db->fetch_array($r1)){ $size_str.=$m1["no"].","; } if($size_str) $size_str=substr($size_str,0,-1); $size=explode(",",$size_str); }else{ $size=explode(",",$msg["size"]); } $tmp1=explode(",",$msg["color"]); for($l=0;$lquery($q); $hj=0; while($m=$db->fetch_array($r)){ $tmp=get_db_msg("select username,title from ".$table_pre."client where id='".$m["uid"]."'"); $m_kh=get_db_msg("select no from ".$table_pre."kh where id='".$m["iid"]."'"); $tbody_str.="{"; $tbody_str.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\","; $tbody_str.="\"kh\":\"".$m_kh["no"]."\","; $tbody_str.="\"color\":\"".$m["color"]."-".get_cate_title_no("color",$m["color"])."\","; if($bx_sizegroup_id==$msg["size_group"]) $tbody_str.="\"bx\":\"".$m["bx"]."\","; //尺码列表 $xj=0; for($l=0;$l"加量","22"=>"减量","24"=>"删单"); //取得数组 $arr1=array(); $q="select * from ".$table_pre."client where face='".$s_group_by."'"; $r=$db->query($q); while($m=$db->fetch_array($r)){ if($s_group_by=="4"){ $tmp_sql=" and uid='".$m["id"]."'"; }else{ $p=$m["path"]."-".$m["id"]; $tmp_sql=" and upath like '".$p."-%'"; } $tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num' from ".$table_pre."order where ".$sql_con.$tmp_sql); //if($tmp["num"]>0) $arr1[$m["id"]]=$tmp["num"]; } arsort($arr1); if($bx_sizegroup_id==$msg["size_group"]){ // $size_str=""; $r1=$db->query("select * from ".$table_pre."size where iid='".$msg["size_group"]."' order by no"); while($m1=$db->fetch_array($r1)){ $size_str.=$m1["no"].","; } if($size_str) $size_str=substr($size_str,0,-1); $size=explode(",",$size_str); }else{ $size=explode(",",$msg["size"]); } $thead_str=""; $thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},"; $thead_str.="{\"zd\":\"client\",\"title\":\"客户\"},"; if($s_group_by=="4"){ foreach($arr_show_log_hd as $k1 => $v1){ $thead_str.="{\"zd\":\"zd_".$k1."\",\"title\":\"".$v1."
次数\"},"; } } for($l=0;$l $num1){ $hj+=$num1; $m=get_db_msg("select * from ".$table_pre."client where id='".$id1."'"); if($s_group_by=="4"){ $tmp_sql=" and uid='".$m["id"]."'"; }else{ $p=$m["path"]."-".$m["id"]; $tmp_sql=" and (upath='".$p."' or upath like '".$p."-%')"; } $tmp=get_db_msg("select ".get_size_sql("sum1")." from ".$table_pre."order where ".$sql_con.$tmp_sql); $tbody_str.="{"; $tbody_str.="\"ct\":\"".$list."\","; $tbody_str.="\"client\":\"".$m["title"]."(".$m["username"].")\","; if($s_group_by=="4"){ foreach($arr_show_log_hd as $k1 => $v1){ //加单次数 $t1=get_db_msg("select count(*) 'num' from ".$table_pre."log_hd where uid='".$m["id"]."' and iid='".$msg["id"]."' and action='".$k1."'"); $tbody_str.="\"zd_".$k1."\":\"".deel_0($t1["num"])."\","; $v1="hj_action_".$k1; $$v1+=$t1["num"]; } } for($l=0;$l $v1){ $v1="hj_action_".$k1; $json_data.="\"zd_".$k1."\":\"".$$v1."\","; } } for($l=0;$l50 or "; } if($sql_size1) $sql_size1=substr($sql_size1,0,-3); $arr_kj=array( "select b.title 'title',sum(".get_size_sql("suma").") 'num' from web_order a,web_client b where b.id=a.uid and b.title like '%' group by b.id order by num;"=>"订单,客户关联查询", "select b.no 'no',sum(".get_size_sql("suma").") 'num' from web_order a,web_kh b where b.id=a.iid and b.no like '%' group by b.no order by no;"=>"订单,款号关联查询", "select ip from web_session group by ip having count(ip)>1 order by ip;"=>"在线用户重复ip查询", "select a.id,".get_size_sql("inserta").",b.username,b.title from web_order a,web_client b where a.uid=b.id and (".$sql_size1.") order by a.uid;"=>"异常订单查询", "select bb,count(*) from web_bb_log group by bb order by count(*) desc;"=>"客户端报表访问量分析" ); $tmp_sql=""; foreach($arr_kj as $k => $v){ $tmp_sql.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_sql=deel_end($tmp_sql); $json_data.="\"select_kj\":{\"no\":\"kj\",\"title\":\"快速|查询\",\"value\":\"\",\"op\":[".$tmp_sql."]},"; if($s_sql && $s_sql!="select"){ //检查 $sign=""; $arr_check=array("delete","update","drop","create","alter"); for($i=0;$iquery($s_sql); $str_table=""; $i=0; while($m=$db->fetch_array($r)){ if($i==0){ $str11=""; $ii=0; foreach($m as $k1 => $v1){ $str11.="\"".$ii."\":\"".deel_td_zz($k1)."\","; $ii++; } $str_table.="{".substr($str11,0,-1)."},"; } $str11=""; $ii=0; foreach($m as $k1 => $v1){ $str11.="\"".$ii."\":\"".deel_td_zz($v1)."\","; $ii++; } $str_table.="{".substr($str11,0,-1)."},"; $i++; } $json_data.="\"table_str\":[".substr($str_table,0,-1)."],"; } }else{ $json_data.="\"is_return\":\"2\","; } break; case "ks": $json_data.="\"s_username\":\"".$s_username."\","; 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\","; } // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $tmp_ka=""; foreach($arr_ka as $k => $v){ $tmp_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_ka=deel_end($tmp_ka); $json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$tmp_ka."]},"; // $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."]},"; $arr_group_by_title=array(); $arr_group_by_title1=array(); //取得表头标题 $r1=$db->query("select no,title from ".$table_pre."keyword where cate='arr_select' and no<>'zd1' and no<>'zd2' and no<>'zd3' and flag_ka='y'"); while($m1=$db->fetch_array($r1)){ $arr_group_by_title[$m1["no"]]=$m1["title"]; $arr_group_by_title1[$m1["no"]]=$m1["title"]; } $arr_group_by_title["size"]="尺码"; $arr_group_by_title["color"]="颜色"; $arr_group_by_title["ks_size"]="款色深度"; $tmp_s_group_by1=""; foreach($arr_group_by_title1 as $k => $v){ $tmp_s_group_by1.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_s_group_by1=deel_end($tmp_s_group_by1); $json_data.="\"select_group_by1\":{\"no\":\"s_group_by1\",\"title\":\"请选择\",\"value\":\"".$s_group_by1."\",\"op\":[".$tmp_s_group_by1."]},"; $tmp_s_group_by2=""; foreach($arr_group_by_title as $k => $v){ $tmp_s_group_by2.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_s_group_by2=deel_end($tmp_s_group_by2); $json_data.="\"select_group_by2\":{\"no\":\"s_group_by2\",\"title\":\"请选择\",\"value\":\"".$s_group_by2."\",\"op\":[".$tmp_s_group_by2."]},"; if($is_sub=="y"){ $json_data.="\"issub\":\"y\","; //------------------条件 $s_key=$s_key?$s_key:$_key; $s_ka=$s_ka?$s_ka:"n"; $con=$con1=""; if($s_username){ $m_client=get_db_msg("select * from ".$table_pre."client where username='".$s_username."'"); if($m_client["id"]){ if($m_client["face"]=="4"){ $con.=" and (uid='".$m_client["id"]."') "; }else if($m_client["face"]=="2"){ $qjarr=explode(",",$m_client["charge_uid"]); if(is_array($qjarr)){ $con.=" and uid in (".$m_client["charge_uid"].") "; }else{ $con.=" and uid='0' "; } }else{ $con.=" and (upath='".$m_client["path"]."-".$m_client["id"]."' or upath like '".$m_client["path"]."-".$m_client["id"]."-%') "; } }else{ $con.=" and uid=0 "; } } 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."' "; } if($s_group_by1==$s_group_by2){ $s_group_by=$s_group_by1; }else{ $s_group_by=trim($s_group_by1." ".$s_group_by2); } $s_group_by=str_replace(" ","|",$s_group_by); $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 $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)){ $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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) 'je' from ".$table_pre."order where id>0 ".$con.$con_f); $total_yd_js=$tmp["num"]; $total_yd_je=$tmp["je"]; $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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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]="".$m1["title"]."".$m["title"]."".$arr1[0]."".deel_bfb($arr1[0],$xj_yd_js)."".$arr1[1]."".deel_bfb($arr1[1],$xj_yd_je).""; $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;$i10 ".$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"]; // $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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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)."},"; } $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'' ".$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"]; $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;$i10 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++; } $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''".$con1); $price_jj=keep_float($tmp["jj"],1); //取得已订总件数和金额 $q="select sum(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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"]; // $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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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++; } } $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)."},"; } }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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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'' ".$con2.$con1); $price_jj=keep_float($tmp["jj"],1); } //取得已订总件数和金额 $tmp=get_db_msg("select sum(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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;$i1query($q2); while($m2=$db->fetch_array($r2)){ $arr1=explode(",",$m2["color"]); $arr2=explode(",",$m2["color_ka"]); for($i1=0;$i1"; $r=$db->query($q); $l=0; //取得已订小计款数 $tmp=get_db_msg("select count(distinct no) 'num' from ".$table_pre."order where ".$s_group_by1."='".$m4["no"]."' and ".$s_group_by2."<>'' and ".$s_group_by1."<>'' ".$con.$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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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'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(".get_size_sql("sum").") 'num',sum((".get_size_sql("sum").")*price) '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)."},"; } } }else{ $json_data.="\"issub\":\"n\","; } 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:"order_num"; 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' and (c.path like '".$m["path"]."-".$m["id"]."-%' or c.path='".$m["path"]."-".$m["id"]."') "; }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."
"; } $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)."],"; $s_order="js"; //--取得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=""; $json_data.="\"q\":\"".$q."\","; $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"]."' and c.face='4' "; $con_ccc=" c.".$s_group_by; }else{ $state_sql=",a.is_jd 'is_jd',a.is_checked 'is_checked'"; $tmp_sql.=" and c.id='".$m["id"]."'"; $con_ccc=" c.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 ".$con_ccc); }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\":\"".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)."},"; } break; case "ph": $s_ka=$s_ka?$s_ka:"n"; $s_key=$s_key?$s_key:$_key; $sql_con=""; if($s_no) $sql_con.="no like '%".$s_no."%' and "; if($s_is_sp){ $sql_con.="is_sp='".$s_is_sp."' and "; } for($i=0;$i $v1){ if(in_array($k1,$arrzd)){ $sign="y"; }else{ $sign="n"; } $th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},"; } $json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],"; $json_data.="\"s_no\":\"".$s_no."\","; $json_data.="\"s_username\":\"".$s_username."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $tmp_ka=""; foreach($arr_ka as $k => $v){ $tmp_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_ka=deel_end($tmp_ka); $json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$tmp_ka."]},"; // $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."]},"; //选项 for($i=0;$i".op_select_cate1($arr_select_no[$i],$$v)." "; } //取得定制选项 $select_dz=""; for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no[$i]; $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); $json_data.="\"select_dz\":[".$select_dz."],"; $thead_str=""; $thead_str.="{\"zd\":\"ct\",\"title\":\"次序\"},"; $thead_str.="{\"zd\":\"pm\",\"title\":\"全国排名\"},"; $thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $thead_str.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\"},"; $colnum++; } } $thead_str.="{\"zd\":\"sl\",\"title\":\"数量(件)\"},"; $thead_str.="{\"zd\":\"je\",\"title\":\"金额(元)\"}"; $json_data.="\"thead_str\":[".$thead_str."],"; //取得全国排名数组 if($s_ka=="n"){ $sql_con2=" and ka<>'y'"; }else{ $sql_con2=" and ka='y'"; } $arr_ph=array(); $q1="select sum(num) 'num' from ".$table_pre."order where id>0".$sql_con2.$con_f." group by iid order by num desc"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_ph[]=$m1["num"]; } $total_num=$total_money=0; $tbody_str=""; $query="select sum(num) 'num',no,iid,sum(je) 'je' from ".$table_pre."order ".$sql_con.$con_f." group by no order by num desc"; $res=$db->query($query); $count=0; while($m=$db->fetch_array($res)){ $list=$count+1; $m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'"); $pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"]); $pic_big=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"]); $arr_pic_set=out_good_pic_set_arr($pic,100,100); $qgsl=get_db_msg("select sum(num) num from ".$table_pre."order where no='".$m1["no"]."'"); $money=$m["je"]; $total_num+=$m["num"]; $total_money+=$money; //$pm=get_main_key($arr_ph,$m["num"])+1; $pm=get_main_key($arr_ph,$qgsl["num"])+1; $tbody_str.="{"; $tbody_str.="\"ct\":\"".$list."\","; $tbody_str.="\"pm\":\"".$pm."\","; $tbody_str.="\"kh\":\"".$m1["no"]."\","; $tbody_str.="\"khpic\":\"".$pic."\","; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $tbody_str.="\"".$k1."\":\"".$m1[$k1]."\","; }else if($k1=="xh"){ $tbody_str.="\"".$k1."\":\"".get_kh_xh($m1)."\","; }else if($k1=="pic"){ $tbody_str.="\"".$k1."\":\"".$pic."\","; $tbody_str.="\"".$k1."_big\":\"".$pic_big."\","; $tbody_str.="\"pic_width\":\"".$arr_pic_set[0]."\","; $tbody_str.="\"pic_height\":\"".$arr_pic_set[1]."\","; }else{ $tbody_str.="\"".$k1."\":\"".deel_td_zz(get_cate_title_no($k1,$m1[$k1]))."\","; } } } $tbody_str.="\"sl\":\"".$m["num"]."\","; $tbody_str.="\"je\":\"".deel_num($money)."\""; $tbody_str.="},"; $count++; } $json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; $tdnum=$colnum+2; $json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",\"tal_sl\":\"".$total_num."\",\"tal_je\":\"".$total_money."\"},"; break; case "ph_export": $s_ka=$s_ka?$s_ka:"n"; $s_key=$s_key?$s_key:$_key; $sql_con=""; if($s_no) $sql_con.="no like '%".$s_no."%' and "; if($s_is_sp){ $sql_con.="is_sp='".$s_is_sp."' and "; } for($i=0;$i $v1){ if(in_array($k1,$arrzd)){ $sign="y"; }else{ $sign="n"; } $th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},"; } //$json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],"; //$json_data.="\"s_no\":\"".$s_no."\","; //$json_data.="\"s_username\":\"".$s_username."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $tmp_ka=""; foreach($arr_ka as $k => $v){ $tmp_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_ka=deel_end($tmp_ka); //$json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$tmp_ka."]},"; // $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."]},"; //选项 for($i=0;$i".op_select_cate1($arr_select_no[$i],$$v)." "; } //取得定制选项 $select_dz=""; for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no[$i]; $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); //$json_data.="\"select_dz\":[".$select_dz."],"; $arr_data=$arr_data["col"]=$arr_data["header"]=array(); $arr_data["header"][0][]="次序"; $arr_data["col"][]="str"; $arr_data["header"][0][]="全国排名"; $arr_data["col"][]="str"; $arr_data["header"][0][]="款号"; $arr_data["col"][]="str"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="pic"){ $arr_data["header"][0][]="图片"; $arr_data["col"][]="img"; }else{ $arr_data["header"][0][]=$v1.""; $arr_data["col"][]="str"; } $colnum++; } } $arr_data["header"][0][]="数量(件)"; $arr_data["col"][]="num"; $arr_data["header"][0][]="金额(元)"; $arr_data["col"][]="num"; //取得全国排名数组 if($s_ka=="n"){ $sql_con2=" and ka<>'y'"; }else{ $sql_con2=" and ka='y'"; } $arr_ph=array(); $q1="select sum(num) 'num' from ".$table_pre."order where id>0".$sql_con2.$con_f." group by iid order by num desc"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_ph[]=$m1["num"]; } $total_num=$total_money=0; $query="select sum(num) 'num',no,iid,sum(je) 'je' from ".$table_pre."order ".$sql_con.$con_f." group by no order by num desc"; $res=$db->query($query); $count=0; while($m=$db->fetch_array($res)){ $list=$count+1; $m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'"); $pic=get_kh_picture($m1["no"],$m1["main_pic"],$m1["color"]); $pic_big=get_kh_picture_big($m1["no"],$m1["main_pic"],$m1["color"]); $arr_pic_set=out_good_pic_set_arr($pic,100,100); $qgsl=get_db_msg("select sum(num) num from ".$table_pre."order where no='".$m1["no"]."'"); $money=$m["je"]; $total_num+=$m["num"]; $total_money+=$money; //$pm=get_main_key($arr_ph,$m["num"])+1; $pm=get_main_key($arr_ph,$qgsl["num"])+1; $arr_data["body"][$count][]=$list; $arr_data["body"][$count][]=$pm; $arr_data["body"][$count][]=$m1["no"]; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $arr_data["body"][$count][]=$m1[$k1]; }else if($k1=="xh"){ $arr_data["body"][$count][]=get_kh_xh($m1); }else if($k1=="pic"){ $pic=str_replace("images/no_pic_80.gif","",$pic); $arr_data["body"][$count][]=$pic; }else{ $arr_data["body"][$count][]=get_cate_title_no($k1,$m1[$k1]); } } } $arr_data["body"][$count][]=$m["num"]; $arr_data["body"][$count][]=$money; $count++; } $tdnum=$colnum+2; $arr_data["body"][$count][]="合计|cs:".($tdnum+1); $arr_data["body"][$count][]=$total_num; $arr_data["body"][$count][]=$total_money; $file_name="ph_".date("Y-m-d-H-i"); output_excel($file_name,$arr_data); exit; break; case "ph_ks": $s_ka=$s_ka?$s_ka:"n"; $s_key=$s_key?$s_key:$_key; $sql_con=""; if($s_no) $sql_con.="no like '%".$s_no."%' and "; if($s_is_sp){ $sql_con.="is_sp='".$s_is_sp."' and "; } for($i=0;$i $v1){ if(in_array($k1,$arrzd)){ $sign="y"; }else{ $sign="n"; } $th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},"; } $json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],"; $json_data.="\"s_no\":\"".$s_no."\","; $json_data.="\"s_username\":\"".$s_username."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $tmp_ka=""; foreach($arr_ka as $k => $v){ $tmp_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_ka=deel_end($tmp_ka); $json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$tmp_ka."]},"; // $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."]},"; //选项 for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no[$i]; $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); $json_data.="\"select_dz\":[".$select_dz."],"; $thead_str=""; $thead_str.="{\"zd\":\"ct\",\"title\":\"次序\"},"; $thead_str.="{\"zd\":\"pm\",\"title\":\"全国排名\"},"; $thead_str.="{\"zd\":\"kh\",\"title\":\"款号\"},"; $thead_str.="{\"zd\":\"color\",\"title\":\"颜色\"},"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $thead_str.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\"},"; $colnum++; } } $thead_str.="{\"zd\":\"sl\",\"title\":\"数量(件)\"},"; $thead_str.="{\"zd\":\"je\",\"title\":\"金额(元)\"}"; $json_data.="\"thead_str\":[".$thead_str."],"; //取得全国排名数组 if($s_ka=="n"){ $sql_con2=" and ka<>'y'"; }else{ $sql_con2=" and ka='y'"; } $arr_ph=array(); $q1="select sum(num) 'num' from ".$table_pre."order where id>0".$sql_con2.$con_f." group by iid,color order by num desc"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_ph[]=$m1["num"]; } $total_num=$total_money=0; $tbody_str=""; $query="select sum(".get_size_sql("sum").") 'num',no,iid,color,sum(je) 'je' from ".$table_pre."order ".$sql_con.$con_f." group by no,color order by num desc"; $res=$db->query($query); $count=0; while($m=$db->fetch_array($res)){ $list=$count+1; $m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'"); $pic=get_kh_color_picture($m1["no"],$m["color"]); $pic_big=get_kh_color_picture_big($m1["no"],$m["color"]); $arr_pic_set=out_good_pic_set_arr($pic,100,100); $qgsl=get_db_msg("select sum(num) num from ".$table_pre."order where no='".$m1["no"]."' and color='".$m["color"]."'"); $money=$m["je"]; $total_num+=$m["num"]; $total_money+=$money; //$pm=get_main_key($arr_ph,$m["num"])+1; $pm=get_main_key($arr_ph,$qgsl["num"])+1; $tbody_str.="{"; $tbody_str.="\"ct\":\"".$list."\","; $tbody_str.="\"pm\":\"".$pm."\","; $tbody_str.="\"kh\":\"".$m1["no"]."\","; $tbody_str.="\"khpic\":\"".$pic."\","; $tbody_str.="\"colordm\":\"".$m["color"]."\","; $tbody_str.="\"color\":\"".$m["color"]."-".deel_td_zz(get_cate_title_no("color",$m["color"]))."\","; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $tbody_str.="\"".$k1."\":\"".$m1[$k1]."\","; }else if($k1=="xh"){ $tbody_str.="\"".$k1."\":\"".get_kh_xh($m1)."\","; }else if($k1=="zt"){ $ztTitle=get_db_msg("select * from web_kh_color where iid='".$m["iid"]."' and color='".$m["color"]."'"); $tbody_str.="\"".$k1."\":\"".$ztTitle["zd1"]."\","; }else if($k1=="pic"){ $tbody_str.="\"".$k1."\":\"".$pic."\","; $tbody_str.="\"".$k1."_big\":\"".$pic_big."\","; $tbody_str.="\"pic_width\":\"".$arr_pic_set[0]."\","; $tbody_str.="\"pic_height\":\"".$arr_pic_set[1]."\","; }else{ $tbody_str.="\"".$k1."\":\"".deel_td_zz(get_cate_title_no($k1,$m1[$k1]))."\","; } } } $tbody_str.="\"sl\":\"".$m["num"]."\","; $tbody_str.="\"je\":\"".deel_num($money)."\""; $tbody_str.="},"; $count++; } $json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; $tdnum=$colnum+3; $json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",\"tal_sl\":\"".$total_num."\",\"tal_je\":\"".$total_money."\"},"; break; case "ph_ks_export": $s_ka=$s_ka?$s_ka:"n"; $s_key=$s_key?$s_key:$_key; $sql_con=""; if($s_no) $sql_con.="no like '%".$s_no."%' and "; if($s_is_sp){ $sql_con.="is_sp='".$s_is_sp."' and "; } for($i=0;$i $v1){ if(in_array($k1,$arrzd)){ $sign="y"; }else{ $sign="n"; } $th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},"; } //$json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],"; //$json_data.="\"s_no\":\"".$s_no."\","; //$json_data.="\"s_username\":\"".$s_username."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $tmp_ka=""; foreach($arr_ka as $k => $v){ $tmp_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $tmp_ka=deel_end($tmp_ka); //$json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$tmp_ka."]},"; // $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."]},"; //选项 for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no[$i]; $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); //$json_data.="\"select_dz\":[".$select_dz."],"; $arr_data=$arr_data["col"]=$arr_data["header"]=array(); $arr_data["header"][0][]="次序"; $arr_data["col"][]="str"; $arr_data["header"][0][]="全国排名"; $arr_data["col"][]="str"; $arr_data["header"][0][]="款号"; $arr_data["col"][]="str"; $arr_data["header"][0][]="颜色"; $arr_data["col"][]="str"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="pic"){ $arr_data["header"][0][]="图片"; $arr_data["col"][]="img"; }else{ $arr_data["header"][0][]=$v1.""; $arr_data["col"][]="str"; } $colnum++; } } $arr_data["header"][0][]="数量(件)"; $arr_data["col"][]="num"; $arr_data["header"][0][]="金额(元)"; $arr_data["col"][]="num"; //$json_data.="\"thead_str\":[".$thead_str."],"; //取得全国排名数组 if($s_ka=="n"){ $sql_con2=" and ka<>'y'"; }else{ $sql_con2=" and ka='y'"; } $arr_ph=array(); $q1="select sum(num) 'num' from ".$table_pre."order where id>0".$sql_con2.$con_f." group by iid,color order by num desc"; $r1=$db->query($q1); while($m1=$db->fetch_array($r1)){ $arr_ph[]=$m1["num"]; } $total_num=$total_money=0; $tbody_str=""; $query="select sum(".get_size_sql("sum").") 'num',no,iid,color,sum(je) 'je' from ".$table_pre."order ".$sql_con.$con_f." group by no,color order by num desc"; $res=$db->query($query); $count=0; while($m=$db->fetch_array($res)){ $list=$count+1; $m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'"); $pic=get_kh_color_picture($m1["no"],$m["color"]); $pic_big=get_kh_color_picture_big($m1["no"],$m["color"]); $arr_pic_set=out_good_pic_set_arr($pic,100,100); $qgsl=get_db_msg("select sum(num) num from ".$table_pre."order where no='".$m1["no"]."' and color='".$m["color"]."'"); $money=$m["je"]; $total_num+=$m["num"]; $total_money+=$money; //$pm=get_main_key($arr_ph,$m["num"])+1; $pm=get_main_key($arr_ph,$qgsl["num"])+1; $arr_data["body"][$count][]=$list; $arr_data["body"][$count][]=$pm; $arr_data["body"][$count][]=$m1["no"]; $arr_data["body"][$count][]=$m["color"]."-".deel_td_zz(get_cate_title_no("color",$m["color"])); foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $arr_data["body"][$count][]=$m1[$k1]; }else if($k1=="xh"){ $arr_data["body"][$count][]=get_kh_xh($m1); }else if($k1=="zt"){ $ztTitle=get_db_msg("select * from web_kh_color where iid='".$m["iid"]."' and color='".$m["color"]."'"); $arr_data["body"][$count][]=$ztTitle["zd1"]; }else if($k1=="pic"){ $pic=str_replace("images/no_pic_80.gif","",$pic); $arr_data["body"][$count][]=$pic; }else{ $arr_data["body"][$count][]=deel_td_zz(get_cate_title_no($k1,$m1[$k1])); } } } $arr_data["body"][$count][]=$m["num"]; $arr_data["body"][$count][]=deel_num($money); $count++; } //$json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; $tdnum=$colnum+3; //$json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",\"tal_sl\":\"".$total_num."\",\"tal_je\":\"".$total_money."\"},"; $arr_data["body"][$count][]="合计|cs:".($tdnum+1); $arr_data["body"][$count][]=$total_num; $arr_data["body"][$count][]=$total_money; $file_name="ph_ks_".date("Y-m-d-H-i"); output_excel($file_name,$arr_data); break; case "detail": //定义显示模式,标准模式(留空),童装模式(child) //$show_detail_ms="child"; $show_detail_ms=""; $s_key=$s_key?$s_key:$_key; $s_ka=$s_ka?$s_ka:"n"; $s_hbkh=$s_hbkh?$s_hbkh:"y"; $sql_con=""; if($s_designer) $sql_con.=" and a.designer='".$s_designer."'"; if($s_no) $sql_con.=" and a.no like '%".$s_no."%'"; if($s_kh_dj){ $sql_con.=" and a.kh_dj='".$s_kh_dj."'"; } if($s_is_sp){ $sql_con.=" and a.is_sp='".$s_is_sp."'"; } for($i=0;$iquery("select * from ".$table_pre."keyword where cate='size' order by ord"); while($m1=$db->fetch_array($r1)){ $size_tr[$num_size_group]=""; for($i=1;$i<=$num_size_total;$i++){ $tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'"); $t=$tmp["title"]?$tmp["title"]:""; $size_tr[$num_size_group].="{\"zd\":\"num_".$i."\",\"title\":\"".$t."\",\"is_size\":\"y\"},"; } $arr_size_merged[]=$m1["no"]; $num_size_group++; } /** $size_str=""; for($i=1;$i<=$num_size_total;$i++){ $size_str.="num_".$i.","; } if($size_str) $size_str=substr($size_str,0,-1); **/ //-------------------/处理尺码表头结束 $json_data.="\"s_username\":\"".$s_username."\","; $json_data.="\"s_no\":\"".$s_no."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $str_ka=""; foreach($arr_ka as $k => $v){ $str_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_ka=deel_end($str_ka); $json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$str_ka."]},"; // $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."]},"; //选项 for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no[$i]; $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); $json_data.="\"select_dz\":[".$select_dz."],"; //排序 $s_pxfs=$s_pxfs?$s_pxfs:"num"; $arr_pxfs=array("num"=>"按数量排序","je"=>"按金额排序","no"=>"按款号排序"); $str_pxfs=""; foreach($arr_pxfs as $k => $v){ $str_pxfs.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_pxfs=deel_end($str_pxfs); $json_data.="\"select_pxfs\":{\"no\":\"s_pxfs\",\"title\":\"排序方式\",\"value\":\"".$s_pxfs."\",\"op\":[".$str_pxfs."]},"; $con_pxfs=""; if($s_pxfs=="no"){ $con_pxfs=$s_pxfs; }else{ $con_pxfs=$s_pxfs." desc"; } // $arrzd=explode(",",$s_zd); $th_zd=""; $zd_ct=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $sign="y"; $zd_ct++; }else{ $sign="n"; } $th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},"; } $json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],"; //判断是否有店铺属性 $check_dpsx=get_db_msg("select count(distinct dpsx) 'num' from ".$table_pre."client where face='4' and dpsx<>''"); //判断是否有店铺等级 $check_dj=get_db_msg("select count(distinct dj) 'num' from ".$table_pre."client where face='4' and dj<>''"); 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\","; } //-----------表体 if($show_detail_ms=="child"){ }else{ $json_data.="\"ischild\":\"n\","; // $arr_hbkh=array("y"=>"合并款号","n"=>"不合并"); $str_hbkh=""; foreach($arr_hbkh as $k => $v){ $str_hbkh.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_hbkh=deel_end($str_hbkh); $json_data.="\"select_hbkh\":{\"no\":\"s_hbkh\",\"title\":\"合并款号\",\"value\":\"".$s_hbkh."\",\"op\":[".$str_hbkh."]},"; $thead_str=""; $thead_str.="{\"zd\":\"no\",\"title\":\"款号\",\"is_size\":\"n\"},"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $thead_str.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\",\"is_size\":\"n\"},"; $colnum++; } } $thead_str.="{\"zd\":\"color_title\",\"title\":\"颜色名称\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"color\",\"title\":\"颜色代码\",\"is_size\":\"n\"},"; if($bx_sizegroup_id>0){ $thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\",\"is_size\":\"n\"},"; } if($is_gg=="y"){ $thead_str.="{\"zd\":\"gg\",\"title\":\"".d_translate("gg")."\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"ggprice\",\"title\":\"".get_main_value($sys_gg_zd,"price")."\",\"is_size\":\"n\"},"; }else if($is_gg=="b"){ $thead_str.="{\"zd\":\"gg\",\"title\":\"".d_translate("gg")."\",\"is_size\":\"n\"},"; } $thead_str.=$size_tr[0]; $thead_str.="{\"zd\":\"js\",\"title\":\"小计\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\",\"is_size\":\"n\"}"; $thead_str2="\"0\":[".$thead_str."],"; for($i=1;$i<$num_size_group;$i++){ $thead_str2.="\"".$i."\":[".substr($size_tr[$i],0,-1)."],"; } $json_data.="\"thead_str\":{".substr($thead_str2,0,-1)."},"; $json_data.="\"thead_str_group\":\"".$num_size_group."\","; } if($s_hbkh=="y"){ $json_data.="\"is_hbkh\":\"y\","; }else{ $json_data.="\"is_hbkh\":\"n\","; } if($is_sub=="y"){ $json_data.="\"issub\":\"y\","; if($show_detail_ms=="child"){ //暂时放弃 }else{ $q="select a.id 'id',a.iid 'iid',a.no 'no',sum(a.num) 'num',sum(a.je) 'je' from ".$table_pre."order a left join ".$table_pre."client c on c.id=a.uid where a.id>0 ".$sql_con.$con_f1." group by a.no order by ".$con_pxfs; $r=$db->query($q); $count=0; $total_num=$total_money=0; $tbody_str=""; while($m=$db->fetch_array($r)){ $list=$count+1; $m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["iid"]."'"); //取得颜色,杯型 $tmp1=get_db_msg("select count(distinct a.color,a.bx) 'num',sum(a.num) 'xj_num',sum(a.je) 'xj_money' from ".$table_pre."order a left join ".$table_pre."client c on c.id=a.uid where a.id>0 ".$sql_con.$con_f1." and a.no='".$m["no"]."'"); $num1=$tmp1["num"]; $q2="select ".$sql_sum_num."a.color 'color',a.bx 'bx',sum(a.je) 'je',a.size_group_id 'size_group_id',a.iid 'iid' from ".$table_pre."order a left join ".$table_pre."client c on c.id=a.uid where a.id>0 ".$sql_con.$con_f1." and a.iid='".$m["iid"]."' group by a.color,a.bx"; //echo $q2."
"; $r2=$db->query($q2); if($s_hbkh=="y"){ //需要合并款号 $tbody_str2=""; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $tbody_str2.="\"".$k1."\":\"".deel_td_zz($m1[$k1])."\","; }else if($k1=="xh"){ $tbody_str2.="\"".$k1."\":\"".get_kh_xh($m1)."\","; }else{ $tbody_str2.="\"".$k1."\":\"".deel_td_zz(get_cate_title_no($k1,$m1[$k1]))."\","; } } } $tbody_str.="{"; $tbody_str.="\"no\":\"".$m1["no"]."\","; $tbody_str.=$tbody_str2; $j=0; $xj_num=$xj_money=0; $tbody_str5=""; while($m2=$db->fetch_array($r2)){ $num=0; $tbody_str3=""; for($k=0;$k<$num_size_total;$k++){ $num+=$m2["num_".$arr_size_merged[$k]]; //计算尺码合计 $v11="hj_num_".$k; $$v11+=$m2["num_".$arr_size_merged[$k]]; if($m2["num_".$arr_size_merged[$k]]>0){ $tbody_str3.="\"num_".$arr_size_merged[$k]."\":\"".deel_td_zz($m2["num_".$arr_size_merged[$k]])."\","; }else{ $tbody_str3.="\"num_".$arr_size_merged[$k]."\":\"\","; } } $money=$m2["je"]; $total_num+=$num; $total_money+=$money; $xj_num+=$num; $xj_money+=$money; $tbody_str4=""; if($bx_sizegroup_id>0){ $tbody_str4.="\"bx\":\"".deel_td_zz($m2["bx"])."\","; } if($is_gg=="y"){ //取得规格价格 $tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m2["iid"]."' and color='".$m2["color"]."' and gg='".$m2["bx"]."'"); $tbody_str4.="\"gg\":\"".deel_td_zz(get_gg_title($m2["bx"]))."\","; $tbody_str4.="\"ggprice\":\"".deel_td_zz($tmp["price"])."\","; }else if($is_gg=="b"){ $tbody_str4.="\"gg\":\"".deel_td_zz(get_gg_title($m2["bx"]))."\","; } $tbody_str5.="{\"color_title\":\"".deel_td_zz(get_cate_title_no("color",$m2["color"]))."\",\"color\":\"".$m2["color"]."\",".$tbody_str4."\"size_tj\":{".substr($tbody_str3,0,-1)."}},"; $j++; $count++; } $tbody_str.="\"color_num\":\"".$j."\","; $tbody_str.="\"color_data\":[".substr($tbody_str5,0,-1)."],"; $tbody_str.="\"js\":\"".$tmp1["xj_num"]."\","; $tbody_str.="\"je\":\"".deel_num($tmp1["xj_money"])."\""; $tbody_str.="},"; }else{ //不需要合并款号 $tbody_str2=""; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $tbody_str2.="\"".$k1."\":\"".deel_td_zz($m1[$k1])."\","; }else if($k1=="xh"){ $tbody_str2.="\"".$k1."\":\"".get_kh_xh($m1)."\","; }else{ $tbody_str2.="\"".$k1."\":\"".deel_td_zz(get_cate_title_no($k1,$m1[$k1]))."\","; } } } //有多种颜色 $j=0; while($m2=$db->fetch_array($r2)){ $tbody_str.="{"; $num=0; $td_size1=""; for($k=0;$k<$num_size_total;$k++){ $num+=$m2["num_".$arr_size_merged[$k]]; if($m2["num_".$arr_size_merged[$k]]>0){ $tbody_str.="\"num_".$arr_size_merged[$k]."\":\"".deel_td_zz($m2["num_".$arr_size_merged[$k]])."\","; }else{ $tbody_str.="\"num_".$arr_size_merged[$k]."\":\"\","; } //计算尺码合计 $v11="hj_num_".$k; $$v11+=$m2["num_".$arr_size_merged[$k]]; } $money=$m2["je"]; $total_num+=$num; $total_money+=$money; $tbody_str.="\"no\":\"".$m1["no"]."\","; $tbody_str.=$tbody_str2; $tbody_str.="\"color_title\":\"".deel_td_zz(get_cate_title_no("color",$m2["color"]))."\","; $tbody_str.="\"color\":\"".$m2["color"]."\","; if($bx_sizegroup_id>0){ $tbody_str.="\"bx\":\"".deel_td_zz($m2["bx"])."\","; } if($is_gg=="y"){ //取得规格价格 $tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m2["iid"]."' and gg='".$m2["bx"]."'"); $tbody_str.="\"gg\":\"".deel_td_zz(get_gg_title($m2["bx"]))."\","; $tbody_str.="\"ggprice\":\"".deel_td_zz($tmp["price"])."\","; }else if($is_gg=="b"){ $tbody_str.="\"gg\":\"".deel_td_zz(get_gg_title($m2["bx"]))."\","; } $tbody_str.="\"js\":\"".$num."\","; $tbody_str.="\"je\":\"".deel_num($money)."\""; $tbody_str.="},"; $j++; $count++; } } } $json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; $hj_colspan=($bx_sizegroup_id>0)?4:3; if($is_gg=="y") $hj_colspan+=2; else if($is_gg=="b") $hj_colspan+=1; $tdnum=$hj_colspan+$zd_ct; $tfoot_str2=""; $ss=1; for($k=0;$k<$num_size_total;$k++){ $v1="hj_num_".$k; $tfoot_str2.="\"num_".$ss."\":\"".deel_td_zz($$v1)."\","; $ss++; } $json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",".$tfoot_str2."\"js\":\"".deel_td_zz($total_num)."\",\"je\":\"".deel_td_zz($total_money)."\"},"; } }else{ $json_data.="\"issub\":\"n\","; } break; case "detail_fb": $s_key=$s_key?$s_key:$_key; $s_ka=$s_ka?$s_ka:"n"; $sql_con=$sql_con2=$sql_con3=""; if($s_designer) $sql_con.=" and a.designer='".$s_designer."'"; if($s_no) $sql_con.=" and a.no like '%".$s_no."%'"; if($s_kh_dj){ $sql_con.=" and a.kh_dj='".$s_kh_dj."'"; } if($s_is_sp){ $sql_con.=" and a.is_sp='".$s_is_sp."'"; } for($i=0;$iquery("select * from ".$table_pre."keyword where cate='size' order by ord"); while($m1=$db->fetch_array($r1)){ $size_tr[$num_size_group]=""; for($i=1;$i<=$num_size_total;$i++){ $tmp=get_db_msg("select title from ".$table_pre."size where iid='".$m1["id"]."' and no='".$i."'"); $t=$tmp["title"]?$tmp["title"]:""; $size_tr[$num_size_group].="{\"zd\":\"num_".$i."\",\"title\":\"".$t."\",\"is_size\":\"y\"},"; } $arr_size_merged[]=$m1["no"]; $num_size_group++; } //-------------------/处理尺码表头结束 $json_data.="\"s_username\":\"".$s_username."\","; $json_data.="\"s_no\":\"".$s_no."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $str_ka=""; foreach($arr_ka as $k => $v){ $str_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_ka=deel_end($str_ka); $json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$str_ka."]},"; // $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."]},"; //选项 for($i=0;$iquery("select no,title from ".$table_pre."keyword where cate='".$arr_select_no[$i]."' order by no"); while($m1=$db->fetch_array($r1)){ $tmp.="{\"no\":\"".$m1["no"]."\",\"title\":\"".$m1["title"]."\"},"; } $tmp=deel_end($tmp); $var="s_".$arr_select_no[$i]; $select_dz.="{\"no\":\"".$arr_select_no[$i]."\",\"title\":\"".$arr_select_title[$i]."\",\"value\":\"".$$var."\",\"op\":[".$tmp."]},"; } $select_dz=deel_end($select_dz); $json_data.="\"select_dz\":[".$select_dz."],"; $arrzd=explode(",",$s_zd); $th_zd=""; $zd_ct=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $sign="y"; $zd_ct++; }else{ $sign="n"; } $th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},"; } $json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],"; //表头 $thead_str=""; $thead_str.="{\"zd\":\"no\",\"title\":\"款号\",\"is_size\":\"n\"},"; $colnum=0; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ $thead_str.="{\"zd\":\"".$k1."\",\"title\":\"".$v1."\",\"is_size\":\"n\"},"; $colnum++; } } $thead_str.="{\"zd\":\"color_title\",\"title\":\"颜色名称\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"color\",\"title\":\"颜色代码\",\"is_size\":\"n\"},"; if($bx_sizegroup_id>0){ $thead_str.="{\"zd\":\"bx\",\"title\":\"杯型\",\"is_size\":\"n\"},"; } if($is_gg=="y"){ $thead_str.="{\"zd\":\"gg\",\"title\":\"".d_translate("gg")."\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"ggprice\",\"title\":\"".get_main_value($sys_gg_zd,"price")."\",\"is_size\":\"n\"},"; }else if($is_gg=="b"){ $thead_str.="{\"zd\":\"gg\",\"title\":\"".d_translate("gg")."\",\"is_size\":\"n\"},"; } $thead_str.=$size_tr[0]; $thead_str.="{\"zd\":\"js\",\"title\":\"小计\",\"is_size\":\"n\"},"; $thead_str.="{\"zd\":\"je\",\"title\":\"吊牌金额\",\"is_size\":\"n\"}"; $thead_str2="\"0\":[".$thead_str."],"; for($i=1;$i<$num_size_group;$i++){ $thead_str2.="\"".$i."\":[".substr($size_tr[$i],0,-1)."],"; } $json_data.="\"thead_str\":{".substr($thead_str2,0,-1)."},"; $json_data.="\"thead_str_group\":\"".$num_size_group."\","; if($is_sub=="y"){ $json_data.="\"issub\":\"y\","; $total_num=$total_money=0; $q="select a.*,sum(b.num) 'js',sum(b.je) 'je',sum(b.jsje) 'jsje' from web_kh as a left join web_order as b on a.id=b.iid ".$sql_con3.$con_f2." where a.id>0 ".$sql_con." group by a.id order by js desc"; //$q="select a.*,sum(b.num) 'js',sum(b.je) 'je',sum(b.jsje) 'jsje' from web_kh as a left join web_order as b on a.id=b.iid ".$sql_con3." where a.id>0 ".$sql_con." group by a.id order by js desc"; $r=$db->query($q); $count=0; $tbody_str=""; while($m=$db->fetch_array($r)){ $list=$count+1; //需要合并款号 $tbody_str2=""; foreach($arr_zd as $k1 => $v1){ if(in_array($k1,$arrzd)){ if($k1=="title" || $k1=="price"){ $tbody_str2.="\"".$k1."\":\"".deel_td_zz($m[$k1])."\","; }else if($k1=="xh"){ $tbody_str2.="\"".$k1."\":\"".get_kh_xh($m)."\","; }else{ $tbody_str2.="\"".$k1."\":\"".deel_td_zz(get_cate_title_no($k1,$m[$k1]))."\","; } } } $tbody_str.="{"; $tbody_str.="\"no\":\"".$m["no"]."\","; $tbody_str.=$tbody_str2; $arr_color1=explode(",",$m["color"]); $xj_num=$xj_money=0; $j=0; $tbody_str5=""; for($i=0;$i0 ".$sql_con2.$con_f." and iid='".$m["id"]."' and color='".$arr_color1[$i]."' group by color"); //$m2=get_db_msg("select ".$sql_sum_num."color 'color',bx 'bx',sum(num) 'js',sum(je) 'je',size_group_id 'size_group_id',iid 'iid' from ".$table_pre."order where id>0 ".$sql_con2." and iid='".$m["id"]."' and color='".$arr_color1[$i]."' group by color"); $tbody_str3=""; $tbody_str4=""; if($m2["js"]>0){ $num=0; for($k=0;$k<$num_size_total;$k++){ $num+=$m2["num_".$arr_size_merged[$k]]; //计算尺码合计 $v11="hj_num_".$k; $$v11+=$m2["num_".$arr_size_merged[$k]]; if($m2["num_".$arr_size_merged[$k]]>0){ $tbody_str3.="\"num_".$arr_size_merged[$k]."\":\"".deel_td_zz($m2["num_".$arr_size_merged[$k]])."\","; }else{ $tbody_str3.="\"num_".$arr_size_merged[$k]."\":\"\","; } } $money=$m2["je"]; $total_num+=$num; $total_money+=$money; $xj_num+=$num; $xj_money+=$money; if($bx_sizegroup_id>0){ $tbody_str4.="\"bx\":\"".deel_td_zz($m2["bx"])."\","; } $j++; }else{ for($k=0;$k<$num_size_total;$k++){ $tbody_str3.="\"num_".$arr_size_merged[$k]."\":\"\","; } if($bx_sizegroup_id>0){ $tbody_str4.="\"bx\":\"".deel_td_zz($m2["bx"])."\","; } $j++; } if($is_gg=="y"){ //取得规格价格 $tmp=get_db_msg("select price from ".$table_pre."kh_gg where iid='".$m2["iid"]."' and color='".$m2["color"]."' and gg='".$m2["bx"]."'"); $tbody_str4.="\"gg\":\"".deel_td_zz(get_gg_title($m2["bx"]))."\","; $tbody_str4.="\"ggprice\":\"".deel_td_zz($tmp["price"])."\","; }else if($is_gg=="b"){ $tbody_str4.="\"gg\":\"".deel_td_zz(get_gg_title($m2["bx"]))."\","; } $tbody_str5.="{\"color_title\":\"".deel_td_zz(get_cate_title_no("color",$arr_color1[$i]))."\",\"color\":\"".$arr_color1[$i]."\",".$tbody_str4."\"size_tj\":{".substr($tbody_str3,0,-1)."}},"; } $tbody_str.="\"color_num\":\"".$j."\","; $tbody_str.="\"color_data\":[".substr($tbody_str5,0,-1)."],"; $tbody_str.="\"js\":\"".$xj_num."\","; $tbody_str.="\"je\":\"".deel_num($xj_money)."\""; $tbody_str.="},"; $count++; } $json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; $hj_colspan=($bx_sizegroup_id>0)?4:3; if($is_gg=="y") $hj_colspan+=2; else if($is_gg=="b") $hj_colspan+=1; $tdnum=$hj_colspan+$zd_ct; $tfoot_str2=""; $ss=1; for($k=0;$k<$num_size_total;$k++){ $v1="hj_num_".$k; $tfoot_str2.="\"num_".$ss."\":\"".deel_td_zz($$v1)."\","; $ss++; } $json_data.="\"tfoot_str\":{\"tdnum\":\"".$tdnum."\",".$tfoot_str2."\"js\":\"".deel_td_zz($total_num)."\",\"je\":\"".deel_td_zz($total_money)."\"},"; }else{ $json_data.="\"issub\":\"n\","; } break; case "gl": $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_key=$s_key?$s_key:$_key; $s_ka=$s_ka?$s_ka:"n"; $s_group_by=$s_group_by?$s_group_by:"uid"; $s_order=$s_order?$s_order:"num"; // $arr_group_by["uid"]="客户"; for($i=0;$i $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($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\","; } // $arr_order=array("num"=>"按数量排序","je"=>"按金额排序"); $str_order=""; foreach($arr_order as $k => $v){ $str_order.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_order=deel_end($str_order); $json_data.="\"select_order\":{\"no\":\"s_order\",\"title\":\"排序\",\"value\":\"".$s_order."\",\"op\":[".$str_order."]},"; if($s_group_by=="uid"){ $json_data.="\"s_group_by\":\"uid\","; $json_data.="\"s_dp\":\"".$s_dp."\","; // $arr_jd_state=array("y"=>"已交单","n"=>"未交单"); $str_jd=""; foreach($arr_jd_state as $k => $v){ $str_jd.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_jd=deel_end($str_jd); $json_data.="\"select_is_jd\":{\"no\":\"s_is_jd\",\"title\":\"交单状态\",\"value\":\"".$s_is_jd."\",\"op\":[".$str_jd."]},"; // $arr_qr_state=array("y"=>"已确认","n"=>"未确认"); $str_qr=""; foreach($arr_qr_state as $k => $v){ $str_qr.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_qr=deel_end($str_qr); $json_data.="\"select_is_checked\":{\"no\":\"s_is_checked\",\"title\":\"确认状态\",\"value\":\"".$s_is_checked."\",\"op\":[".$str_qr."]},"; // $arr_print_state=array("y"=>"已打印","n"=>"未打印"); $str_print=""; foreach($arr_print_state as $k => $v){ $str_print.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_print=deel_end($str_print); $json_data.="\"select_is_print\":{\"no\":\"s_is_print\",\"title\":\"打印状态\",\"value\":\"".$s_is_print."\",\"op\":[".$str_print."]},"; }else{ $json_data.="\"s_group_by\":\"".$s_group_by."\","; // $arr_ka=array("n"=>"不显示删除款","y"=>"显示删除款"); $str_ka=""; foreach($arr_ka as $k => $v){ $str_ka.="{\"no\":\"".$k."\",\"title\":\"".$v."\"},"; } $str_ka=deel_end($str_ka); $json_data.="\"select_ka\":{\"no\":\"s_ka\",\"title\":\"删除款\",\"value\":\"".$s_ka."\",\"op\":[".$str_ka."]},"; } //表体 if($s_group_by=="uid"){ //判断是否有店铺属性 $show_dpsx="n"; $check_dpsx=get_db_msg("select count(distinct dpsx) 'num' from ".$table_pre."client where face='4' and dpsx<>''"); if($check_dpsx["num"]>0){ $show_dpsx="y"; } //判断是否有店铺等级 $show_dpdj="n"; $check_dj=get_db_msg("select count(distinct dj) 'num' from ".$table_pre."client where face='4' and dj<>''"); if($check_dj["num"]>0){ $show_dpdj="y"; } $thead_str=""; $thead_str.="{\"zd\":\"ct\",\"title\":\"序号\"},"; $thead_str.="{\"zd\":\"qy\",\"title\":\"".d_translate("qy")."\"},"; $thead_str.="{\"zd\":\"dl\",\"title\":\"".d_translate("dl")."\"},"; if($show_dpsx=="y") $thead_str.="{\"zd\":\"dpsx\",\"title\":\"店铺属性\"},"; if($show_dpdj=="y") $thead_str.="{\"zd\":\"dpdj\",\"title\":\"店铺等级\"},"; $thead_str.="{\"zd\":\"group_by\",\"title\":\"".get_main_value($arr_group_by,$s_group_by)."\"},"; $thead_str.="{\"zd\":\"order_js\",\"title\":\"订单数量\"},"; $thead_str.="{\"zd\":\"order_je\",\"title\":\"吊牌金额\"},"; if($show_jsje=="y") $thead_str.="{\"zd\":\"order_jsje\",\"title\":\"结算金额\"},"; if(in_array("js",$arr_zb_type)){ $thead_str.="{\"zd\":\"jszb\",\"title\":\"件数指标\"},"; $thead_str.="{\"zd\":\"jswcl\",\"title\":\"件数完成率\"},"; } if(in_array("je",$arr_zb_type)){ $thead_str.="{\"zd\":\"jezb\",\"title\":\"金额指标\"},"; $thead_str.="{\"zd\":\"jewcl\",\"title\":\"金额完成率\"},"; } $thead_str.="{\"zd\":\"jd_state\",\"title\":\"交单状态\"},"; $thead_str.="{\"zd\":\"order_state\",\"title\":\"确认状态\"},"; $thead_str.="{\"zd\":\"order_print\",\"title\":\"打印状态\"}"; $json_data.="\"thead_str\":[".$thead_str."],"; }else{ $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\":\"sjks\",\"title\":\"设计款数\"},"; $thead_str.="{\"zd\":\"order_js\",\"title\":\"订单数量\"},"; $thead_str.="{\"zd\":\"order_je\",\"title\":\"订单金额\"}"; $json_data.="\"thead_str\":[".$thead_str."],"; } $tmp_sql_con=""; if($s_dp && $s_group_by=="uid"){ $tmp=get_db_msg("select * from ".$table_pre."client where username='".$s_dp."'"); if($tmp["id"]>0) $s_jxs=$tmp["path"]."-".$tmp["id"]; $tmp_sql_con.=" and (upath='".$s_jxs."' || upath like '".$s_jxs."-%')"; } if($is_brand=="y" && $s_brand){ $tmp_sql_con.=" and brand='".$s_brand."'"; } if($is_spk=="y"){ $tmp_sql_con.=" and is_sp<>'y'"; } $sql_dz1=""; for($i=0;$iquery($q); $count=$total_num=$total_money=0; $total_sjks=0; $tbody_str=""; $flag1=($is_spk=="y")?"1":""; $total_zb_js=$total_zb_je=0; $total_js=$total_je=$total_jsje=0; while($m=$db->fetch_array($r)){ if($s_group_by=="uid"){ //客户分组 $m1=get_db_msg("select * from ".$table_pre."client where id='".$m["uid"]."'"); $is_checked=$is_jd="null"; if($is_brand=="y" && $s_brand){ $m_brand=get_db_msg("select * from ".$table_pre."client_brand where cid='".$m1["id"]."' and brand='".$s_brand."'"); $is_checked=$m_brand["is_checked"]; $is_jd=$m_brand["is_jd"]; }else{ $is_checked=$m1["is_checked"]; $is_jd=$m1["is_jd"]; } $print_state=get_client_print_state($m["uid"]); if((!$s_is_jd || ($s_is_jd && $s_is_jd==$is_jd)) &&(!$s_is_checked || ($s_is_checked && $s_is_checked==$is_checked)) && (!$s_is_print || ($s_is_print && $s_is_print==$print_state))){ $list=$count+1; $m_qy=get_db_msg("select title from ".$table_pre."client where id='".get_qy_id($m["upath"])."'"); $m_dl=get_db_msg("select title from ".$table_pre."client where id='".get_dl_id($m["upath"])."'"); $gtitle=$m1["title"]."(".$m1["username"].")"; //指标 $zb=$zb_style=$wcl=""; $td_zb=""; if($is_brand=="y"){ if($s_brand) $m_client_brand=get_db_msg("select * from ".$table_pre."client_brand where cid='".$m["uid"]."' and brand='".$s_brand."'"); else $m_client_brand=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client_brand where cid='".$m["uid"]."'"); $zb_js=$m_client_brand["zb_js"]; $zb=$m_client_brand["zb"]*10000; if($s_brand){ $client_state=get_client_state($m_client_brand["is_jd"],$m_client_brand["is_checked"]); }else{ $client_state=get_client_state_all_brand($m["uid"]); } }else{ $zb_js=$m1["zb_js"]; $zb=$m1["zb"]*10000; if(trim($zk_type)){ $ydje=$m1["order_money".$flag1."_zk"]; }else{ $ydje=$m1["order_money".$flag1]; } $client_state=get_client_state($m1["is_jd"],$m1["is_checked"]); } $total_zb_js+=$zb_js; $total_zb_je+=$zb; $tmp_js=$m["num"]; $tmp_je=$m["je"]; $tmp_jsje=$m["jsje"]; $tbody_str.="{"; $tbody_str.="\"ct\":\"".$list."\","; $tbody_str.="\"qy\":\"".deel_td_zz($m_qy["title"])."\","; $tbody_str.="\"dl\":\"".deel_td_zz($m_dl["title"])."\","; if($show_dpsx=="y") $tbody_str.="\"dpsx\":\"".deel_td_zz($m1["dpsx"])."\","; if($show_dpdj=="y") $tbody_str.="\"dpdj\":\"".deel_td_zz($m1["dj"])."\","; $tbody_str.="\"group_by\":\"".deel_td_zz($gtitle)."\","; $tbody_str.="\"uname\":\"".deel_td_zz($m1["username"])."\","; $tbody_str.="\"order_js\":\"".$tmp_js."\","; $tbody_str.="\"order_je\":\"".deel_td_zz(deel_num($tmp_je))."\","; if($show_jsje=="y") $tbody_str.="\"order_jsje\":\"".deel_td_zz(deel_num($tmp_jsje))."\","; if(in_array("js",$arr_zb_type)){ $wcl=deel_bfb1($tmp_js,$zb_js,1); $tbody_str.="\"jszb\":\"".deel_td_zz($zb_js)."\","; $tbody_str.="\"jswcl\":\"".deel_td_zz($wcl)."\","; } if(in_array("je",$arr_zb_type)){ $wcl=deel_bfb1($tmp_jsje,$zb,1); $tbody_str.="\"jezb\":\"".deel_td_zz(deel_je_show($zb))."\","; $tbody_str.="\"jewcl\":\"".deel_td_zz($wcl)."\","; } $jdst=get_main_value($arr_jd_state,$is_jd); $checkedst=get_main_value($arr_qr_state,$is_checked); $tbody_str.="\"jd_state\":\"".$is_jd."\","; $tbody_str.="\"order_state\":\"".$is_checked."\","; //$print_state=get_main_value($arr_print_state,$print_state); $tbody_str.="\"order_print\":\"".$print_state."\""; $tbody_str.="},"; $total_js+=$tmp_js; $total_je+=$tmp_je; $total_jsje+=$tmp_jsje; $count++; } }else{ $list=$count+1; $gtitle=get_cate_title_no($s_group_by,$m[$s_group_by]); //取得设计款数 $tmp=get_db_msg("select count(*) 'num' from ".$table_pre."kh where ".$s_group_by."='".$m[$s_group_by]."'"); $sjks=$tmp["num"]; $total_sjks+=$sjks; $tbody_str.="{"; $tbody_str.="\"ct\":\"".$list."\","; $tbody_str.="\"group_by\":\"".deel_td_zz($gtitle)."\","; $tbody_str.="\"sjks\":\"".$sjks."\","; $tbody_str.="\"order_js\":\"".$m["num"]."\","; $tbody_str.="\"order_je\":\"".$m["je"]."\" "; $tbody_str.="},"; $total_js+=$m["num"]; $total_je+=$m["je"]; $count++; } } $json_data.="\"tbody_str\":[".substr($tbody_str,0,-1)."],"; if($s_group_by=="uid"){ $hj_colspan=4; if($show_dpsx=="y") $hj_colspan++; if($show_dpdj=="y") $hj_colspan++; $tfoot_str=""; $tfoot_str.="\"order_js\":\"".$total_js."\","; $tfoot_str.="\"order_je\":\"".$total_je."\","; if($show_jsje=="y") $tfoot_str.="\"order_jsje\":\"".deel_td_zz(deel_num($total_jsje))."\","; if(in_array("js",$arr_zb_type)){ $wcl=deel_bfb1($total_js,$total_zb_js,1); $tfoot_str.="\"jszb\":\"".deel_td_zz(deel_num($total_zb_js))."\","; $tfoot_str.="\"jswcl\":\"".deel_td_zz($wcl)."\","; } if(in_array("je",$arr_zb_type)){ $wcl=deel_bfb1($total_jsje,$total_zb_je,1); $tfoot_str.="\"jezb\":\"".deel_td_zz(deel_je_show($total_zb_je))."\","; $tfoot_str.="\"jewcl\":\"".deel_td_zz($wcl)."\","; } $tfoot_str.="\"jd_state\":\"\","; $tfoot_str.="\"order_state\":\"\","; $tfoot_str.="\"order_print\":\"\""; $json_data.="\"tfoot_str\":{".$tfoot_str."},"; $json_data.="\"tfoot_colhj\":\"".$hj_colspan."\","; }else{ $json_data.="\"tfoot_str\":{\"tal_ks\":\"".$total_sjks."\",\"tal_js\":\"".$total_js."\",\"tal_je\":\"".$total_je."\"},"; } break; case "plugin": $str_plugin=""; if(check_table_exist($table_pre."plugin")=="y"){ $qq="select * from ".$table_pre."plugin where cate='admin_bb'"; $rr=$db->query($qq); while($mm=$db->fetch_array($rr)){ $str_plugin.="{\"id\":\"".$mm["id"]."\",\"no\":\"".$mm["file_name"]."\",\"title\":\"".$mm["title"]."\"},"; } $str_plugin=deel_end($str_plugin); } $json_data.="\"select_plugin\":{\"no\":\"s_group_by\",\"title\":\"-请选择报表-\",\"value\":\"".$s_group_by."\",\"op\":[".$str_plugin."]},"; $json_data.="\"code\":\"0\","; break; } } $json_data=substr($json_data,0,-1)."}"; echo $json_data; if($dbhost_slave){ $db->close(); $db=new DB_Sql; $db->connect($dbhost,$dbuser,$dbpw,$dbname); } ?>