<?php
|
$UnitNameID=empty($_REQUEST['UnitNameID'])!=false ? "" : addslashes($_REQUEST['UnitNameID']);
|
|
//分页信息
|
$page=empty($_REQUEST['page'])!=false ? 1 : $_REQUEST['page'];
|
$QuantityInt = 20; //每页显示数量
|
$acc1=$page; //当前页数
|
$acc2=0; //总页数
|
$acc3=0; //总记录数
|
|
//类型列表
|
$ArrayOrdType=array();
|
$sql = "select vID,vtext from dictionary where vtitle='ServiceOrderType' order by vOrder" ;
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
$i=0;
|
while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
|
$ArrayOrdType[$rs['vID']]=$rs['vtext'];
|
$i++;
|
}
|
}
|
|
//查看各分公司报表权限
|
if (isDepartment("070109")==1) {
|
$OrdClassListSql="";
|
//$UnitNameID="1";
|
If ($UnitNameID!="" and $UnitNameID!="0") {
|
$sql="select vOrder2 from dictionary where vtitle='UnitName' and vID=".$UnitNameID;
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
if (sqlsrv_rows_affected($data)!=0) {
|
while($rs = sqlsrv_fetch_array($data) ) {
|
$UnitTypeID = $rs[0];
|
$sql="select vID,vtext,vOrder2 from dictionary where vID in (".$UnitTypeID.") and vtitle='OrderClass' order by vOrder";
|
$data1 = sqlsrv_query($conn,$sql);
|
if($data1 == true){
|
while($rs1 = sqlsrv_fetch_array($data1) ) {
|
$OrderClassID = $rs1['vOrder2'];
|
$OrdClassListSql .= ",".$OrderClassID;
|
}
|
}
|
$OrdClassListSql=substr($OrdClassListSql,1);
|
$OrdClassListSql=str_replace(",","','",$OrdClassListSql);
|
}
|
}
|
}
|
}else{
|
$sql="select vID,vtext,vOrder2 from dictionary where vType in (1,2) and vtitle='OrderClass' order by vOrder";
|
$data1 = sqlsrv_query($conn,$sql);
|
if($data1 == true){
|
while($rs1 = sqlsrv_fetch_array($data1) ) {
|
$OrderClassID = $rs1['vOrder2'];
|
$OrdClassListSql .= ",".$OrderClassID;
|
}
|
}
|
$OrdClassListSql=substr($OrdClassListSql,1);
|
$OrdClassListSql=str_replace(",","','",$OrdClassListSql);
|
}
|
}
|
|
//查询条件
|
$searchSql="";
|
$searchTXT=empty($searchTXT)!=false ? "" : $searchTXT;
|
if ($searchTXT!=""){
|
$searchSql=" and (OA_Name like '%$searchTXT%') ";
|
}else{
|
$searchSql="";
|
}
|
if ($StaffScoreID=="1") {
|
$searchSql=$searchSql." and (Guest_PointE like '%9%' or Guest_PointE like '%8%' or RV_PointE like '%9%' or RV_PointE like '%8%') ";
|
}elseif ($StaffScoreID=="2") {
|
$searchSql=$searchSql." and (Guest_PointE like '%1%' or Guest_PointE like '%2%' or RV_PointE like '%1%' or RV_PointE like '%2%') ";
|
}elseif ($StaffScoreID=="3") {
|
$searchSql=$searchSql." and (Guest_PointE='0' and RV_PointE='0' and ServiceOrdVisit<>'') ";
|
}
|
|
$orderby=empty($orderby)!=false ? "" : $orderby;
|
If (strrpos($orderby," desc")>1){
|
$orderbydesc="";
|
$descTXT="↓";
|
}else{
|
$orderbydesc=" desc";
|
$descTXT="↑";
|
}
|
|
If ($orderby=="") {
|
$orderby="OA_DepartmentID,OA_User_ID";
|
$descTXT="↓";
|
}
|
|
if ($OrdDateType=="0" and $OrdDateStart=="" and $OrdDateEnd=="") {$OrdDateType=4;}
|
|
|
$SqlOrdDateType=empty($SqlOrdDateType)!=false ? "" : $SqlOrdDateType;
|
$OAOccupationSQL=empty($OAOccupation)!=false ? "" : " and EntourageID in (".$OAOccupation.") ";
|
$StaffScoreSum=0;
|
$StaffScoreSum_Bad=0;
|
$StaffScoreSum_Other=0;
|
//条件查询
|
$ListSql="";
|
$OtherFormArray=array();
|
$OtherArray=array();
|
$sql="select vId,vtext from dictionary where vType=1 and vtitle='VisitDict' order by vOrder";
|
//echo $sql;exit;
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
|
$vId = $rs['vId'];
|
$vtext = $rs['vtext'];
|
array_push($OtherFormArray,"other".$vId);
|
array_push($OtherArray,$vtext);
|
$ListSql=$ListSql.",(select COUNT(ServiceOrdID) from ServiceOrder as b where b.ServiceOrdVisit_Dict= '".$vtext."' and a.ServiceOrdVisit_ID=b.ServiceOrdVisit_ID and b.ServiceOrdVisit_time ".$SqlOrdDateType.") other".$vId;
|
}
|
}
|
|
//查询开始
|
$sql="select OA_Name,ServiceOrdVisit_ID,COUNT(ServiceOrdID) VisitSum,
|
( select COUNT(*) from (select b.ServiceOrdID VisitSum from ServiceOrder b,DispatchOrd_Entourage,DispatchOrd where a.ServiceOrdVisit_ID=b.ServiceOrdVisit_ID and EntourageState<>4 and DispatchOrdIDDt=DispatchOrdID and b.ServiceOrdID=ServiceOrdIDDt and DispatchOrdState not in (10,9) and (RV_PointE like '%1%' or RV_PointE like '%2%') and b.ServiceOrdVisit_time ".$SqlOrdDateType." GROUP BY b.ServiceOrdID) as bb) dissatisfied".$ListSql."
|
from ServiceOrder as a left join OA_User on ServiceOrdVisit_ID=OA_User_ID
|
where ServiceOrdVisit<>'' and ServiceOrdVisit_time ".$SqlOrdDateType."
|
GROUP BY OA_Name,ServiceOrdVisit_ID order by COUNT(ServiceOrdID) desc";
|
//echo $sql;exit;
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
$FormArray=array();
|
//表头
|
$FormArray[0]=array("回访客服","总回访数量","满意任务数量","不满意任务数量");
|
$FormArray[0]=array_merge($FormArray[0],$OtherArray);
|
|
$FormArrayX=count($FormArray[0]);
|
if (sqlsrv_rows_affected($data)==0) {
|
$SystemMessageType=2;
|
$SystemMessageTXT="数据库中相关无数据!";
|
$y=0;
|
} else {
|
$i=1;
|
while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
|
//读取数据
|
$OA_Name = $rs['OA_Name'];
|
$ServiceOrdVisit_ID = $rs['ServiceOrdVisit_ID'];
|
$VisitSum = $rs['VisitSum'];
|
$dissatisfied = $rs['dissatisfied'];
|
|
//读取数据--End
|
|
//写入数组
|
$FormArray[$i][0]=$OA_Name;
|
$FormArray[$i][1]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore2|总量|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$VisitSum."</a>";
|
$FormArray[$i][2]=$VisitSum-$dissatisfied;
|
$FormArray[$i][3]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore3|".$FormArray[0][3]."|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$dissatisfied."</a>";
|
$OtherInt=0;
|
foreach($OtherFormArray as $value){
|
$OtherInt++;
|
$FormArray[$i][3+$OtherInt]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore1|".$FormArray[0][3+$OtherInt]."|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$rs[$value]."</a>";
|
$FormArray[$i][2]=$FormArray[$i][2]-$rs[$value];
|
}
|
$FormArray[$i][2]="<a href='/Report_StaffScoreUserList.php?searchTXT=StaffScore0|满意|".$ServiceOrdVisit_ID."&OrdDateType=".$OrdDateType."&h_menu1_1=1' target='_blank'>".$FormArray[$i][2]."</a>";
|
$i++;
|
|
}
|
|
|
}
|
}
|
|
if ($is_CSV==2) {
|
echo json_encode($FormArray);
|
}
|
//echo print_r($FormArray);
|
//exit;
|
?>
|