<!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">
                	<form id="form1" name="form1" action="faqList.php" method="get">
                    	<fieldset style="width: 960px;">
                        	<div class="abbNew" style="width: 125px; float: left; margin: 10px;"><a class="add" href="faqEdit.php?pUrl=<?# encodeUrl ?>">新增問與答</a></div>
                            <p style="width: 800px; margin: 15px auto;">問與答分類：
                                <select id="cid" name="cid">
                                    <option value="0" style="#000">全部分類</option>
                                        <php:repeater id="listC">
                                            <template>
                                                <option value="<?# CategoryID ?>"<?# opStyle ?>><?# CategoryName ?></option>
                                            </template>
                                        </php:repeater>
                                </select>
                                <input type="button" id="btnOK" name="btnOK" value="搜尋" />
                            </p>
                            <div class="titleTyp" style=" width: 960px;">
                                <div class="visible"><input type="checkbox" id="chkAll" name="chkAll" /></div>
                                <div class="visible">啟用</div>
                                <div class="loginName" style="width: 280px;">問與答名稱</div>
                                <div class="userName">問與答分類</div>
                                <div class="visible">排序</div>
                                <div class="operating">操作</div>
                            </div>
                            <php:repeater id="list">
                                <template>
                                    <div class="listTyp" style=" width: 960px;">
                                        <div class="visible"><input type="checkbox" name="chk[]" value="<?# FaqID ?>" /></div>
                                        <div class="visible"><?# Visible ?></div>
                                        <div class="loginName" style="width: 280px;"><?# Title ?></div>
                                        <div class="userName"><?# CategoryName ?></div>
                                        <div class="visible"><?# OrderNO ?></div>
                                        <div class="operating">
                                            <div class="modification"><a href="faqEdit.php?id=<?# FaqID ?>&pUrl=<?# encodedUrl ?>"><span></span>修改</a></div>
                                            <div class="delete"><a data-action="delItem" data-id="<?# FaqID ?>" href="javascript:void(0);"><span></span>刪除</a></div>
                                        </div>
                                    </div>
                                </template>
                            </php:repeater>
                            <p>
                            	<input type="button" id="btnDel" value="刪除" />
								<input type="button" id="btnVis" value="啟用" />
								<input type="button" id="btnUnVis" value="不啟用" />
                            	<?# 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(){
		$('#cid').val('<?# cid ?>');
		$('#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/faq.php',
					async: false,
					type: 'POST',
					data: {'do':'del','id':$(this).data('id')},
					dataType: "text",
					context: $(this).parent('div').parent('div').parent('div'),
					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/faq.php',
						async: false,
						type: 'POST',
						data: {'do':'del','ids':ids.join(',')},
						dataType: "text",
						success: function(msg){
							if(msg == '1'){
								if('<?# currentUrl ?>' == ''){
									location.href = 'faqList.php';
								}else{
									location.href = '<?# currentUrl ?>';
								}
							}else{
								alert('刪除失敗!\r\n'+msg);
							}
						},
						error: function(){
							alert('系統異常!!');
						}
					});
				}
			}
		});
		$('#btnVis').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{
				$.ajax({
					url: 'ajax/faq.php',
					async: false,
					type: 'POST',
					data: {'do':'vis','ids':ids.join(',')},
					dataType: "text",
					success: function(msg){
						if(msg == '1'){
							if('<?# currentUrl ?>' == ''){
								location.href = 'faqList.php';
							}else{
								location.href = '<?# currentUrl ?>';
							}
						}else{
							alert('啟用失敗!\r\n'+msg);
						}
					},
					error: function(){
						alert('系統異常!!');
					}
				});
			}
		});
		$('#btnUnVis').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{
				$.ajax({
					url: 'ajax/faq.php',
					async: false,
					type: 'POST',
					data: {'do':'unvis','ids':ids.join(',')},
					dataType: "text",
					success: function(msg){
						if(msg == '1'){
							if('<?# currentUrl ?>' == ''){
								location.href = 'faqList.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>