<!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>
<!--[if lt IE 9]>
<script src="/js/html5.js"></script>
<![endif]-->
<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><?# webTitle ?></title>
<meta name="keywords" content="<?# webKeyword ?>" />
<meta name="description" content="<?# webDescription ?>" />
<meta property="og:url" content="<?# RelLink ?><?# REQUESTURI ?>" />
<meta property="og:type" content="website" />
<meta property="og:title" content="<?# ogTitle ?>" />
<meta property="og:description" content="<?# ogDescription ?>" />
<meta property="og:image" content="<?# ogImage ?>" />
<meta name="robots" content="INDEX, FOLLOW" />
<link href="/css/<?# webTemplates ?>/main.css" rel="stylesheet">
<link href="/css/<?# webTemplates ?>/layout.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>
<?# headHTML ?>
</head>
<body<?# JumpBody ?>>
<?# bodyTopHTML ?>
<div style="margin: 0; padding: 0; border: 0; width: 100%;<?# JumpStyle ?>">
<?# JumpHTML ?>
<?# JumpScript ?>
<link href="/css/order.css" rel="stylesheet">
<link href="/css/<?# webTemplates ?>/contact.css" rel="stylesheet">
<div class="wrapper">
    <?# header ?>
    <?# banner ?>
    <div id="content">
    	<div class="content-wrraper">
            <div class="waylink">
                <ol>
                    <li><a title="首頁" href="/">首頁</a></li>
                    <li><?# OrderName ?></li>
                </ol>
            </div>
            <div class="workframe inside">
            	<div class="main-article">
                    <h1 class="pagetitle"><?# OrderName ?></h1>
                    <div id="describe">
                        <div id="order">
                            <div class="orderWrap">
                                <php:repeater id="listCP">
                                    <template>
                                        <div class="orderList">
                                            <p>
                                                <label>產品名稱</label>
                                                <b><a href="<?# link ?>" target="_blank" title="<?# name ?>"><img src="<?# image ?>" alt="<?# name ?>" /><?# name ?></a></b>
                                            </p>
                                            <p><label>單價</label><b><?# price ?></b></p>
                                            <p><label>數量</label><b><input type="text" data-id="<?# id ?>" data-action="chgQ" name="q" value="<?# q ?>"></b></p>
                                            <p><label>小計</label><b><?# amount ?></b></p>
                                            <p><label>操作</label><b><input class="Del" type="button" data-id="<?# id ?>" data-action="delI" name="btnDel" value="刪除" /></b></p>
                                        </div>
                                    </template>
                                </php:repeater>
                            </div>
                            <div id="orderTotal">
                                <p id="price1">產品金額：<?# ProductPrice ?></p>
                                <p id="price2">運費：<?# TransPrice ?></p>
                                <p id="price3">總計：<?# OrderPrice ?></p>
                            </div>
                            <div class="button">
                                <p><a href="javascript:void('0');" id="btnClean" title="清空購物車"><i class="fa fa-trash-o"></i> 清空購物車</a></p>
                                <p class="link"><a href="<?# htLink4 ?>" title="繼續購物"><i class="fa fa-shopping-basket"></i> 繼續購物</a></p>
                            </div>
                            <script>
                                function sumPrice(){
                                    $.ajax({
                                        url: '/ajax/cart.php',
                                        async: false,
                                        type: 'POST',
                                        data: {'do':'sum'},
                                        dataType: 'json',
                                        success: function(obj){
                                            if(obj.err == "0"){
                                                $('#price1').html('產品金額：'+obj.pprice);
                                                $('#price2').html('運費：'+obj.tprice);
                                                $('#price3').html('總計：'+obj.oprice);
                                                $('#ProductPrice').val(obj.pprice);
                                                $('#TransPrice').val(obj.tprice);
                                                $('#OrderPrice').val(obj.oprice);
                                            }else{
                                                alert(obj.msg);
                                                location.href = location.href;
                                            }
                                        },
                                        error: function(){
                                            alert('系統異常!請重新整理頁面再試一次!');
                                            location.href = location.href;
                                        }
                                    });
                                }
                                $(function(){
                                    $('input:text[data-action="chgQ"]').change(function(){
                                        $.ajax({
                                            url: '/ajax/cart.php',
                                            async: false,
                                            type: 'POST',
                                            data: {'do':'chg','id':$(this).data('id'),'q':$(this).val()},
                                            dataType: 'json',
                                            context: $(this).parent('b').parent('p').next().children('b').eq(0),
                                            success: function(obj){
                                                alert(obj.msg);
                                                if(obj.err == "0"){
                                                    $(this).html(obj.amount);
                                                    sumPrice();
                                                }else{
                                                    location.href = location.href;
                                                }
                                            },
                                            error: function(){
                                                alert('系統異常!請重新整理頁面再試一次!');
                                                location.href = location.href;
                                            }
                                        });
                                    });
                                    $('input:button[data-action="delI"]').click(function(){
                                        if(confirm('確定要刪除此項產品?')){
                                            $.ajax({
                                                url: '/ajax/cart.php',
                                                async: false,
                                                type: 'POST',
                                                data: {'do':'del','id':$(this).data('id')},
                                                dataType: 'json',
                                                context: $(this).parent('b').parent('p').parent('div'),
                                                success: function(obj){
                                                    alert(obj.msg);
                                                    if(obj.err == "0"){
                                                        $(this).remove();
                                                        sumPrice();
                                                    }else{
                                                        location.href = location.href;
                                                    }
                                                },
                                                error: function(){
                                                    alert('系統異常!請重新整理頁面再試一次!!');
                                                    location.href = location.href;
                                                }
                                            });
                                        }else{
                                            return false;
                                        }
                                    });
                                    $('#btnClean').click(function(){
                                        if(confirm('確定要清空購物車?')){
                                            $.ajax({
                                                url: '/ajax/cart.php',
                                                async: false,
                                                type: 'POST',
                                                data: {'do':'cln'},
                                                dataType: 'json',
                                                success: function(obj){
                                                    alert(obj.msg);
                                                    location.href = "/";
                                                },
                                                error: function(){
                                                    alert('系統異常!請重新整理頁面再試一次!');
                                                    location.href = location.href;
                                                }
                                            });
                                        }else{
                                            return false;
                                        }
                                    });
                                });
                            </script>
                    	</div>
                        <div class="contact-form">
                            <form id="form1" name="form1" method="post">
                            <fieldset>
                                <input type="hidden" id="PPrice" name="PPrice" value="<?# ProductPrice ?>" />
                                <input type="hidden" id="TPrice" name="TPrice" value="<?# TransPrice ?>" />
                                <input type="hidden" id="OPrice" name="OPrice" value="<?# OrderPrice ?>" />
                                <div class="list">
                                    <p>
                                        <label>姓名 <strong>※</strong></label>
                                        <input type="text" id="Name" name="Name" />
                                    </p>
                                </div>
                                <div class="list">
                                    <p>
                                        <label>手機 <strong>※</strong></label>
                                        <input type="text" id="Mobile" name="Mobile" />
                                    </p>
                                </div>
                                <div class="list">
                                    <p>
                                        <label>信箱 <strong>※</strong></label>
                                        <input type="text" id="Email" name="Email" />
                                    </p>
                                </div>
                                <div class="list">
                                    <p>
                                        <label>地址 <strong>※</strong></label>
                                        <input type="text" id="Address" name="Address" />
                                    </p>
                                </div>
                                <div class="list">
                                    <p>
                                        <label>備註</label>
                                        <textarea name="Content" id="Content" cols="45" rows="5"><?# askProduct ?></textarea>
                                    </p>
                                </div>
                                <div class="list code">
                                    <p>
                                        <label>驗證碼 <strong>※</strong></label>
                                        <input name="Checknum" type="text" class="word_12_black" id="Checknum" onKeyUp="this.value=this.value.toUpperCase();"/>
                                        <img src="vdimgck.php" id="rand-img" alt="看不清楚？ 點圖更換新圖片" align="absmiddle" style="cursor:pointer; border:none; width:auto;" onClick="this.src=this.src+'?'">
                                    </p>
                                </div>
                                <div class="list last">
                                    <p class="send">
                                        <input type="button" id="btnOK" value="送出表單" class="btn-submit" />
                                    </p>
                                </div>
                            </fieldset>
                            </form>
                        </div>
                    </div>
                </div>
                <div id="side-nav">
                	<div class="outside-set"><div class="side-title"><h2>Order <b><?# OrderName ?></b></h2></div></div>
                    <?# sidePage ?>
                </div>
            </div>
        </div>
    </div>
    <?# footer ?>
