【调度系统】广东民航医疗快线调度系统源代码
克樊道人
2024-12-02 61ce8cc6883e5f94e6470141df3484167caf31ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
//分页信息
$page=empty($_REQUEST['page'])!=false ? 1 : $_REQUEST['page'];
$QuantityInt = 20;    //每页显示数量
$acc1=$page;        //当前页数
$acc2=0;            //总页数
$acc3=0;            //总记录数
 
//查询条件
$searchSql="";
/*
$searchTXT=empty($searchTXT)!=false ? "" : $searchTXT;
if ($searchTXT!=""){
    $searchSql=" and (OA_Name like '%$searchTXT%') ";
}else{
    $searchSql="";
}
*/
if (!empty($OrdAreaTypeID)) {
    $searchSql=$searchSql." and ServiceOrdAreaType=".$OrdAreaTypeID;
}
if (!empty($OrdTypeID)) {
     $searchSql=$searchSql." and ServiceOrdType=".$OrdTypeID;
}
 
 
//$OrdClassListSql="";
//查看各分公司报表权限
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);
    }
}
 
$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="↓";
}
 
//查询开始
$SqlOrdDateType=empty($SqlOrdDateType)!=false ? "" : $SqlOrdDateType;
$OrdClassType=empty($OrdClassType)!=false ? "1" : $OrdClassType;
 
$sql="select UserID,UserName,UserPhone,
    PointsSpent=(select isnull(sum(Points_Score),0) from UserPoints
            where Points_State=1 and ToUserID=UserID and Points_Score<0
            and Points_Time ".$SqlOrdDateType."),
    PointsIncome=(select isnull(sum(Points_Score),0) from UserPoints
            where Points_State=1 and ToUserID=UserID and Points_Score>0
            and Points_Time ".$SqlOrdDateType.")
    from UserData where 
    UserID in (select ToUserID from UserPoints where Points_State=1 and Points_Time ".$SqlOrdDateType.")";
//echo $sql;exit;
$data = sqlsrv_query($conn,$sql);
if($data == true){
    $FormArray=array();
    //表头
    $FormArray[0]=array("序号","客户手机","积分支出汇总","积分收入汇总","积分累计");
    $FormArrayX=count($FormArray[0]);
    if (sqlsrv_rows_affected($data)==0) {
        $SystemMessageType=2;
        $SystemMessageTXT="数据库中相关无数据!";
        $y=0;
    } else {
        $y=0;
        $i=0;
        while($rs = sqlsrv_fetch_array( $data, SQLSRV_FETCH_ASSOC) ) {
            //读取数据
            $UserID            = $rs['UserID'];
            $UserPhone        = $rs['UserPhone'];
            $PointsSpent        = intval($rs['PointsSpent']);
            $PointsIncome    = intval($rs['PointsIncome']);
            //读取数据--End
            
            //写入数组
            $i++;
            $FormArray[$i][0]=$i;
            $FormArray[$i][1]="<a href='/Report_PointsUser.php?searchTXT=&orderby=&UnitNameID=&StaffScoreID=0&OrdDateType=$OrdDateType&UserPhone=$UserPhone'>$UserPhone</a>";
            $FormArray[$i][2]=$PointsSpent;
            $FormArray[$i][3]=$PointsIncome;
            $FormArray[$i][4]=$PointsIncome+$PointsSpent;
            
            
            //写入数组--End
        }
 
    }
}
 
//echo print_r($FormArray);
//exit;
?>