7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
179 lines
5.4 KiB
PHP
179 lines
5.4 KiB
PHP
<?php
|
|
//款数5维分析报表
|
|
//可配置参数:zd1|bc|横向维度1,zd2|series|横向维度2,zd3|category|横向维度3,zd4|theme|纵向维度1,zd5|jgd|纵向维度2
|
|
//2018-12-10 by hehe
|
|
//------横向维度:zd1,zd2,zd3;纵向维度:zd4,zd5。
|
|
//-----参数配置
|
|
//横向维度
|
|
$zd1=get_plugin_set("zd1","bc");
|
|
$zd2=get_plugin_set("zd2","series");
|
|
$zd3=get_plugin_set("zd3","category");
|
|
//纵向维度
|
|
$zd4=get_plugin_set("zd4","theme");
|
|
$zd5=get_plugin_set("zd5","jgd");
|
|
//
|
|
$json_data.="\"use_layui\":1,";//使用layui表格
|
|
$select_client_type="y";//dp:开启店铺查询框
|
|
//$select="{\"name\":\"s_s1\",\"title\":\"条件1\",\"value\":\"".$s_s1."\",\"op\":[{\"no\":\"1\",\"title\":\"第一个\"},{\"no\":\"2\",\"title\":\"第二个\"}]}";//筛选条件
|
|
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;
|
|
}
|
|
//表头第一行
|
|
$thead0="";
|
|
$thead0.="{\"field\":\"row11\",\"title\":\"".$zd_title1."\",\"rowspan\":2,\"fixed\":\"left\",\"width\":80},";
|
|
$thead0.="{\"field\":\"row12\",\"title\":\"".$zd_title2."\",\"rowspan\":2,\"width\":80},";
|
|
$thead0.="{\"field\":\"row13\",\"title\":\"".$zd_title3."\",\"rowspan\":2,\"width\":80},";
|
|
$thead0.="{\"field\":\"row14\",\"title\":\"设计款量\",\"rowspan\":2,\"width\":80},";
|
|
$i=5;
|
|
foreach($arr_zd4 as $n1 => $t1){
|
|
$thead0.="{\"field\":\"row1".$i."\",\"title\":\"".$t1.$zd_title5."\",\"colspan\":".count($arr_zd5)."},";
|
|
$i++;
|
|
}
|
|
$thead0.="{\"field\":\"row1".$i."\",\"title\":\"整体".$zd_title5."\",\"colspan\":".count($arr_zd5)."},";
|
|
//表头第二行
|
|
$thead1="";
|
|
$i=1;
|
|
foreach($arr_zd4 as $n1 => $t1){
|
|
foreach($arr_zd5 as $n2 => $t2){
|
|
$thead1.="{\"field\":\"row2".$i."\",\"title\":\"".$t2."\",\"width\":80},";
|
|
$i++;
|
|
}
|
|
}
|
|
foreach($arr_zd5 as $n2 => $t2){
|
|
$thead1.="{\"field\":\"row2".$i."\",\"title\":\"".$t2."\",\"width\":80},";
|
|
$i++;
|
|
}
|
|
$thead="\"thead\":[{\"index\":0,\"content\":[".deel_end($thead0)."]},{\"index\":1,\"content\":[".deel_end($thead1)."]}],";
|
|
$json_data.=$thead;
|
|
//-----------取得报表数据
|
|
//查询条件
|
|
$con="";
|
|
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"]."-%')";
|
|
}
|
|
}
|
|
//订单数据
|
|
$q1="select ".$zd1.",".$zd2.",".$zd3.",".$zd4.",".$zd5.",count(distinct no) '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++;
|
|
}
|
|
//-----------输出报表
|
|
$tbody="";
|
|
$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){
|
|
$col=1;
|
|
$row="";
|
|
$row.="\"row".$col."\":\"".$t1."\",";
|
|
$col++;
|
|
$row.="\"row".$col."\":\"".$t2."\",";
|
|
$col++;
|
|
$row.="\"row".$col."\":\"".$t3."\",";
|
|
$col++;
|
|
//小计
|
|
$row.="\"row".$col."\":\"".$arr_data1[$n1][$n2][$n3]."\",";
|
|
$col++;
|
|
$$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;
|
|
$row.="\"row".$col."\":\"".deel_0($arr_data[$n1][$n2][$n3][$n4][$n5])."\",";
|
|
$col++;
|
|
$$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;
|
|
$row.="\"row".$col."\":\"".deel_0($$var1)."\",";
|
|
$col++;
|
|
}
|
|
$tbody.="{".deel_end($row)."},";
|
|
$i3++;
|
|
}
|
|
}
|
|
//---------------zd2合计
|
|
$col=1;
|
|
$row="";
|
|
$row.="\"row".$col."\":\" \",";
|
|
$col++;
|
|
$row.="\"row".$col."\":\" \",";
|
|
$col++;
|
|
$row.="\"row".$col."\":\"小计\",";
|
|
$col++;
|
|
//小计
|
|
$row.="\"row".$col."\":\"".$$var_hj_zd2."\",";
|
|
$col++;
|
|
foreach($arr_zd4 as $n4 => $t4){
|
|
foreach($arr_zd5 as $n5 => $t5){
|
|
$var1="zt1_".$n1."_".$n2."_".$n4."_".$n5;
|
|
$row.="\"row".$col."\":\"".deel_0($$var1)."\",";
|
|
$col++;
|
|
}
|
|
}
|
|
//整体
|
|
foreach($arr_zd5 as $n5 => $t5){
|
|
$var1="zt_".$n1."_".$n2."_".$n5;
|
|
$row.="\"row".$col."\":\"".deel_0($$var1)."\",";
|
|
$col++;
|
|
}
|
|
$tbody.="{".deel_end($row)."},";
|
|
$i3++;
|
|
$i2++;
|
|
}
|
|
$i1++;
|
|
}
|
|
$json_data.="\"tbody\":[".deel_end($tbody)."],";
|
|
?>
|