<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/header.php";
include $_SERVER[DOCUMENT_ROOT] . "/module/mail/mail.lib.php";
include $_SERVER[DOCUMENT_ROOT] . "/common/fckeditor/fckeditor.php";
if(!in_array("mail_manage",$_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["AUTH"]) && $_SESSION[$_SITE["DOMAIN"]]["ADMIN"]["GRADE"]!="ROOT"):
	jsMsg("권한이 없습니다.");
	jsHistory("-1");
endif;

//DB연결
$dblink = SetConn($_conf_db["main_db"]);


if($_POST[evnMode]=="update"){
	setMailConfig(mysql_real_escape_string($_REQUEST[code]));
}

if($_REQUEST[code]){
	$arrInfo = getMailConfig(mysql_real_escape_string($_REQUEST[code]));

	if($_REQUEST[code]=="join"){
		$strTitle = "회원가입";
	}else if($_REQUEST[code]=="leave"){
		$strTitle = "회원탈퇴";
	}else{
		$strTitle = $_SITE["SHOP"]["ORDER_STATE"][$_REQUEST[code]];
	}
}

//DB해제
SetDisConn($dblink);
?>
<div id="admin-container">
	<? include "menu.php"; ?>
    <div id="admin-content">
		<h2 class="admin-title">메일 관리</h2>

		<div class="mgb5 space-right">
			<img src="/backoffice/images/arrow.gif" align=absmiddle> <a href="<?=$_SERVER[PHP_SELF]?>?code=join">회원가입</a>
			<img src="/backoffice/images/arrow.gif" align=absmiddle> <a href="<?=$_SERVER[PHP_SELF]?>?code=withdrawal">회원탈퇴</a>
			<?if($_SITE["SHOP"]["USE_SHOP"]=="Y"){?>
			<? 
				foreach ($_SITE["SHOP"]["ORDER_STATE"] as $key => $val){ 
			?>
			<img src="/backoffice/images/arrow.gif" align=absmiddle> <a href="<?=$_SERVER[PHP_SELF]?>?code=<?=$key?>"><?=$val?></a>
			<? 
				} 
			}
			?>
		</div>
		<?
		if(!$_REQUEST[code]){
		?>

		<fieldset>
			<legend>회원가입/탈퇴 시 제목</legend>
			<ul class="list-dot">
				<li>{NAME} 회원명</li>
			</ul>
		</fieldset>

		<br />

		<fieldset>
			<legend>회원가입/탈퇴 시 내용</legend>
			<ul class="list-dot">
				<li>{ID} 회원ID</li>
				<li>{NAME} 회원명</li>
				<li>{EMAIL} 이메일</li>
				<li>{ZIP} 우편번호</li>
				<li>{ADDRESS} 주소</li>
				<li>{ADDRESSEXT} 상세주소</li>
				<li>{WDATE} 가입일</li>
				<li>{NDATE} 오늘</li>
			</ul>
		</fieldset>

		<?if($_SITE["SHOP"]["USE_SHOP"]=="Y"){?>
		<br />
		<fieldset>
			<legend>쇼핑주문 시 제목</legend>
			<ul class="list-dot">
				<li>{NAME} 회원명</li>
			</ul>
		</fieldset>

		<br />

		<fieldset>
			<legend>내용</legend>
			<ul class="list-dot">
				<li>{ID} 회원ID</li>
				<li>{NAME} 회원명</li>
				<li>{EMAIL} 이메일</li>
				<li>{ORDERZIP} 주문자 우편번호</li>
				<li>{ORDERADDRESS} 주문자 주소</li>
				<li>{ORDERADDRESSEXT} 주문자 상세주소</li>
				<li>{ORDERPHONE} 주문자 전화</li>
				<li>{ORDERNO} 주문번호</li>
				<li>{SUMMARY} 주문요약</li>
				<li>{PAYTYPE} 결제방식</li>
				<li>{BANKTYPE} 결제계좌</li>
				<li>{TOTAL} 주문금액</li>
				<li>{PAYTOTAL} 결제금액</li>
				<li>{SHIPNAME} 수령자명</li>
				<li>{SHIPZIP} 수령자 우편번호</li>
				<li>{SHIPADDRESS} 수령자 주소</li>
				<li>{SHIPADDRESSEXT} 수령자 상세주소</li>
				<li>{SHIPPHONE} 수령자 전화</li>
				<li>{SHIPMOBILE} 수령자 휴대전화</li>
				<li>{COMMENT} 주문시 하실 말씀</li>
			</ul>
		</fieldset>
		<?
			}
		}
		?>
		<?
		if($arrInfo["total"] > 0){
		?>
		<script>
		function frmCheck(frm){
			try{ contents.outputBodyHTML(); } catch(e){ }
		}
		</script>

		<h3 class="admin-title-middle"><?=$strTitle?> 시 발송메일 설정</h3>
		<form id="frmMailConfig" name="frmMailConfig" method="post" action="<?=$_SERVER[PHP_SELF]?>" onsubmit="javascript:return frmCheck(this);">
		<input type="hidden" name="evnMode" value="update">
		<input type="hidden" name="code" value="<?=$arrInfo["list"][0][code]?>">
		<table class="admin-table-type1">
		  <colgroup>
		    <col width="120" />
			<col width="*" />
		  </colgroup>
		  <tbody>
			<tr>
				<th>사용여부</th>
				<td class="space-left"><input type="checkbox" name="is_use" id="is_use" value="Y"<?=$arrInfo["list"][0][is_use]=="Y"?" checked":""?>> <label for="is_use">체크해제시 메일이 발송되지 않습니다.</label></td>
			</tr>
			<tr>
				<th>제목</th>
				<td class="space-left"><input type="text" name="subject" style="width:99%" maxlength="200" value="<?=stripslashes($arrInfo["list"][0][subject])?>" class="input" /></td>
			</tr>
			<tr>
				<th>내용</th>
				<td class="space-left">
					<?
					$edit_content = stripslashes($arrInfo["list"][0]["contents"]) ;
					include $_SERVER[DOCUMENT_ROOT] . "/webedit/Editor.html";
					?>
				</td>
			</tr>
		  </tbody>
		</table>
		<div class="admin-buttons">
			<div class="cen">
				<span class="btn_pack xlarge"><input type="submit" value="정보저장" style="font-weight:bold" /></span>
			</div>
		</div>	
		<?
		}
		?>
  </div>
</div>
<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/footer.php" ;
?>