adminBoard.php 8 KB
<? 
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);
		}
		
	}
	
}

?>