<?
$menu_code = '721';
require_once (APPPATH.'views/skin/admin/_content_comm.php');
?>



<form name="input_form" id="input_form" method="post" action="/admin/cs/cs_faq_list/7">
<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="search_category_code" name="search_category_code" value="<?=$search_category_code?>">


<div class="common_tep clearfix type01">
<? 	if(count($arr_category1) > 0) {?>
	<ul class="clearfix">
<?		foreach ($arr_category1 as $val) {
			$css = '';
			if($search_category1 == $val['category_code']) {
				$css = ' class="on"';
			}
?>
		<li><a href="/admin/cs/cs_faq_list/7?search_category_code=<?=$val['category_code']?>" <?=$css?>><?=$val['category_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="content" <? if($search_type=='content'){ 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>


<? 	if(isset($arr_category2[$search_category1])==true) {?>
<div class="common_tep type2 clearfix">
	<ul class="clearfix">
		<li><a href="/admin/cs/cs_faq_list/7?search_category_code=<?=$search_category1?>" <? if($search_category2=='') { echo 'class="on"';}?>>전체</a></li>
<?
		foreach ($arr_category2[$search_category1] as $val) {
			$css = '';
			if($search_category1.$val['category_code'] == $search_category_code) {
				$css = ' class="on"';
			}
?>
		<li><a href="/admin/cs/cs_faq_list/7?search_category_code=<?=$search_category1.$val['category_code']?>" <?=$css?>><?=$val['category_name']?></a></li>
<?		}?>
	</ul>
</div>
<?	}?>




<div class="common_table">
	<span style="font-weight:bold">Total:</span> <?=number_format($total_count);?>
	<table>
		<thead>
			<th><input type="checkbox" name="allcheck" id="allcheck"></th>
			<th>번호</th>
			<th>1차</th>
			<th>2차</th>
			<th>제목</th>
			<th>글쓴이</th>
			<th>작성일</th>
			<th>조회수</th>
			<th>관리</th>
		</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'];
			$title 			= $val['title'];
			$write_id 		= $val['write_id'];
			$write_name 	= $val['write_name'];
			$reg_date 	    = $val['reg_date'];
            $hit_count 	    = $val['hit_count'];
			$category_name1	= $val['category_name1'];
			$category_name2	= $val['category_name2'];
			$reg_date		= substr($reg_date, 0, 10);

?>

		<tr>
			<td><input type="checkbox" name="is_del[]" value="<?=$idx?>"></td>
			<td><?=$dataNumber?></td>
			<td><?=$category_name1?></td>
			<td><?=$category_name2?></td>
			<td class="title" style="text-align: left"><a href="javascript:faq_reg('<?=$idx?>')"><?=$title?></a></td>
			<td><?=$write_id?>(<?=$write_name?>)</td>
			<td><?=$reg_date?></td>
			<td><?=$hit_count?></td>
			<td class="tool_btn">
				<a href="javascript:faq_reg('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
				<a href="javascript:faq_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>삭제</a>
			</td>
		</tr>

<?
		    $dataNumber--;
		}
	}
?>

	</tbody>
	</table>
</div>

<div class="write_btn">
	<a href="javascript:faq_arr_del_proc()">삭제</a>
	<a href="/admin/cs/cs_faq_reg/7?search_category_code=<?=$search_category_code?>">FAQ등록</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();
}

// edit
function faq_reg(idx){
	$("#idx").val(idx);
	$("#mode").val('edit');
	$("#input_form").attr("action", "/admin/cs/cs_faq_reg/7");
	$("#input_form").submit();
}

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

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