AdminPush.php
5.76 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminBase.php" ;?>
<?
/*
* Admin process
* add by dev.lee
* */
if(!class_exists("AdminPush")){
class AdminPush extends AdminBase {
function __construct($req)
{
parent::__construct($req);
}
function sendPushForAnswer()
{
$user_fk = $this->req["user_fk"] ;
$push_msg = "문의에 대한 답변이 달렸습니다." ;
$push_code = $this->getBulkPushCode();
$sql = "
INSERT INTO tbl_push_target_bulk(push_code, registration_key, device_type_id, app_type)
(
SELECT '{$push_code}', registration_key, device_type_id, app_type
FROM tbl_user U
WHERE U.no='{$user_fk}' AND U.status = 'Y' AND U.registration_key != '' AND is_push = 1 AND comm_push = 1
LIMIT 0, 1
)
";
$push_count = $this->update($sql);
// 푸시 전송
$params = Array(
"push_code" => $push_code,
"push_msg" => $push_msg,
"push_type" => $this->PUSH_TYPE_ADMIN
);
$this->sendPushBulk($params);
return $this->makeResultJson(1, "전송되었습니다.");
}
function sendPushForBillSend()
{
$room_fk = $this->req["room_fk"] ;
$push_msg = "청구서가 도착했습니다." ;
$push_code = $this->getBulkPushCode();
$sql="
SELECT user_fk
FROM tbl_room
WHERE no='{$room_fk}'
";
$result=$this->getRow($sql);
$user_fk=$result["user_fk"];
$sql = "
INSERT INTO tbl_push_target_bulk(push_code, registration_key, device_type_id, app_type)
(
SELECT '{$push_code}', registration_key, device_type_id, app_type
FROM tbl_user U
WHERE U.no='{$user_fk}' AND U.status = 'Y' AND U.registration_key != '' AND is_push = 1
LIMIT 0, 1
)";
$push_count = $this->update($sql);
// 푸시 전송
$params = Array(
"push_code" => $push_code,
"push_msg" => $push_msg,
"push_type" => $this->PUSH_TYPE_ADMIN
);
$this->sendPushBulk($params);
return $this->makeResultJson(1, "전송되었습니다.");
}
function sendPushForChargeSend()
{
$building_name = $this->req["building_name"] ;
$room_name = $this->req["room_name"];
$push_msg = "청구서가 도착했습니다." ;
$push_code = $this->getBulkPushCode();
$sql="
SELECT vip_fk
FROM tbl_building AS `B`
JOIN tbl_room AS `R` ON `B`.no = `R`.building_fk
WHERE `R`.name='{$room_name}' AND `B`.name='{$building_name}'
";
$result=$this->getRow($sql);
$vip_fk=$result["vip_fk"];
$sql = "
INSERT INTO tbl_push_target_bulk(push_code, registration_key, device_type_id, app_type)
(
SELECT '{$push_code}', registration_key, device_type_id, app_type
FROM tbl_user U
WHERE U.no='{$vip_fk}' AND U.status = 'Y' AND U.registration_key != '' AND is_push = 1
LIMIT 0, 1
)
";
$push_count = $this->update($sql);
// 푸시 전송
$params = Array(
"push_code" => $push_code,
"push_msg" => $push_msg,
"push_type" => $this->PUSH_TYPE_ADMIN
);
$this->sendPushBulk($params);
return $this->makeResultJson(1, "전송되었습니다.");
}
function sendAdminPush()
{
$push_msg = $this->req["push_msg"];
$group_no = $this->req["group_no"];
$push_target_type = $this->req["push_target_type"];
$push_code = $this->getBulkPushCode();
$push_succeed=0;
if($push_target_type == "1"){
$sql = "
INSERT INTO tbl_push_target_bulk(push_code, registration_key, device_type_id, app_type)
(
SELECT '{$push_code}', registration_key, device_type_id, app_type
FROM tbl_user U
WHERE U.status = 'Y' AND U.registration_key != '' AND is_push = 1
)
";
$push_count = $this->update($sql);
$sql="SELECT count(*) as rn
FROM tbl_user U
WHERE U.status = 'Y' AND U.registration_key != '' AND is_push = 1";
$result=$this->getRow($sql);
$push_succeed = $result["rn"];
}
else
{
$sql = "
INSERT INTO tbl_push_target_bulk(push_code, registration_key, device_type_id, app_type)
(
SELECT '{$push_code}', registration_key, device_type_id, app_type
FROM tbl_user U
WHERE U.group_fk = '{$group_no}' AND U.status = 'Y' AND U.registration_key != '' AND is_push = 1
)
";
$push_count = $this->update($sql);
$sql="SELECT count(*) as rn
FROM tbl_user U
WHERE U.status = 'Y' AND U.registration_key != '' AND is_push = 1";
$result=$this->getRow($sql);
$push_succeed = $result["rn"];
}
$sql = "
INSERT INTO tbl_push_log(push_target_type, group_fk, push_msg, push_count, push_dt)
VALUES('{$push_target_type}', '{$group_no}', '{$push_msg}', '{$push_succeed}', NOW())
";
$this->update($sql);
$push_msg = $this->req["push_msg"];
$group_no = $this->req["group_no"];
$push_target_type = $this->req["push_target_type"];
// 푸시 전송
$params = Array(
"push_code" => $push_code,
"push_msg" => $push_msg,
"push_type" => $this->PUSH_TYPE_ADMIN
);
$this->sendPushBulk($params);
return $this->makeResultJson(1, "전송되었습니다.");
}
// 푸시키 코드 조회
function getBulkPushCode()
{
$microTime = microtime();
$timeArr = explode(" ", $microTime);
$code = str_replace(".", "", ($timeArr[1] . ($timeArr[0]*1E8)));
return $code;
}
function getListOfAdminPush()
{
//최초 페이지 설정
$this->initPage();
$sql = "
SELECT COUNT(*) AS rn
FROM tbl_push_log
{$where}
";
$this->rownum = $this->getValue($sql, 'rn');
//총 로우수를 획득후 페이지 최종 설정
$this->setPage($this->rownum);
$sql = "
SELECT
*
FROM tbl_push_log
ORDER BY no DESC
LIMIT {$this->startNum}, {$this->endNum} ;
";
$result = $this->getArray($sql);
return $result;
}
} // class end
}
?>