<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
		<title>添加广告</title>
		<link rel="stylesheet" href="/static/web/css/font-awesome.min.css">
		<link rel="stylesheet" href="/static/web/css/bootstrap.min.css">
		<link rel="stylesheet" href="/static/web/css/admin.css">
		<link rel="stylesheet" href="/static/web/css/daterangepicker.css">
		<script src="/static/web/js/jquery.min.js"></script>
		<script src="/static/web/js/moment.min.js"></script>
		<script src="/static/web/js/daterangepicker.js"></script>
	</head>
	<body>
		<div class="container-fluid">
			<ol class="breadcrumb">
				<li class="breadcrumb-item"><a href="index_body.php">后台面板</a></li>
				<li class="breadcrumb-item"><a href="ad_main.php">广告管理</a></li>
				<li class="breadcrumb-item active">添加广告</li>
			</ol>
			<div class="card shadow-sm">
				<div class="card-header">添加广告</div>
				<div class="card-body">
					<div class="alert alert-info">标签{dede:myad name='广告标记'/}调用</div>
					<form name="form1" action="ad_add.php" method="post">
						<input type="hidden" name="normbody[style]" value="code" id="adstyle">
						<input type="hidden" name="_csrf_token" value="<?php echo $GLOBALS['csrf_token'];?>">
						<input type="hidden" name="dopost" value="save">
						<div class="table-responsive">
							<table class="table table-borderless">
								<tbody>
									<tr>
										<td width="260">广告名称</td>
										<td><input type="text" name="adname" id="adname" class="admin-input-lg" required></td>
									</tr>
									<tr>
										<td>广告标记</td>
										<td><input type="text" name="tagname" id="tagname" class="admin-input-lg" required>（使用英文或数字表示标识）</td>
									</tr>
									<tr>
										<td>广告分类</td>
										<td>
											<select name="clsid" id="clsid" class="admin-input-sm">
												<option value="0">默认分类</option>
												<?php echo $option;?>
											</select>
										</td>
									</tr>
									<tr>
										<td>投放范围</td>
										<td>
											<?php
											$tl = new TypeLink(0);
											$typeOptions = $tl->GetOptionArray(0,0,0);
											echo "<select name='typeid' class='admin-input-sm'>";
											echo "<option value='0' selected>没有同名标记所有栏目</option>";
											echo $typeOptions;
											echo "</select>";
											?>
											<span>（栏目找不到指定广告标记，则自动搜索父栏目）</span>
										</td>
									</tr>
									<tr>
										<td>时间限制</td>
										<td>
											<label><input type="radio" name="timeset" value="0" checked> 不限时间</label>
											<label><input type="radio" name="timeset" value="1"> 限制时间</label>
										</td>
									</tr>
									<tr>
										<td>投放时间</td>
										<td>
											<label>从：<input type="text" name="starttime" id="starttime" value="<?php echo $startDay?>" class="datepicker admin-input-sm"></label>
											<label>到：<input type="text" name="endtime" id="endtime" value="<?php echo $endDay?>" class="datepicker admin-input-sm"></label>
										</td>
									</tr>
									<tr>
										<td>广告内容</td>
										<td>
											<ul id="adTab" class="adtab">
												<li id="t_code" class="active">代码</li>
												<li id="t_txt">文字</li>
												<li id="t_img">图片</li>
												<li id="t_flash">Flash</li>
											</ul>
											<div id="advert"></div>
										</td>
									</tr>
									<tr>
										<td>过期内容</td>
										<td><textarea name="expbody" id="expbody" class="admin-textarea-xl"></textarea></td>
									</tr>
									<tr>
										<td colspan="3" align="center">
											<button type="submit" class="btn btn-success btn-sm">保存</button>
											<button type="reset" class="btn btn-outline-success btn-sm">重置</button>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</form>
					<div id="formtxt" style="display:none">
						<div id="code" class="content">
							<textarea name="normbody[htmlcode]" class="admin-textarea-xl" placeholder="请输入广告，支持网页代码"></textarea>
						</div>
						<div id="txt" class="content">
							<p><input type="text" name="normbody[title]" class="admin-input-lg" placeholder="请输入文字标题"></p>
							<p><input type="text" name="normbody[link]" class="admin-input-lg" placeholder="请输入文字链接"></p>
							<p><input type="text" name="normbody[color]" class="admin-input-lg" placeholder="请输入文字颜色"></p>
							<input type="text" name="normbody[size]" class="admin-input-lg" placeholder="请输入文字大小">
						</div>
						<div id="img" class="content">
							<p><input type="text" name="normbody[url]" class="admin-input-lg" placeholder="请输入图片地址"></p>
							<p><input type="text" name="normbody[link]" class="admin-input-lg" placeholder="请输入图片链接"></p>
							<p><input type="text" name="normbody[width]" class="admin-input-lg" placeholder="请输入图片宽度"></p>
							<p><input type="text" name="normbody[height]" class="admin-input-lg" placeholder="请输入图片高度"></p>
							<input type="text" name="normbody[descrip]" class="admin-input-lg" placeholder="请输入图片描述">
						</div>
						<div id="flash" class="content">
							<p><input type="text" name="normbody[link]" class="admin-input-lg" placeholder="请输入flash链接"></p>
							<p><input type="text" name="normbody[width]" class="admin-input-lg" placeholder="请输入flash宽度"></p>
							<input type="text" name="normbody[height]" class="admin-input-lg" placeholder="请输入flash高度">
						</div>
					</div>
				</div>
			</div>
		</div>
		<script>
			function showcode(idName) {
				$("#advert").html("").html($("#formtxt>#" + idName).html());
				$("#adstyle").val(idName);
			}
			showcode('code');
			$(document).ready(function() {
				$("#adTab>li").click(function() {
					var tabLi = $(this);
					var thistab = tabLi[0].id;
					$(".content").each(function() {
						if ("t_" + $(this)[0].id == thistab) {
							$("#adTab>li").removeClass("active");
							$("#t_" + $(this)[0].id).addClass("active");
							showcode($(this)[0].id);
						}
					})
				});
				$('.datepicker').daterangepicker({
					"singleDatePicker": true,
					"autoApply": true,
					"showDropdowns": true,
					"linkedCalendars": false,
					"timePicker": true,
					"timePicker24Hour": true,
					"showCustomRangeLabel": false,
					ranges: {
						'今日': [moment(), moment()],
						'昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
						'本月': [moment().startOf('month'), moment().startOf('month')],
						'上月': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').startOf('month')]
					},
					"locale": {
						format: 'YYYY-MM-DD HH:mm',
						applyLabel: '确定',
						cancelLabel: '取消',
						daysOfWeek: ['日', '一', '二', '三', '四', '五', '六'],
						monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
						firstDay: 1
					}
				}, function(start) {
					$(this).val(start.format("YYYY-MM-DD HH:mm"));
				});
			});
		</script>
	</body>
</html>