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

<form name="input_form" id="input_form" method="post">
<input type="hidden" name="member_type" value="<?=$member_type?>">
<input type="hidden" name="page" value="<?=$page?>">
<input type="hidden" name="mode" id="mode">

	
<div class="common_tep clearfix type01" style="margin-bottom: 30px">
	<ul class="clearfix">
		<li><a href="/admin/member/member_group_list/4/1?member_type=1" <? if($member_type=='1') { echo 'class="on"';}?>>일반</a></li>
		<li><a href="/admin/member/member_group_list/4/1?member_type=2" <? if($member_type=='2') { echo 'class="on"';}?>>파트너</a></li>
	</ul>

</div>

- 회원그룹관리에서 생성된 회원그룹의 레벨을 설정합니다.</br>
- 레벨업 설정값은 자유롭게 입력이 가능하며 회원의 활동이 설정 조건에 일치할때 해당하는 레벨에 적용되어 레벨업 됩니다.</br>
- 사용안함을 체크하시면 체크된 레벨에 해당하는 회원은 다른 레벨로의 이동이나 변경이 불가능하며 다른레벨에서 체크된 레벨로 이동/변경도 차단됩니다.</br>



<div class="common_table">
<table>
<thead>
	<tr>
		<th><input type="checkbox" id="allCheck"></th>
		<th>회원그룹명</th>
		<th>사용안함</th>
		<th>관리</th>
	</tr>
</thead>
<tbody>
	
<?
	if(count($list)==0) {
?>
	<tr>
		<td colspan="4">등록된 내용이 없습니다.</td>
	</tr>

<?
	} else {
		foreach($list as $val) {
			$idx = $val['idx'];
			$member_group_name 	= $val['member_group_name'];
			$member_group_status= $val['member_group_status'];
			$is_default			= $val['is_default'];
?>
		
	<tr>
		<td>
		<? 	if($is_default == 'N') { ?>
			<input type="checkbox" name="is_del[]" value="<?=$idx?>">
		<?	} ?>
		</td>
		<td><?=$member_group_name?><input type="hidden" name="member_group_name_<?=$idx?>" id="member_group_name_<?=$idx?>" value="<?=$member_group_name?>"></td>
		<td>
		<? 	if($is_default == 'N') { ?>
			<input type="checkbox" name="member_group_status[]" value="<?=$idx?>" <? if($member_group_status=='2'){ echo 'checked';}?>>
		<?	} ?>
		</td>
		<td class="tool_btn">
			<a href="javascript:member_group_menu_auth('<?=$idx?>');"><i class="fa fa-pencil"></i>권한</a>
			<a href="javascript:member_group_edit('<?=$idx?>');"><i class="fa fa-pencil"></i>수정</a>
		</td>

	</tr>

	
<? 		}
	}
?>



</tbody>
</table>
</div>
<div class="write_btn">
	<a href="/admin/member/member_group_menu_auth_reg/4/<?=$page?>?member_type=0&member_group_idx=8">비회원 권한설정</a>
	<a href="javascript:member_group_del_proc();">삭제</a>
	<a href="javascript:member_group_status_proc();">저장</a>
	<a href="javascript:member_group_add();">그룹생성</a>
</div>

<div class="pasing_wrap">
	<?=$pagination?>
</div>






<div id="member_group_reg_layer" style="display:none">
<div class="black_board" style="display:block"></div>
<div class="pop_con common_table moving_all" style="display:block;top:100px;">
   <a href="javascript:commonLayerClose('member_group_reg_layer')" class="pop_close">x</a>
	<h2>회원그룹추가</h2>
	<table>
		<tr>
			<th>그룹명</th>
			<td>
				<input type="text" name="member_group_name" id="member_group_name" class="input00" size="30">
				<input type="hidden" name="member_group_idx" id="member_group_idx">
			</td>
		</tr>
	</table>
	<div class="write_btn tc">
		<a href="javascript:member_group_reg_proc('add')" id="member_group_add">신규등록</a>
		<a href="javascript:member_group_reg_proc('edit')" id="member_group_edit">수정</a>
		<a href="javascript:commonLayerClose('member_group_reg_layer')">취소하기</a>
	</div>
</div>
</div>


</form>




<script type="text/javascript">
// 삭제
function member_group_del_proc() {
	if($("input:checkbox[name='is_del[]']").is(":checked") == false) {
		alert("삭제할 내용이 없습니다.");
		return false;
	}
	if(confirm("그룹이 삭제됩니다. 삭제하시겠습니까?") == true) {    //확인
		$("#input_form").attr("action", "/admin/member/member_group_del_proc");
		$("#input_form").submit();
	} else {   //취소
		return;
	}
}

// 상태변경
function member_group_status_proc(){
	if($("input:checkbox[name='member_group_status[]']").is(":checked") == false) {
		alert("저장할 내용이 없습니다.");
		return false;
	}
	$("#input_form").attr("action", "/admin/member/member_group_status_proc");
	$("#input_form").submit();

}

function member_group_menu_auth(idx){
	if(idx == '6' || idx == '7') {
		alert("파트너회원은 권한을 수정하실수 없습니다.");
		return false;
	}
	location.href='/admin/member/member_group_menu_auth_reg/4/<?=$page?>?member_type=<?=$member_type?>&member_group_idx='+idx;
}



// 회원그룹추가
function member_group_reg_proc(mode){
	var member_group_name 	= $("#member_group_name").val();
	var member_group_idx 	= $("#member_group_idx").val();
	if(member_group_name=='') {
		alert("그룹명을 입력해주세요.");
		return false;
	}

	$("#mode").val(mode);

	$("#input_form").attr("action", "/admin/member/member_group_reg_proc");
	$("#input_form").submit();


}


// 회원그룹등록 - layer열기
function member_group_add(){
	$("#member_group_edit").hide();
	$("#member_group_add").show();
	$("#member_group_idx").val('');
	$("#member_group_name").val('');
	commonLayerOpen('member_group_reg_layer');
}

// 회원그룹수정 - layer열기
function member_group_edit(idx){
	$("#member_group_edit").show();
	$("#member_group_add").hide();
	$("#member_group_idx").val(idx);
	$("#member_group_name").val($("#member_group_name_"+idx).val());
	commonLayerOpen('member_group_reg_layer');
}


// 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>