<?
	$menu_code = '81';
	require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>



<form name="input_form" id="input_form" method="post" action="/admin/design/design_popup_list/8">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="idx" name="idx">
<input type="hidden" id="mode" name="mode">

<div class="common_table clearfix type01">
	<div class="searh_area">
		<select name="search_type" id="search_type">
			<option value="">선택</option>
			<option value="popup_type_name" <? if($search_type=='popup_type_name'){ echo 'selected';}?>>구분</option>
			<option value="title" <? if($search_type=='title'){ echo 'selected';}?>>제목</option>
		</select> <input type="text" name="search_keyword" id="search_keyword" value="<?=$search_keyword?>" onkeypress="if( event.keyCode==13 ){check_search();}">
		<a href="javascript:check_search();" class="btn"><i class="fa moving_all fa-search" style="margin-left:8px;"></i></a>
	</div>
</div>


<div class="common_table" style="margin-top: 30px">
	<span><b>Total:</b> <?=number_format($total_count);?></span>
	<div class="searh_area">
		<select name="search_menu_code" onchange="check_search();" style="width:100px">
			<option value="">위치</option>
			<option value="1" <? if($search_menu_code==1){ echo 'selected';}?>>홈</option>
			<option value="2" <? if($search_menu_code==2){ echo 'selected';}?>>홈(은혜)</option>
			<option value="3" <? if($search_menu_code==3){ echo 'selected';}?>>라이프</option>
			<option value="4" <? if($search_menu_code==4){ echo 'selected';}?>>뉴스</option>
		</select>
	</div>

</div>

<div class="common_table">
	<table>
		<thead>
			<th><input type="checkbox" name="allcheck" id="allcheck"></th>
			<th>번호</th>
			<th>썸네일</th>
			<th>구분</th>
			<th>위치</th>
			<th>제목</th>
			<th>top</th>
			<th>left</th>
			<th>크기</th>
			<th>출력상태</th>
			<th>마감일</th>
			<th>관리</th>
		</thead>
		<tbody>

<?
	if(count($list)==0) {
?>
		<tr>
			<td colspan="12">등록된 내용이 없습니다.</td>
		</tr>
<?
	} else {

	    $dataNumber = ($total_count + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx            = $val['idx'];
			$popup_type_name= $val['popup_type_name'];
			$title 			= $val['title'];
			$menu_code 		= $val['menu_code'];
			$top_margin 	= $val['top_margin'];
			$left_margin    = $val['left_margin'];
			$width_size 	= $val['width_size'];
			$height_size 	= $val['height_size'];
			$is_display 	= $val['is_display'];
			$end_date 		= $val['end_date'];
			$end_date		= substr($end_date, 0, 16);
			$prev_img 		= $val['prev_img'];

			switch ($menu_code) {
				case '1': $menu_code_txt = '<a href="/" target="_blank">홈(PC)</a>'; break;
				case '2': $menu_code_txt = '<a href="/m/" target="_blank">은혜(모바일)</a>'; break;
				case '3': $menu_code_txt = '<a href="/web/life/" target="_blank">라이프</a>'; break;
				case '4': $menu_code_txt = '<a href="/web/news/" target="_blank">뉴스</a>'; break;
				default : $menu_code_txt = ''; break;
			}

			switch ($is_display) {
				case 'Y': $is_display_txt = 'ON'; break;
				case 'N': $is_display_txt = 'OFF'; break;
				default : $is_display_txt = ''; break;
			}



?>

		<tr>
			<td><input type="checkbox" name="is_del[]" value="<?=$idx?>"></td>
			<td><?=$dataNumber?></td>
			<td><img src="<?=$prev_img?>" width="35"></td>
			<td><?=$popup_type_name?></td>
			<td><?=$menu_code_txt?></td>
			<td><?=$title?></td>
			<td><?=$top_margin?></td>
			<td><?=$left_margin?></td>
			<td><?=$width_size?>*<?=$height_size?></td>
			<td><?=$is_display_txt?></td>
			<td><?=$end_date?></td>
			<td class="tool_btn">
				<a href="javascript:popup_edit('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
				<a href="javascript:popup_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>삭제</a>
			</td>
		</tr>

<?
		    $dataNumber--;
		}
	}
?>

</tbody>
</table>
</div>

<div class="write_btn">
	<a href="javascript:popup_arr_del_proc()">삭제</a>
	<a href="/admin/design/design_popup_reg/8?mode=add">팝업등록</a>
</div>

<div class="pasing_wrap">
	<?=$pagination?>
</div>

</form>


<script type="text/javascript">
function check_search(){
    if($("#search_type").val()=="" && $("#search_keyword").val()!=""){
        alert("검색할 항목을 선택해주세요.");
        return false;
    }

    $("#input_form").submit();
}

// 수정페이지로
function popup_edit(idx){
	$("#idx").val(idx);
	$("#mode").val('edit');
	$("#input_form").attr("action", "/admin/design/design_popup_reg/8");
	$("#input_form").submit();
}

// 삭제
function popup_del_proc(idx) {
	if(confirm("팝업이 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
		$("#idx").val(idx);
		$("#input_form").attr("action", "/admin/design/design_popup_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}


// 복수 삭제
function popup_arr_del_proc() {
	if($("input:checkbox[name='is_del[]']").is(":checked") == false) {
		alert("삭제할 내용이 없습니다.");
		return false;
	}
	if(confirm("팝업이 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
		$("#input_form").attr("action", "/admin/design/design_popup_arr_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}

// checkbox all checked/unchecked
$(function(){
	$("#allcheck").click(function(){
    	if($("#allcheck").prop("checked")) {
    		$("input:checkbox[name='is_del[]']").prop('checked', true); // 전체선택하기
		} else {
      		$("input:checkbox[name='is_del[]']").prop("checked", false);
    	}
  	})
})


</script>