AdminCompany.php 4.69 KB
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminBase.php" ;
include $_SERVER[DOCUMENT_ROOT] . "/common/php/LoginUtil.php";

if (! class_exists("AdminCompany")){
	class AdminCompany extends AdminBase{
		function __construct($req)
		{
			parent::__construct($req);
		}
		
		function getListOfCompany(){
			$productCode=$this->req["productCode"];
		
			$sql="
			SELECT COUNT(*) AS rn
			FROM tblCompany
			WHERE productCode='{$productCode}' AND status=1
			";
			$this->initPage();
			$this->rownum=$this->getValue($sql, 'rn');
			$this->setPage($this->rownum);
			$limit=" LIMIT {$this->startNum}, {$this->endNum} ;";
				
				
				
			$sql="
			SELECT companyNo, name, provinceCode, address, telephone
			FROM tblCompany
			WHERE productCode='{$productCode}' AND status=1
			ORDER BY regDate DESC
			{$limit}
			";
			$result=$this->getArray($sql);
			return $result;
		}
		
		function getInfoOfCompany(){
			$companyNo=$_REQUEST["companyNo"];
			$sql="
			SELECT *
			FROM tblCompany
			WHERE companyNo='{$companyNo}' AND status=1
			";
			$result=$this->getRow($sql);
			//echo json_encode($result);
			return $result;
		}
		
		function getListOfProvince(){
			$sql="
				SELECT *
				FROM tblZipProvince
				ORDER BY provinceNumber ASC
			";
			$result=$this->getArray($sql);
			return $result;
		}
		
		function saveCompany(){
			$companyType=$this->req["companyType"];
			$companyNo=$this->req["companyNo"];
			$name=$this->req["name"];
			
			$productCode=$this->req["productCode"];
			$provinceCode=$this->req["provinceCode"];
			$address=$this->req["address"];
			$telephone1=$this->req["telephone1"];
			$telephone2=$this->req["telephone2"];
			$telephone3=$this->req["telephone3"];
			$telephone=$telephone1.$telephone2.$telephone3;
			$fax1=$this->req["fax1"];
			$fax2=$this->req["fax2"];
			$fax3=$this->req["fax3"];
			$fax=$fax1.$fax2.$fax3;
			$eMail=$this->req["eMail"];
			$companyProductList=$this->req["companyProductList"];
			
			$imgResult = $this->inFn_Common_fileSave($_FILES);
			
			$imgPathCompany1 = $imgResult["imgPathCompany1"]["saveURL"] != "" ? $imgResult["imgPathCompany1"]["saveURL"] : $this->req["imgPathCompany1"];
			$imgPathCompany2 = $imgResult["imgPathCompany2"]["saveURL"] != "" ? $imgResult["imgPathCompany2"]["saveURL"] : $this->req["imgPathCompany2"];
			$imgPathCompany3 = $imgResult["imgPathCompany3"]["saveURL"] != "" ? $imgResult["imgPathCompany3"]["saveURL"] : $this->req["imgPathCompany3"];
			$imgPathCompany4 = $imgResult["imgPathCompany4"]["saveURL"] != "" ? $imgResult["imgPathCompany4"]["saveURL"] : $this->req["imgPathCompany4"];
			$imgPathCompany5 = $imgResult["imgPathCompany5"]["saveURL"] != "" ? $imgResult["imgPathCompany5"]["saveURL"] : $this->req["imgPathCompany5"];
			
			if($companyNo == ""){
				$sql="
					insert INTO `tblCompany`
            			(
             			`name`,
             			`imgPathCompany1`,
             			`imgPathCompany2`,
             			`imgPathCompany3`,
             			`imgPathCompany4`,
             			`imgPathCompany5`,
             			`provinceCode`,
             			`productCode`,
             			`address`,
             			`telephone`,
             			`fax`,
             			`eMail`,
             			`companyProductList`,
             			`status`,
             			`regDate`
						)
					VALUES 
						(
        				'{$name}',
        				'{$imgPathCompany1}',
        				'{$imgPathCompany2}',
        				'{$imgPathCompany3}',
        				'{$imgPathCompany4}',
        				'{$imgPathCompany5}',
        				'{$provinceCode}',
        				'{$productCode}',
        				'{$address}',
        				'{$telephone}',
        				'{$fax}',
        				'{$eMail}',
        				'{$companyProductList}',
        				1,
        				NOW()
						);
				";
				$this->update($sql);
				
				return $this->makeResultJson(1, "저장되었습니다");
			}
			else{
				$sql="
					UPDATE tblCompany
					SET
						name='{$name}',
						`imgPathCompany1`= '{$imgPathCompany1}',
             			`imgPathCompany2`= '{$imgPathCompany2}',
             			`imgPathCompany3`= '{$imgPathCompany3}',
             			`imgPathCompany4`= '{$imgPathCompany4}',
             			`imgPathCompany5`= '{$imgPathCompany5}',
						provinceCode='{$provinceCode}',
						productCode='{$productCode}',
						address='{$address}',
						telephone='{$telephone}',
						fax='{$fax}',
						eMail='{$eMail}',
						companyProductList='{$companyProductList}'
					WHERE companyNo='{$companyNo}'
				";
				$this->update($sql);
				return $this->makeResultJson(1, "수정되었습니다");
			}
		}
		
		function deleteCompany(){
			$noArr = $this->req["no"];
			
			$noStr = implode(',', $noArr);
			
			$sql = "
			UPDATE tblCompany
			SET status = 0
			WHERE `companyNo` IN({$noStr})
			";
			$this->update($sql);
		}
		
		
		
	}
}
?>