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

if($search_comment_type == 'Y') {
	$menu_code = '262';
} else {
	$menu_code = '261';
}
require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>



<form name="input_form" id="input_form" method="post" action="/admin/news/news_comment_list/2">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="search_comment_type" name="search_comment_type" value="<?=$search_comment_type?>">
<input type="hidden" id="search_today" name="search_today" value="<?=$search_today?>">
<input type="hidden" id="search_today_best" name="search_today_best" value="<?=$search_today_best?>">
<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="write_name" <? if($search_type=='write_name'){ echo 'selected';}?>>닉네임</option>
                    <option value="write_id" <? if($search_type=='write_id'){ echo 'selected';}?>>아이디</option>
                    <option value="comment" <? if($search_type=='comment'){ 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">
	<span style="font-weight:bold">Total:</span> <?=number_format($total_count);?>
	<a href="javascript:search_today();"><span style="font-weight:bold">오늘신규:</span> <?=number_format($new_count);?></a>
	<a href="/admin/news/news_comment_list/2?search_comment_type=Y"><span style="font-weight:bold" class="text_red">배댓전체:</span> <?=number_format($best_count);?></a>
	<a href="javascript:search_today_best();"><span style="font-weight:bold" class="text_blue">오늘의배댓:</span> <?=number_format($best_new_count);?></a>
	<div class="searh_area">
		<select name="search_news_type" onchange="check_search();">
			   <option value="">기능별</option>
		<?  foreach ($def_arr_news_type as $key=>$val) {?>
				<option value="<?=$key?>" <? if($search_news_type==$key){ echo 'selected';}?>><?=$val?></option>
		<?  }?>
		</select>


		<select name="search_theme_type" onchange="check_search();">
			   <option value="">테마별</option>
		<?  foreach ($def_arr_news_theme as $val) {?>
				<option value="<?=$val['code']?>" <? if($search_theme_type==$val['code']){ echo 'selected';}?>><?=$val['name']?></option>
		<?  }?>
		</select>
	</div>
</div>





<div class="common_table">
	<table>

<?
	if(count($list)==0) {
?>
		<tr><td>등록된 내용이 없습니다.</td></tr>
<?
	} else {
		$now_date = date("Y-m-d");
	    $dataNumber = ($total_count + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx            = $val['idx'];
            $p_idx      	= $val['p_idx'];
			$member_img 	= $val['member_img'];
			$write_name 	= $val['write_name'];
			$write_id 		= $val['write_id'];
			$reg_date 		= $val['reg_date'];
			$like_count		= $val['like_count'];
			$bad_count		= $val['bad_count'];
			$title       	= $val['title'];
			$press_name 	= $val['press_name'];
			$reporter_name 	= $val['reporter_name'];
			$news_type 	    = $val['news_type'];
			$theme_types 	= $val['theme_types'];
			$comment 	    = $val['comment'];
			$category_name1 = $val['category_name1'];
			$category_name2 = $val['category_name2'];
			$category_name3 = $val['category_name3'];
			$content_idx 	= $val['content_idx'];
			$is_best 	    = $val['is_best'];
			$best_txt = '';
			if($is_best == 'Y') {
				$best_txt = '[best]';
			}


			$category_name = $category_name1;
			if($category_name2!='')	$category_name.= '> '.$category_name2;
			if($category_name3!='')	$category_name.= '> '.$category_name3;

			$parent_comment = '';
			if($p_idx!=$idx) {
				# model - 카테고리 list
				$ci=& get_instance();
        		$ci->load->model('admin/comm/m_comment');
        		$arr_parent_comment    = $ci->m_comment->comment_where_p_idx_select($p_idx);
				if(count($arr_parent_comment) > 0) {
					$parent_comment = '</br></br>---------------- 원댓글 내용 --------------------</br>';
					$parent_comment.= $arr_parent_comment['comment'];

				}
			}
			$comment = $comment.$parent_comment.'<p>&nbsp;</p>';

?>
				<tr>
					<th style="text-align: left">
                       <img src="<?=$member_img?>" width="25"> <?=$write_name?>(<?=$write_id?>) <?=$reg_date?>
                    </th>
					<th style="text-align: right">
						<?=$best_txt?> <img src="/img/web/img_thumbup.jpg" style="vertical-align:middle;margin-top:-3px;"><?=number_format($like_count)?> <img src="/img/web/img_thumbdown.jpg" style="vertical-align:middle;margin-top:-3px;"><?=number_format($bad_count)?>
						<button type="button" class="btn_s_blue" style="width:40px" onclick="news_comment_del_proc('<?=$idx?>');" style="cursor: pointer;">삭제</button>
					</th>
				</tr>
				<tr>
					<td style="text-align: left">
						<a href="/web/news/news_view/<?=$content_idx?>" target="_blank">[<?=$category_name?>]</br><?=$title?></a>
					</td>
					<td style="text-align:right"><?=$def_arr_news_type[$news_type]?> | <?=$press_name?> | <?=$reporter_name?>기자</td>
				</tr>
                <tr>
					<td style="text-align:left;vertical-align: top" colspan="2"><?=$comment?></td>
				</tr>


<?
		    $dataNumber--;
		}
	}
?>


</table>

<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 search_today(){
	$("#search_today").val('Y');
	$("#input_form").submit();
}

function search_today_best(){
	$("#search_today_best").val('Y');
	$("#input_form").submit();
}


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


</script>