<?php

$partner_img        = '';
$partner_name       = '';
$partner_id         = '';
$partner_gender     = '';
$partner_mobile1    = '';
$partner_mobile2    = '';
$partner_mobile3    = '';
$partner_real_name 	= '';
$partner_email1     = '';
$partner_email2     = '';
$write_count        = 0;
$hit_count          = 0;
$visit_count        = 0;
$last_login_date    = '';
$display_sort		= 0;
if($mode=='edit') {
	if(count($result)==0) {
		gf_alert("잘못된 접근입니다.", '/admin/main');
		exit;
	}

	$partner_img        = $result['partner_img'];
	$partner_name       = $result['partner_name'];
	$partner_id         = $result['partner_id'];
	$partner_gender     = $result['partner_gender'];
	$partner_mobile    	= $result['partner_mobile'];
	$partner_real_name 	= $result['partner_real_name'];
	$partner_email     	= $result['partner_email'];
	$last_login_date    = $result['last_login_date'];
	$display_sort    	= $result['display_sort'];

    if($partner_email!='') {
        $partner_email       = explode("@", $partner_email);
        $partner_email1      = $partner_email[0];
        $partner_email2      = $partner_email[1];
    }

    if($partner_mobile!='') {
        $partner_mobile     = explode("-", $partner_mobile);
        $partner_mobile1    = $partner_mobile[0];
        $partner_mobile2    = $partner_mobile[1];
        $partner_mobile3    = $partner_mobile[2];
    }

}


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

$admin_type = $this->session->userdata('Adm_Type');

?>



<form name="input_form" id="input_form" action="/admin/member/columnist_reg_proc" method="post" enctype="multipart/form-data">
<input type="hidden" name="mode" id="mode" value="<?=$mode?>">
<input type="hidden" name="idx" id="idx" value="<?=$idx?>">
<input type="hidden" name="sort" id="sort" value="<?=$sort?>">
<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="page" name="page" value="<?=$page?>">

<div class="common_table news">
<table>
<tr>
	<th>사진</th>
	<td class="tl"><input type="file" name="partner_img" id="partner_img" class="input00">
	<? 	if($partner_img!='') { ?>
		<input type="checkbox" name="is_del_partner_img" value="Y">삭제
		<input type="hidden" name="org_partner_img" value="<?=$partner_img?>">
		<img src="<?=$partner_img?>" width="100px">
	<?	} ?>
	</td>
</tr>
<tr>
	<th>칼럼명</th>
	<td class="tl">
<? 	if($mode=='add' || $admin_type == '0') { ?>
		<input type="text" name="partner_name" id="partner_name" class="type02" size="30" value="<?=$partner_name?>">
<?	} else {?>
		<input type="hidden" name="partner_name" id="partner_name" class="type02" size="30" value="<?=$partner_name?>"><?=$partner_name?>

<? 	}?>
		</td>
</tr>
<tr>
	<th>이름</th>
	<td class="tl"><input type="text" name="partner_real_name" id="partner_real_name" class="type02" size="30" value="<?=$partner_real_name?>"></td>
</tr>
<tr>
	<th>아이디</th>
	<td class="tl">
	<? 	if($mode=='add') {?>
		<input type="text" name="partner_id" id="partner_id" class="type02" size="30" value="<?=$partner_id?>"> <button type="button" class="btn_black" style="width:100px" onclick="partner_id_check();" style="cursor: pointer;">중복체크</button>
	<?	} else {?>
			<input type="hidden" name="partner_id" id="partner_id" class="input00" size="30" value="<?=$partner_id?>">
			<?=$partner_id?>
	<?	} ?>
		</td>
</tr>
 <tr>
	<th>비밀번호</th>
	<td class="tl"><input type="password" name="partner_pwd" id="partner_pwd" class="type02" size="30"></td>
</tr>

 <tr>
	<th>비밀번호확인</th>
	<td class="tl"><input type="password" name="partner_re_pwd" id="partner_re_pwd" class="type02" size="30"></td>
