<!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="管理後臺" />
<link href="/css/font-awesome.css" rel="stylesheet">
<script src="/jquery/jquery-1.8.2.min.js"></script>
<script src="ckeditor/ckeditor.js" type="text/javascript"></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%;">
					<script>
                    $(function () {
						$('#form1 p font a[href*=#]:not([href=#])').click(function() {
							var target = $(this.hash);
							$('html,body').animate({
								scrollTop: target.offset().top
							}, 1000);
							return false;
						});
                    });
                    </script>
                    <form id="form1" name="form1" action="productEdit.php" method="post">
                        <fieldset style="width: 100%; padding:0;">
                        	<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="ProductName" name="ProductName" value="<?# ProductName ?>" maxlength="128" style="width: 300px;" />
                                </p>
                                <p>
                                    <label>產品分類</label>
                                    <select id="CategoryID" name="CategoryID"></select>
                                </p>
                                <p>
                                    <label>官網連結</label>
                                    <input type="text" id="ProductNO" name="ProductNO" value="<?# ProductNO ?>" maxlength="50" style="width: 300px;" />
                                    <b style="color:#e00000;">注意:請貼上完整網址。(例: https://goo.gl/vCJiOP)</b>
                                </p>
                                <p style="display: none;">
                                    <label>產品原價</label>
                                    <input type="text" id="OldPrice" name="OldPrice" value="<?# OldPrice ?>" onkeypress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;" style="width: 300px;" />
                                </p>
                                <p style="display: none;">
                                    <label>產品售價</label>
                                    <input type="text" id="Price" name="Price" value="<?# Price ?>" onkeypress="if (event.keyCode < 48 || event.keyCode >57) event.returnValue = false;" style="width: 300px;" />
                                </p>
                                <p>
                                    <label style="float: left;">產品縮圖</label>
                                    <a id="aIImg" class="fancybox" href="" style="float: left; margin: 0 10px;"><img id="imgIImg" src="" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="IconImage" name="IconImage" value="<?# IconImage ?>" />
                                    <input type="button" id="btnIImg" name="btnIImg" value="瀏覽" />
                                </p>
                                <p>
                                    <label style="float: left;">產品圖片一</label>
                                    <a id="aImg1" class="fancybox" href="" style="float: left; margin: 0 10px;"><img id="imgImg1" src="" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="Image1" name="Image1" value="<?# Image1 ?>" />
                                    <input type="button" id="btnImg1" name="btnImg1" value="瀏覽" />
                                </p>
                                <p>
                                    <label style="float: left;">產品圖片二</label>
                                    <a id="aImg2" class="fancybox" style="float: left; margin: 0 10px;"><img id="imgImg2" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="Image2" name="Image2" value="<?# Image2 ?>" />
                                    <input type="button" id="btnImg2" name="btnImg2" value="瀏覽" />
                                </p>
                                <p>
                                    <label style="float: left;">產品圖片三</label>
                                    <a id="aImg3" class="fancybox" style="float: left; margin: 0 10px;"><img id="imgImg3" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="Image3" name="Image3" value="<?# Image3 ?>" />
                                    <input type="button" id="btnImg3" name="btnImg3" value="瀏覽" />
                                </p>
                                <p>
                                    <label style="float: left;">產品圖片四</label>
                                    <a id="aImg4" class="fancybox" style="float: left; margin: 0 10px;"><img id="imgImg4" style="width:50px; height:50px; border:0; display:none;" /></a>
                                    <input type="text" id="Image4" name="Image4" value="<?# Image4 ?>" />
                                    <input type="button" id="btnImg4" name="btnImg4" value="瀏覽" />
                                <p>
                                    <label>評論和評分</label>
                                    <?# averageStar ?> <?# averageStarIcon ?> 
                                    <font><a href="#comList" style="text-decoration:underline;"><?# totalNO ?> 篇評論</a></font>
                                    <a href="commentAdd.php?pid=<?# id ?>" style="margin-left: 10px; padding: 2px 5px; background: #de3352; display: inline-block; color: #fff;" target="_blank">新增評論</a>
                                </p>
                                <p>
                                    <label>產品介紹</label>
                                    <textarea style="width:540px; height:100px;" id="Introduction" name="Introduction"><?# Introduction ?></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;" />
                                </p>
                                <p>
                                    <label>點閱次數</label>
                                    <input type="text" id="ViewCount" name="ViewCount" value="<?# ViewCount ?>" disabled="disabled" />
                                </p>
                                <div class="writList">
                                    <label style="float: left; width:120px; height: 40px; display: block;">詳細介紹</label>
                                    <input type="hidden" id="Title1" name="Title1" value="詳細介紹" maxlength="50" />
                                    <div class="ckeList"><textarea class="ckeditor" id="Description1" name="Description1"><?# Description1 ?></textarea></div>
                                </div>
                                <p style="display: none;">
                                    <label>標題二</label>
                                    <input type="text" id="Title2" name="Title2" value="<?# Title2 ?>" maxlength="50" />
                                </p>
                                <div class="writList" style="display: none;">
                                    <label style="float: left;">說明二</label>
                                    <div class="ckeList"><textarea class="ckeditor" id="Description2" name="Description2"><?# Description2 ?></textarea></div>
                                </div>
                                <p style="display: none;">
                                    <label>標題三</label>
                                    <input type="text" id="Title3" name="Title3" value="<?# Title3 ?>" maxlength="50" />
                                </p>
                                <div class="writList" style="display: none;">
                                    <label style="float: left;">說明三</label>
                                    <div class="ckeList"><textarea class="ckeditor" id="Description3" name="Description3"><?# Description3 ?></textarea></div>
                                </div>
                            </div>
                            <div class="titleTyp" style="background: #66CC96; margin: 5px 0 0;"><p>評論</p></div>
                            <div id="comList" class="comment" style="background: rgba(102, 204, 150, 0.11); padding: 10px 0;">
                                <?# commentText ?>
                                <ul id="imgUL"<?# commentC ?>>
                                    <php:repeater id="listM">
                                    <template>
                                    <li>
                                        <p><b><?# CustomerName ?></b> <span><?# CreatedTime ?></span></p>
                                        <p class="star"><?# StarsIcon ?></p>
                                        <article><?# Content ?></article>
                                        <p><a class="butDel" href="javascript:void(0);" data-type="del" data-id="<?# CommentID ?>">刪除</a></p>
                                    </li>
                                    </template>
                                    </php:repeater>
                                </ul>                            
                            </div>
                            <div class="titleTyp" style="background: #C66; margin: 5px 0 0;"><p>SEO設定</p></div>
                            <div style="background: rgba(204, 102, 102, 0.14); padding: 10px 0;">
                                <p>
                                    <label>頁面標題</label>
                                    <input type="text" id="WebTitle" name="WebTitle" value="<?# WebTitle ?>" maxlength="128" />
                                </p>
                                <p>
                                    <label>頁面關鍵字</label>
                                    <input type="text" id="WebKeyword" name="WebKeyword" value="<?# WebKeyword ?>" maxlength="256" />
                                </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>
                </div>
            </div>
        </div>
        <?# footer ?>
    </div>

<script>
<!--
	var jsonC = '<?# jsonC ?>';
	var aryC = JSON.parse(jsonC);
	function SetFileField(fileUrl,data){
		$('#'+data["selectActionData"]).val(fileUrl);
		$('#'+data["selectActionData"]).change();
	}
	$(function(){
		$(".fancybox").fancybox();

		$.each(aryC,function(a,b){
			if(b.Sub.length == 0){
				$('#CategoryID').append($('<option></option>').val(b.ID).text(b.Name));
			}else{
				var optg = $('<optgroup></optgroup>').attr('label',b.Name);
				$.each(b.Sub,function(c,d){
					optg.append($('<option></option>').val(d.SubID).text(d.SubName));
				});
				$('#CategoryID').append(optg);
			}
		});
		$('#CategoryID').val('<?# CategoryID ?>');

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

		$('#IconImage').change(function(){
			if($(this).val() == ''){
				$('#imgIImg').attr('src','');
				$('#imgIImg').css('display','none');
				$('#aIImg').attr('href','');
			}else{
				$('#imgIImg').attr('src',$(this).val());
				$('#imgIImg').css('display','block');
				$('#aIImg').attr('href',$(this).val());
			}
		})
		$('#Image1').change(function(){
			if($(this).val() == ''){
				$('#imgImg1').attr('src','');
				$('#imgImg1').css('display','none');
				$('#aImg1').attr('href','');
			}else{
				$('#imgImg1').attr('src',$(this).val());
				$('#imgImg1').css('display','block');
				$('#aImg1').attr('href',$(this).val());
			}
		});
		$('#Image2').change(function(){
			if($(this).val() == ''){
				$('#imgImg2').attr('src','');
				$('#imgImg2').css('display','none');
				$('#aImg2').attr('href','');
			}else{
				$('#imgImg2').attr('src',$(this).val());
				$('#imgImg2').css('display','block');
				$('#aImg2').attr('href',$(this).val());
			}
		});
		$('#Image3').change(function(){
			if($(this).val() == ''){
				$('#imgImg3').attr('src','');
				$('#imgImg3').css('display','none');
				$('#aImg3').attr('href','');
			}else{
				$('#imgImg3').attr('src',$(this).val());
				$('#imgImg3').css('display','block');
				$('#aImg3').attr('href',$(this).val());
			}
		});
		$('#Image4').change(function(){
			if($(this).val() == ''){
				$('#imgImg4').attr('src','');
				$('#imgImg4').css('display','none');
				$('#aImg4').attr('href','');
			}else{
				$('#imgImg4').attr('src',$(this).val());
				$('#imgImg4').css('display','block');
				$('#aImg4').attr('href',$(this).val());
			}
		});
		$('#IconImage').change();
		$('#Image1').change();
		$('#Image2').change();
		$('#Image3').change();
		$('#Image4').change();

		$('#btnIImg').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'IconImage';
			finder.popup();
		});
		$('#btnImg1').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'Image1';
			finder.popup();
		});
		$('#btnImg2').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'Image2';
			finder.popup();
		});
		$('#btnImg3').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'Image3';
			finder.popup();
		});
		$('#btnImg4').click(function(){
			var finder = new CKFinder();
			finder.basePath = 'ckfinder/';
			finder.resourceType = 'Images';
			finder.selectActionFunction = SetFileField;
			finder.selectActionData = 'Image4';
			finder.popup();
		});
		$('a[data-type="del"]').click(function(){
			if(!confirm('刪除資料後將無法恢復!是否確定要刪除產品資料?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/comment.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "text",
					context: $(this).parent('p').parent('li'),
					success: function(msg){
						if(msg == '1'){
							$(this).remove();
						}else{
							alert('刪除失敗!\r\n'+msg);
						}
					},
					error: function(){
						alert('系統異常!!');
					}
				});
			}
		});
		$('#btnOK').click(function(){
			if($('#ProductName').val() == ''){
				alert('產品名稱不可空白!');
				$('#ProductName').focus();
				return false;
			}
			if($('#CategoryID').val() == '' || $('#CategoryID').val() == '0'){
				alert('請選擇產品分類!');
				$('#CategoryID').focus();
				return false;
			}
			if($('#IconImage').val() == ''){
				alert('產品縮圖不可空白!');
				$('#IconImage').focus();
				return false;
			}
			if($('input:radio[name="IsIndex"]:checked').size() == 0){
				alert('請選擇此產品是否顯示到首頁!');
				return false;
			}
			if($('input:radio[name="Visible"]:checked').size() == 0){
				alert('請選擇是否啟用此產品!');
				return false;
			}
			if($('#Title1').val() == ''){
				alert('產品說明標題!');
				$('#Title1').focus();
				return false;
			}
			$('#form1').submit();
		});
		$('#btnCancel').click(function(){
			if($('#pUrl').val() == '')
				location.href = 'productList.php';
			else
				location.href = $('#pUrl').val();
		});
	});
//-->
</script>
</body>
</html>