adminBoard.php 15.2 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
<? 
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);
		}
		
		function getListOfCS(){
			$sql="
				SELECT COUNT(*) AS rn
				FROM tblCustomerService CS
				JOIN tblUser U ON CS.userFk=U.userNo
				WHERE CS.status=1 AND U.status=1
			";
			$this->initPage();
			$this->rownum=$this->getValue($sql, 'rn');
			$this->setPage($this->rownum);
			$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
			
			$sql="
				SELECT CS.*, U.userName
				FROM tblCustomerService CS
				JOIN tblUser U ON CS.userFk=U.userNo
				WHERE CS.status=1 AND U.status=1
				ORDER BY CS.regDate DESC
				{$limit}
			";
			$result=$this->getArray($sql);
			return $result;
		}
		
		function getInfoOfCS(){
			$csNo=$this->req["no"];
			
			$sql="
				SELECT CS.*, U.userName
				FROM tblCustomerService CS
				JOIN tblUser U ON CS.userFk=U.userNo
				WHERE CS.csNo='{$csNo}'
			";
			$result=$this->getRow($sql);
			return $result;
		}
		
		function saveCS(){
			$targetFk=$this->req["csNo"];
			$content=$this->req["content"];
			
			$sql="
			INSERT INTO tblComment(userFk, targetFk, commentGroup, gOrder, depth, content, commentType, status, regDate)
			VALUES
			(
			0,
			'{$targetFk}',
			0,
			1,
			1,
			'{$content}',
			'CS',
			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", "저장되었습니다");
		}
		
		function deleteCS(){
			$noArr = $this->req["no"];
			
			$noStr = implode(',', $noArr);
			
			$sql = "
			UPDATE tblCustomerService
			SET status = 0
			WHERE `csNo` IN({$noStr})
			";
			$this->update($sql);
		}
		
		function getListOfCSComment(){
			$no=$this->req["no"];
			if($no != ""){
				$sql="
				SELECT C.*, IFNULL(U.userName, '관리자') AS userName
				FROM tblComment C
				LEFT JOIN tblUser U ON C.userFk=U.userNo
				WHERE C.commentType='CS' AND C.targetFk='{$no}' AND C.status=1
				ORDER BY commentGroup DESC, gOrder ASC
				";
				$result=$this->getArray($sql);
				//echo json_encode($result);
				return $result;
			}
				
		}
		
		function getListOfProductionPortrait(){
			$sql="
				SELECT COUNT(*) AS rn
				FROM tblProductionPortrait
				WHERE status=1
			";
			$this->initPage();
			$this->rownum=$this->getValue($sql, 'rn');
			$this->setPage($this->rownum);
			$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
			
			
			$sql="
				SELECT ppNo, title, regDate
				FROM tblProductionPortrait
				WHERE status=1
				ORDER BY ppNo DESC
				{$limit}
			";
			$result=$this->getArray($sql);
			return $result;
		}
		
		function getInfoOfProductionPortrait(){
			$ppNo=$this->req["no"];
				
			$sql="
			SELECT *
			FROM tblProductionPortrait
			WHERE ppNo='{$ppNo}'
			";
			$result=$this->getRow($sql);
				
			return $result;
		}
		
		function getInfoOfProductionPortraitForJson(){
			$ppNo=$this->req["no"];
				
			$sql="
			SELECT *
			FROM tblProductionPortrait
			WHERE ppNo='{$ppNo}'
			";
			$result=$this->getRow($sql);
				
			return json_encode($result);
		}
		
		function saveProductionPortrait(){
			$ppNo=$this->req["no"];
			$title=$this->req["title"];
			$content1=$this->req["content1"];
			$content2=$this->req["content2"];
			$content3=$this->req["content3"];
			$content4=$this->req["content4"];
			$content5=$this->req["content5"];
			$content6=$this->req["content6"];
			$content7=$this->req["content7"];
			$content8=$this->req["content8"];
			$content9=$this->req["content9"];
			$content10=$this->req["content10"];
			
			$imgResult = $this->inFn_Common_fileSave($_FILES);
				
			$imgPathPP1 = $imgResult["img01"]["saveURL"] != "" ? $imgResult["img01"]["saveURL"] : $this->req["imgPathPP1"];
			$imgPathPP2 = $imgResult["img02"]["saveURL"] != "" ? $imgResult["img02"]["saveURL"] : $this->req["imgPathPP2"];
			$imgPathPP3 = $imgResult["img03"]["saveURL"] != "" ? $imgResult["img03"]["saveURL"] : $this->req["imgPathPP3"];
			$imgPathPP4 = $imgResult["img04"]["saveURL"] != "" ? $imgResult["img04"]["saveURL"] : $this->req["imgPathPP4"];
			$imgPathPP5 = $imgResult["img05"]["saveURL"] != "" ? $imgResult["img05"]["saveURL"] : $this->req["imgPathPP5"];
			$imgPathPP6 = $imgResult["img06"]["saveURL"] != "" ? $imgResult["img06"]["saveURL"] : $this->req["imgPathPP6"];
			$imgPathPP7 = $imgResult["img07"]["saveURL"] != "" ? $imgResult["img07"]["saveURL"] : $this->req["imgPathPP7"];
			$imgPathPP8 = $imgResult["img08"]["saveURL"] != "" ? $imgResult["img08"]["saveURL"] : $this->req["imgPathPP8"];
			$imgPathPP9 = $imgResult["img09"]["saveURL"] != "" ? $imgResult["img09"]["saveURL"] : $this->req["imgPathPP9"];
			$imgPathPP10 = $imgResult["img10"]["saveURL"] != "" ? $imgResult["img10"]["saveURL"] : $this->req["imgPathPP10"];
			
			if($ppNo==""){
				$sql="
					INSERT INTO `tblProductionPortrait`
            		(
             		`title`,
             		`content1`,
             		`content2`,
             		`content3`,
             		`content4`,
             		`content5`,
             		`content6`,
             		`content7`,
             		`content8`,
             		`content9`,
             		`content10`,
             		`imgPathPP1`,
             		`imgPathPP2`,
             		`imgPathPP3`,
             		`imgPathPP4`,
             		`imgPathPP5`,
             		`imgPathPP6`,
             		`imgPathPP7`,
             		`imgPathPP8`,
             		`imgPathPP9`,
             		`imgPathPP10`,
             		`status`,
             		`regDate`
					)
					VALUES 
					(
        			'{$title}',
        			'{$content1}',
        			'{$content2}',
        			'{$content3}',
        			'{$content4}',
        			'{$content5}',
        			'{$content6}',
        			'{$content7}',
        			'{$content8}',
        			'{$content9}',
        			'{$content10}',
        			'{$imgPathPP1}',
        			'{$imgPathPP2}',
        			'{$imgPathPP3}',
        			'{$imgPathPP4}',
        			'{$imgPathPP5}',
        			'{$imgPathPP6}',
        			'{$imgPathPP7}',
        			'{$imgPathPP8}',
        			'{$imgPathPP9}',
        			'{$imgPathPP10}',
        			1,
        			NOW()
					);
				";
				$this->update($sql);
				return $this->makeResultJson(1, "등록되었습니다");
			}
			else{
				$sql="
					UPDATE `tblProductionPortrait`
					SET 
  					`title` = '{$title}',
  					`content1` = '{$content1}',
  					`content2` = '{$content2}',
  					`content3` = '{$content3}',
  					`content4` = '{$content4}',
  					`content5` = '{$content5}',
  					`content6` = '{$content6}',
  					`content7` = '{$content7}',
  					`content8` = '{$content8}',
  					`content9` = '{$content9}',
  					`content10` = '{$content10}',
  					`imgPathPP1` = '{$imgPathPP1}',
  					`imgPathPP2` = '{$imgPathPP2}',
  					`imgPathPP3` = '{$imgPathPP3}',
  					`imgPathPP4` = '{$imgPathPP4}',
  					`imgPathPP5` = '{$imgPathPP5}',
  					`imgPathPP6` = '{$imgPathPP6}',
  					`imgPathPP7` = '{$imgPathPP7}',
  					`imgPathPP8` = '{$imgPathPP8}',
  					`imgPathPP9` = '{$imgPathPP9}',
  					`imgPathPP10` = '{$imgPathPP10}'
					WHERE `ppNo` = '{$ppNo}';
				";
				$this->update($sql);
				return $this->makeResultJson(1, "수정되었습니다");
			}
		}
		
		function deleteProductionPortrait(){
			$noArr = $this->req["no"];
			
			$noStr = implode(',', $noArr);
			
			$sql = "
			UPDATE tblProductionPortrait
			SET status = 0
			WHERE `ppNo` IN({$noStr})
			";
			$this->update($sql);
		}
	}
	
}

?>