<!DOCTYPE html>
<!--[if IE 8 ]><html dir="ltr" lang="zh-TW" class="ie8"><![endif]-->
<!--[if IE 9 ]><html dir="ltr" lang="zh-TW" class="ie9"><![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html dir="ltr" lang="zh-TW">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
<title>管理後臺</title>
<meta name="robots" content="noindex, nofollow" />
<link href="less/page.less" rel="stylesheet/less">
<link href="css/main.css" rel="stylesheet">
<link href="css/page.css" rel="stylesheet">
<script src="/jquery/jquery-1.10.js"></script>
<script>
	if('<?# alertMsg ?>' != ''){
		alert('<?# alertMsg ?>');
		if('<?# goBack ?>' == 'Y') history.back();
	}
	if('<?# locationHref ?>' != '') location.href = '<?# locationHref ?>';
</script>
</head>
<body>
	<?# sidePage ?>
	<div class="pos_rel" id="content">
		<?# header ?>
		<div class="row mt_10 mb_5 h3 page_title"><?# page_name ?></div>
		<form id="form1" name="form1">
			<input type="hidden" id="id" name="id" value="<?# id ?>" />
			<div class="card">
				<div class="pos_rel bg_g_100 tabs_warp" id="tabs_warp">
					<div class="tabs_list">
						<a class="tabs_item" href="index.php">控制台</a>
						<a class="tabs_item" data-action="true" href="javascript:void(0);"><?# page_name ?></a>
					</div>
				</div>
				<div class="mall_5 add_btn"><a class="btn btn_success" href="menuEdit.php">新增功能</a></div>
                <ul class="list_box">
                    <php:repeater id="list">
                    <template>
                    <li class="d_lg_flex">
                        <p class="col_lg_2"><label>功能標題</label><font><?# MenuName ?></font></p>
                        <p class="col_lg_2"><label>上層功能</label><font><?# ParentName ?></font></p>
                        <p class="col_lg_2"><label>連結網址</label><font><?# MenuLink ?></font></p>
                        <p class="col_lg_1"><label>狀態</label><font><?# txtV ?></font></p>
                        <p class="col_lg_1"><label>排序</label><font><?# OrderNO ?></font></p>
                        <p class="col_lg_1"><label>限主</label><font><?# txtOA ?></font></p>
                        <p class="col_lg_3">
                            <label>操作</label>
                            <font>
                                <a class="mr_2 btn btn_primary" href="menuEdit.php?id=<?# MenuID ?>&pUrl=<?# encodeUrl ?>">修改</a>
                                <a class="mr_2 btn btn_yellow" data-action="cvItem" data-id="<?# MenuID ?>" data-visible="<?# Visible ?>" href="javascript:void(0);">啟用/不啟用</a>
                                <a class="mr_2 btn btn_red" data-action="delItem" data-id="<?# MenuID ?>" href="javascript:void(0);">修改</a>
                            </font>
                        </p>
                    </li>
                    </template>
                    </php:repeater>
                </ul>
			</div>
		</form>
		<?# footer ?>
	</div>
</body>
</html>
<script>
	$(function(){
		$('a[data-action="cvItem"]').click(function(){
			if(!confirm('是否確定變更此項功能的狀態?')){
				return false;
			}else{
				var nv = ($(this).data('visible') == '1')?'0':'1';
				$.ajax({
					url: 'ajax/menu2.php',
					async: false,
					type: 'POST',
					data: {'do':'vis','id':$(this).data('id'),'vis':nv},
					dataType: "json",
					context: $(this),
					success: function(obj){
						if(obj.err == '0'){
							var txtV = (obj.newVisible == '1')?'<span class="badge badge_soft_success">使用</span>':'<span class="badge badge_soft_danger">不使用</span>';
							$(this).data('visible', obj.newVisible);
							$(this).parents('li').children('p').eq(3).children('font').html(txtV);
						}else{
							alert(obj.msg);
						}
					},
					error: function(e){
						console.log(e);
						alert('系統異常!請重新整理頁面再試一次!');
					}
				});
			}
		});
		$('a[data-action="delItem"]').click(function(){
			if(!confirm('一旦刪除將無法回復!是否確定刪除此項功能?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/menu2.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "json",
					context: $(this).parents('li'),
					success: function(obj){
						if(obj.err == '0'){
							$(this).remove();
						}else{
							alert(obj.msg);
						}
					},
					error: function(e){
						console.log(e);
						alert('系統異常!請重新整理頁面再試一次!');
					}
				});
			}
		});
	});
</script>