ef7cdce3fff4c5410a6b239b5611a2d00f68b658.svn-base 9.44 KB
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminUser.php" ?>
<? include $_SERVER["DOCUMENT_ROOT"] . "/admin/inc/php/header.php" ?>
<? include $_SERVER["DOCUMENT_ROOT"] . "/admin/inc/php/leftUserManage.php" ?>
<?
	$obj		= new AdminUser($_REQUEST, "");
	$userInfo	= $obj->getInfoOfAdminUser();
	
	$rurl		= pack("H*", $_REQUEST["rurl"]) ;
?>

<script type="text/javascript">
	var _rurl = "<?=$rurl?>";
	var _no = "<?=$_REQUEST[no]?>";


	$(document).ready(function(){

		//=====프레입웤 변수들==================================================================================//
		var FORM_TARGET_CLS_NM		= ".data"	;		// 폼을 동적 wrap 할 타겟 ID이름
		var FORM_NAME				= "alf"		;		// 폼이름
		var FORM_METHOD				= "POST"		;		// 폼 메쏘드
		var FORM_USE_FILE			= false		;		// 파일폼 사용 여부
		var FORM_ACTION				= "/action_front.php" ; 
		
		
		var NEXT_CMD				= ""		;		// 다은 수행 할 cmd
		//=====================================================================================================//
		
		var dates = $("[name='birthDT[]']").datepicker({
			showMonthAfterYear:true,
			inline: true,
			changeMonth: true,
			changeYear: true,
			yearRange: '1970',
			dateFormat : 'yy-mm-dd',
			dayNamesMin:['일', '월', '화', '수', '목', '금', ' 토'],
			monthNames:['1월','2월','3월','4월','5월','6월','7 월','8월','9월','10월','11월','12월'],
			monthNamesShort:['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
			showButtonPanel: true, currentText: '오늘 ' , closeText: '닫기'
		});

		var jForm = $(FORM_TARGET_CLS_NM).mf({ "name" : FORM_NAME , "method" : FORM_METHOD , "action" : FORM_ACTION , "useFile" : FORM_USE_FILE }) ;

		$(".jCancel").click2(function(){
			location.href = _rurl;
		});


		// 회원 수정
		$(".jSave").click2(function(){

			var confirmStr = (_no == "") ? "등록하시겠습니까?" : "수정하시겠습니까?";
			var target_fk = $("#target_fk").val();
			var admin_type = $("#admin_type").val();
			var admin_id = $("#admin_id").val();
			var admin_pwd = $("#admin_pwd").val();
			var admin_name = $("#admin_name").val();
			var admin_phone = $("#admin_phone").val();
			var is_inquire_position = $("#is_inquire_position:checked").length > 0 ? "1" : "0";


			if(target_fk == "")
			{
				if(admin_type == "2")
				{
					alert("관리 그룹을 선택해주세요.");
					return false;
				}
				else if(admin_type == "3")
				{
					alert("관리 상점을 선택해주세요.");
					return false;
				}
			}

			if(admin_id == "")
			{
				alert("아이디를 입력해주세요.");
				return false;
			}

			if(admin_name == "")
			{
				alert("이름을 입력해주세요.");
				return false;
			}

			if(admin_phone == "")
			{
				alert("전화번호를 입력해주세요.");
				return false;
			}

			if(_no == "" && admin_pwd == "")
			{
				alert("비밀번호를 입력해주세요.");
				return false;
			}
			
			if(confirm(confirmStr))
			{
				$.ajax({
					url : "/action_front.php?cmd=AdminUser.saveAdminUser",
					async : false,
					cache : false,
					dataType : "json",
					data : {
						"no"	: _no
						, "admin_type"	: admin_type
						, "admin_id"		: admin_id
						, "admin_pwd"	: admin_pwd
						, "admin_name"		: admin_name
						, "admin_phone"	: admin_phone
						, "is_inquire_position"	: is_inquire_position
						, "target_fk"	: target_fk
					},
					success : function(data){
						alert(data.returnMessage);

						if(data.returnCode == "1")
						{
							if(_no != "")
								location.reload();
							else
								location.href = _rurl;
						}
					}
				});

			}

		}) ;

		$("#admin_type").change(function(){
			setTargetView(false);
		});

		$(".jResetTargetData").click2(function(){
			resetTargetData();
		});

		$(".jViewSearchBtn").click2(function(){

			var admin_type = $("[name='admin_type']").val();
			var title = "그룹 검색";

			if(admin_type == "3")
				title = "상점 검색";
			
			$('#jDialogArea').dialog({
				modal : true,
				title : title,
				open : function(event, ui) { $(".ui-dialog-titlebar-close").hide(); },
				width : 400,
				height : 500,
				resizable : false,
				buttons: [
					{
						text: "확인",
						click: function() {
							var target_fk = $(".jTargetNo:checked").val();
							var target_name = $(".jTargetNo:checked").parents("tr").find(".jTargetName").attr("data");

							if(target_fk == undefined)
							{
								alert("대상을 선택해주세요.");
								return false;
							}
							else
							{
								$("#target_fk").val(target_fk);
								$("#jTargetName").val(target_name);
								$( this ).dialog( "close" );

								$("#jTargetSearchText").val("");
								$("#jSearchResultArea").empty();
							}
						}
					},
					{
						text: "닫기",
						click: function() {
							$("#jTargetSearchText").val("");
							$("#jSearchResultArea").empty();
							$( this ).dialog( "close" );
						}
					}
				],
				closeOnEscape: false
			});
		});


		$(".jTargetSearchBtn").click2(function(){
			var search_text = $("#jTargetSearchText").val();
			var ajax_url = "";

			if(search_text == "")
			{
				alert("검색어를 입력해주세요.");
				return false;
			}

			if($("#admin_type").val() == "2")
				ajax_url = "/admin/entity/entityGroupSearch.php";
			else
				ajax_url = "/admin/entity/entityShopSearch.php";


			$.ajax({
				url : ajax_url,
				data : {
					"search_text" : search_text
				},
				dataType:"html",
				success : function(data)
				{
					$("#jSearchResultArea").html(data);
					setSearchAreaEventHandler();
				}
			});
			
		});


		setTargetView(true);
		
	}) ;


	function setSearchAreaEventHandler()
	{
		$(".jTargetNo").unbind("change");
		$(".jTargetNo").change(function(){
			$(".jTargetNo").prop("checked", false);
			$(this).prop("checked", true);
		});
	}


	function setTargetView(isInit)
	{
		if(!isInit)
			resetTargetData();

		if($("#admin_type").val() == "2")
		{
			$("#jTargetTitle").html("관리 그룹");
		}
		else
		{
			$("#jTargetTitle").html("관리 상점");
		}
	}

	function resetTargetData()
	{
		$("#target_fk").val("");
		$("#jTargetName").val("");
	}

</script>

<div id="Contents"  class="notice">

	<h1>관리자 상세화면</h1>

	<!-- location area -->
	<h2>
		회원 관리 > <span>관리자 상세화면</span>
	</h2>
	<!-- location area -->

	
	<div class="data" style="width:50%;">
		
		<h3>관리자 정보</h3>

		<input type="hidden" id="target_fk" name="target_fk" value="<?=$userInfo["target_fk"]?>" />

		<table class="datav" style="width:100%;">
			<colgroup>
				<col width="30%" />
				<col width="70%" />
			</colgroup>
			<tr>
				<th style="height:25px;">관리자 타입</th>
				<td class="l">
					<select name="admin_type" id="admin_type" <?= ($loginInfo["admin_type"] == "1") ? "" : "disabled='disabled'" ?>>
						<option value="2" <?=$userInfo["admin_type"] == "2" ? "SELECTED" : ""?> >그룹관리자</option>
						<option value="3" <?=$userInfo["admin_type"] == "3" ? "SELECTED" : ""?> >상점관리자</option>
					</select>
				</td>
			</tr>
			<tr>
				<th style="height:25px;">관리자 아이디</th>
				<td class="l">
					<input type="text" id="admin_id" name="admin_id" value="<?=$userInfo["admin_id"]?>" />
					<label style="margin-left:20px; <?= ($loginInfo["admin_type"] == "1") ? "" : " display:none;" ?>">
						<input type="checkbox" id="is_inquire_position" style="vertical-align:middle; margin:auto; " value="1" <?=$userInfo["is_inquire_position"] == "1" ? "CHECKED" : "" ?> > 민원 담당자로 지정
					</label>
				</td>
			</tr>
			<tr>
				<th style="height:25px;">관리자 비밀번호</th>
				<td class="l">
					<input type="password" id="admin_pwd" name="admin_pwd" value="" />
				</td>
			</tr>
			<tr>
				<th style="height:25px;">관리자 이름</th>
				<td class="l">
					<input type="text" id="admin_name" name="admin_name" value="<?=$userInfo["admin_name"]?>" />
				</td>
			</tr>
			<tr>
				<th style="height:25px;">관리자 전화번호</th>
				<td class="l">
					<input type="text" id="admin_phone" name="admin_phone" value="<?=$userInfo["admin_phone"]?>" />
				</td>
			</tr>
			
			<tr>
				<th style="height:25px;" id="jTargetTitle">관리 그룹</th>
				<td class="l">
					<input type="text" id="jTargetName" value="<?=$userInfo["target_name"]?>" disabled="disabled" />
					<?if($loginInfo["admin_type"] == "1"){ ?>
					<input type="button" class="button searchsmall white jViewSearchBtn" value="검색"  />
                    <input type="button" class="button searchsmall white jResetTargetData" value="삭제"/>
                    <?} ?>
				</td>
			</tr>
			
		</table>

		<div class="btngroupcenter">
			<span class="button bigrounded blue jCancel">목록으로 </span>
			<span class="button bigrounded blue jSave" >저장</span>
		</div>

	</div>
	
	<div id="jDialogArea" style="display:none;">
		<table class="datacList" style="width:100%;">
			<thead>
				<tr>
					<td class="no" colspan="2" style="text-align:center; height:35px;">
						<input type="text" id="jTargetSearchText" style="width:50%;" placeholder="검색어를 입력해야 결과가 노출 됩니다.">
						<input type="button" class="button searchsmall white jTargetSearchBtn" value="검색"  />
					</td>
				</tr>
			</thead>
			<thead>
                <tr>
                    <th class="no" colspan="2">검색결과</th>
                </tr>
            </thead>
            <tbody id="jSearchResultArea"><!-- 10줄 리스트// 마지막 tr에 class="last" 넣어주세요 -->
                
            </tbody>
		</table>
	</div>
</div>