adminBoard.php
8 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
<?
include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminBase.php" ;
include $_SERVER[DOCUMENT_ROOT] . "/common/php/LoginUtil.php";
if (! class_exists("AdminBoard")){
class AdminBoard extends AdminBase{
function __construct($req)
{
parent::__construct($req);
}
function getListOfBoard(){
$boardType=$this->req["boardType"];
if($boardType == "NO"){
$sql="
SELECT COUNT(*) AS rn
FROM tblNotice
WHERE status=1
";
$this->initPage();
$this->rownum=$this->getValue($sql, 'rn');
$this->setPage($this->rownum);
$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
$sql="
SELECT N.noticeNo AS no, N.title, DATE_FORMAT(N.regDATE, '%Y%m%d') AS regDate
FROM tblNotice N
WHERE N.status=1
ORDER BY N.regDate DESC
{$limit}
";
$result=$this->getArray($sql);
return $result;
}
else if($boardType == "EV"){
$sql="
SELECT COUNT(*) AS rn
FROM tblEvent
WHERE status=1
";
$this->initPage();
$this->rownum=$this->getValue($sql, 'rn');
$this->setPage($this->rownum);
$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
$sql="
SELECT E.eventNo AS no, E.title, DATE_FORMAT(E.regDATE, '%Y%m%d') AS regDate
FROM tblEvent E
WHERE E.status=1
ORDER BY E.regDate DESC
{$limit}
";
$result=$this->getArray($sql);
return $result;
}
}
function getInfoOfBoard(){
$boardType=$this->req["boardType"];
$boardNo=$this->req["no"];
if($boardType == "NO"){
$sql="
SELECT noticeNo AS no, title, imgPathNotice1 AS imgPath1, imgPathNotice2 AS imgPath2, imgPathNotice3 AS imgPath3, imgPathNotice4 AS imgPath4, imgPathNotice5 AS imgPath5, content, regDate
FROM tblNotice
WHERE noticeNo='{$boardNo}'
";
$result=$this->getRow($sql);
//echo json_encode($result);
return $result;
}
else if($boardType == "EV"){
$sql="
SELECT eventNo AS no, title, imgPathEvent1 AS imgPath1, imgPathEvent2 AS imgPath2, imgPathEvent3 AS imgPath3, imgPathEvent4 AS imgPath4, imgPathEvent5 AS imgPath5, content, regDate
FROM tblEvent
WHERE eventNo='{$boardNo}'
";
$result=$this->getRow($sql);
return $result;
}
}
function getListOfEComment($boardNo){
$no=$this->req["no"];
if($boardNo != ""){
$sql="
SELECT C.*, U.userName
FROM tblComment C
JOIN tblUser U ON C.userFk=U.userNo
WHERE C.commentType='EV' AND C.targetFk='{$no}' AND C.status=1 AND U.status=1
ORDER BY commentGroup DESC, gOrder ASC
";
$result=$this->getArray($sql);
//echo json_encode($result);
return $result;
}
}
function saveBoard(){
$no=$this->req["no"];
$boardType=$this->req["boardType"];
$title=$this->req["title"];
$content=$this->req["content"];
$imgResult = $this->inFn_Common_fileSave($_FILES);
$imgPath1 = $imgResult["imgPath1"]["saveURL"] != "" ? $imgResult["imgPath1"]["saveURL"] : $this->req["imgPath1"];
$imgPath2 = $imgResult["imgPath2"]["saveURL"] != "" ? $imgResult["imgPath2"]["saveURL"] : $this->req["imgPath2"];
$imgPath3 = $imgResult["imgPath3"]["saveURL"] != "" ? $imgResult["imgPath3"]["saveURL"] : $this->req["imgPath3"];
$imgPath4 = $imgResult["imgPath4"]["saveURL"] != "" ? $imgResult["imgPath4"]["saveURL"] : $this->req["imgPath4"];
$imgPath5 = $imgResult["imgPath5"]["saveURL"] != "" ? $imgResult["imgPath5"]["saveURL"] : $this->req["imgPath5"];
if($no == ""){
if($boardType=="NO"){
$sql="
INSERT INTO `tblNotice`
(
`title`,
`imgPathNotice1`,
`imgPathNotice2`,
`imgPathNotice3`,
`imgPathNotice4`,
`imgPathNotice5`,
`content`,
`status`,
`regDate`
)
VALUES
(
'{$title}',
'{$imgPath1}',
'{$imgPath2}',
'{$imgPath3}',
'{$imgPath4}',
'{$imgPath5}',
'{$content}',
1,
NOW()
);
";
$this->update($sql);
return $this->makeResultJson(1, "공지사항이 저장되었습니다");
}
else if($boardType=="EV"){
$sql="
INSERT INTO `tblEvent`
(
`title`,
`imgPathEvent1`,
`imgPathEvent2`,
`imgPathEvent3`,
`imgPathEvent4`,
`imgPathEvent5`,
`content`,
`status`,
`regDate`)
VALUES
(
'{$title}',
'{$imgPath1}',
'{$imgPath2}',
'{$imgPath3}',
'{$imgPath4}',
'{$imgPath5}',
'{$content}',
1,
NOW()
);
";
$this->update($sql);
return $this->makeResultJson(1, "이벤트가 저장되었습니다");
}
}
else{
if($boardType=="NO"){
$sql="
UPDATE `tblNotice`
SET
`title` = '{$title}',
`imgPathNotice1` = '{$imgPath1}',
`imgPathNotice2` = '{$imgPath2}',
`imgPathNotice3` = '{$imgPath3}',
`imgPathNotice4` = '{$imgPath4}',
`imgPathNotice5` = '{$imgPath5}',
`content` = '{$content}'
WHERE `noticeNo` = '{$no}';
";
$this->update($sql);
return $this->makeResultJson(1, "공지사항이 수정되었습니다");
}
else if($boardType=="EV"){
$sql="
UPDATE `tblEvent`
SET
`title` = '{$title}',
`imgPathEvent1` = '{$imgPath1}',
`imgPathEvent2` = '{$imgPath2}',
`imgPathEvent3` = '{$imgPath3}',
`imgPathEvent4` = '{$imgPath4}',
`imgPathEvent5` = '{$imgPath5}',
`content` = '{$content}'
WHERE `eventNo` = '{$no}';
";
$this->update($sql);
return $this->makeResultJson(1, "이벤트가 수정되었습니다");
}
}
}
function deleteBoard(){
$noArr = $this->req["no"];
$boardType=$this->req["boardType"];
$noStr = implode(',', $noArr);
if($boardType == "NO"){
$sql = "
UPDATE tblNotice
SET status = 0
WHERE `noticeNo` IN({$noStr})
";
$this->update($sql);
}
else if($boardType=="EV"){
$sql = "
UPDATE tblEvent
SET status = 0
WHERE `eventNo` IN({$noStr})
";
$this->update($sql);
}
}
function getListOfOrganizationCert(){
$sql="
SELECT COUNT(*) AS rn
FROM tblOrganizationCert
WHERE status=1
";
$this->initPage();
$this->rownum=$this->getValue($sql, 'rn');
$this->setPage($this->rownum);
$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
$sql="
SELECT *
FROM tblOrganizationCert
WHERE status=1
ORDER BY regDate DESC
{$limit}
";
$result=$this->getArray($sql);
return $result;
}
function getInfoOfOrganizationCert(){
$certNo=$this->req["certNo"];
$sql="
SELECT *
FROM tblOrganizationCert
WHERE certNo='{$certNo}'
LIMIT 1
";
$result=$this->getRow($sql);
return $result;
}
function saveOrganizationCert(){
$name=$this->req["name"];
$imgResult = $this->inFn_Common_fileSave($_FILES);
$imgPathCert = $imgResult["imgPathCert1"]["saveURL"] != "" ? $imgResult["imgPathCert1"]["saveURL"] : $this->req["imgPathCert"];
$certNo=$this->req["certNo"];
if($certNo == ""){
$sql="
INSERT INTO tblOrganizationCert(name, imgPathCert, status, regDate)
VALUES
(
'{$name}',
'{$imgPathCert}',
1,
NOW()
)
";
$this->update($sql);
return $this->makeResultJson(1, "저장되었습니다");
}
else{
$sql="
UPDATE tblOrganizationCert
SET
name='{$name}',
imgPathCert='{$imgPathCert}'
WHERE certNo='{$certNo}'
";
$this->update($sql);
return $this->makeResultJson(1, "수정되었습니다");
}
}
function deleteCert(){
$noArr = $this->req["no"];
$noStr = implode(',', $noArr);
$sql = "
UPDATE tblOrganizationCert
SET status = 0
WHERE `certNo` IN({$noStr})
";
$this->update($sql);
}
}
}
?>