<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>管理後臺</title>
<meta name="keywords" content="管理後臺" />
<meta name="description" content="管理後臺" />
<script src="/jquery/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
<!-- 瀏覽用燈箱片效果 -->
<link rel="stylesheet" href="/jquery/fancybox/source/jquery.fancybox.css?v=2.1.5" type="text/css" media="screen" />
<script type="text/javascript" src="/jquery/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
</head>
<body>
	<div class="wrapper">
    	<?# header ?>
    	<div class="wrap">
        	<?# sidePage ?>
            <div class="contentMain">
            	<h3><?# editTitle ?></h3>
                <div class="article" style="width: 100%;">
                    <form id="form1" name="form1" action="bookEdit.php" method="post">
                        <fieldset style="width: 100%;">
                        	<div class="titleTyp"><p>相本資訊</p></div>
                            <div style=" background: rgba(75, 141, 248, 0.07); padding: 10px 0;">
                                <p>
                                    <label>相本名稱</label>
                                    <input type="text" id="BookName" name="BookName" value="<?# BookName ?>" maxlength="50" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>相本分類</label>
                                    <select id="CategoryID" name="CategoryID">
                                        <php:repeater id="listC">
                                            <template>
                                                <option value="<?# CategoryID ?>"><?# CategoryName ?></option>
                                            </template>
                                        </php:repeater>
                                    </select>
                                </p>
                                <div class="writList">
                                    <label>相本封面</label>
                                    <a id="aImg" class="fancybox"><img id="imgImg" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="Image" name="Image" value="<?# Image ?>" />
                                    <input type="button" id="btnImg" name="btnImg" value="瀏覽" />
                                </div>
                                <p>
                                	<label>相本說明</label>
                                    <textarea id="Description" name="Description" style="width:540px; height:200px;"><?# Description ?></textarea>
                                </p>
                                <p>
                                	<label>首頁顯示</label>
                                    <input type="radio" name="IsIndex" value="1" />首頁顯示
                                    <input type="radio" name="IsIndex" value="0" />首頁不顯示
                                </p>
                                <p>
                                    <label>啟用</label>
                                    <input type="radio" name="Visible" value="1" />啟用
                                    <input type="radio" name="Visible" value="0" />不啟用
                                </p>
                                <p>
                                    <label>排序</label>
                                    <input type="text" id="OrderNO" name="OrderNO" value="<?# OrderNO ?>" onkeypress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;" style="width: 300px;" />
                                </p>
                            </div>
                            <div class="titleTyp" style="background: #66CC96; margin: 5px 0 0;"><p>SEO設定</p></div>
                            <div style="background: rgba(102, 204, 150, 0.11); padding: 10px 0;">
                                <p>
                                    <label>頁面標題</label>
                                    <input type="text" id="WebTitle" name="WebTitle" value="<?# WebTitle ?>" maxlength="128" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>頁面關鍵字</label>
                                    <input type="text" id="WebKeyword" name="WebKeyword" value="<?# WebKeyword ?>" maxlength="256" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>頁面描述</label>
                                    <textarea style="width:540px; height:100px;" id="WebDescription" name="WebDescription"><?# WebDescription ?></textarea>
                                </p>
                            </div>
                            <p>
                                <input type="button" id="btnOK" name="btnOK" value="確 定" />
								<input type="button" id="btnCancel" value="返 回" />
                            </p>
                            <input type="hidden" id="id" name="id" value="<?# id ?>" />
                            <input type="hidden" id="pUrl" name="pUrl" value="<?# pUrl ?>" />
                        </fieldset>
                    </form>
                        <h3>相片/影片列表</h3>
                        <form id="form2" name="form2" action="photoEdit.php" method="get">
                            <fieldset style="width: 960px;">
                                <div style="overflow: hidden;">
                                    <div class="abbNew" style="width: 135px; float: left; margin: 10px;"><input type="button" id="btnAdd" name="btnAdd" value="新增相片/影片" /></div>
                                    <div class="abbNew" style="width: 125px; float: left; margin: 10px; background: #178169;"><input type="button" id="btnMulti" name="btnMulti" value="批量新增相片" /></div>
                                </div> 
                                    
                            <ul class="photoUL">
                                <php:repeater id="listP">
                                    <template>
                                        <li class="vis<?# Visible ?>">
                                            <div class="photo"><a class="fancybox" href="<?# Image ?>" style="float:inherit; margin:0;" title="<?# PhotoName ?>"><img src="<?# Image ?>" /></a></div>
                                            <p>類型：<?# PhotoTypeName ?></p>
                                            <p class="pName">相片名稱：<?# PhotoName ?></p>
                                            <p>排序：<?# OrderNO ?></p>
                                            <div class="operating">
                                                <div class="modification"><span></span><a href="photoEdit.php?id=<?# PhotoID ?>&pUrl2=<?# encodedUrl ?>">修改</a></div>
                                                <div class="delete"><span></span><a data-action="delItem" data-id="<?# PhotoID ?>" href="javascript:void(0);">刪除</a></div>
                                            </div>                                            
                                        </li>
                                    </template>
                                </php:repeater>
                            </ul>
                            <input type="hidden" id="bookID" name="bookID" value="<?# id ?>" />
                            <input type="hidden" id="pUrl2" name="pUrl2" value="<?# currentUrl ?>" />
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
        <?# footer ?>
    </div>
