<?
$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 type="text/css">
.subject	{ border:1px solid #EFEFEF; background-color:#FBFBFB; padding:5px; line-height:160%; margin:3px; }
.item		{ background-color:#F7F7F7; font-weight:bold; height:30px; padding:0 0 0 5px; }
.smalltxt	{ font-size:11px; color:#A2A2A2; }
</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();
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 = "checked";
	else							$chk_layer = "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

	$chk_layer	= "checked";

	$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("공지사항")?>
<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=750 cellpadding=0 cellspacing=0>
<colgroup height=25 width="130">
<colgroup width="*">
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">종류</td>
	<td><input type="radio" name="in_winstyle" value="1" <?=$chk_win?> itemname="새창">새창, <input type="radio" name="in_winstyle" value="2" <?=$chk_layer?> itemname="레이어">레이어</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">창 크기</td>
	<td>가로: <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 colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">창 위치</td>
	<td>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 colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">노출 시작 시간</td>
	<td><?=date_select($now_date, "in_start_date")?>
	<?=time_select($now_time, "in_start_time")?>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">노출 종료 시간</td>
	<td><?=date_select($end_date, "in_end_date")?>
	<?=time_select($end_time, "in_end_time")?>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">적용 대상</td>
	<td><?=zm_get_member_level("in_target_level", $rd_pop[db_target_level])?>
	<?=help("회원 레벨이 $rd[db_target_level]이상인 사람에게만 적용")?>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">적용 스킨</td>
	<td><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("팝업 공지창의 레이아웃이 있는 스킨")?>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td class="item">제목</td>
	<td><input name="in_subject" style="width:100%;" value="<?=$rd_pop[db_subject]?>" itemname="제목" maxlength="60" required>
	</td>
</tr>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr>
	<td colspan="<?=$colspan?>" bgcolor=#FFFFFF>
	<textarea class=ed name=in_content id=in_content rows=5 style='width:100%; min-width:610px;'><?=$rd_pop[db_content]?></textarea>
	<script language="javascript">
		var oEditors = [];
		nhn.husky.EZCreator.createInIFrame({
			oAppRef: oEditors,
			elPlaceHolder: "in_content",
			sSkinURI: "<?=$g4[path]?>/SmartEditorZium/SmartEditor2Skin.html",	
			fCreator: "createSEditor2"
		});
	</script></td>
</tr>
</table>
<div align=center>
	<input type="submit" value="저장하기" class="btn1">
	<input type="button" value="취소" class="btn1" 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;
}
</script>
<? include_once("./admin.tail.php"); ?>
</body>
</html>