<!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>
		<form name="form1" action="ad_edit.php" method="post" enctype="multipart/form-data">
			<input type="hidden" name="aid" value="<?php echo $aid?>">
			<input type="hidden" name="dopost" value="saveedit">
			<input type="hidden" name="_csrf_token" value="<?php echo $GLOBALS['csrf_token'];?>">
			<table class="table shadow-sm my-3">
				<tr>
					<td colspan="2"><a href="ad_main.php">广告管理</a> - 修改广告</td>
				</tr>
				<tr>
					<td width="260">广告位标识：</td>
					<td><?php echo $row['tagname'];?></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($row['typeid'],0,0);
						echo "<select name='typeid' class='admin-input-lg'>";
						echo "<option value='0' selected>投放在没有同名标识的所有栏目</option>";
						echo $typeOptions;
						echo "</select>";
						?>
						<span>（如果在所选栏目找不到指定标识的广告文档，系统会自动搜索父栏目）</span>
					</td>
				</tr>
				<tr>
					<td>广告位名称：</td>
					<td><input type="text" name="adname" id="adname" value="<?php echo $row['adname']?>" class="admin-input-lg"></td>
				</tr>
				<tr>
					<td>时间限制：</td>
					<td>
						<label><input type="radio" name="timeset" value="0" <?php if ($row['timeset']==0) echo 'checked';?>> 永不过期</label>
						<label><input type="radio" name="timeset" value="1" <?php if ($row['timeset']==1) echo 'checked';?>> 在设内时间内有效</label>
					</td>
				</tr>
				<tr>
					<td>投放时间：</td>
					<td>
						<label>从：<input type="text" name="starttime" id="starttime" value="<?php echo GetDateTimeMk($row['starttime'])?>" class="datepicker admin-input-sm"></label>
						<label>到：<input type="text" name="endtime" id="endtime" value="<?php echo GetDateTimeMk($row['endtime'])?>" class="datepicker admin-input-sm"></label>
					</td>
				</tr>
				<tr>
					<td>正常显示：</td>
					<td><textarea name="normbody" id="normbody" class="admin-textarea-xl"><?php echo dede_htmlspecialchars(stripslashes($row['normbody']))?></textarea></td>
				</tr>
				<tr>
					<td>过期显示：</td>
					<td><textarea name="expbody" id="expbody" class="admin-textarea-xl"><?php echo dede_htmlspecialchars($row['expbody'])?></textarea></td>
				</tr>
				<tr>
					<td colspan="2" align="center"><button type="submit" class="btn btn-success btn-sm">保存</button></td>
				</tr>
			</table>
		</form>
		<script>
			function checkSubmit() {
				if (document.form1.tagname.value == "") {
					alert("请输入广告位标识");
					document.form1.tagname.focus();
					return false;
				}
			}
			$(document).ready(function() {
				$('.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>