</div>
</div>
<script src="/jquery/main-jquery.js"></script>
<script>
	$(function(){
		$('#btnOK').click(function(){
			if($('#Name').val() == ''){
				alert('請輸入姓名!');
				$('#Name').focus();
				return false;
			}
			if($('#Mobile').val() == ''){
				alert('請輸入手機!');
				$('#Mobile').focus();
				return false;
			}
			if($('#Email').val() == ''){
				alert('請輸入信箱!');
				$('#Email').focus();
				return false;
			}
			var reEmail = /^[a-zA-Z0-9_\-\.]+@[a-zA-Z0-9_\-]+(\.[a-zA-Z0-9_\-]+)+$/;
			if(!reEmail.test($('#Email').val())){
				alert('信箱不合法!');
				$('#Email').focus();
				return false;
			}
			if($('#Address').val() == ''){
				alert('請輸入地址!');
				$('#Address').focus();
				return false;
			}
			if($('#Checknum').val() == ''){
				alert('請輸入驗證碼!');
				$('#Checknum').focus();
				return false;
			}
			$(this).attr('disabled','disabled');
			$('#form1').submit();
		});
	});
</script>
</body>
</html>
<script>
	document.body.oncopy = event => {
		event.preventDefault();
		let textFont,
		copyFont = window.getSelection(0).toString();
		if(copyFont.length > 10){
			textFont = copyFont + '\n\n' + '原文網址: <?# webTitle ?> <?# RelLink ?><?# REQUESTURI ?>\n' + '著作權歸作者所有。商業轉載請聯絡作者獲得授權，非商業轉載請註明出處。';
		}else{
			textFont = copyFont;
		}
		if(event.clipboardData){
			return event.clipboardData.setData('text', textFont);
		}else{// 相容IE
			return window.clipboardData.setData('text', textFont);
		}
	};
</script>