<?php
$arr_default_member_age     = array(array('code'=>10, 'txt'=>'10대'), array('code'=>20, 'txt'=>'20대'), array('code'=>30, 'txt'=>'30대'), array('code'=>40, 'txt'=>'40대'), array('code'=>50, 'txt'=>'50대'), array('code'=>60, 'txt'=>'60대'), array('code'=>70, 'txt'=>'70대'), array('code'=>80, 'txt'=>'80대이상'));
$arr_default_member_gendar  = array(array('code'=>1, 'txt'=>'남'), array('code'=>2, 'txt'=>'여'));
$arr_default_member_group   = array(array('code'=>'3', 'txt'=>'불량회원'), array('code'=>'5', 'txt'=>'영구탈퇴'));

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



<form name="input_form" id="input_form" method="post" action="/admin/member/member_list/4">
<input type="hidden" id="search_member_gender" name="search_member_gender" value="<?=$search_member_gender?>">
<input type="hidden" id="search_member_age" name="search_member_age" value="<?=$search_member_age?>">
<input type="hidden" id="search_member_new" name="search_member_new" value="<?=$search_member_new?>">
<input type="hidden" id="page" name="page" value="<?=$page?>">
<input type="hidden" id="member_idx" name="member_idx">
<input type="hidden" id="search_member_group" name="search_member_group" value="<?=$search_member_group?>">
<input type="hidden" id="member_id" name="member_id">

<div class="common_tep clearfix type01">

	<ul class="clearfix">
		<li><a href="/admin/member/member_list/4" <? if($search_member_group=='') { echo 'class="on"';} ?>>전체</a></li>
