<?php
$SES_MEMBER_ID          = $this->session->userdata('C_Member_Id');
?>


	<div class="contents">
		<div class="mypage_right" style="min-height: 900px;">
			<div class="mypage_right_top">
				<h2 class="mypage_title">1:1 문의</h2>
			</div>
			<div style="margin:10px 0;overflow:hidden" >
	            <span><a href="/web/mypage/qna_add" class="fr btn btn-default_bb">글쓰기</a></span>
			</div>
			<form name="input_form" id="input_form" method="post">
			<div>
				<table class="table board">
					<thead>
						<tr>
							<th class="mypage_tbl_box10"><input name="allcheck" id="allcheck" type="checkbox"></th>
							<th class="mypage_tbl_box10">번호</th>
							<th class="mypage_tbl_box60" style="text-align:center">제목</th>
							<th class="mypage_tbl_box10" style="text-align:left">글쓴이 </th>
							<th class="mypage_tbl_box20">날짜 </th>
						</tr>
					</thead>
					<tbody>
                <?
				if($total_count==0) {
					echo '<tr><td colspan="5" align="center">등록된 문의가 없습니다.</td></tr>';

				} else {
                    foreach ($list as $val) {
                        $title          = $val['title'];
                        $write_name     = $val['write_name'];
                        $reg_date       = $val['reg_date'];
                        $reg_date_txt   = str_replace('-', '.', $reg_date);
                        $reg_date_txt   = substr($reg_date_txt, 0, 10);

                        $class = ''; $write_class = '';
                        if($val['s_idx'] > 1){
                            $class = ' class="btn-reply"';
                            $title = '<img src="/img/web/mypage_reply.gif">'.$title;
                            $write_class = ' beachblue';
                        }
                ?>
						<tr>
							<th scope="row"><?	if($val['write_id'] ==$SES_MEMBER_ID) {?><input value="<?=$val['idx']?>"  name="is_del[]" type="checkbox"><?}?></th>
							<td class="no"><?=number_format($data_num)?></th>
							<td<?=$class?>><a href="/web/mypage/qna_view/<?=$val['idx']?>?search_type=<?=$search_type?>&search_keyword=<?=$search_keyword?>&data_num=<?=$data_num?>"><?=$title?></a><span class="chain"><img src="/img/web/chain.jpg"></span></td>
							<td class="writer<?=$write_class?>"><a href=""><?=$write_name?></a></td>
							<td class="date"><?=$reg_date_txt?></td>
						</tr>
                <?
                        $data_num--;
                    }

                }
				?>

					</tbody>
				</table>
			</div>
			<ul class="pagenumber2"><?=$pagination?></ul>
			<div class="fr btns" style="margin-top: 0px">
				<span><a href="/web/mypage/qna_add" class="fr btn btn-default_bb">글쓰기</a></span>
			<? if($total_count > 0){ ?><span><a href="javascript:qna_arr_del();" class="fr btn btn-default_bb">삭제</a></span><?}?>
			</div>
			<div class="slct_box" style="width: 500px; margin: 0 auto; border-bottom:0;">
				<span class="slct">
				   <select id="search_type" name="search_type">
					   <option value="total" <? if($search_type=='total') { echo 'selected'; }?>>제목+본문</option>
				   </select>
				</span>
				<span class="srch">
					<span><input name="search_keyword" id="search_keyword" placeholder="내용검색" type="text" value="<?=$search_keyword?>"><a href="javascript:search_list()"><img src="/img/web/mypage_serch_icon.gif" alt="검색하기"></a></span>
				</span>
			</div>
			</form>
		</div>
	</div>



<script>
// 검색
function search_list(){
	if($("#search_keyword").val()==''){
		alert("검색할 내용을 입력해주세요.");
		return false;
	}
	$("#input_form").attr("action", "/web/mypage/qna");
	$("#input_form").submit();
}


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