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


$arr_status = array();
foreach ($status_list as $val) {
	$arr_status[$val['blind_status']] = $val['cnt'];
}

?>



<form name="input_form" id="input_form" method="post" action="/admin/setting/blind_list/1">
<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="status" name="status">
<input type="hidden" id="search_status" name="search_status" value="<?=$search_status?>">


<div class="common_table clearfix type01">
	<div class="searh_area">
		<select name="search_type" id="search_type">
		 	<option value="" <? if($search_type==''){ echo 'selected';}?>>선택</option>
		 	<option value="blind_comment" <? if($search_type=='blind_comment'){ echo 'selected';}?>>댓글내용</option>
			<option value="blind_id" <? if($search_type=='blind_id'){ echo 'selected';}?>>신고대상아이디</option>
			<option value="blind_name" <? if($search_type=='blind_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" style="margin-top: 30px">
	<span><a href="/admin/setting/blind_list/1"><b>Total:</b> <?=number_format($total_count);?></a></span>
<?
foreach ($def_arr_blind_status as $key=>$val) {
	switch ($key) {
		case '0' : $class="text_green"; break;
		case '1' : $class="text_blue"; break;
		case '2' : $class="text_red"; break;
	}

	$count = 0;
	if(isset($arr_status[$key])==true)	$count = $arr_status[$key];

?>
	<span style="margin-left:10px"><a href="/admin/setting/blind_list/1?search_status=<?=$key?>" class="<?=$class?>" ><b><?=$val?>:</b> <?=number_format($count);?></a></span>
<?
}
?>
	<span style="margin-left:10px">본인삭제: <?=number_format($self_del_count)?></span>

	<div class="searh_area">
		<select name="search_spam_reason" onchange="check_search();" style="width:100px">
			<option value="">신고사유</option>
	<? 	foreach ($def_arr_spam_reason as $key=>$val) {?>
			<option value="<?=$key?>" <? if($search_spam_reason==$key){ echo 'selected';}?>><?=$val?></option>

	<? 	}?>
		</select>
		<select name="search_content_type" onchange="check_search();" style="width:100px">
			<option value="">카테고리</option>
	<? 	foreach ($def_arr_content as $key=>$val) {?>
			<option value="<?=$key?>" <? if($search_content_type==$key){ echo 'selected';}?>><?=$val?></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>
	</tr>
	</thead>
	<tbody>


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

	} else {

		$now_date = date("Y-m-d");
	    $dataNumber = ($total_count + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx            	= $val['idx'];
			$reason_type 		= $val['reason_type'];
			$blind_status 		= $val['blind_status'];
			$blind_id       	= $val['blind_id'];
			$blind_name			= $val['blind_name'];
			$blind_comment		= $val['blind_comment'];
			$spam_count			= $val['spam_count'];
			$admin_spam_count	= $val['admin_spam_count'];
			$content_type		= $val['content_type'];
			$blind_status		= $val['blind_status'];

			$arr_reason_type = explode(",", $reason_type);

			$reason_txt	= '';
			$reason_count  = count($arr_reason_type);
			if($reason_type > 0 && $reason_count > 0) {
				$reason_txt = $def_arr_spam_reason[$arr_reason_type[0]];
				if($reason_count > 1) {
					$reason_txt.=' 외 '.($reason_count-1).'개';
				}
			}
            $content_txt  		= $def_arr_content[$content_type];

			switch ($blind_status) {
				case '0': $blind_status_txt = '<span class="text_green">블라인드 해지</span>'; 	break;
				case '1': $blind_status_txt = '<span class="text_blue">블라인드</span>';		break;
				case '2': $blind_status_txt = '<span class="text_red">블라인드 승인</span>';	break;
			}


?>

			<tr>
				<td><?=$dataNumber?></td>
				<td><?=$reason_txt?></td>
				<td><?=$content_txt?></td>
				<td><?=$blind_id?>(<?=$blind_name?>)</td>
				<td class="title" style="text-align:left;">
					<a href="javascript:blind_view('<?=$idx?>')"><?=$blind_comment?></a>
				</td>
				<td><?=number_format($spam_count)?></td>
				<td><?=number_format($admin_spam_count)?></td>
				<td><?=$blind_status_txt?></td>
				<td class="tool_btn">
					<? if($blind_status == '1') {?>
						<a href="javascript:blind_status_proc('2', '<?=$idx?>')"><i class="fa fa-pencil"></i>블라인드승인</a>
						<a href="javascript:blind_status_proc('0', '<?=$idx?>')"><i class="fa fa-close"></i>블라인드해지</a>
					<? }?>

				</td>

			</tr>

<?
		    $dataNumber--;
		}
	}
?>
</tbody>
</table>

<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 media_list_reg(){
	$("#mode").val('add');
	$("#input_form").attr("action", "/admin/etc_section/media_list_reg/6");
	$("#input_form").submit();
}


// view
function blind_view(idx){
	$("#idx").val(idx);
	$("#input_form").attr("action", "/admin/setting/blind_view/1");
	$("#input_form").submit();
}



//  블라인드 승인 / 해지
function blind_status_proc(status, idx) {
	if(status == '0') {
		var msg = "블라인드를 해지하시겠습니까?";
	} else {
		var msg = "블라인드를 승인하시겠습니까?";
	}

	if(confirm(msg) == true) {    //확인
		$("#idx").val(idx);
		$("#status").val(status);
		$("#input_form").attr("action", "/admin/setting/blind_status_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}





</script>