ApiBoard.php
16.9 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/ApiBase.php" ;?>
<?
if (! class_exists("ApiBoard"))
{
class ApiBoard extends ApiBase
{
function __construct($req)
{
parent::__construct($req);
}
//공지사항 리스트
function getListOfNotice(){
$sql="
SELECT *
FROM tblNotice
ORDER BY noticeNo DESC
";
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//공지사항 정보
function getInfoOfNotice(){
$noticeNo=$this->req["no"];
$sql="
SELECT *
FROM tblNotice
WHERE noticeNo='{$noticeNo}'
";
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//이벤트 리스트
function getListOfEvent(){
$sql="
SELECT *
FROM tblEvent
ORDER BY eventNo DESC
";
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//이벤트 정보
function getInfoOfEvent(){
$eventNo=$this->req["no"];
$sql="
SELECT *
FROM tblEvent
WHERE eventNo='{$eventNo}'
";
$result=$this->getArray($sql);
return $this->makeResultJson("1", "", $result);
}
//자유게시판 게시물 작성
function saveBoard(){
$title=$this->req["title"];
$userFk = $this->appUser["no"];
$imgPathBoard1=$this->req["imgPathBoard1"];
$imgPathBoard2=$this->req["imgPathBoard2"];
$imgPathBoard3=$this->req["imgPathBoard3"];
$content=$this->req["content"];
$sql="
INSERT INTO tblBoard(userFk, title, imgPathBoard1, imgPathBoard2, imgPathBoard3, content, status, regDate)
VALUES
(
'{$userFk}',,
'{$title}',
'{$imgPathBoard1}',
'{$imgPathBoard2}',
'{$imgPathBoard3}',
'{$content}',
1,
NOW()
)
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
//자유게시판 리스트
function getListOfBoard(){
$searchText=$this->req["searchText"];
$searchType=$this->req["searchType"];
$where="WHERE B.status=1";
if(!empty($searchText)){
if(empty($search_type)){
$where.=" AND (U.userID LIKE '%{$searchText}%' OR B.title LIKE '%{$searchText}%')";
}
else if($searchType=="작성자"){
$where.=" AND U.userID LIKE '%{$searchText}%'";
}
else if($searchType=="제목"){
$where.=" AND B.title LIKE '%{$searchText}%'";
}
}
$sql="
SELECT COUNT(*)
FROM tblBoard B
JOIN tblUser U ON B.userFk=U.userNo
{$where}
ORDER BY boardNo DESC
";
$this->rownum = $this->getValue($sql, "rn");
$this->initPage();
$this->setPageForDevice($this->rownum);
$sql="
SELECT B.*, U.userID, U.userNo
FROM tblBoard B
JOIN tblUser U ON B.userFk=U.userNo
{$where}
ORDER BY boardNo DESC
LIMIT {$this->startNum}, {$this->endNum}
";
$list=$this->getArray($sql);
if (sizeof($list) > 0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
//게시물 정보
function getInfoOfBoard(){
//$boardNo = $this->req["no"];
$boardNo=1;
$sql="
SELECT *
FROM tblBoard
WHERE boardNo='{$boardNo}' AND status=1
LIMIT 1
";
$result=$this->getRow($sql);
if($result != null){
$sql="
SELECT C.*, U.userID, U.userNo
FROM tblComment C
JOIN tblUser U ON C.userFk=U.userNo
WHERE targetFk='{$boardNo}' AND commentType='FB'
ORDER BY C.commentGroup ASC, C.gOrder ASC
";
$commentList=$this->getArray($sql);
return $this->makeResultJson("1", "", $result, Array(
"commentList" => $commentList
));
}
else{
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
}
//고객센터 게시물 저장
function saveCS(){
$title=$this->req["title"];
$userFk = $this->appUser["no"];
$targetType=$this->req["targetType"];
$imgPathCS1=$this->req["imgPathCS1"];
$imgPathCS2=$this->req["imgPathCS2"];
$imgPathCS3=$this->req["imgPathCS3"];
$content=$this->req["content"];
$sql="
INSERT INTO tblCustomerService(userFk, title, targetType, imgPathCS1, imgPathCS2, imgPathCS3, content, status, regDate)
VALUES
(
'{$userFk}',
'{$title}',
'{$targetType}',
'{$imgPathCS1}',
'{$imgPathCS2}',
'{$imgPathCS3}',
'{$content}',
1,
NOW()
)
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
//고객센터 게시물 리스트
function getListOfCS(){
$searchText=$this->req["searchText"];
$searchType=$this->req["searchType"];
$where="status=1 AND targetType = 1";
if(!empty($searchText)){
if(empty($search_type)){
$where.=" AND (U.userID LIKE '%{$searchText}%' OR CS.title LIKE '%{$searchText}%')";
}
else if($searchType=="작성자"){
$where.=" AND U.userID LIKE '%{$searchText}%'";
}
else if($searchType=="제목"){
$where.=" AND CS.title LIKE '%{$searchText}%'";
}
}
$sql="
SELECT COUNT(*)
FROM tblCustomerService CS
JOIN tblUser U ON CS.userFk=U.no
WHERE status=1
ORDER BY csNo DESC
";
$this->rownum = $this->getValue($sql, "rn");
$this->setPageForDevice($this->rownum);
$sql="
SELECT CS.*, U.userID, U.userNo
FORM tblCustomerService CS
JOIN tblUser U ON CS.userFk=U.no
WHERE status=1
ORDER BY csNo DESC
LIMIT {$this->startNum}, {$this->endNum}
";
$list=$this->getArray($sql);
if(sizeof($list)>0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("1000", "내역이 없습니다.");
}
//고객센터 게시물 내용
function getInfoOfCS(){
$csNo=$this->req["no"];
$sql="
SELECT *
FROM tblCustomerService
WHERE csNo='{$csNo}' AND status=1
LIMIT 1
";
$result=$this->getRow($sql);
if($result != null){
$sql="
SELECT U.userNo, U.userID, C.*
FROM tblComment C
JOIN tblUser U ON C.userFk=U.userNo
WHERE targetFk='{$csNo}' AND commentType='CS'
ORDER BY C.commentGroup ASC, C.gOrder ASC
";
$commentList=$this->getArray($sql);
return $this->makeResultJson("1", "", $result, Array(
"commentList" => $commentList
));
}
else{
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
}
//AS엄체 리스트
function getListOfCompany(){
$provinceNumber=$this->req["provinceNumber"];
$cityNumber=$this->req["cityNumber"];
$searchText=$this->req["searchText"];
$where="status=1";
if(!empty($provinceNumber)){
$where.=" AND address LIKE (SELECT abbreviation FROM tblZipProvince WHERE provinceNumber='{$provinceNumber}')";
}
$sql="
SELECT COUNT(*)
FROM tblCompany
{$where}
ORDER BY companyNo DESC
";
$this->rownum=$this->getValue($sql, "rn");
$this->setPageForDevice($this->rownum);
$sql="
SELECT companyNo, name, telephone
FROM tblCompany
{$where}
ORDER BY companyNo DESC
LIMIT {$this->startNum}, {$this->endNum}
";
$list=$this->getArray($sql);
if(sizeof($list)>0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
//AS업체 상세
function getInfoOfCompany(){
$companyNo=$this->req["no"];
$sql="
SELECT *
FROM tblCompany
WHERE companyNo='{$companyNo}' AND status=1
LIMIT 1
";
$result=$this->getRow($sql);
if($result != null){
$sql="
SELECT U.userNo, U.userID, C.*
FROM tblComment C
JOIN tblUser U ON C.userFk=U.userNo
WHERE targetFk='{$companyNo}' AND commentType='CP'
ORDER BY C.ommentGroup ASC, C.gOrder ASC
";
$commentList=$this->getArray($sql);
return $this->makeResultJson("1", "", $result, Array(
"commentList" => $commentList
));
}
else{
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
}
//댓글 저장
function saveComment(){
$commentType=$this->req["commentType"];
$targetFk=$this->req["targetFk"];
//$userFk = $this->appUser["no"];;
$userFk=$this->req["userFk"];
$content=$this->req["content"];
$parentNo=$this->req["parentNo"]; //부모 댓글의 기본키
if(empty($parentNo)){ //부모가 없을 때
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
(
'{$userFk}',
'{$targetFk}',
0,
1,
1,
'{$content}',
'{$commentType}',
1,
NOW()
)
";
$this->update($sql);
$currentNo=$this->mysql_insert_id();
$sql="
UPDATE tblComment
SET commentGroup='{$currentNo}'
WHERE commentNo='{$currentNo}'
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
else{ //부모 있을 때
$sql="
SELECT *
FROM tblComment
WHERE commentType='{$commentType}'
AND commentGroup=(SELECT commentGroup FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND gOrder=(SELECT gOrder + 1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
AND depth=(SELECT depth+1 FROM tblComment WHERE commentType='{$commentType}' AND commentNo='{$parentNo}' AND status=1)
ORDER BY gOrder DESC
LIMIT 0, 1
";
$child=$this->getRow($sql);
$childNo=$child["commentNo"];
$childGroup=$child["commentGroup"];
$childOrder=$child["gOrder"];
$childDepth=$child["depth"];
if(!empty($childNo)){ //부모에게 자식이 있을 때
echo "child exists";
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
(
'{$userFk}',
'{$targetFk}',
'{$childGroup}',
'{$childOrder}' + 1,
'{$childDepth}',
'{$content}',
'{$commentType}',
1,
NOW()
)
";
$this->update($sql);
$sql="
UPDATE tblComment
SET gOrder=gOrder+1
WHERE commentGroup='{$childGroup}' AND gOrder > '{$childOrder}' + 1 AND status=1
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
else{ //부모에게 자식이 없을 때
echo "no child";
$sql="
INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
VALUES
(
'{$userFk}',
'{$targetFk}',
(SELECT commentGroup FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT gOrder + 1 FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1),
(SELECT depth + 1 FROM (SELECT * FROM tblComment) AS tblComment WHERE commentNo='{$parentNo}' AND status=1),
'{$content}',
'{$commentType}',
1,
NOW()
)
";
$this->update($sql);
$currentNo=$this->mysql_insert_id();
$sql="SELECT commentGroup FROM tblComment WHERE commentNo='{$parentNo}' AND status=1";
$commentGroup=$this->getValue($sql, "commentGroup");
$sql="SELECT gOrder + 1 FROM tblComment WHERE commentNo='{$parentNo}' AND status=1";
$gOrder=$this->getValue($sql, "gOrder + 1");
$sql="
UPDATE tblComment
SET gOrder=gOrder+1
WHERE commentGroup='{$commentGroup}' AND gOrder >= '{$gOrder}' AND commentNo <> '{$currentNo}' AND status=1
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
}
}
//제작사양서 저장
function saveProductionSpec(){
$userFk = $this->appUser["no"];
$requestDate=$this->req["requestDate"];
$companyName=$this->req["companyName"];
$vehicleTON=$this->req["vehicleTON"];
$vehicleText=$this->req["vehicleText"];
$vehicleType=$this->req["vehicleType"];
$productName=$thie->req["productName"];
$telephone=$this->req["telephone"];
$managerFk=$this->req["managerFk"];
$type=$this->req["type"];
$internalLength=$this->req["internalLength"];
$internalHeight=$this->req["internalHeight"];
$internalWidth=$this->req["internalWidth"];
$alCoil=$this->req["alCoil"];
$floor=$this->req["floor"];
$floorValue=$this->req["floorValue"];
$tent=$this->req["tent"];
$sideBoard=$this->req["sideBoard"];
$windStopper=$this->req["windStopper"];
$freezer=$this->req["freezer"];
$gate=$this->req["gate"];
$load=$this->req["load"];
$eTrackGate=$this->req["eTrackGate"];
$eTrackWing=$this->req["eTrackWing"];
$turnBuckle=$this->req["turnBuckle"];
$toolBucket=$this->req["toolBucket"];
$bumperFootHold=$this->req["bumperFootHold"];
$wingProtector=$this->req["wingProtector"];
$axis=$this->req["axis"];
$axisValue=$this->req["axisValue"];
$specialAddition=$this->req["specialAddition"];
$sql="
INSERT INTO tblProductionSpec(userFk, requestDate, companyName, vehicleTON, vehicleText, vehicleType, productName, telephone, managerFk, type, internalLength, internalHeight, internalWidth, alCoil,
floor, floorValue, tent, sideBoard, windStopper, freezer, gate, load, eTrackGate, eTrackWing, turnBuckle, toolBucket, bumperFootHold, wingProtector, axis, axisValue, specialAddition)
VALUES
(
'{$userFk}',
'{$requestDate}',
'{$companyName}',
'{$vehicleTON}',
'{$vehicleText}',
'{$vehicleType}',
'{$productName}',
'{$telephone}',
'{$managerFk}',
'{$type}',
'{$internalLength}',
'{$internalHeight}',
'{$internalWidth}',
'{$alCoil}',
'{$floor}',
'{$floorValue}',
'{$tent}',
'{$sideBoard}',
'{$windStopper}',
'{$freezer}',
'{$gate}',
'{$load}',
'{$eTrackGate}',
'{$eTrackWing}',
'{$turnBuckle}',
'{$toolBucket}',
'{$bumperFootHold}',
'{$wingProtector}',
'{$axis}',
'{$axisValue}',
'{$specialAddition}',
1,
NOW()
)
";
$this->update($sql);
return $this->makeResultJson("1", "저장되었습니다");
}
//내 제작사양서
function getListOfMyProductionSpec(){
$userFk=$this->appUser["no"];
$sql="
SELECT productionNo, companyName, requestDate
FROM tblProductionSpec
WHERE userFk='{$userFk}'
ORDER BY productionNO DESC
";
$list=$this->getArray($sql);
if(sizeof($list)>0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
//제작사양서 리스트(검색)
function getListOfProductionSpec(){
$dateFormer=$this->req["dateFormer"];
$dateLatter=$this->req["dateLatter"];
$managerFk=$this->req["managerFk"];
$where="status=1";
if(!empty($dateFormer)){
$where .= " AND DATE_FORMAT(requestDate, '%Y%m%d') >= DATE_FORMAT('{$dateFormer}', '%Y%m%d')";
}
if(!empty($dateLatter)){
$where .= " AND DATE_FORMAT(requestDate, '%Y%m%d') <= DATE_FORMAT('{$dateLatter}', '%Y%m%d')";
}
if(!empty($managerFk)){
$where .= " AND managerFk='{$managerFk}'";
}
$sql="
SELECT productionNo, companyName, requestDate
FROM tblProduntionSpec
{$where}
ORDER BY productionNo DESC
";
$list=$this->getArray($sql);
if(sizeof($list)>0)
return $this->makeResultJson("1", "", $list);
else
return $this->makeResultJson("-1000", "내역이 없습니다.");
}
//제작사양서 상세정보
function getInfoOfProductionSpec(){
$productionNo=$this->req["productionNo"];
$sql="
SELECT *
FROM tblProductionSpec
WHERE productionNo='{$productionNo}'
";
$info=$this->getRow($sql);
return $this->makeResultJson("1", "", $info);
}
//담당자 리스트
function getListOfManager(){
$sql="
SELECT managerNo, name
FROM tblManager
WHERE status=1
ORDER BY name ASC
";
$list=$this->getArray($sql);
return $this->makeResultJson("1", "", $list);
}
//좋아요
function productionLike(){
$userNo=$this->appUser["userNo"];
$productionNo=$this->req["productionNo"];
$sql="
INSERT INTO tblLike(userNo, productionNo, regDate)
VALUES('{$userNo}', '{$productionNo}', NOW())
";
$this->update($sql);
return $this->makeResultJson("1", "등록되었습니다");
}
//좋아요 취소
function productionLikeCancel(){
$userNo=$this->req["userNo"];
$productionNo=$this->req["productionNo"];
$sql="DELETE FROM tblLike WHERE userNo='{$userNo}' AND productionNo='{$productionNo}'";
$this->update($sql);
return $this->makeResultJson("1", "취소되었습니다");
}
//제작사양서 보관함 리스트(좋아요 리스트)
function productionLikeList(){
$userNo=$this->appUser["no"];
$sql="
SELECT productionNo, companyName, requestDate
FROM tblProductionSpec PS
JOIN tblLike L ON PS.productionNo=L.productionNo
WHERE L.userNo='{$userNo}'
";
$result=$this->getArray($sql);
return $this->makeResultJson("1","", $result);
}
} // 클래스 종료
}
?>