<script>
<!--
	function SetFileField(fileUrl,data){
		$('#'+data["selectActionData"]).val(fileUrl);
		$('#'+data["selectActionData"]).change();
	}
	$(function(){
		$(".fancybox").fancybox();

		$('#CategoryID').val("<?# CategoryID ?>");
		$('input:radio[name="IsIndex"][value="<?# IsIndex ?>"]').attr('checked',true);
		$('input:radio[name="Visible"][value="<?# Visible ?>"]').attr('checked',true);

		$('#Image').change(function(){
			if($(this).val() == ''){
				$('#imgImg').attr('src','');
				$('#imgImg').css('display','none');
				$('#aImg').attr('href','');
			}else{
				$('#imgImg').attr('src',$(this).val());
				$('#imgImg').css('display','block');
				$('#aImg').attr('href',$(this).val());
			}
		});
		$('#Image').change();

		if($('#id').val() != '' && $('#id').val() != '0'){
			$('#photoList').css('display','block');
		}

		$('#btnImg').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'Image';
			finder.popup();
		});
		$('#btnOK').click(function(){
			if($('#BookName').val() == ''){
				alert('相本名稱不可空白!');
				$('#BookName').focus();
				return false;
			}
			if($('#CategoryID').val() == '0'){
				alert('請選擇相本分類!');
				$('#CategoryID').focus();
				return false;
			}
			if($('#Image').val() == ''){
				alert('相本封面不可空白!');
				return false;
			}
			if($('input:radio[name="IsIndex"]:checked').size() == 0){
				alert('請選擇此相本是否顯示到首頁!');
				return false;
			}
			if($('input:radio[name="Visible"]:checked').size() == 0){
				alert('請選擇是否啟用此相本!');
				return false;
			}
			$('#form1').submit();
		});
		$('#btnCancel').click(function(){
			if($('#pUrl').val() == '')
				location.href = 'bookList.php';
			else
				location.href = $('#pUrl').val();
		});
		$('#btnAdd').click(function(){
			if($('#bookID').val() == '' || $('#bookID').val() == '0'){
				alert('必須先建立相本才能新增相片/影片!');
				return false;
			}
			$('#form2').attr('action','photoEdit.php');
			$('#form2').submit();
		});
		$('#btnMulti').click(function(){
			if($('#bookID').val() == '' || $('#bookID').val() == '0'){
				alert('必須先建立相本才能新增相片/影片!');
				return false;
			}
			$('#form2').attr('action','photoMulti.php');
			$('#form2').submit();
		});
		$('a[data-action="delItem"]').click(function(){
			if(!confirm('刪除資料後將無法恢復!確定要刪除此相片/影片資料?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/photo.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "text",
					context: $(this).parent('div').parent('div').parent('li'),
					success: function(msg){
						if(msg == '1'){
							$(this).remove();
						}else{
							alert('刪除失敗!\r\n'+msg);
						}
					},
					error: function(){
						alert('系統異常!!');
					}
				});
			}
		});
	});
//-->
</script>
</body>
</html>