<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=popbox}-->
<!--{include file=elements/header.js.html type=valid}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>赚钱广告&nbsp;&gt;&nbsp;网站广告&nbsp;&gt;&nbsp;广告内容管理
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=Ad.adlist&menu_id=51" class="nolink">广告内容管理</a>
				<a href="index.php?r=Ad.report&menu_id=51" class="link">广告数据报表</a>
			</div>
			<div id="secrightContent">
				<div class="tableContent2">
					<form id="searchForm" action="index.php" method="get" onSubmit="setDisabled(':button',window.document)">
						<input type="hidden" name="r" value="Ad.adlist"/>
						<input type="hidden" id="status" name="status" value="<!--{$status}-->"/>
						<input type="hidden" id="orderby" name="orderby" value="<!--{$orderby}-->"/>
					</form>
					<div class="operation">
						<button type="button" class="but2font" onClick="addAd('<!--{$returnParams}-->')">新增</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=Ad.updatestatus&status=1&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定发布？')">发布</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=Ad.updatestatus&status=9&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定下线？')">下线</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=Ad.delete&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '删除之后，信息无法恢复，是否确定删除？')">删除</button>
					</div>
					<table class="tbl_list" width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr class="thead">
							<td width="5%"><input type="checkbox" class="checkall"/></td>
							<td width="7%">广告ID</td>
							<td width="15%">广告名称</td>
							<td width="25%">广告语</td>
							<td width="10%">
								<!--{if $orderby == pv0}-->
									<a class="link" onClick="$('#orderby').val('pv1');$('#searchForm').submit();">今日点击↑</a>
								<!--{else}-->
									<a class="link" onClick="$('#orderby').val('pv0');$('#searchForm').submit();">今日点击↓</a>
								<!--{/if}-->
							</td>
							<td width="14%">备注</td>
							<td width="10%">投放位置</td>
							<td width="6%"><select onChange="$('#status').val($(this).val());$('#searchForm').submit();">
								<option value="">状态</option>
								<option value="1" <!--{if $status == 1}-->selected<!--{/if}-->>已发布</option>
								<option value="9" <!--{if $status == 9}-->selected<!--{/if}-->>未发布</option>
							</select></td>
							<td width="8%">操作</td>
						</tr>
						<!--{foreach from=$datalist item=data}-->
						<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
							<td><input type="checkbox" name="recordId" value="<!--{$data.id}-->"/></td>
							<td><!--{$data.id}--></td>
							<td><!--{$data.ad_name}--></td>
							<td><!--{$data.ad_language}--></td>
							<td><!--{$data.pv}--></td>
							<td><!--{$data.memo}--></td>
							<td><a href="index.php?r=Ad.setupad&ad_id=<!--{$data.id}-->&returnParams=<!--{$returnParams}-->">设置</a><!--{if $data.setup_flag == 0}-->[未设置]<!--{elseif $data.setup_flag == 1}-->[已设置]<!--{/if}--></td>
							<td><!--{if $data.status == 1}-->已发布<!--{elseif $data.status == 9}-->未发布<!--{/if}--></td>
							<td>
								<a href="javascript:updateAd('<!--{$data.id}-->', '<!--{$returnParams}-->')">修改</a>
								<a href="index.php?r=Ad.report&ad_id=<!--{$data.id}-->">报表</a>
							</td>
						</tr>
						<!--{foreachelse}-->
						<tr><td colspan="9">没有对应数据</td></tr>
						<!--{/foreach}-->
					</table>
					<div class="operation">
						<button type="button" class="but2font" onClick="addAd('<!--{$returnParams}-->')">新增</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=Ad.updatestatus&status=1&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定发布？')">发布</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=Ad.updatestatus&status=9&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '确定下线？')">下线</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=Ad.delete&returnParams=<!--{$returnParams}-->', 'recordId', 'ids', '删除之后，信息无法恢复，是否确定删除？')">删除</button>
					</div>
					<div class="page"><!--{$pager}--></div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
function addAd(returnParams){
	var str = "<form id=\"adForm\" action=\"index.php?r=Ad.add\" method=\"post\">";
	str += "<input type=\"hidden\" name=\"returnParams\" value=\""+decodeURIComponent(returnParams)+"\"/>";
	str += "<table class=\"tbl_edit\" width=\"100%\"><tr>";
	str += "<td class=\"td_name\">广告名称<span style=\"color:red;\">*</span></td>";
	str += "<td class=\"td_content\"><input type=\"text\" class=\"text\" id=\"ad_name\" name=\"data[Ad][ad_name]\" maxlength=\"128\"/><span id=\"span_ad_name\"></span></td>";
	str += "</tr><tr>";
	str += "<td class=\"td_name\">广告语(用 | 分割)<span style=\"color:red;\">*</span></td>";
	str += "<td class=\"td_content\"><input type=\"text\" class=\"text\" id=\"ad_language\" name=\"data[Ad][ad_language]\" maxlength=\"512\"/><span id=\"span_ad_language\"></span></td>";
	str += "</tr><tr>";
	str += "<td class=\"td_name\">广告链接<span style=\"color:red;\">*</span></td>";
	str += "<td class=\"td_content\"><input type=\"text\" class=\"text\" id=\"ad_url\" name=\"data[Ad][ad_url]\" maxlength=\"512\"/><span id=\"span_ad_url\"></span></td>";
	str += "</tr><tr>";
	str += "<td class=\"td_name\">备注</td>";
	str += "<td class=\"td_content\"><input type=\"text\" class=\"text\" name=\"data[Ad][memo]\" maxlength=\"1000\"/></td>";
	str += "</tr><tr>";
	str += "<td class=\"noborder\"></td>";
	str += "<td class=\"noborder\"><button type=\"submit\" class=\"butsubmit\">提交</button></td>";
	str += "</tr></table></form>";
	$.popbox({title:"新增广告内容", content:str, height:220});
	adValid();
}

function updateAd(id, returnParams){
	$.popbox({title:"修改广告内容", content:popstr_search});
	$.ajax({
		url: "index.php?r=Ad.update&id="+id+"&returnParams="+returnParams,
		type: "get",
		cache: false,
		dataType: "text",
		success: function(data){
			$.popbox.setcontent({title:"修改广告内容", content:data, height:220});
		}
	});
}

function adValid(){
	$("#adForm").validate({
		rules: {
			"data[Ad][ad_name]" : "required",
			"data[Ad][ad_language]" : "required",
			"data[Ad][ad_url]" : "required"
		},
		messages: {
			"data[Ad][ad_name]" : "请输入广告名称",
			"data[Ad][ad_language]" : "请输入广告语",
			"data[Ad][ad_url]" : "请输入广告链接"
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			setDisabled(":button",window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		},
		onkeyup: false
	});
}
</script>
</html>