<?php
include_once ("./static_data/code.php");


$menu_code = '33';
require_once (APPPATH.'views/skin/admin/_content_comm.php');



$arr_display = array();
foreach ($arr_display_count as $val) {
	$arr_display[$val['is_display']] = $val['cnt'];
}
$is_display1 = 0; $is_display2 = 0;
if(isset($arr_display['Y'])==true) 	$is_display1 = $arr_display['Y'];
if(isset($arr_display['N'])==true) 	$is_display2 = $arr_display['N'];
?>

<form name="input_form" id="input_form" method="post" action="/admin/column/column_theme_list/3">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="page" name="search_theme_type" value="<?=$search_theme_type?>">
<input type="hidden" id="search_click1" name="search_click1" value="<?=$search_click1?>">
<input type="hidden" id="search_click2" name="search_click2" value="<?=$search_click2?>">
<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>
		<li><a href="/admin/column/column_theme_list/3" <? if($search_theme_type=='') { echo 'class="on"';}?>>전체</a></li>
 <?  foreach($def_arr_column_theme1 as $val) {
	 	$css = '';
 		if($search_theme_type==$val['code']){
	 		$css = ' class="on"';
		}

 	?>
	 	<li><a href="/admin/column/column_theme_list/3?search_theme_type=<?=$val['code']?>" <?=$css?>><?=$val['name']?></a></li>

<?  }?>

	</ul>
	<div class="searh_area">
		<select name="search_type" id="search_type">
			<option value="">선택</option>
			<option value="column_name" <? if($search_type=='column_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_tep clearfix type01">
	<ul class="clearfix">
		 <li style="width:100px">모바일테마</li>
 <?  foreach($def_arr_column_theme2 as $val) {
	 	$css = '';
 		if($search_theme_type==$val['code']){
	 		$css = ' class="on"';
		}

 	?>
	 	<li><a href="/admin/column/column_theme_list/3?search_theme_type=<?=$val['code']?>" <?=$css?>><?=$val['name']?></a></li>

<?  }?>

	</ul>
</div>


<div class="common_table" style="margin-top: 20px">
	<span style="font-weight:bold">Total:</span> <?=number_format($total_count);?>
	<a href="javascript:click_search('1', 'search_click1');"><span style="margin-left: 5px;font-weight:bold">오늘신규:</span> <?=number_format($new_count);?></a>
	<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>
	<span style="margin-left: 10px">
		<a href="javascript:click_search('1', 'search_click2');"><span class="text_blue">출력중: <?=number_format($is_display1)?></span></a>&nbsp;&nbsp;&nbsp;
		<a href="javascript:click_search('2', 'search_click2');"><span class="text_red">예약중: <?=number_format($is_display2)?></span></a>
	</span>


	<table>
		<thead>
			<th><input type="checkbox" name="allcheck" id="allcheck"></th>
			<th>번호</th>
			<th>썸네일</th>
			<th>테마명</th>
			<th>칼럼명</th>
			<th>제목</th>
			<th>등록일시</br>(예약일시)</th>
			<th>출력순위</th>
			<th>조회수</th>
			<th>좋아요</th>
			<th>댓글수</th>
			<th>관리</th>
		</thead>
		<tbody>

<?
	if(count($list)==0) {
?>
		<tr>
			<td colspan="12">등록된 내용이 없습니다.</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'];
			$main_img       = $val['main_img'];
			$column_name 	= $val['column_name'];
			$theme_type 	= $val['theme_type'];
			$reg_date 	    = $val['reg_date'];
            $hit_count 	    = $val['hit_count'];
            $like_count 	= $val['like_count'];
            $comment_count 	= $val['comment_count'];
            $is_display 	= $val['is_display'];
            $reg_date 		= $val['reg_date'];
			$display_date 	= $val['display_date'];
            $rank 	        = $val['rank'];
            $content_idx 	= $val['content_idx'];

			$display_date_txt = '';
			if($is_display == 'N') {
				$display_date_txt = '</br><span class="text_green">('.$display_date.')</span>';
			}

            $theme_type_txt = $def_arr_column_theme[$theme_type]['name'];

			$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><?=$dataNumber?></td>
					<td><img src="<?=$main_img?>" width="35"></td>
					<td><?=$theme_type_txt?></td>
					<td><a href="/admin/column/column_reg/3?mode=edit&idx=<?=$content_idx?>"><?=$column_name?></a></td>
					<td class="title" style="text-align:left;"><a href="/admin/column/column_reg/3?mode=edit&idx=<?=$content_idx?>"><?=$new?><?=$title?></a></td>
					<td><?=$reg_date?><?=$display_date_txt?></td>
					<td><?=$rank?></td>
					<td><?=$hit_count?></td>
					<td><?=$like_count?></td>
					<td><?=$comment_count?></td>
					<td class="tool_btn">
						<a href="javascript:column_theme_edit('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
						<a href="javascript:column_theme_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>삭제</a>
					</td>

				</tr>

<?
		    $dataNumber--;
		}
	}
?>

</tbody>
</table>
</div>
<div class="write_btn">
	<a href="javascript:column_theme_reg_arr_del_proc();">삭제</a>
	<a href="javascript:column_theme_list_reg();">송출관리</a>
	<a href="/admin/column/column_reg/3?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 click_search(type, id){
	$("#"+id).val(type);
	$("#input_form").submit();
}

function column_theme_list_reg(){
	$("#mode").val('add');
	$("#input_form").attr("action", "/admin/column/column_theme_list_reg/3");
	$("#input_form").submit();
}

// edit
function column_theme_edit(idx){
	$("#idx").val(idx);
	$("#input_form").attr("action", "/admin/column/column_theme_edit/3");
	$("#input_form").submit();
}

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

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