<?
$sub_menu = "400110";
include_once("./_common.php");

auth_check($auth[$sub_menu], "r");

$token		= get_token();
include_once("$g4[path]/head.sub.php");
?>
<script type="text/javascript" src="<?=$g4[path]?>/js/sideview.js"></script>
<style>
table tr td	{ color:#414141; }
table tr td input	{ color:#3C3D3E; font-family:Dotum; padding:3px; }
table tr td textarea	{ color:#3C3D3E; font-family:Dotum; padding:3px; line-height:160%; }
table tr td.col1	{ padding:3px; color:#71777F; font-weight:bold; }
table tr td.col2	{ padding:5px; color:#868687; }

div.msg		{ font:normal 11px Dotum; padding:4px; }

a:hover	{ text-decoration:underline; }
</style>
<link rel="stylesheet" href="<?=$g4[path]?>/adm/admin.style.css" type="text/css">
<?
$colspan = 2;
$g4[title] = "팝업 공지사항";

include_once("./admin.head.php");

//-- 수정 모드 ----------------------------------
$rd_pop			= array();
$chk_win		= array();
if($ncode) {
	$recno		= base64_decode($ncode);
	$rd_pop		= sql_fetch("select * from $zmb[table_popup_notice] where db_recno='$recno'");
	$tmp_size	= explode("x", $rd_pop[db_winsize]);
	$tmp_pos	= explode("x", $rd_pop[db_winpos]);
	$rd_pop[db_width]	= $tmp_size[0];		//-- 창의 폭
	$rd_pop[db_height]	= $tmp_size[1];		//-- 창의 높이
	$rd_pop[db_top]		= $tmp_pos[0];		//-- 창의 위치. top
	$rd_pop[db_left]	= $tmp_pos[1];		//-- 창의 위치. left

	if($rd_pop[db_winstyle] == "1")		$chk_win[1] = "checked";		//-- 새창
	elseif($rd_pop[db_winstyle] == "2")	$chk_win[2] = "checked";		//-- 레이어
	else								$chk_win[3] = "checked";		//-- 모바일

	$tmp_date	= explode(" ", $rd_pop[db_start_datetime]);
	$now_date	= $tmp_date[0];
	$now_time	= $tmp_date[1];

	$tmp_date	= explode(" ", $rd_pop[db_end_datetime]);
	$end_date	= $tmp_date[0];
	$end_time	= $tmp_date[1];

	$mode		= "update";
}else{
	$rd_pop[db_width]	= 350;		//-- 창의 폭
	$rd_pop[db_height]	= 350;		//-- 창의 높이
	$rd_pop[db_top]		= 80;		//-- 창의 위치. top
	$rd_pop[db_left]	= 100;		//-- 창의 위치. left

	$now_date	= date("Y-m-d", $g4[server_time]);
	$now_time	= date("H:i:s", $g4[server_time]);
	$end_date	= date("Y-m-d", $g4[server_time]+604800);
	$end_time	= date("H:i:s", $g4[server_time]+604800);

	$mode		= "save";
}
?>
<?=subtitle("팝업 공지사항")?>
<div class="subtitle_msg">팝업 공지 내용 작성 없이 각 스킨 경로에 있는 파일에서 내용을 직접 작성 할 수 있습니다.</div>
<form method=post name="formnotice" onSubmit="return senddata(this, 'submit');" enctype="multipart/form-data">
<input type="hidden" name="recno" value="<?=$rd_pop[db_recno]?>">
<input type="hidden" name="mode" value="<?=$mode?>">
<table width=100% cellpadding=0 cellspacing=0>
<colgroup height=25 width="130">
<colgroup width="*">
<tr>
	<td class="col1">종류</td>
	<td class="col2"><input type="radio" name="in_winstyle" value="1" <?=$chk_win[1]?> itemname="새창" onclick="chk_mobile(formnotice, this.value)" required>새창, <input type="radio" name="in_winstyle" value="2" <?=$chk_win[2]?> itemname="레이어" onclick="chk_mobile(formnotice, this.value)" required>레이어, <input type="radio" name="in_winstyle" value="3" itemname="모바일" <?=$chk_win[3]?> onclick="chk_mobile(formnotice, this.value)" required>모바일</td>
</tr>
<tr>
	<td class="col1">창 크기</td>
	<td class="col2">가로: <input name="in_width" required value="<?=$rd_pop[db_width]?>" size="3" itemname="가로">px, 세로: <input name="in_height" value="<?=$rd_pop[db_height]?>" required size="3" itemname="세로">px <span class="smalltxt"> (가로 X 세로 크기는 각각 150px 이상)</span></td>
</tr>
<tr>
	<td class="col1">창 위치</td>
	<td class="col2">TOP: <input name="in_top" value="<?=$rd_pop[db_top]?>" required size="3" itemname="TOP">px, LEFT: <input name="in_left" value="<?=$rd_pop[db_left]?>" required size="3" itemname="LEFT">px <span class="smalltxt"> <?=help("0 : 임의로 위치 지정. 새창은 화면에서의 위치, 레이어는 브라우저에서의 위치.")?></span></td>
</tr>
<tr>
	<td class="col1">노출 시작 시간</td>
	<td class="col2"><?=date_select($now_date, "in_start_date")?>
	<?=time_select($now_time, "in_start_time")?>
	</td>
</tr>
<tr>
	<td class="col1">노출 종료 시간</td>
	<td class="col2"><?=date_select($end_date, "in_end_date")?>
	<?=time_select($end_time, "in_end_time")?>
	</td>
</tr>
<tr>
	<td class="col1">적용 대상</td>
	<td class="col2"><?=zm_get_member_level("in_target_level", $rd_pop[db_target_level])?>
	<?=help("회원 레벨이 $rd[db_target_level]이상인 사람에게만 적용")?>
	</td>
</tr>
<tr>
	<td class="col1">적용 스킨</td>
	<td class="col2"><select name=in_skin required itemname="스킨 디렉토리">
<?      $arr = get_skin_dir("popup");
        for ($i=0; $i<count($arr); $i++) {
			if($arr[$i] == $rd_pop[db_skin]) $chk = "selected"; else $chk = "";
            echo "<option value='$arr[$i]' $chk>$arr[$i]</option>\n";
        }
?>		</select>
        <script type="text/javascript">document.fboardform.in_skin.value="<?=$rd[db_skin]?>";</script>
	<?=help("경로 : skin/popup/ \n팝업 공지창의 레이아웃이 있는 스킨")?>
	</td>
</tr>
<tr>
	<td class="col1">모바일 적용 스킨</td>
	<td class="col2"><select name=in_m_skin required itemname="스킨 디렉토리">
<?      $arr = get_m_skin_dir("popup");
        for ($i=0; $i<count($arr); $i++) {
			if($arr[$i] == $rd_pop[db_skin]) $chk = "selected"; else $chk = "";
            echo "<option value='$arr[$i]' $chk>$arr[$i]</option>\n";
        }
?>		</select>
        <script type="text/javascript">document.fboardform.in_m_skin.value="<?=$rd[db_m_skin]?>";</script>
	<?=help("경로 : skin.mobile/popup/\n모바일 공지사항 스킨")?>
	</td>
</tr>
<tr>
	<td class="col1">제목</td>
	<td class="col2"><input name="in_subject" style="width:80%;" value="<?=$rd_pop[db_subject]?>" itemname="제목" maxlength="60" required>
	</td>
</tr>
<tr>
	<td class="col2" colspan="<?=$colspan?>" bgcolor=#FFFFFF>
	<textarea name=in_content id=in_content rows=10 style='width:80%; min-width:610px; margin:auto;'><?=$rd_pop[db_content]?></textarea>
	<script language="javascript">
		var oEditors = [];
		nhn.husky.EZCreator.createInIFrame({
			oAppRef: oEditors,
			elPlaceHolder: "in_content",
			sSkinURI: "<?=$g4[path]?>/zm.smarteditor/SmartEditor2Skin.html",	
			fCreator: "createSEditor2"
		});
	</script></td>
</tr>
<tr>
	<td colspan="<?=$colspan?>"><div class="msg">공지사항 내용을 스킨에서 대신 할 경우 입력하지 않으셔도 됩니다.</div></td>
</tr>
</table>
<div align=center>
	<input type="submit" value="저장하기" class="bttn_adj">
	<input type="button" value="취소" class="bttn_common" onclick="zm_gourl('./zm.popup_notice.php')"></td>
</div>
</form>

<script language="javascript">
function senddata(f, mode) {
	try{
		oEditors.getById['in_content'].exec('UPDATE_CONTENTS_FIELD', []);
	}catch(e) {}

	f.action		= "./zm.popup_notice_process.php";

	return true;
}

function chk_mobile(f, v){
	//-- 모바일 선택일 때 창크기, 위치, 스킨 사용 안 함
	if(v == "3"){
		f.in_width.disabled = true;
		f.in_height.disabled = true;
		f.in_top.disabled = true;
		f.in_left.disabled = true;
		f.in_skin.disabled = true;
		f.in_m_skin.disabled = false;

		f.in_width.required = false;
		f.in_height.required = false;
		f.in_top.required = false;
		f.in_left.required = false;
	}else{
		f.in_width.disabled = false;
		f.in_height.disabled = false;
		f.in_top.disabled = false;
		f.in_left.disabled = false;
		f.in_skin.disabled = false;
		f.in_m_skin.disabled = true;
	}
}
$(function(){
	var f	= document.formnotice;
	if(f.in_winstyle[2].value){
		chk_mobile(f, "3");
	}
})

</script>
<? include_once("./admin.tail.php"); ?>
</body>
</html>