<?		foreach ($group_list as $val) {
			$css = '';
			if($search_member_group == $val['idx']) {
				$css = ' class="on"';
			}
?>
		<li><a href="/admin/member/member_list/4?search_member_group=<?=$val['idx']?>" <?=$css?>><?=$val['member_group_name']?></a></li>
<?
		}?>
	</ul>

	<div class="searh_area">
		<select name="search_type" id="search_type">
			<option value="">선택</option>
			<option value="member_nickname" <? if($search_type=='member_nickname'){ echo 'selected';}?>>닉네임</option>
			<option value="member_id" <? if($search_type=='member_id'){ echo 'selected';}?>>아이디</option>
            <option value="member_name" <? if($search_type=='member_name'){ echo 'selected';}?>>이름</option>
			<option value="member_church" <? if($search_type=='member_church'){ echo 'selected';}?>>출석교회</option>
			<option value="etc2" <? if($search_type=='etc2'){ 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 style="font-weight:bold">Total:</span> <?=number_format($total_count);?>

	 <span style="margin-left:20px">
    <?
        foreach ($arr_default_member_gendar as $val) {
            $member_gender_count = 0;
            if(isset($arr_member_gender[$val['code']])==true) {
                $member_gender_count = $arr_member_gender[$val['code']];
            }
	?>
			<b><?=$val['txt']?>:</b> <a href="javascript:click_search('search_member_gender', '<?=$val['code']?>');"><?=number_format($member_gender_count)?></a>&nbsp;&nbsp;
    <?
        }
    ?>
        </span>
        <span style="margin-left:20px">
    <?
        foreach ($arr_default_member_group as $val) {
            $member_group_count = 0;
            if(isset($arr_member_group[$val['code']])==true) {
                $member_group_count = $arr_member_group[$val['code']];
            }
            echo '<b>'.$val['txt'].':</b> '.number_format($member_group_count).'&nbsp;&nbsp;';
        }
    ?>
        </span>
        <span style="margin-left:20px"><b>오늘신규가입:</b> <a href="javascript:click_search('search_member_new', 'today');"><?=number_format($member_new_count);?></a></span>
	</ul>
    <ul style="text-align:left; padding-top:10px; padding-bottom:10px;">
        <span>
    <?
        foreach ($arr_default_member_age as $val) {
            $member_age_count = 0;
            if(isset($arr_member_age[$val['code']])==true) {
                $member_age_count = $arr_member_age[$val['code']];
            }
	?>
			<b><?=$val['txt']?>:</b> <a href="javascript:click_search('search_member_age', '<?=$val['code']?>');"><?=number_format($member_age_count)?></a>&nbsp;&nbsp;
    <?
        }
    ?>
        </span>


</div>




<!-- 테이블 시작-->
<div class="common_table">
<table>
	<thead>
		<th>번호</th>
		<th>사진</th>
		<th>구분</th>
		<th>닉네임</th>
		<th>아이디</th>
		<th>이름</th>
		<th>성별</th>
		<th>가입일</th>
		<th>최종방문</th>
		<th>방문수</th>
		<th>출석교회</th>
		<th>담임목사</th>
		<th>관리</th>
	</thead>
	<tbody>

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

	    $dataNumber = ($total_rows + $limit)-($page*$limit);
		foreach($list as $val) {
            $idx                = $val['idx'];
			$member_img 	    = $val['member_img'];
			$member_name 	    = $val['member_name'];
			$member_id 	        = $val['member_id'];
			$member_group_name 	= $val['member_group_name'];
			$member_nickname 	= $val['member_nickname'];
			$member_gender 	    = $val['member_gender'];
			$reg_date 	        = $val['reg_date'];
			$last_login_date 	= $val['last_login_date'];
			$visit_count 	    = $val['visit_count'];
			$member_church 	    = $val['member_church'];
			$etc2 	    		= $val['etc2'];

            $member_gender_txt = '여';
            if($member_gender == 1) $member_gender_txt = '남';

?>

				<tr>
					<td><?=$dataNumber?></td>
                    <td><img src="<?=$member_img?>" width="40"></td>
					<td><?=$member_group_name?></td>
					<td><?=$member_nickname?></td>
                    <td><?=$member_id?></td>
                    <td><?=$member_name?></td>
                    <td><?=$member_gender_txt?></td>
                    <td><?=$reg_date?></td>
                    <td><?=$last_login_date?></td>
                    <td><?=number_format($visit_count)?></td>
					<td><?=$member_church?></td>
					<td><?=$etc2?></td>
					<td style="width:200px" class="tool_btn">
						<a href="javascript:member_edit('<?=$idx?>')"><i class="fa fa-pencil"></i>수정</a>
						<a href="javascript:member_del_proc('<?=$idx?>')"><i class="fa fa-close"></i>탈퇴</a>
						<a href="javascript:member_comment_del_proc('<?=$member_id?>')"><i class="fa fa-close"></i>전체글삭제</a>
						<a href="javascript:popup_member_comment_view('<?=$member_id?>')"><i class="fa fa-file"></i>전체댓글보기</a>
					</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;
    } else {
    	$("#input_form").submit();
	}
}

function click_search(id, code){
	$("#search_type").val('');
	$("#search_keyword").val('');
	$("#search_member_group").val('');
	$("#search_member_gender").val('');
	$("#search_member_age").val('');
	$("#search_member_new").val('');

	$("#"+id).val(code);

	$("#input_form").submit();

}

// 회원수정페이지로
function member_edit(idx){
	$("#member_idx").val(idx);
	$("#input_form").attr("action", "/admin/member/member_edit/4");
	$("#input_form").submit();
}

// 회원탈퇴
function member_del_proc(idx) {
	if(confirm("회원이 탈퇴처리됩니다. 진행하시겠습니까?") == true) {    //확인
		$("#member_idx").val(idx);
		$("#input_form").attr("action", "/admin/member/member_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}

// 회원의 모든 댓글 삭제
function member_comment_del_proc(member_id) {
	if(confirm("회원의 모든 댓글이 삭제됩니다. 진행하시겠습니까?") == true) {    //확인
		$("#member_id").val(member_id);
		$("#input_form").attr("action", "/admin/member/member_comment_all_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}



// 전체글보기
function popup_member_comment_view(member_id){
	window.open("/admin/member/member_comment_list/4?member_id="+member_id, "", "width=650, height=600, resizable=no, scrollbars=no, status=no;");

}






</script>