<!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>
</head>

<body>
	<div class="wrapper">
    	<?# header ?>
    	<div class="wrap">
        	<?# sidePage ?>
            <div class="contentMain">
            	<h3>聯絡我們列表</h3>
                <div class="article" style=" width: 100%;">
                    <form id="form1" name="form1" action="contactList.php" method="get">
                    	<fieldset style="width: 100%;">
                            <p style="width: 900px; margin: 15px auto;">
                            關鍵字： <input type="text" id="kw" name="kw" value="<?# kw ?>" />
                            <input type="button" id="btnOK" name="btnOK" value="搜尋" />
                            </p>
                            <div class="titleTyp" style=" width: 100%;">
                            	<div class="visible"><input type="checkbox" id="chkAll" name="chkAll" /></div>
                                <div class="visible">讀取</div>
                                <div class="visible">回覆</div>
                                <div class="loginName" style=" width: 180px;">標題</div>
                                <div class="loginName">姓名</div>
                                <div class="mail" style=" width: 180px;">信箱</div>
                                <div class="userName" style=" width: 130px;">電話</div>
                                <div class="mail">日期</div>
                                <div class="operating">操作</div>
                            </div>
                            <php:repeater id="list">
                                <template>
                                    <div class="listTyp" style=" width: 100%;">
                                        <div class="visible"><input type="checkbox" name="chk[]" value="<?# ContactID ?>" /></div>
                                        <div class="visible"><?# IsView ?></div>
                                        <div class="visible"><?# IsReply ?></div>
                                        <div class="loginName" style=" width: 180px;"><?# Title ?></div>
                                        <div class="loginName"><?# Name ?></div>
                                        <div class="mail" style=" width: 180px;"><?# Email ?></div>
                                        <div class="userName" style=" width: 130px;"><?# Phone ?></div>
                                        <div class="mail"><?# CreatedDate ?></div>
                                        <div class="operating">
                                            <div class="modification"><a href="contactView.php?id=<?# ContactID ?>&pUrl=<?# encodedUrl ?>"><span></span>修改</a></div>
                                            <div class="delete"><a data-action="delItem" data-id="<?# ContactID ?>" href="javascript:void(0);"><span></span>刪除</a></div>
                                        </div>
                                    </div>
                                </template>
                            </php:repeater>
                            <p>
                            	<input type="button" id="btnDel" value="刪除" /> &nbsp;&nbsp;
                                <?# pagtxt ?>&nbsp; &nbsp;每頁&nbsp;<input type="text" id="pz" name="pz" value="<?# pz ?>" style="width:20px;" />&nbsp;筆資料，跳到第&nbsp;<input type="text" id="p" name="p" value="<?# p ?>" style="width:20px;" />&nbsp;頁&nbsp;<input type="button" id="btnGO" name="btnGO" value="GO" /
                            </p>
                        </fieldset>
                    </form>
                </div>
            </div>
        </div>
        <?# footer ?>
    </div>
<script>
<!--
	$(function(){
		$('#btnOK').click(function(){
			$('#p').val('1');
			$('#form1').submit();
		});
		$('#chkAll').click(function(){
			$('input:checkbox[name="chk[]"]').attr('checked',$('#chkAll').is(':checked'));
		});
		$('a[data-action="delItem"]').click(function(){
			if(!confirm('刪除資料後將無法恢復!是否確定要刪除聯絡我們資料?')){
				return false;
			}else{
				$.ajax({
					url: 'ajax/contact.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "text",
					context: $(this).parent('td').parent('tr'),
					success: function(msg){
						if(msg == '1'){
							$(this).remove();
						}else{
							alert('刪除失敗!\r\n'+msg);
						}
					},
					error: function(){
						alert('系統異常!!');
					}
				});
			}
		});
		$('#btnDel').click(function(){
			var ids = [];
			$('input:checkbox[name="chk[]"]:checked').each(function(index, element){
				ids[ids.length] = $(element).val();
			});
			if(ids.length == 0){
				alert('請先勾選要刪除的聯絡我們!');
				return false;
			}else{
				if(!confirm('刪除資料後將無法恢復!是否確定要刪除勾選的聯絡我們資料?')){
					return false;
				}else{
					$.ajax({
						url: 'ajax/contact.php',
						async: false,
						type: 'POST',
						data: {'do':'del','ids':ids.join(',')},
						dataType: "text",
						success: function(msg){
							if(msg == '1'){
								if('<?# currentUrl ?>' == ''){
									location.href = 'contactList.php';
								}else{
									location.href = '<?# currentUrl ?>';
								}
							}else{
								alert('刪除失敗!\r\n'+msg);
							}
						},
						error: function(){
							alert('系統異常!!');
						}
					});
				}
			}
		});
		$('a[data-action="goPage"]').click(function(){
			$('#p').val($(this).data('id'));
			$('#form1').submit();
		});
		$('#btnGO').click(function(){
			$('#form1').submit();
		});
	});
//-->
</script>
</body>
</html>