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



<form name="input_form" id="input_form" method="post" action="/admin/cs/cs_notice_list/7">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="idx" name="idx">
<input type="hidden" id="mode" name="mode">
<input type="hidden" id="search_click" name="search_click" value="<?=$search_click?>">


<div class="common_table clearfix type01">
	<div class="searh_area">
		<select name="search_type" id="search_type">
			<option value="">선택</option>
			<option value="title" <? if($search_type=='title'){ echo 'selected';}?>>제목</option>
			<option value="content" <? if($search_type=='content'){ 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">
	<span style="font-weight:bold">Total:</span> <?=number_format($total_count);?>
	<a href="javascript:click_search('1');"><span style="font-weight:bold">오늘신규:</span> <?=number_format($new_count);?></a>
	<table>
		<thead>
			<th><input type="checkbox" name="allcheck" id="allcheck"></th>
			<th>번호</th>
			<th>제목</th>
			<th>글쓴이</th>
			<th>작성일</th>
			<th>조회수</th>
			<th>관리</th>
		</thead>
		<tbody>


<?
	if(count($list)==0) {
?>
		<tr>
			<td colspan="7">등록된 내용이 없습니다.</td>
		</tr>
<?
	} else {
		$now_date = date("Y-m-d");
	    $dataNumber = ($total_count + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx            = $val['idx'];
			$title 			= $val['title'];
			$write_id 		= $val['write_id'];
			$write_name 	= $val['write_name'];
			$reg_date 	    = $val['reg_date'];
            $hit_count 	    = $val['hit_count'];

			$reg_date		= substr($reg_date, 0, 10);
			
			$new = '';
            if($reg_date == $now_date)	$new = '<img src="/img/admin/board/icon_new.gif"  style="vertical-align:middle;margin-top:-3px;" border="0"> ';



?>

			<tr>
				<td><input type="checkbox" name="is_del[]" value="<?=$idx?>"></td>
				<td><?=number_format($dataNumber)?></td>
				<td class="title" style="text-align:left;"><a href="javascript:notice_reg('<?=$idx?>')"><?=$new?><?=$title?></a></td>
				<td><?=$write_id?>(<?=$write_name?>)</td>
				<td><?=$reg_date?></td>
				<td><?=number_format($hit_count)?></td>
				<td class="tool_btn">
					<a href="javascript:notice_reg('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
					<a href="javascript:notice_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>삭제</a>
				</td>

			</tr>

<?
		    $dataNumber--;
		}
	}
?>

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

<div class="write_btn">
	<a href="javascript:notice_arr_del_proc()">삭제</a>
	<a href="/admin/cs/cs_notice_reg/7">공지등록</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 click_search(type){
	$("#search_click").val(type);
	$("#input_form").submit();
}

// edit
function notice_reg(idx){
	$("#idx").val(idx);
	$("#mode").val('edit');
	$("#input_form").attr("action", "/admin/cs/cs_notice_reg/7");
	$("#input_form").submit();
}

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

// 복수 삭제
function notice_arr_del_proc() {
	if($("input:checkbox[name='is_del[]']").is(":checked") == false) {
		alert("삭제할 내용이 없습니다.");
		return false;
	}
	if(confirm("글이 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
		$("#input_form").attr("action", "/admin/cs/cs_notice_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>