<?
include_once ("./static_data/code.php");
$menu_code = '67';
require_once (APPPATH.'views/skin/admin/_content_comm.php');

?>



<form name="input_form" id="input_form" method="post" action="/admin/etc_section/channel_list/6">
<input type="hidden" id="search_etc_section_type" name="search_etc_section_type" value="<?=$search_etc_section_type?>">
<input type="hidden" id="search_category" name="search_category" value="<?=$search_category?>">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="search_type" name="search_type" value="channel_name">
<input type="hidden" id="idx" name="idx">
<input type="hidden" id="mode" name="mode">


<div class="common_tep clearfix type01">
	<ul class="clearfix">
		<li style="width:100px">PC섹션</li>
<?  foreach ($def_arr_channel_etc_section1 as $val) {    ?>
        <li><a href="/admin/etc_section/channel_list/6?search_etc_section_type=<?=$val['code']?>" <? if($search_etc_section_type==$val['code']) { echo 'class="on"';}?>><?=$val['name']?></a></li>
<?  }?>

	</ul>

	<div class="searh_area">
		<input type="text" name="search_keyword" id="search_keyword" value="<?=$search_keyword?>" placeholder="채널명" 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_tep clearfix type01">
	<ul class="clearfix">
		<li style="width:100px">모바일섹션</li>
<?  foreach ($def_arr_channel_etc_section2 as $val) {    ?>
        <li><a href="/admin/etc_section/channel_list/6?search_etc_section_type=<?=$val['code']?>" <? if($search_etc_section_type==$val['code']) { echo 'class="on"';}?>><?=$val['name']?></a></li>
<?  }?>

	</ul>
</div>


<div class="common_table" style="margin-top: 30px">
	<span><b>Total:</b> <?=number_format($total_count);?></span>
	<span style="margin-left: 5px"><input type="radio" name="sort" value="1" <? if($sort=='1') { echo 'checked';}?> onclick="check_search();"> 최신순</span>
	<span style="margin-left: 5px"><input type="radio" name="sort" value="2" <? if($sort=='2') { echo 'checked';}?> onclick="check_search();"> 조회순</span>
	<span style="margin-left: 5px"><input type="radio" name="sort" value="3" <? if($sort=='3') { echo 'checked';}?> onclick="check_search();"> 등록글순</span>
	<span style="margin-left: 5px"><input type="radio" name="sort" value="4" <? if($sort=='4') { echo 'checked';}?> onclick="check_search();"> 등록에디터순</span>
	<div class="searh_area">
		<select name="search_category" onchange="check_search();" style="width:100px">
			<option value="">카테고리</option>
	<? 	foreach ($category_list as $key=>$val) {?>
			<option value="<?=$val['idx']?>" <? if($search_category==$val['idx']){ echo 'selected';}?>><?=$val['category_name']?></option>

	<? 	}?>
		</select>
	</div>
</div>







<div class="common_table">

<table>
	<thead>
	<tr>
		<th><input type="checkbox" name="allcheck" id="allcheck"></th>
		<th>번호</th>
		<th>순위</th>
        <th>카테고리</th>
		<th>채널아이콘</th>
		<th>채널명</th>
		<th>등록에디터수</th>
		<th>등록글수</th>
		<th>조회수</th>
		<th>등록일</th>
		<th>관리</th>
	</tr>
	</thead>
	<tbody>


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

	} else {
	    $dataNumber = ($total_count + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx          		= $val['idx'];
			$rank 		= $val['rank'];
			$category_name 		= $val['category_name'];
			$channel_icon      	= $val['channel_icon'];
			$channel_name      	= $val['channel_name'];
			$editor_count		= $val['editor_count'];
			$article_count		= $val['article_count'];
			$hit_count			= $val['hit_count'];
			$reg_date 	    	= $val['reg_date'];






?>

			<tr>
				<td><input type="checkbox" name="is_del[]" value="<?=$idx?>"></td>
				<td><?=$dataNumber?></td>
				<td><?=$rank?></td>
				<td><a href="/admin/life/life_category_list/5?search_type=category_name&search_keyword=<?=$category_name?>"><?=$category_name?></a></td>
				<td><img src="<?=$channel_icon?>" width="35"></td>
				<td><a href="/admin/life/life_channel_list/5?search_type=channel_name&search_keyword=<?=$channel_name?>"><?=$channel_name?></a></td>
				<td><?=number_format($editor_count)?></td>
				<td><?=number_format($article_count)?></td>
				<td><?=number_format($hit_count)?></td>
				<td><?=$reg_date?></td>
				<td class="tool_btn">
					<a href="javascript:channel_edit('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
					<a href="javascript:channel_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>삭제</a>
				</td>

			</tr>

<?
		    $dataNumber--;
		}
	}
?>
</tbody>
</table>
<div class="write_btn">
	<a href="javascript:channel_arr_del_proc()">삭제</a>
	<a href="javascript:channel_list_reg()">송출관리</a>
</div>

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



<!--// 카테고리 등록/수정 layer -->


</form>


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

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


function channel_list_reg(){
	$("#mode").val('add');
	$("#input_form").attr("action", "/admin/etc_section/channel_list_reg/6");
	$("#input_form").submit();
}


// edit
function channel_edit(idx){
	$("#idx").val(idx);
	$("#input_form").attr("action", "/admin/etc_section/channel_edit/6");
	$("#input_form").submit();
}

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

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