7e47ce238b
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
159 lines
5.6 KiB
PHP
159 lines
5.6 KiB
PHP
<?php
|
|
//件数、金额4维报表
|
|
//可配置参数:zd1|sxz|横向维度1,zd2|category|横向维度2,zd3|brand|纵向维度1,zd4|theme|纵向维度2
|
|
//2018-12-11 by hehe
|
|
//-----参数配置
|
|
//横向维度
|
|
$zd1=get_plugin_set("zd1","sxz");
|
|
$zd2=get_plugin_set("zd2","category");
|
|
//纵向维度
|
|
$zd3=get_plugin_set("zd3","brand");
|
|
$zd4=get_plugin_set("zd4","theme");
|
|
//
|
|
$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<5;$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'> </th><th align='center'><strong>".$zd_title3."</strong></th>";
|
|
foreach($arr_zd3 as $n1 => $t1){
|
|
$content_data.="<th align='center' colspan='".(count($arr_zd4)*2)."'><strong>".$t1."</strong></th>";
|
|
}
|
|
$content_data.="<th align='center' colspan='2' rowspan='2'><strong>总计</strong></th>";
|
|
$content_data.="</tr>";
|
|
//表头第二行
|
|
$content_data.="<tr><th align='center'> </th><th align='center'><strong>".$zd_title4."</strong></th>";
|
|
foreach($arr_zd3 as $n1 => $t1){
|
|
foreach($arr_zd4 as $n2 => $t2){
|
|
$content_data.="<th align='center' colspan='2'><strong>".$t2."</strong></th>";
|
|
}
|
|
}
|
|
$content_data.="</tr>";
|
|
//表头第三行
|
|
$content_data.="<tr><th align='center'>".$zd_title1."</th><th align='center'><strong>".$zd_title2."</strong></th>";
|
|
$i=1;
|
|
foreach($arr_zd3 as $n1 => $t1){
|
|
foreach($arr_zd4 as $n2 => $t2){
|
|
$content_data.="<th align='center'><strong>件数</strong></th><th align='center'><strong>金额</strong></th>";
|
|
$i++;
|
|
}
|
|
}
|
|
$content_data.="<th align='center'><strong>件数</strong></th><th align='center'><strong>金额</strong></th>";
|
|
$content_data.="</tr>";
|
|
//
|
|
$content_data.="</thead><tbody>";
|
|
//-----------取得报表数据
|
|
//订单数据
|
|
$q1="select ".$zd1.",".$zd2.",".$zd3.",".$zd4.",sum(je) 'je',sum(num) 'js' from ".$table_pre."order where ka<>'y' ".$con." group by ".$zd1.",".$zd2.",".$zd3.",".$zd4;
|
|
$r1=$db->query($q1);
|
|
$arr_data=array();
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arr_data_je[$m1[$zd1]][$m1[$zd2]][$m1[$zd3]][$m1[$zd4]]=$m1["je"];
|
|
$arr_data_js[$m1[$zd1]][$m1[$zd2]][$m1[$zd3]][$m1[$zd4]]=$m1["js"];
|
|
}
|
|
//款号数据
|
|
$q1="select ".$zd1.",".$zd2.",count(*) 'ks' from ".$table_pre."kh where ka<>'y' group by ".$zd1.",".$zd2;
|
|
$r1=$db->query($q1);
|
|
$arr_data1=array();
|
|
while($m1=$db->fetch_array($r1)){
|
|
$arr_data_ks[$m1[$zd1]][$m1[$zd2]]=$m1["ks"];
|
|
}
|
|
//-----------计算rowspan
|
|
$arr_rowspan_zd1=$arr_rowspan_zd2=array();
|
|
$i1=0;
|
|
foreach($arr_zd1 as $n1 => $t1){
|
|
$xj1=0;
|
|
foreach($arr_zd2 as $n2 => $t2){
|
|
if($arr_data_ks[$n1][$n2]>0)
|
|
$xj1++;
|
|
}
|
|
$arr_rowspan_zd1[$i1]=$xj1;
|
|
$i1++;
|
|
}
|
|
//-----------输出报表
|
|
$i1=$i2=0;
|
|
$total_js=$total_je=0;
|
|
foreach($arr_zd1 as $n1 => $t1){
|
|
foreach($arr_zd2 as $n2 => $t2){
|
|
$var_hj_zd2="hj_".$n1."_".$n2;
|
|
if($arr_data_ks[$n1][$n2]>0){
|
|
$content_data.="<tr>";
|
|
if($i2==count_arr_num_before($arr_rowspan_zd1,$i1))
|
|
$content_data.="<td align='center' rowspan='".$arr_rowspan_zd1[$i1]."'>".$t1."</th>";
|
|
$content_data.="<td align='center'>".$t2."</th>";
|
|
foreach($arr_zd3 as $n3 => $t3){
|
|
foreach($arr_zd4 as $n4 => $t4){
|
|
$var1="hj_je_".$n3."_".$n4;
|
|
$var2="hj_js_".$n3."_".$n4;
|
|
$var3="xj_je_".$n1."_".$n2;
|
|
$var4="xj_js_".$n1."_".$n2;
|
|
$content_data.="<td align='center'>".deel_0($arr_data_js[$n1][$n2][$n3][$n4])."</th><td align='center'>".deel_num($arr_data_je[$n1][$n2][$n3][$n4])."</th>";
|
|
$$var1+=$arr_data_je[$n1][$n2][$n3][$n4];
|
|
$$var2+=$arr_data_js[$n1][$n2][$n3][$n4];
|
|
$$var3+=$arr_data_je[$n1][$n2][$n3][$n4];
|
|
$$var4+=$arr_data_js[$n1][$n2][$n3][$n4];
|
|
$total_je+=$arr_data_je[$n1][$n2][$n3][$n4];
|
|
$total_js+=$arr_data_js[$n1][$n2][$n3][$n4];
|
|
}
|
|
}
|
|
//小计
|
|
$var1="xj_je_".$n1."_".$n2;
|
|
$var2="xj_js_".$n1."_".$n2;
|
|
$content_data.="<td align='center'>".deel_0($$var2)."</th><td align='center'>".deel_0($$var1)."</th>";
|
|
$content_data.="</tr>";
|
|
}
|
|
$i2++;
|
|
}
|
|
$i1++;
|
|
}
|
|
//---------------zd2合计
|
|
$content_data.="<tr><td align='center' colspan='2'><b>合计</b></th>";
|
|
foreach($arr_zd3 as $n3 => $t3){
|
|
foreach($arr_zd4 as $n4 => $t4){
|
|
$var1="hj_je_".$n3."_".$n4;
|
|
$var2="hj_js_".$n3."_".$n4;
|
|
$content_data.="<td align='center'>".deel_0($$var2)."</th><td align='center'>".deel_0($$var1)."</th>";
|
|
}
|
|
}
|
|
//总计合计
|
|
$content_data.="<td align='center'>".deel_0($total_js)."</th><td align='center'>".deel_0($total_je)."</th>";
|
|
$content_data.="</tr>";
|
|
$content_data.="</tbody></table>";
|
|
$json_data.="\"table_html\":\"".$content_data."\",";
|
|
?>
|