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/report_khzb_1w.php
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

300 lines
13 KiB
PHP

<?php
//1维指标分析
//可配置参数:keyword_zd1|category|字段1,icon|menu_icon_bb_xw_ms|菜单图标,select_zd1||搜索1,select_zd2||搜索2,select_zd3||搜索3,head_zd1|y|数量,head_zd2|y|吊牌金额,head_zd3|y|结算金额,head_zd4|y|款色数,head_zd5|y|金额指标,head_zd6|n|件数指标,head_zd7|n|款色指标
//-----参数配置start
//菜单图标
$icon=get_plugin_set("icon","menu_icon_bb_xw_ms");//支持以下目录的图标ipad/images/menu_icon_*.png
//字段
$zd1=get_plugin_set("keyword_zd1","category");
//指标数据指向表
$data_name=$table_pre."plugin_report_khzb_1w";
//区域代理指标合计店铺
$count_by_dp="y";
//表头
$head_zd1=get_plugin_set("head_zd1","y");
$head_zd2=get_plugin_set("head_zd2","y");
$head_zd3=get_plugin_set("head_zd3","y");
$head_zd4=get_plugin_set("head_zd4","y");
$head_zd5=get_plugin_set("head_zd5","y");
$head_zd6=get_plugin_set("head_zd6","n");
$head_zd7=get_plugin_set("head_zd7","n");
$arr_sx=array("3"=>"代理","4"=>"店铺","9"=>"区域");
//
$select_client_type="y";//dp:允许筛选店铺
$use_layui_datatable="n";//使用标准layui datatable格式数据
$s_key=$s_key?$s_key:$_key;
//搜索
$search_arr=array();
$searh_select1=get_plugin_set("select_zd1","");
$searh_select2=get_plugin_set("select_zd2","");
$searh_select3=get_plugin_set("select_zd3","");
array_push($search_arr,$searh_select1,$searh_select2,$searh_select3);
//
$str_select="";
for($i=0;$i<count($search_arr);$i++){
$arr_val=$search_arr[$i];
if($arr_val){
if($arr_val=="s_spk"){
$str_select.="{\"name\":\"s_spk\",\"title\":\"是否饰品款\",\"value\":\"".$s_spk."\",\"op\":[{\"no\":\"y\",\"title\":\"\"},{\"no\":\"n\",\"title\":\"\"}]},";
}else if($arr_val=="s_ka"){
$str_select.="{\"name\":\"s_ka\",\"title\":\"是否删除款\",\"value\":\"".$s_ka."\",\"op\":[{\"no\":\"y\",\"title\":\"\"},{\"no\":\"n\",\"title\":\"\"}]},";
}else{
$str_op="";
$sql_select="select no,title from web_keyword where cate='".$arr_val."' order by ord";
$res_select=$db->query($sql_select);
while($msg_select=$db->fetch_array($res_select)){
$str_op.="{\"no\":\"".$msg_select["no"]."\",\"title\":\"".$msg_select["title"]."\"},";
}
$str_select.="{\"name\":\"".$arr_val."\",\"title\":\"".get_cate_title_no("arr_select",$arr_val)."\",\"value\":\"".$$arr_val."\",\"op\":[".substr($str_op,0,-1)."]},";
}
}
}
$json_data.="\"select_report\":[".substr($str_select,0,-1)."],";
//end
//-------------------------条件
//-------con为web_order
//-------con1为web_kh
$con=$con1=$con_zb=$con_u="";
if($searh_select1!="s_ka" && $searh_select2!="s_ka" && $searh_select3!="s_ka"){
//没有删除款搜索时
$con.=" and ka<>'y' ";
$con1.=" and ka<>'y' ";
}else{
if($s_ka){
$con.=" and ka='".$s_ka."' ";
$con1.=" and ka='".$s_ka."' ";
}
}
if($searh_select1!="s_spk" && $searh_select2!="s_spk" && $searh_select3!="s_spk"){
//没有饰品款搜索时
$con.=" and is_sp<>'y' ";
$con1.=" and is_sp<>'y' ";
}else{
if($s_spk){
$con.=" and is_sp='".$s_spk."' ";
$con1.=" and is_sp='".$s_spk."' ";
}
}
if($s_key){
if($s_key=="all"){
$con.="";
}else{
$con.=" and _key='".$s_key."'";
}
}
//其他
for($i=0;$i<count($search_arr);$i++){
$arr_val=$search_arr[$i];
if($arr_val && $arr_val!="s_spk" && $arr_val!="s_ka"){
if($$arr_val){
$con.=" and ".$arr_val."='".$$arr_val."' ";
$con1.=" and ".$arr_val."='".$$arr_val."' ";
$con_zb.=" and zd1='".get_cate_title_no($zd1,$$arr_val)."'";
}
}
}
//店铺查询条件
if($msg_client["face"]=="4"){
$s_username=$msg_client["username"];
$con.=" and uid='".$msg_client["id"]."'";
$con_u.=" and id='".$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"]."'";
$con_u.=" and id='".$m2["id"]."'";
}else{
$con.=" and (upath='".$m2["path"]."-".$m2["id"]."' or upath like '".$m2["path"]."-".$m2["id"]."-%')";
$con_u.=" and (id='".$m2["id"]."' or path='".$m2["path"]."-".$m2["id"]."' or path like '".$m2["path"]."-".$m2["id"]."-%')";
}
}else if($msg_client["face"]=="2"){
//区经角色所有客户
$con.=get_qj_ucon_all($msg_client["charge_path_real"]);
$con_u.="";
}else if($msg_client["face"]=="1"){
//区经角色所有客户
$con_u.="";
}else{
//代理角色所有客户
$con.=" and (upath='".$msg_client["path"]."-".$msg_client["id"]."' or upath like '".$msg_client["path"]."-".$msg_client["id"]."-%')";
$con_u.=" and (id='".$msg_client["id"]."' or path='".$msg_client["path"]."-".$msg_client["id"]."' or path like '".$msg_client["path"]."-".$msg_client["id"]."-%')";
}
}
//---------------------------------------------
if($zd1==""){
//请求数据有误
$content_data="<div align='center'>请先配置参数!</div>";
$json_data.="\"sys_bb_type\":\"report_null\",";
}else{
//---------------------------------------一维报表
$json_data.="\"sys_bb_type\":\"nochart\",";
$s_group_by=$zd1;
//
$content_data="";
$content_data.="<table id='tabledetail' class='cell-border nowrap' width='100%' lay-filter='layui_table' cellspacing='0' cellpadding='0' border='0' class='layui-table'>";
$content_data.="<thead><tr style='background-color:#f2f2f2' align=center><td>客户代码</td>";
$content_data.="<td>客户名称</td>";
$content_data.=($head_zd1=="y")?"<td>数量</td>":"";
$content_data.=($head_zd2=="y")?"<td>吊牌金额</td>":"";
$content_data.=($head_zd3=="y")?"<td>结算金额</td>":"";
$content_data.=($head_zd4=="y")?"<td>款色数</td>":"";
$content_data.=($head_zd5=="y")?"<td>金额指标</td><td>金额完成率</td>":"";
$content_data.=($head_zd6=="y")?"<td>件数指标</td><td>件数完成率</td>":"";
$content_data.=($head_zd7=="y")?"<td>款色指标</td><td>款色完成率</td>":"";
$content_data.="</tr>";
$content_data.="</thead>";
$content_data.="<tbody>";
//
$tb_data_x="";
$tb_data_y=",";
if($s_username){
$m3=get_db_msg("select id,face,path from ".$table_pre."client where username='".$s_username."'");
$uface=$m3["face"];
$uface2=$m3["face"];
}else{
$uface=$msg_client["face"];
}
$arr_uid=$arr_qy=$arr_dl=$arr_dp=array();
if($uface=="2"){
$arr_path=explode(",",$msg_client["charge_path"]);
}else{
$q="select id,path from ".$table_pre."client where available='y'".$con_u;
//echo $q;
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$arr_path[]=$m["path"]."-".$m["id"];
}
}
foreach($arr_path as $key => $value){
$arr_id=explode("-",$value);
$tmp_client=get_db_msg("select id,face from ".$table_pre."client where id='".end($arr_id)."'");
if($tmp_client["face"]=='4'){
$arr_dp[$tmp_client["id"]]=$value;
}
}
foreach($arr_dp as $key1 => $value1){
$arr_id_tmp=explode("-",$value1);
$check_dl=$check_qy=0;
foreach($arr_id_tmp as $key2 => $value2){
$m1=get_db_msg("select id,face from ".$table_pre."client where id='".$value2."'");
if($m1["face"]=="3"){
$dlid=$value2;
$check_dl++;
}
}
foreach($arr_id_tmp as $key2 => $value2){
$m1=get_db_msg("select id,face from ".$table_pre."client where id='".$value2."'");
if($m1["face"]=="9"){
$qyid=$value2;
$check_qy++;
}
}
if($uface=="3"){
$check_qy=0;
}
if($uface=="4"){
$check_qy=0;
$check_dl=0;
}
if($check_dl!=0 && $check_qy!=0){
$arr_uid_tmp[$qyid][$dlid][$key1]=$value1;
}else if($check_dl!=0 && $check_qy==0){
$arr_uid_tmp["0"][$dlid][$key1]=$value1;
}else if($check_dl==0 && $check_qy!=0){
$arr_uid_tmp[$qyid]["0"][$key1]=$value1;
}else if($check_dl==0 && $check_qy==0){
$arr_uid_tmp["0"]["0"][$key1]=$value1;
}
}
$arr_uid=$arr_uid_tmp;
$tbody_str="";
foreach($arr_uid as $k1 => $v1){
$tmp_client1=get_db_msg("select * from ".$table_pre."client where id='".$k1."'");
$upath1=" and (upath='".$tmp_client1["path"]."-".$tmp_client1["id"]."' or upath like '".$tmp_client1["path"]."-".$tmp_client1["id"]."-%')";
if($count_by_dp=="y"){
$count_con1=$upath1;
}else{
$count_con1=" and uid='".$k1."'";
}
if($tmp_client1["id"]){
$tmp_zb1=get_db_msg("select sum(zb) zb,sum(zb_js) zb_js,sum(zb_skc) zb_skc from ".$data_name." where id>0".$count_con1.$con_zb);
$tmp_order1=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje,count(distinct no,color) skc from ".$table_pre."order where id>0".$upath1.$con1);
$content_data.="<td>".$tmp_client1["username"]."</td><td>".$tmp_client1["title"]."<span style='color:red;'>(".$arr_sx[$tmp_client1["face"]].")</span>"."</td>";
$content_data.=($head_zd1=="y")?"<td>".$tmp_order1["num"]."</td>":"";
$content_data.=($head_zd2=="y")?"<td>".$tmp_order1["je"]."</td>":"";
$content_data.=($head_zd3=="y")?"<td>".$tmp_order1["jsje"]."</td>":"";
$content_data.=($head_zd4=="y")?"<td>".$tmp_order1["skc"]."</td>":"";
$content_data.=($head_zd5=="y")?"<td>".$tmp_zb1["zb"]."</td><td>".deel_bfb($tmp_order1["je"],$tmp_zb1["zb"])."</td>":"";
$content_data.=($head_zd6=="y")?"<td>".deel_01($tmp_zb1["zb_js"])."</td><td>".deel_bfb($tmp_order1["num"],$tmp_zb1["zb_js"])."</td>":"";
$content_data.=($head_zd7=="y")?"<td>".deel_01($tmp_zb1["zb_skc"])."</td><td>".deel_bfb($tmp_order1["skc"],$tmp_zb1["skc"])."</td>":"";
$content_data.="</tr>";
}
foreach($v1 as $k2 => $v2){
$tmp_client2=get_db_msg("select * from ".$table_pre."client where id='".$k2."'");
$upath2=" and (upath='".$tmp_client2["path"]."-".$tmp_client2["id"]."' or upath like '".$tmp_client2["path"]."-".$tmp_client2["id"]."-%')";
if($count_by_dp=="y"){
$count_con2=$upath2;
}else{
$count_con2=" and uid='".$k2."'";
}
if($tmp_client2["id"]){
$tmp_zb2=get_db_msg("select sum(zb) zb,sum(zb_js) zb_js,sum(zb_skc) zb_skc from ".$data_name." where id>0".$count_con2.$con_zb);
$tmp_order2=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje,count(distinct no,color) skc from ".$table_pre."order where id>0".$upath2.$con1);
$content_data.="<td>".$tmp_client2["username"]."</td><td>".$tmp_client2["title"]."<span style='color:red;'>(".$arr_sx[$tmp_client2["face"]].")</span>"."</td>";
$content_data.=($head_zd1=="y")?"<td>".$tmp_order2["num"]."</td>":"";
$content_data.=($head_zd2=="y")?"<td>".$tmp_order2["je"]."</td>":"";
$content_data.=($head_zd3=="y")?"<td>".$tmp_order2["jsje"]."</td>":"";
$content_data.=($head_zd4=="y")?"<td>".$tmp_order2["skc"]."</td>":"";
$content_data.=($head_zd5=="y")?"<td>".$tmp_zb2["zb"]."</td><td>".deel_bfb($tmp_order2["je"],$tmp_zb2["zb"])."</td>":"";
$content_data.=($head_zd6=="y")?"<td>".deel_01($tmp_zb2["zb_js"])."</td><td>".deel_bfb($tmp_order2["num"],$tmp_zb2["zb_js"])."</td>":"";
$content_data.=($head_zd7=="y")?"<td>".deel_01($tmp_zb2["zb_skc"])."</td><td>".deel_bfb($tmp_order2["skc"],$tmp_zb2["skc"])."</td>":"";
$content_data.="</tr>";
}
foreach($v2 as $k3 => $v3){
$tmp_client3=get_db_msg("select * from ".$table_pre."client where id='".$k3."'");
$upath3=" and (upath='".$tmp_client3["path"]."-".$tmp_client3["id"]."' or upath like '".$tmp_client3["path"]."-".$tmp_client3["id"]."-%')";
if($count_by_dp=="y"){
$count_con3=$upath3;
}else{
$count_con3=" and uid='".$k3."'";
}
if($tmp_client3["id"]){
$tmp_zb3=get_db_msg("select sum(zb) zb,sum(zb_js) zb_js,sum(zb_skc) zb_skc from ".$data_name." where id>0".$count_con3.$con_zb);
//echo "select sum(zb) zb,sum(zb_js) zb_js,sum(zb_skc) zb_skc from ".$data_name." where id>0".$count_con3.$con_zb.";<br>";
$tmp_order3=get_db_msg("select sum(num) num,sum(je) je,sum(jsje) jsje,count(distinct no,color) skc from ".$table_pre."order where id>0".$upath3.$con1);
$content_data.="<td>".$tmp_client3["username"]."</td><td>".$tmp_client3["title"]."<span style='color:red;'>(".$arr_sx[$tmp_client3["face"]].")</span>"."</td>";
$content_data.=($head_zd1=="y")?"<td>".$tmp_order3["num"]."</td>":"";
$content_data.=($head_zd2=="y")?"<td>".$tmp_order3["je"]."</td>":"";
$content_data.=($head_zd3=="y")?"<td>".$tmp_order3["jsje"]."</td>":"";
$content_data.=($head_zd4=="y")?"<td>".$tmp_order3["skc"]."</td>":"";
$content_data.=($head_zd5=="y")?"<td>".$tmp_zb3["zb"]."</td><td>".deel_bfb($tmp_order3["je"],$tmp_zb3["zb"])."</td>":"";
$content_data.=($head_zd6=="y")?"<td>".deel_01($tmp_zb3["zb_js"])."</td><td>".deel_bfb($tmp_order3["num"],$tmp_zb3["zb_js"])."</td>":"";
$content_data.=($head_zd7=="y")?"<td>".deel_01($tmp_zb3["zb_skc"])."</td><td>".deel_bfb($tmp_order3["skc"],$tmp_zb3["skc"])."</td>":"";
$content_data.="</tr>";
}
}
}
}
$content_data.="</tbody>";
$content_data.="</table>";
//图
$tb_data_y=deel_end($tb_data_y);
$tb_data_x=deel_end($tb_data_x);
//$json_data.="\"chart_title\":\"\",";
//$json_data.="\"chart_type\":\"pie\",";
//$json_data.="\"chart_data_x\":\"".$tb_data_x."\",";
//$json_data.="\"chart_data_y\":\"".$tb_data_y."\",";
}
$json_data.="\"table_html\":\"".$content_data."\",";
?>