<?php
$member_idx         = $result['idx'];
$member_img         = $result['member_img'];
$member_name        = $result['member_name'];
$member_id          = $result['member_id'];
$member_group_idx   = $result['member_group_idx'];
$member_email       = $result['member_email'];
$member_nickname    = $result['member_nickname'];
$member_birth       = $result['member_birth'];
$member_calendar    = $result['member_calendar'];
$member_gender      = $result['member_gender'];
$member_mobile      = $result['member_mobile'];
$is_member_auth     = $result['is_member_auth'];
$member_church      = $result['member_church'];
$etc1        		= $result['etc1'];
$etc2        		= $result['etc2'];
$etc3        		= $result['etc3'];
$etc4        		= $result['etc4'];
$etc5        		= $result['etc5'];
$is_agree_sms       = $result['is_agree_sms'];
$is_agree_mail      = $result['is_agree_mail'];
$is_agree_info_open = $result['is_agree_info_open'];
$last_login_date    = $result['last_login_date'];
$visit_count        = $result['visit_count'];
$bbs_write_count    = $result['bbs_write_count'];
$reply_write_count  = $result['reply_write_count'];
$sns_type           = $result['sns_type'];

$member_email       = explode("@", $member_email);
$member_email1      = $member_email[0];
$member_email2      = $member_email[1];

$member_birth       = explode("-", $member_birth);
$member_birth1      = $member_birth[0];
$member_birth2      = $member_birth[1];
$member_birth3      = $member_birth[2];

$member_mobile      = explode("-", $member_mobile);
$member_mobile1     = $member_mobile[0];
$member_mobile2     = $member_mobile[1];
$member_mobile3     = $member_mobile[2];

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



<form name="input_form" id="input_form" action="/admin/member/member_edit_proc" method="post" enctype="multipart/form-data">
<input type="hidden" name="member_idx" id="member_idx" value="<?=$member_idx?>">
<input type="hidden" id="search_type" name="search_type" value="<?=$search_type?>">
<input type="hidden" id="search_keyword" name="search_keyword" value="<?=$search_keyword?>">
<input type="hidden" id="search_member_group" name="search_member_group" value="<?=$search_member_group?>">
<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?>">
	
	
	
<div class="common_table news">
<table>
<tr>
	<th>사진</th>
	<td class="tl"><input type="file" name="member_img" id="member_img" class="input00">
	<? 	if($member_img!='') { ?>
		<input type="checkbox" name="is_del_member_img" value="Y">삭제
		<input type="hidden" name="org_member_img" value="<?=$member_img?>">
		<img src="<?=$member_img?>" width="100px">
	<?	} ?>
	</td>
</tr>
<tr>
	<th>이름</th>
	<td class="tl"><?=$member_name?></td>
</tr>
<tr>
	<th>아이디</th>
	<td class="tl"><?=$member_id?></td>
</tr>
<tr>
	<th>이메일</th>
	<td class="tl">
		<input type="text" name="member_email1" id="member_email1" class="type02" size="30" value="<?=$member_email1?>">@<input type="text" name="member_email2" id="member_email2" class="type02" size="30" value="<?=$member_email2?>">
		<select name="select_member_email2" onchange="change_email_domail(this.value);">
			<option name="직접입력" value="">직접입력</option>
			<option value="naver.com">네이버</option>
			<option value="daum.net">다음</option>
			<option value="nate.com">네이트</option>
			<option value="gmail.com">지메일</option>
		</select>
	</td>
</tr>
<tr>
	<th>생년월일</th>
	<td class="tl">
		<input type="text" name="member_birth1" id="member_birth1" class="type02" size="10" value="<?=$member_birth1?>">년 <input type="text" name="member_birth2" id="member_birth2" class="type03" size="10" value="<?=$member_birth2?>">월 <input type="text" name="member_birth3" id="member_birth3" class="type03" size="10" value="<?=$member_birth3?>">일
	</td>
</tr>
<tr>
	<th>음력/양력</th>
	<td class="tl">
		<input type="radio" name="member_calendar" id="member_calendar" value="1" class="input00" <? if($member_calendar=='1') { echo 'checked';}?>> 양력&nbsp;&nbsp;
		<input type="radio" name="member_calendar" id="member_calendar" value="2" class="input00" <? if($member_calendar=='2') { echo 'checked';}?>> 음력
	</td>
</tr>
<tr>
	<th>성별</th>
	<td class="tl">
		<input type="radio" name="member_gender" id="member_gender" value="1" class="input00" <? if($member_gender=='1') { echo 'checked';}?>> 남자&nbsp;&nbsp;
		<input type="radio" name="member_gender" id="member_gender" value="2" class="input00" <? if($member_gender=='2') { echo 'checked';}?>> 여자
	</td>
</tr>
<tr>
	<th>모바일폰</th>
	<td class="tl">
		<?=$member_mobile1?>-<?=$member_mobile2?>-<?=$member_mobile3?>
		<? if($is_member_auth=='Y') { echo '(본인인증완료)'; } else { echo '(본인인증)'; }?>
	</td>
