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

$arr_category_add1 = array();
$arr_category_add2 = array();
foreach ($arr_category1 as $key=>$val) {
    $arr_category_add1[] = array('category_code'=>$val['idx'], 'category_name'=>$val['category_name']);
}

foreach ($arr_category2 as $key=>$val) {
	$arr_category_add2[$val['category_idx']][] = array('category_code'=>$val['idx'], 'category_name'=>$val['channel_name']);
}


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

?>



<form name="input_form" id="input_form" method="post" action="/admin/life/life_ranking_log_list/5">
<input type="hidden" id="search_ranking_type" name="search_ranking_type" value="<?=$search_ranking_type?>">
<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_tep clearfix type01">
	<ul class="clearfix">
		<li><a href="/admin/life/life_ranking_log_list/5" <? if($search_ranking_type=='') { echo 'class="on"';}?>>전체</a></li>
<?  foreach($def_arr_ranking as $val) {
		$css = '';
		if($search_ranking_type == $val['code']) {
			$css = ' class="on"';
		}
?>
		<li><a href="/admin/life/life_ranking_log_list/5?search_ranking_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="title" <? if($search_type=='title'){ echo 'selected';}?>>제목</option>
            <option value="editor_name" <? if($search_type=='editor_name'){ 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 clearfix" style="margin-top: 30px">
	<span style="font-weight:bold">Total:</span> <?=number_format($total_count);?>

	<div class="searh_area">

        <select name="search_life_type" onchange="category_search()">
				<option value="">기능</option>
<?	if(count($def_arr_life_type) > 0) {
		foreach ($def_arr_life_type as $key=>$val) {?>
				<option value="<?=$key?>" <? if($search_life_type==$key) { echo 'selected'; }?>><?=$val?></option>
<?		}
	}	?>
			</select>



		<select name="search_category_code1" onchange="category_search()">
							<option value="">카테고리</option>
			<?	if(count($arr_category_add1) > 0) {
			 		foreach ($arr_category_add1 as $val) {?>
							<option value="<?=$val['category_code']?>" <? if($search_category_code1==$val['category_code']) { echo 'selected'; }?>><?=$val['category_name']?></option>
			<?		}
				}	?>
						</select>
						<select name="search_category_code2" onchange="category_search()">
							<option value="">채널</option>
			<?	if(isset($arr_category_add2[$search_category_code1])==true) {
			 		foreach ($arr_category_add2[$search_category_code1] as $val) {
			?>
							<option value="<?=$val['category_code']?>" <? if($search_category_code2==$val['category_code']) { echo 'selected'; }?>><?=$val['category_name']?></option>
			<?		}
				}
			?>
            </select>


	</div>
</div>





<div class="common_table">
	<table>
	<thead>
		<tr>
			<th>순위</th>
			<th>썸네일</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="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'];
			$category_name1 = $val['category_name1'];
			$category_name2 = $val['category_name2'];
			$ranking_type 	= $val['ranking_type'];
			$life_type 	    = $val['life_type'];
			$editor_name    = $val['editor_name'];
			$reg_date 	    = $val['reg_date'];
            $hit_count 	    = $val['hit_count'];
            $like_count 	= $val['like_count'];
            $comment_count 	= $val['comment_count'];
            $rank 	        = $val['rank'];
            $content_idx 	= $val['content_idx'];

            $ranking_type_txt   = $def_arr_ranking[$ranking_type]['name'];
            $life_type_txt      = $def_arr_life_type[$life_type];

?>

			<tr>
				<td><?=$rank?></td>
				<td><img src="<?=$main_img?>" width="35"></td>
				<td><?=$ranking_type_txt?></td>
				<td><a href="/admin/life/life_category_list/5?search_type=category_name&search_keyword=<?=$category_name1?>"><?=$category_name1?></a></td>
				<td><a href="/admin/life/life_channel_list/5?search_type=channel_name&search_keyword=<?=$category_name2?>"><?=$category_name2?></a></td>
				<td><?=$life_type_txt?></td>
				<td style="text-align:left;" class="title"><a href="/admin/life/life_reg/5?mode=edit&idx=<?=$content_idx?>"><?=$title?></a></td>
				<td><a href="/admin/life/life_list/5?search_type=editor_name&search_keyword=<?=$editor_name?>"><?=$editor_name?></a></td>
				<td><?=$reg_date?></td>
				<td><?=$hit_count?></td>
				<td><?=$like_count?></td>
				<td><?=$comment_count?></td>
			</tr>

<?
		    $dataNumber--;
		}
	}
?>
	</tbody>
	</table>
</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 category_search(){
	$("#input_form").submit();
}





</script>