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

157 lines
6.5 KiB
PHP

<?php
//----------设置指标相关
require "../config.php";
include "../../tmpl/config.php";
require THIS_FILE_ROOT."/include/function.php";
require THIS_FILE_ROOT."/include/db_mysql.php";
//require THIS_FILE_ROOT."/include/page.class.php";
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//-------------------------------mysql connect
$db=new DB_Sql;
$db->connect($dbhost,$dbuser,$dbpw,$dbname,"p");
$is_brand=get_set("is_brand");
$zb_type=get_set("zb_type");
$arr_zb_type=explode(",",$zb_type);
$arr_hj_type=array("qy"=>"合计区域","dl"=>"合计代理");
$sub=$_POST["sub"];
$hj_type=$_POST["hj_type"]?$_POST["hj_type"]:array("1","2");
$content="<tr><td align=\"left\" bgcolor=\"#ffffff\" valign=\"top\" style=\"line-height:150%;\"><table width=\"100%\" border=\"0\" align=\"center\" cellpadding=\"3\" cellspacing=\"1\" bgcolor=\"#cccccc\">";
if($sub=="y"){
if($is_brand=="y"){
$content.="<tr bgcolor=\"#eeeeee\"><td>客户</td><td>品牌</td>";
if(in_array("je",$arr_zb_type))
$content.="<td>指标金额(万)</td>";
if(in_array("js",$arr_zb_type))
$content.="<td>指标件数</td>";
$content.="</tr>";
if(in_array("dl",$hj_type)){
//合计代理指标
$q="select * from ".$table_pre."client where face='3'";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$q2="select * from ".$table_pre."keyword where cate='brand'";
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
$m1=get_db_msg("select sum(b.zb) 'zb',sum(b.zb_js) 'zb_js' from ".$table_pre."client_brand b,".$table_pre."client c where b.cid=c.id and b.brand='".$m2["no"]."' and c.path='".$m["path"]."-".$m["id"]."'");
$tmp1=get_db_msg("select id from ".$table_pre."client_brand where cid='".$m["id"]."' and brand='".$m2["no"]."'");
if($tmp1["id"]>0){
$q1="update ".$table_pre."client_brand set zb='".$m1["zb"]."',zb_js='".$m1["zb_js"]."' where id='".$tmp1["id"]."'";
}else{
$q1="insert into ".$table_pre."client_brand (cid,brand,zb,zb_js) values ('".$m["id"]."','".$m2["no"]."','".$m1["zb"]."','".$m1["zb_js"]."')";
}
$db->query($q1);
$content.="<tr bgcolor=\"#ffffff\"><td>代理:".$m["title"]."(".$m["username"].")</td><td>".$m2["title"]."</td>";
if(in_array("je",$arr_zb_type))
$content.="<td>".$m1["zb"]."</td>";
if(in_array("js",$arr_zb_type))
$content.="<td>".$m1["zb_js"]."</td>";
$content.="</tr>";
}
}
}
if(in_array("qy",$hj_type)){
//合计区域指标
$q="select * from ".$table_pre."client where face='9'";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$q2="select * from ".$table_pre."keyword where cate='brand'";
$r2=$db->query($q2);
while($m2=$db->fetch_array($r2)){
$m1=get_db_msg("select sum(b.zb) 'zb',sum(b.zb_js) 'zb_js' from ".$table_pre."client_brand b,".$table_pre."client c where b.cid=c.id and b.brand='".$m2["no"]."' and c.path='".$m["path"]."-".$m["id"]."'");
$tmp1=get_db_msg("select id from ".$table_pre."client_brand where cid='".$m["id"]."' and brand='".$m2["no"]."'");
if($tmp1["id"]>0){
$q1="update ".$table_pre."client_brand set zb='".$m1["zb"]."',zb_js='".$m1["zb_js"]."' where id='".$tmp1["id"]."'";
}else{
$q1="insert into ".$table_pre."client_brand (cid,brand,zb,zb_js) values ('".$m["id"]."','".$m2["no"]."','".$m1["zb"]."','".$m1["zb_js"]."')";
}
$db->query($q1);
$content.="<tr bgcolor=\"#ffffff\"><td>区域:".$m["title"]."(".$m["username"].")</td><td>".$m2["title"]."</td>";
if(in_array("je",$arr_zb_type))
$content.="<td>".$m1["zb"]."</td>";
if(in_array("js",$arr_zb_type))
$content.="<td>".$m1["zb_js"]."</td>";
$content.="</tr>";
}
}
}
}else{
$content.="<tr bgcolor=\"#eeeeee\"><td>客户</td>";
if(in_array("je",$arr_zb_type))
$content.="<td>指标金额(万)</td>";
if(in_array("js",$arr_zb_type))
$content.="<td>指标件数</td>";
$content.="</tr>";
if(in_array("dl",$hj_type)){
//合计代理指标
$q="select * from ".$table_pre."client where face='3'";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client where path='".$m["path"]."-".$m["id"]."'");
$q1="update ".$table_pre."client set zb='".$m1["zb"]."',zb_js='".$m1["zb_js"]."' where id='".$m["id"]."'";
$db->query($q1);
$content.="<tr bgcolor=\"#ffffff\"><td>代理:".$m["title"]."(".$m["username"].")</td>";
if(in_array("je",$arr_zb_type))
$content.="<td>".$m1["zb"]."</td>";
if(in_array("js",$arr_zb_type))
$content.="<td>".$m1["zb_js"]."</td>";
$content.="</tr>";
}
}
if(in_array("qy",$hj_type)){
//合计区域指标
$q="select * from ".$table_pre."client where face='9'";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select sum(zb) 'zb',sum(zb_js) 'zb_js' from ".$table_pre."client where path='".$m["path"]."-".$m["id"]."'");
$q1="update ".$table_pre."client set zb='".$m1["zb"]."',zb_js='".$m1["zb_js"]."' where id='".$m["id"]."'";
$db->query($q1);
$content.="<tr bgcolor=\"#ffffff\"><td>区域:".$m["title"]."(".$m["username"].")</td>";
if(in_array("je",$arr_zb_type))
$content.="<td>".$m1["zb"]."</td>";
if(in_array("js",$arr_zb_type))
$content.="<td>".$m1["zb_js"]."</td>";
$content.="</tr>";
}
}
}
$content.="</table></td></tr>";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>自动合计客户指标</title>
<style>
BODY{
font-family:宋体;FONT-SIZE:12px;margin:0px;padding:0px;
}
a,a:link,a:visited,a:active {
text-decoration:none;COLOR: #0000ff;FONT-SIZE:12px;
}
a:hover {
TEXT-DECORATION: underline;COLOR: #aaaa9f;FONT-SIZE:12px;
}
body,input,td,select,div,li,ul,textarea,form {
font-family:宋体;
FONT-SIZE:12px;
}
.wrong{
color:#ff0000;font-weight:bold;
}
</style>
</head>
<body>
<br />
<table width="80%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#cccccc">
<tr>
<td align="center" bgcolor="#f0f0f0"><b>自动合计客户指标</b></td>
</tr>
<tr>
<td align="center" bgcolor="#ffffff"><form name="form1" action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post"><input type="hidden" name="sub" value="y">
<?php echo get_main_checkbox($arr_hj_type,"hj_type",arr_to_str($hj_type)); ?><input type="submit" value="开始合计"></form></td>
</tr>
<?php echo $content; ?>
</table>
</body>
</html>