<!DOCTYPE html>
<html lagn="ko" xmlns:th="http://www.thymeleaf.org">

<th:block th:fragment="layout_leftMenu">
<!--왼쪽메뉴-->
<ul id="menu_list" class="menu_list">
	<!-- <li>
		<a href="home.html">
			<img src="/image/web/menu_1_off.svg" alt="병원현황"/>
			<span>병원현황</span>
		</a>
	</li>
	<li>
		<a href="customer.html" class="on">
			<img src="/image/web/menu_2_on.svg" alt="고객"/>
			<span>고객</span>
		</a>
	</li>
	<li>
		<a href="#">
			<img src="/image/web/menu_3_off.svg" alt="수납"/>
			<span>수납</span>
		</a>
	</li>
	<li>
		<a href="stock.html">
			<img src="/image/web/menu_4_off.svg" alt="재고"/>
			<span>재고</span>
		</a>
	</li>
	<li>
		<a href="#">
			<img src="/image/web/menu_5_off.svg" alt="통계"/>
			<span>통계</span>
		</a>
	</li>
	<li>
		<a href="hospital.html">
			<img src="/image/web/menu_6_off.svg" alt="원무"/>
			<span>원무</span>
		</a>
	</li>
	<li>
		<a href="#">
			<img src="/image/web/menu_7_off.svg" alt="마케팅"/>
			<span>마케팅</span>
		</a>
	</li>
	<li>
		<a href="#">
			<img src="/image/web/menu_8_off.svg" alt="멤버십"/>
			<span>멤버십</span>
		</a>
	</li> -->
</ul>

<script>
/****************************************************************************
* 메뉴 조회
****************************************************************************/
function fn_selectListMenu(){
	let formData = new FormData();
	formData.append("type", "A");
	
	$.ajax({
		url: encodeURI('/webmenu/selectListMenu.do'),
		data: formData,
		dataType: "json",
		processData: false,
		contentType: false,
		type: 'POST',
		async: true,
		success: function(data){
			if('0'==data.msgCode){
				let listHTML = '';
				
				for(let i = 0; i < data.rows.length; i++){
					let menuCode     = data.rows[i].menuCode;
					let icon         = data.rows[i].icon;
					let icon2        = data.rows[i].icon2;
					let menuName     = data.rows[i].menuName;
					let subMenuCode  = data.rows[i].subMenuCode;
					let subAction    = data.rows[i].subAction;
					
					listHTML += '<li>';
					listHTML += '	<a id="menu'+menuCode+'" href="javascript:;" onClick="javascript:fn_leftFormAction2(\''+subMenuCode+'\',\''+subAction+'\');">';
					listHTML += '		<img src="'+icon+'" alt="'+menuName+'">';
					listHTML += '		<img src="'+icon2+'" style="display:none;" alt="'+menuName+'">';
					listHTML += '		<span>'+menuName+'</span>';
					listHTML += '	</a>';
					listHTML += '</li>';
				}
				$("#menu_list").empty().html(listHTML).trigger("create");
				
				// 선택 처리
				if(!fn_emptyYn(menuClass)){
					let parentMenuCode = menuClass.substr(0, 2);
					$("#menu_list #menu"+parentMenuCode).addClass("on");
					$("#menu_list #menu"+parentMenuCode).find("img:eq(1)").show();
					$("#menu_list #menu"+parentMenuCode).find("img:eq(0)").hide();
				}
				else{
					let parentMenuCode = data.rows[0].menuCode;
					menuClass = data.rows[0].subMenuCode;
					
					$("#menu_list #menu"+parentMenuCode).addClass("on");
					$("#menu_list #menu"+parentMenuCode).find("img:eq(1)").show();
					$("#menu_list #menu"+parentMenuCode).find("img:eq(0)").hide();
				}
			}
			else if(data.msgCode=='-1'){
				modalEvent.warning("조회 오류", data.msgDesc);
			}
			else{
				modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
			}
		},
		error : function(xhr, status, error) {
			modalEvent.danger("조회 오류", "조회 중 오류가 발생하였습니다. 잠시후 다시시도하십시오.");
		},
		beforeSend:function(){
			
		},
		complete:function(){
			
		}
	});
}

$(function(){
	// 메뉴 조회
	fn_selectListMenu();
	
	if(!fn_emptyYn(menuClass)){
		let parentMenuCode = menuClass.substr(0, 2);
		
		fn_selectListSubMenu(parentMenuCode);
	}
});

</script>
</th:block>
</html>