This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
EDT/plugin/client_bb/ks5.php
T
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

176 lines
5.9 KiB
PHP

<?php
//款数5维报表
//可配置参数:zd1|bc|横向维度1,zd2|sxz|横向维度2,zd3|category|横向维度3,zd4|brand|纵向维度1,zd5|theme|纵向维度2,tjs|ks|支持ks(款数)js(件数)je(金额)
//2018-12-11 by hehe
//-----参数配置
//横向维度
$zd1=get_plugin_set("zd1","bc");
$zd2=get_plugin_set("zd2","sxz");
$zd3=get_plugin_set("zd3","category");
//纵向维度
$zd4=get_plugin_set("zd4","brand");
$zd5=get_plugin_set("zd5","theme");
$tjs=get_plugin_set("tjs","ks");
//
$select_client_type="y";//dp:允许筛选店铺
$use_layui_datatable="n";//使用标准layui datatable格式数据
//店铺查询条件
$con="";
if($msg_client["face"]=="4"){
$s_username=$msg_client["username"];
$con=" and uid='".$msg_client["id"]."'";
}else{
if($s_username){
$m2=get_db_msg("select id,face,path from ".$table_pre."client where username='".$s_username."'");
if($m2["face"]=="4"){
$con=" and uid='".$m2["id"]."'";
}else{
$con=" and (upath='".$m2["path"]."-".$m2["id"]."' or upath like '".$m2["path"]."-".$m2["id"]."-%')";
}
}else if($msg_client["face"]=="2"){
//区经角色所有客户
$con=get_qj_ucon_all($msg_client["charge_path_real"]);
}else{
//代理角色所有客户
$con=" and (upath='".$msg_client["path"]."-".$msg_client["id"]."' or upath like '".$msg_client["path"]."-".$msg_client["id"]."-%')";
}
}
//
for($i=1;$i<6;$i++){
$v="zd".$i;
$v1="zd_title".$i;
$v2="arr_zd".$i;
//取得对应字段的名称
$$v1=get_cate_title_no("arr_select",$$v);
//取得字段的选项值
$q1="select no,title from ".$table_pre."keyword where cate='".$$v."' order by no";
$r1=$db->query($q1);
$arr_tmp=array();
while($m1=$db->fetch_array($r1)){
$arr_tmp[$m1["no"]]=$m1["title"];
}
$$v2=$arr_tmp;
}
$content_data="<table border='0' cellspacing='1' cellpadding='4' class='layui-table'><thead>";
//表头第一行
$content_data.="<tr><th align='center' rowspan='2'><strong>".$zd_title1."</strong></th><th align='center' rowspan='2'><strong>".$zd_title2."</strong></th><th align='center' rowspan='2'><strong>".$zd_title3."</strong></th><th align='center' rowspan='2'><strong>参与订货<br>款量</strong></th>";
foreach($arr_zd4 as $n1 => $t1){
$content_data.="<th align='center' colspan='".count($arr_zd5)."'><strong>".$t1.$zd_title5."</strong></th>";
}
$content_data.="<th align='center' colspan='".count($arr_zd5)."'><strong>整体".$zd_title5."</strong></th>";
$content_data.="</tr>";
//表头第二行
$content_data.="<tr>";
foreach($arr_zd4 as $n1 => $t1){
foreach($arr_zd5 as $n2 => $t2){
$content_data.="<th align='center' width='50'><strong>".$t2."</strong></th>";
}
}
foreach($arr_zd5 as $n2 => $t2){
$content_data.="<th align='center' width='50'><strong>".$t2."</strong></th>";
}
$content_data.="</tr></thead>";
//
$content_data.="<tbody>";
//-----------取得报表数据
if($tjs=="ks"){
$str1="count(distinct no)";
}else if($tjs=="je"){
$str1="sum(jsje)";
}else{
$str1="sum(num)";
}
//订单数据
$q1="select ".$zd1.",".$zd2.",".$zd3.",".$zd4.",".$zd5.",".$str1." 'ks' from ".$table_pre."order where ka<>'y' ".$con." group by ".$zd1.",".$zd2.",".$zd3.",".$zd4.",".$zd5;
$r1=$db->query($q1);
$arr_data=array();
while($m1=$db->fetch_array($r1)){
$arr_data[$m1[$zd1]][$m1[$zd2]][$m1[$zd3]][$m1[$zd4]][$m1[$zd5]]=$m1["ks"];
}
//款号数据
$q1="select ".$zd1.",".$zd2.",".$zd3.",count(*) 'ks' from ".$table_pre."kh where ka<>'y' group by ".$zd1.",".$zd2.",".$zd3;
$r1=$db->query($q1);
$arr_data1=array();
while($m1=$db->fetch_array($r1)){
$arr_data1[$m1[$zd1]][$m1[$zd2]][$m1[$zd3]]=$m1["ks"];
}
//-----------计算rowspan
$arr_rowspan_zd1=$arr_rowspan_zd2=array();
$i1=$i2=0;
foreach($arr_zd1 as $n1 => $t1){
$xj1=0;
foreach($arr_zd2 as $n2 => $t2){
$xj2=0;
foreach($arr_zd3 as $n3 => $t3){
if($arr_data1[$n1][$n2][$n3]>0){
$xj1++;
$xj2++;
}
}
$arr_rowspan_zd2[$i2]=$xj2;
$xj1++;
$i2++;
}
$arr_rowspan_zd1[$i1]=$xj1;
$i1++;
}
//-----------输出报表
$i1=$i2=$i3=0;
foreach($arr_zd1 as $n1 => $t1){
foreach($arr_zd2 as $n2 => $t2){
$var_hj_zd2="hj_".$n1."_".$n2;
foreach($arr_zd3 as $n3 => $t3){
if($arr_data1[$n1][$n2][$n3]>0){
$content_data.="<tr>";
if($i3==count_arr_num_before($arr_rowspan_zd1,$i1))
$content_data.="<td align='center' rowspan='".$arr_rowspan_zd1[$i1]."'>".$t1."</th>";
if($i3==(count_arr_num_before($arr_rowspan_zd2,$i2)+$i2))
$content_data.="<td align='center' rowspan='".$arr_rowspan_zd2[$i2]."'>".$t2."</th>";
$content_data.="<td align='center'>".$t3."</th>";
//小计
$content_data.="<td align='center'>".deel_num($arr_data1[$n1][$n2][$n3])."</th>";
$$var_hj_zd2+=$arr_data1[$n1][$n2][$n3];
foreach($arr_zd4 as $n4 => $t4){
foreach($arr_zd5 as $n5 => $t5){
$var1="zt_".$n1."_".$n2."_".$n3."_".$n5;
$var2="zt_".$n1."_".$n2."_".$n5;
$var3="zt1_".$n1."_".$n2."_".$n4."_".$n5;
$content_data.="<td align='center'>".deel_num($arr_data[$n1][$n2][$n3][$n4][$n5])."</th>";
$$var1+=$arr_data[$n1][$n2][$n3][$n4][$n5];
$$var2+=$arr_data[$n1][$n2][$n3][$n4][$n5];
$$var3+=$arr_data[$n1][$n2][$n3][$n4][$n5];
}
}
//整体
foreach($arr_zd5 as $n5 => $t5){
$var1="zt_".$n1."_".$n2."_".$n3."_".$n5;
$content_data.="<td align='center'>".deel_num($$var1)."</th>";
}
$content_data.="</tr>";
$i3++;
}
}
//---------------zd2合计
$content_data.="<tr><td align='center' colspan='2'><b>".$t2."合计</b></th>";
//小计
$content_data.="<td align='center'>".deel_num($$var_hj_zd2)."</th>";
foreach($arr_zd4 as $n4 => $t4){
foreach($arr_zd5 as $n5 => $t5){
$var1="zt1_".$n1."_".$n2."_".$n4."_".$n5;
$content_data.="<td align='center'>".deel_num($$var1)."</th>";
}
}
//整体
foreach($arr_zd5 as $n5 => $t5){
$var1="zt_".$n1."_".$n2."_".$n5;
$content_data.="<td align='center'>".deel_num($$var1)."</th>";
}
$content_data.="</tr>";
$i3++;
$i2++;
}
$i1++;
}
$content_data.="</tbody></table>";
$json_data.="\"table_html\":\"".$content_data."\",";
?>