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

293 lines
9.6 KiB
PHP

<?php
//-------------------------------
header("Content-type: text/html; charset=utf-8");
if(THIS_IN!="edt_admin")
exit("错误的访问!");
//-------------------------------execute action
$db=_mysql_connect();
$msg_login_user=get_db_msg("select * from ".$table_pre."user where id='".$uid."'");
//权限判断
$priv=return_priv($_m,$msg_login_user["priv"]);
$arr_report=array("gl"=>"评价概览报表","detail"=>"评价明细");
$_a=$_a?$_a:"gl";
//
//取得选项
$arr_select_no=array();
$arr_select_title=array();
$q="select no,title from ".$table_pre."keyword where cate='arr_select' and flag_ka='y' and no<>'jgd' and no<>'sx' order by ord";
$r=$db->query($q);
while($m=$db->fetch_array($r)){
$arr_select_no[]=$m["no"];
$arr_select_title[]=$m["title"];
}
//可选择字段
$arr_zd=array(
"xh"=>"序号",
"price"=>"价格",
"title"=>"款式名"
);
for($i=0;$i<count($arr_select_no);$i++){
$arr_zd[$arr_select_no[$i]]=$arr_select_title[$i];
}
//
$json_data="{";
if($priv[0]=="n"){
//没有操作权限
$json_data.="\"error\":\"没有操作权限\",\"code\":0,\"msg\":\"\",\"count\":0,\"data\":[],";
}else{
$json_data.="\"uid\":".$uid.",";
$json_data.="\"s_a\":\"".$_a."\",";
$str_tab="";
foreach($arr_report as $k1=>$v1){
$str_tab.="{\"_a\":\"".$k1."\",\"title\":\"".$v1."\"},";
}
$str_tab=deel_end($str_tab);
$json_data.="\"tab\":[".$str_tab."],";
switch($_a){
//----------------------------------------------------------------------导出数据
case "export":
$column="";
foreach($arr_zd as $k => $v){
$column.="{\"k\":\"".$k."\",\"t\":\"".$v."\"},";
}
if($column)
$column=substr($column,0,-1);
$json_data.="\"col\":[".$column."],";
break;
case "export_do":
//取得字段选择的值
foreach($arr_zd as $k => $v){
$var="col_".$k;
if($$var=="on"){
$ex_col[]=$k;
}
}
$num=count($ex_col);
if($num==0)
alert_and_back("请至少选择一个要导出的字段");
$data["header"][0][]="区域";
$data["col"][]='str';
$data["header"][0][]="代理";
$data["col"][]='str';
$data["header"][0][]="客户名称";
$data["col"][]='str';
$data["header"][0][]="客户代码";
$data["col"][]='str';
$data["header"][0][]="款号";
$data["col"][]='str';
for($i=0;$i<$num;$i++){
$data["col"][]='str';
$data["header"][0][]=get_main_value($arr_zd,$ex_col[$i]);
}
$data["header"][0][]="星级";
$data["col"][]='str';
$data["header"][0][]="文字";
$data["col"][]='str';
$data["header"][0][]="评价时间";
$data["col"][]='str';
$query="select * from ".$table_pre."client_pj ";
$r=$db->query($query);
$row=0;
while($m=$db->fetch_array($r)){
$m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["khid"]."'");
$m2=get_db_msg("select title,username,path from ".$table_pre."client where id='".$m["cid"]."'");
$m_dl=get_db_msg("select title from ".$table_pre."client where id='".get_dl_id($m2["path"])."'");
$m_qy=get_db_msg("select title from ".$table_pre."client where id='".get_qy_id($m2["path"])."'");
$data["body"][$row][]=$m_qy["title"];
$data["body"][$row][]=$m_dl["title"];
$data["body"][$row][]=$m2["title"];
$data["body"][$row][]=$m2["username"];
$data["body"][$row][]=$m1["no"];
for($i=0;$i<$num;$i++){
$k=$ex_col[$i];
if($k=="xh" || $k=="title" || $k=="price"){
$data["body"][$row][]=$m1[$k];
}else{
$data["body"][$row][]=get_cate_title_no($k,$m1[$k]);
}
}
$data["body"][$row][]=$m["race"];
$data["body"][$row][]=$m["remark"];
$data["body"][$row][]=date("Y-m-d H:i:s",$m["add_date"]);
$row++;
}
$file_name="pj_".date("Y-m-d-H-i");
output_excel($file_name,$data);
set_log("导出 评价信息");
exit;
break;
//删除
case "del" :
$id=(is_array($id))?$id:array($id);
$num=count($id);
for($i=0;$i<$num;$i++){
$tmp=get_db_msg("select * from ".$table_pre."client_pj where id='".$id[$i]."'");
//
$db->query("delete from ".$table_pre."client_pj where id='".$id[$i]."'");
$lid.=$id[$i].", ";
}
$lid=substr($lid,0,-2);
set_log("删除评价",$lid);
$json_data.="\"code\":1,";
break;
case "detail":
$json_data.="\"s_client\":\"".$s_client."\",";
$json_data.="\"s_no\":\"".$s_no."\",";
$json_data.="\"s_xh\":\"".$s_xh."\",";
//
$page=$page>0?$page:1;
$limit=$limit>0?$limit:10;
$start=($page-1)*$limit;
$end=$limit;
$sql_con="";
if($s_no)
$sql_con.=" and b.no like '%".$s_no."%'";
if($s_xh)
$sql_con.=" and b.xh='".$s_xh."'";
if($s_client){
$tmp=get_db_msg("select id from ".$table_pre."client where username='".$s_client."'");
$sql_con.=" and a.cid='".$tmp["id"]."'";
}
//取得总条数
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client_pj a,".$table_pre."kh b where a.khid=b.id ".$sql_con);
$total_num=$tmp["num"];
$json_data.="\"code\":0,\"msg\":\"\",\"count\":\"".$total_num."\",\"data\":[";
$query="select a.id 'id',a.cid 'uid',a.race 'race',a.remark 'remark',a.add_date 'add_date',b.no 'no',b.xh 'xh' from ".$table_pre."client_pj a,".$table_pre."kh b where a.khid=b.id ".$sql_con."order by a.add_date desc limit ".$start.",".$end;
$res=$db->query($query);
$count=1;
while($msg=$db->fetch_array($res)){
$list=$count+$start;
$tmp=get_db_msg("select * from ".$table_pre."client where id='".$msg["uid"]."'");
$str_tmp.="{";
$str_tmp.="\"id\":\"".$msg["id"]."\",";
$str_tmp.="\"ct\":\"".$list."\",";
$str_tmp.="\"kh\":\"".$msg["no"]."\",";
$str_tmp.="\"xh\":\"".$msg["xh"]."\",";
$str_tmp.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
$str_tmp.="\"xj\":\"".$msg["race"]."\",";
$str_tmp.="\"remark\":\"".dhtmlchars($msg["remark"])."\",";
$str_tmp.="\"pjtime\":\"".date("Y-m-d H:i",$msg["add_date"])."\"";
$str_tmp.="},";
$count++;
}
$json_data.=substr($str_tmp,0,-1)."],";
break;
case "gl":
$sql_con="";
if($s_no){
$sql_con.=" where khid in (select id from ".$table_pre."kh where no like '%".$s_no."%')";
}
$arrzd=explode(",",$s_zd);
$th_zd="";
foreach($arr_zd as $k1 => $v1){
if(in_array($k1,$arrzd)){
$sign="y";
}else{
$sign="n";
}
$th_zd.="{\"no\":\"".$k1."\",\"title\":\"".$v1."\",\"sign\":\"".$sign."\"},";
}
$json_data.="\"th_zd\":[".substr($th_zd,0,-1)."],";
//取得总条数
$tmp=get_db_msg("select count(distinct khid) 'num' from ".$table_pre."client_pj ".$sql_con);
$total_num=$tmp["num"];
$json_data.="\"s_no\":\"".$s_no."\",";
$json_data.="\"code\":0,\"msg\":\"\",\"count\":\"".$total_num."\",\"data\":[";
$str_tmp="";
$query="select khid,sum(race) 'num_race',sum(case when race>0 then 1 else 0 end) 'num_client',sum(race)/sum(case when race>0 then 1 else 0 end) 'num_pj',sum(case when race=5 then 1 else 0 end) 'num_5',sum(case when race=4 then 1 else 0 end) 'num_4',sum(case when race=3 then 1 else 0 end) 'num_3',sum(case when race=2 then 1 else 0 end) 'num_2',sum(case when race=1 then 1 else 0 end) 'num_1' from ".$table_pre."client_pj ".$sql_con." group by khid order by num_pj desc";
$res=$db->query($query);
$count=1;
while($m=$db->fetch_array($res)){
$m1=get_db_msg("select * from ".$table_pre."kh where id='".$m["khid"]."'");
$str_tmp.="{";
$str_tmp.="\"ct\":\"".$count."\",";
$str_tmp.="\"khid\":\"".$m["khid"]."\",";
foreach($arr_zd as $k1 => $v1){
if($k1=="title" || $k1=="price" || $k1=="xh"){
$str_tmp.="\"".$k1."\":\"".deel_td($m1[$k1])."\",";
}else{
$str_tmp.="\"".$k1."\":\"".deel_td(get_cate_title_no($k1,$m1[$k1]))."\",";
}
}
$str_tmp.="\"kh\":\"".$m1["no"]."\",";
$str_tmp.="\"pjf\":\"".keep_float($m["num_pj"],1)."\",";
$str_tmp.="\"zf\":\"".$m["num_race"]."\",";
$str_tmp.="\"zkhs\":\"".$m["num_client"]."\",";
$str_tmp.="\"fs5\":\"".$m["num_5"]."\",";
$str_tmp.="\"fs4\":\"".$m["num_4"]."\",";
$str_tmp.="\"fs3\":\"".$m["num_3"]."\",";
$str_tmp.="\"fs2\":\"".$m["num_2"]."\",";
$str_tmp.="\"fs1\":\"".$m["num_1"]."\"";
$str_tmp.="},";
$count++;
}
$json_data.=substr($str_tmp,0,-1)."],";
break;
case "openDetail":
$msg=get_db_msg("select * from ".$table_pre."kh where id='".$id."'");
$pic=get_kh_picture($msg["no"],$msg["main_pic"],$msg["color"]);
$pic_big=get_kh_picture_big($msg["no"],$msg["main_pic"],$msg["color"]);
$arr_pic_set=out_good_pic_set_arr($pic,200,200);
$json_data.="\"pic\":\"".$pic."\",\"picbig\":\"".$pic_big."\",\"pic_w\":\"".$arr_pic_set[0]."\",\"pic_h\":\"".$arr_pic_set[1]."\",";
//取得总条数
$tmp=get_db_msg("select count(*) 'num' from ".$table_pre."client_pj where khid='".$id."'");
$total_num=$tmp["num"];
$json_data.="\"code\":0,\"msg\":\"\",\"count\":\"".$total_num."\",\"data\":[";
$query="select * from ".$table_pre."client_pj where khid='".$id."' order by add_date";
$res=$db->query($query);
$i=1;
$str_tmp="";
$tal=0;
while($m=$db->fetch_array($res)){
$tmp=get_db_msg("select * from ".$table_pre."client where id='".$m["cid"]."'");
$str_tmp.="{";
$str_tmp.="\"ct\":\"".$i."\",";
$str_tmp.="\"client\":\"".$tmp["title"]."(".$tmp["username"].")\",";
$str_tmp.="\"xj\":\"".$m["race"]."\",";
$str_tmp.="\"wz\":\"".dhtmlchars($m["remark"])."\",";
$str_tmp.="\"pjtime\":\"".date("d日 H点i分",$m["add_date"])."\"";
$str_tmp.="},";
$i++;
$tal+=$m["race"];
}
$str_tmp.="{";
$str_tmp.="\"ct\":\"\",";
$str_tmp.="\"client\":\"合计\",";
$str_tmp.="\"xj\":\"".$tal."\",";
$str_tmp.="\"wz\":\"\",";
$str_tmp.="\"pjtime\":\"\"";
$str_tmp.="},";
$json_data.=substr($str_tmp,0,-1)."],";
break;
}
}
$json_data=substr($json_data,0,-1)."}";
echo $json_data;
?>