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

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

$token		= get_token();
include_once("$g4[path]/head.sub.php");

$winstyle	= array("1"=>"새창", "2"=>"레이어", "3"=>"모바일");
?>
<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; }
.write		{ padding:3px; text-align:right; }
</style>
<link rel="stylesheet" href="<?=$g4[path]?>/adm/admin.style.css" type="text/css">
<?
$colspan = 9;
$g4[title] = "공지사항";

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

//-- 공지사항 읽어오기
$s_where	= "where 1";
if(!$s_orderby)
	$s_orderby	= "order by db_recno desc";

$sql	= "select count(*) as cnt from $zmb[table_popup_notice] $s_where";
$row	= sql_fetch($sql);
$total_count = $row[cnt];
$rows	= 25;
$total_page  = ceil($total_count / $rows);		// 전체 페이지 계산
if ($page == "") { $page = 1; }					// 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows;				// 시작 열을 구함
$rs			= sql_query("select * from $zmb[table_popup_notice] $s_where $s_orderby limit $from_record, $rows");

?>
<?=subtitle("팝업 공지사항")?>
<table width=100% cellpadding=0 cellspacing=1 border=0 align="center">
<colgroup width=5%>
<colgroup width=35%>
<colgroup width=10%>
<colgroup width=8%>
<colgroup width=10%>
<colgroup width=8%>
<colgroup width=8%>
<colgroup width=*>
<tr><td colspan='<?=$colspan?>' class='line1'></td></tr>
<tr class='bgcol1 bold col1 ht center'>
    <td>번호</td>
	<td>제목</td>
	<td>작성일</td>
	<td>시작일</td>
	<td>종료일</td>
	<td>종류</td>
	<td>레벨</td>
	<td></td>
</tr>
<?
$i		= 0;
while($rd = sql_fetch_array($rs)) :
$i++;
$win_size	= explode("x", $rd[db_winsize]);
$ncode		= base64_encode($rd[db_recno]);
if($rd[db_winstyle] == "3") {
	$skin_path	= "$g4[path]/skin.mobile/popup/$rd[db_skin]/popup.skin.php?ncode=$ncode";		//-- 모바일 스킨
}else{
	$skin_path	= "$g4[path]/skin/popup/$rd[db_skin]/popup.skin.php?ncode=$ncode";
}
?>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
<tr class='list<?=$list?> col1 ht center' onMouseOver="this.style.backgroundColor='#EFEFEF'" onMouseOut="this.style.backgroundColor=''">
	<td align="left"><?=$i?></td>
    <td align="left"><?=cut_str($rd[db_subject], 50)?></td>
    <td><?=substr($rd[db_datetime], 0, 10)?></td>
    <td><?=substr($rd[db_start_datetime], 0, 10)?></td>
    <td><?=substr($rd[db_end_datetime], 0, 10)?></td>
    <td><?=$winstyle[$rd[db_winstyle]]?></td>
	<td align=left><?=$rd[db_target_level]?>:<?=$zm_levelname[$rd[db_target_level]]?></td>
    <td>
	<input type="button" value="수정" class="btn1" onClick="zm_gourl('./zm.popup_notice_write.php?ncode=<?=$ncode?>');">
	<input type="button" value="보기" class="btn1" onClick="window.open('<?=$skin_path?>', 'popup', 'width=<?=$win_size[0]?>, height=<?=$win_size[1]?>, scrollbar=0, toolbar=0');">
	<input type="button" value="X" class="btn1" onClick="if(confirm('선택한 공지사항을 삭제 합니다.')) zm_gourl('./zm.popup_notice_process.php?mode=del&ncode=<?=$ncode?>');">
	</td>
</tr>
<? endwhile; ?>
<? if ($i == 0)
    echo "<tr height='50'><td colspan='$colspan' align=center height=100 bgcolor=#ffffff>내용이 없습니다.</td></tr>"; 
?>
<tr><td colspan='<?=$colspan?>' class='line2'></td></tr>
</table>
<div class="write">
	<input type="button" value="공지사항 작성하기" class="btn1" onClick="zm_gourl('./zm.popup_notice_write.php')">
</div>
<?
$pagelist = get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");
?>
<div><?=$pagelist?></div>
<script language="javascript">
</script>
<? include_once("./admin.tail.php"); ?>
</body>
</html>