</tr>
</table>



<h2 class="subtitle">옵션정보</h2>
<table>
<tr>
	<th>출석교회</th>
	<td class="tl">
		<input type="text" name="member_church" id="member_church" class="type01" size="40" value="<?=$member_church?>">
	</td>
</tr>
<?	for($i=10;$i<=14;$i++) {
if($member_setting_list[$i]['is_use'] == 'Y' ) {
	$field_value = ${"".$member_setting_list[$i]['item_field_name']};
?>
<tr>
	<th><?=$member_setting_list[$i]['item_title']?></th>
	<td class="tl">
		<input type="text" name="<?=$member_setting_list[$i]['item_field_name']?>" id="<?=$member_setting_list[$i]['item_field_name']?>" class="type01" size="40" value="<?=$field_value?>">
	</td>
</tr>

<?		}
}?>

</table>


<h2 class="subtitle">동의설정</h2>
<table>
<tr>
	<th>SMS수신</th>
	<td class="tl">
		<input type="checkbox" name="is_agree_sms" id="is_agree_sms" class="input00" value="Y" <? if($is_agree_sms=='Y'){ echo 'checked';}?>> SMS 수신을 동의합니다.
	</td>
</tr>
<tr>
	<th>이메일수신</th>
	<td class="tl">
		<input type="checkbox" name="is_agree_mail" id="is_agree_mail" class="input00" value="Y" <? if($is_agree_mail=='Y'){ echo 'checked';}?>> 이메일 수신을 동의합니다.
	</td>
</tr>
<tr>
	<th>정보공개</th>
	<td class="tl">
		<input type="checkbox" name="is_agree_info_open" id="is_agree_info_open" class="input00" value="Y" <? if($is_agree_info_open=='Y'){ echo 'checked';}?>> 정보를 공개합니다.
	</td>
</tr>
</table>


<h2 class="subtitle">기타정보</h2>
<table>
<tr>
	<th>작성글수</th>
	<td class="tl"><?=number_format($bbs_write_count)?></td>
</tr>
<tr>
	<th>작성댓글수</th>
	<td class="tl"><?=number_format($reply_write_count)?></td>
</tr>
<tr>
	<th>방문수</th>
	<td class="tl"><?=number_format($visit_count)?></td>
</tr>
 <tr>
	<th>최종방문일</th>
	<td class="tl"><?=$last_login_date?></td>
</tr>
<tr>
	<th>회원그룹</th>
	<td class="tl">
		<select name="member_group_idx" id="member_group_idx" onchange="chk_member_group();">
			<option value="">선택</option>
	<? 	foreach ($group_list as $val) {?>
			<option value="<?=$val['idx']?>" <? if($member_group_idx==$val['idx']) { echo 'selected';}?>><?=$val['member_group_name']?></option>
	<?	} ?>
		</select>


	</td>
</tr>
</table>
</div>
<div class="write_btn tc">
	<a href="javascript:member_edit_proc();">저장하기</a>
	<a href="/admin/member/member_list/4/<?=$page?>?search_type=<?=$search_type?>&search_keyword=<?=$search_keyword?>&search_member_group=<?=$search_member_group?>&search_member_gender=<?=$search_member_gender?>&search_member_age=<?=$search_member_age?>&search_member_new=<?=$search_member_new?>">목록으로</a>

</div>
</form>







<script type="text/javascript">
function change_email_domail(val){
    $("#member_email2").val(val);
}

function chk_member_group() {
	var now_member_group_idx = "<?=$member_group_idx?>";
	if(now_member_group_idx == '2' || now_member_group_idx == '4' || now_member_group_idx == '5') {	// 2:sns회원, 4:탈퇴회원, 5:영구회원 는 수정 안되게
		alert("현재 그룹은 변경할 수 없습니다.");
		$("#member_group_idx").val(now_member_group_idx).prop("selected", true);
		return false;
	}
	return true
}


function member_edit_proc(){
    var member_email = $("#member_email1").val()+"@"+$("#member_email2").val();
    if(checkEmail(member_email)==false) {
		alert("이메일을 확인해주세요.");
		return false;
	}

	var member_birth = $("#member_birth1").val()+$("#member_birth2").val()+$("#member_birth3").val();
    if(checkNumber(member_birth)==false) {
		alert("생년월일을 확인해주세요.");
		return false;
	}

	if($("#member_group_idx").val()=='') {
		alert("회원그룹을 선택해주세요.");
		return false;
	}
	var now_member_group_idx = "<?=$member_group_idx?>";
	var member_group_idx = $("#member_group_idx").val();
	if(chk_member_group()==false) {
		alert("현재 그룹은 변경할 수 없습니다.");
		return;
	}
	if(now_member_group_idx != '4' && now_member_group_idx != '5') {
		if(member_group_idx == '4' || member_group_idx == '5') {	// 4:탈퇴회원, 5:영구회원로 변경할때 알림창
			if(confirm("탈퇴회원으로 변경하겠습니까?") == false) {    //확인
				return;
			}
		}
	}

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


}
</script>