</tr>
 <tr>
	<th>이메일</th>
	<td class="tl">
		<input type="text" name="partner_email1" id="partner_email1" class="type02" size="30" value="<?=$partner_email1?>">@<input type="text" name="partner_email2" id="partner_email2" class="type02" size="30" value="<?=$partner_email2?>">
		<select name="select_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="radio" name="partner_gender" id="partner_gender1" value="1" class="input00" <? if($partner_gender=='1') { echo 'checked';}?>> 남자&nbsp;&nbsp;
		<input type="radio" name="partner_gender" id="partner_gender2" value="2" class="input00" <? if($partner_gender=='2') { echo 'checked';}?>> 여자
	</td>
</tr>
<tr>
	<th>모바일폰</th>
	<td class="tl">
		<input type="text" name="partner_mobile1" id="partner_mobile1" size="10" class="type02" value="<?=$partner_mobile1?>">-
		<input type="text" name="partner_mobile2" id="partner_mobile2" size="10" class="type02" value="<?=$partner_mobile2?>">-
		<input type="text" name="partner_mobile3" id="partner_mobile3" size="10" class="type02" value="<?=$partner_mobile3?>">
	</td>
</tr>

<tr>
	<th>출력순위</th>
	<td class="tl">
		<? if($admin_type=='0') {?>
		<input type="text" name="display_sort" id="display_sort" size="10" class="type02" value="<?=$display_sort?>">
		<?	} else { ?>
		<input type="hidden" name="display_sort" id="display_sort" size="10" class="type02" value="<?=$display_sort?>"><?=$display_sort?>
		<?	}?>
	</td>
</tr>

</table>
	
	
	
<? if($mode=='edit') {?>
<h2 class="subtitle">기타정보</h2>
<table>

<tr>
	<th>작성글수</th>
	<td class="tl"><?=number_format($write_count)?></td>
</tr>
<tr>
	<th>받은조회수</th>
	<td class="tl"><?=number_format($hit_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>

</table>

<?  }?>
</div>
<div class="write_btn tc">
	<a href="javascript:columnist_reg_proc();">저장하기</a>
<?	if($admin_type == '0') { ?>
	<a href="/admin/member/columnist_list/4/<?=$page?>?search_type=<?=$search_type?>&search_keyword=<?=$search_keyword?>">목록으로</a>
<?	}?>
</div>

</form>







<script type="text/javascript">
function partner_id_check(){
	if($("#partner_id").val()=='') {
		alert("아이디를 입력해주세요.");
		return false;
	}
	var form_data = {
		"partner_id"	: $("#partner_id").val()
    };
    $.ajax({
        url: '/admin/member/partner_id_check_proc',
        sync: false,
        type: 'POST',
        dataType: 'json',
        data: form_data,
        success: function (rtn_json) {
        	if(rtn_json.result_code!='0000') {
				alert("사용할수없는 아이디입니다.");
				$("#partner_id").val('');
				return false;
			} else {
				alert("사용가능한 아이디입니다.");
				return false;
			}
        },
        error: function (rtnHtml) {
            return false;
        }
    });

}


function change_email_domail(val){
    $("#partner_email2").val(val);
}

function columnist_reg_proc(){
	if($("#partner_write_name").val()=='') {
		alert("칼럼명을 입력해주세요.");
		return false;
	}
	if($("#partner_name").val()=='') {
		alert("이름을 입력해주세요.");
		return false;
	}
	if($("#partner_id").val()=='') {
		alert("아이디를 입력해주세요.");
		return false;
	}

<? if($mode=='add') {?>

	var idReg =  /^[A-za-z0-9]/g;
	if( !idReg.test( $("#partner_id").val() ) ) {
		alert("아이디는 영문자 또는 숫자여여 합니다.");
		return;
	}

	if($("#partner_pwd").val()=='') {
		alert("비밀번호를 입력해주세요.");
		return false;
	}
<?  }?>
    if($("#partner_pwd").val()!='') {
		if($("#partner_pwd").val()!=$("#partner_re_pwd").val()) {
		    alert("비밀번호를 확인해주세요.");
            return false;
        }
	}

    var partner_email = $("#partner_email1").val()+"@"+$("#partner_email2").val();
    if(checkEmail(partner_email)==false) {
		alert("이메일을 확인해주세요.");
		return false;
	}

	var mobile = $("#partner_mobile1").val()+$("#partner_mobile2").val()+$("#partner_mobile3").val();
	if(mobile !='') {
		if(checkNumber(mobile)==false) {
			alert("모바일폰을 확인해주세요.");
			return false;
		}
	}


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


}

</script>