<!--{template 'head'}-->
<table cellpadding="1" cellspacing="1" border="0" align=center class="tableborder" >
	<tr>
		<td class="tablerow"><b>管理选项：</b>
			<a href="plugin.php?plugin=money&action=manage">广告位管理</a> | 
			<a href="plugin.php?plugin=money&action=add">添加广告位</a> | 
			<a href="plugin.php?plugin=money&action=cache">重新生成广告JS</a>
		</td>
	</tr>
</table>

<!--{if $action=='manage'}-->
<form method="post" name="myform">
<table cellpadding="0" cellspacing="0" class="tableborder bg" id="mytable">
	<tr>
		<td class="submenu" colspan=7 align=center> 广告位管理 </td>
	</tr>
	<tr align="center">
		<td width="30" class="tablerowhighlight" style="padding:0"></td>
		<td width="100" class="tablerowhighlight">唯一标识</td>
		<td class="tablerowhighlight">说明</td>
		<td class="tablerowhighlight" width="60">宽度</td>
		<td class="tablerowhighlight" width="60">广告数量</td>
		<td class="tablerowhighlight" width="60">展示数量</td>
		<td class="tablerowhighlight" width="280" >管理操作</td>
	</tr>
	<!--{if $data}-->
	<!--{loop $data $val}-->
	<tr align="center" class="item" id="item-{$id}">
		<td><input type="checkbox" name="id[]" id="ids_{$val[id]}" value="{$val[id]}"></td>
		<td align="left" style="padding-left:10px;">{$val[name]}</td>
		<td align="left" style="padding-left:10px;">{$val['description']}</td>
		<td>{$val[width]}</td>
		<td>{$val[total]}</td>
		<td><!--{if $val['num']}-->{$val[num]}个<!--{else}-->不限<!--{/if}--></td>
		<td style="padding-left:10px;text-align:left">
			<a href='plugin.php?plugin=money&action=manage_ad&id={$val[id]}'>管理广告</a> | <a href='plugin.php?plugin=money&action=add_ad&id={$val[id]}'>添加广告</a> | <a href='plugin.php?plugin=money&action=js&id={$val[id]}'>生成JS</a> | <a href='plugin.php?plugin=money&action=edit&id={$val[id]}'>修改</a> | <a href='plugin.php?plugin=money&action=delete&id={$val[id]}' onclick="return makeSure();">删除</a>
			<p style="color:blue;padding-top:5px"><input type="text" style="width:250px;" class="f-text" value="{$val['url']}" /></p>
		</td>
	</tr>
	<!--{/loop}-->
	<!--{else}-->
	<tr align="center">
		<td style="padding:15px;text-align:center" colspan="7">还没有广告位，<a href="plugin.php?plugin=money&action=add">点击添加</a></td>
	</tr>
	<!--{/if}-->
</table>	
</form>
<!--{/if}-->

<!--{if $action=='add' || $action == 'edit'}-->
<script language=JavaScript>
function doCheck()
{
	var field = ['name','description','width'];
	for(var i=0;i<field.length;i++){
		if(!$('ad_'+field[i]).value.trim()){
			alert("请认真填写");
			return false;
		}
	}
	$('submit').disabled = true;
}
</script>
<form name="myform" id="myform" method="post" action="plugin.php?plugin=money&action={$action}" onsubmit="return doCheck();">
<table cellpadding="2" cellspacing="1" class="tableborder">
	<tr>
		<th colspan=2>添加广告位</th>
	</tr>
	<tr>
		<td width="180" class="tablerowl"><font color="red">唯一标识</font></td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<input  <!--{if $action == 'add'}-->class="f-text"<!--{else}-->class="f-text readonly" readonly <!--{/if}-->  name="name" id="ad_name" type="text" size="30" value="{$_output['name']}" />
			</p>
			<p style="padding:5px 0;"><font color="green">只能使用英文字母a-z以及数字，一旦添加不允许修改</font></p>
		</td>
	</tr>
	<tr>
		<td class="tablerowl"><font color="red">广告位说明</font></td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<input name="description"  id="ad_description" class="f-text" type="text" size="60" value="{$_output['description']}" />
			</p>
			<p style="padding:5px 0;"><font color="green">方便管理人员自己记忆</font></p>
		</td>
	</tr>
	<tr>
		<td class="tablerowl"><font color="red">限制宽度</font></td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<input name="width" id="ad_width" class="f-text" type="text" size="10" value="{$_output['width']}" /> px 
			</p>
			<p style="padding:5px 0;"><font color="green">该广告位下的广告宽度均不能超过此限制</font></p>
		</td>
	</tr>
	<tr>
		<td class="tablerowl"><font color="red">该广告位下最大展现广告数量</font></td>
		<td class="tablerow">
			<p style="padding-top:5px;">
				<input name="num" id="ad_num" class="f-text" type="text" size="10" value="{$_output['num']}" /> 个 
			</p>
			<p style="padding-top:5px;"><font color="green">如果为空或者0，则表示不限制</font></p>
			<p style="padding:5px 0;"><font color="green">否则系统只会显示广告位下排序最高的几个广告</font></p>
		</td>
	</tr>
	<tr>
		<td class="tablerowl" colspan=2>
			<input type='hidden' name='id' value='{$_output['id']}' />
			<input type='hidden' name='myFormAc' value='update' />
			<input type="submit" id='submit' value=" 确定 " class="f-button" > &nbsp;
		</td>
	</tr>
</table>
</form>
<!--{/if}-->


<!--{if $action=='manage_ad'}-->
<form method="post" name="myform">
<table cellpadding="0" cellspacing="0" class="tableborder bg" id="mytable">
	<tr>
		<td class="submenu" colspan=8 align=center> 广告管理 </td>
	</tr>
	<tr align="center">
		<td width="40" class="tablerowhighlight"></td>
		<td width="200" class="tablerowhighlight">广告名称</td>
		<td width="120" class="tablerowhighlight">所属广告位</td>
		<td width="100" class="tablerowhighlight">广告类型</td>
		<td width="80" class="tablerowhighlight">广告状态</td>
		<td width="80" class="tablerowhighlight">排序</td>
		<td width="80" class="tablerowhighlight">截止时间</td>
		<td class="tablerowhighlight">管理操作</td>
	</tr>
	<!--{if $data}-->
	<!--{loop $data $val}-->
	<tr align="center" class="item" id="item-{$pid}">
		<td><input type="checkbox" name="id[]" id="ids_{$val[pid]}" value="{$val[pid]}"></td>
		<td align="left" style="padding-left:10px;">
			{$val['subject']}
		</td>
		<td align="left" style="padding-left:10px;">{$val['name']}</td>
		<td align="left" style="padding-left:10px;">{$val['type']}</td>
		<td align="left" style="text-align:center"><!--{if $val['status']}-->正常<!--{else}-->关闭<!--{/if}--></td>
		<td align="left" style="text-align:center">{$val['ordering']}</td>
		<td align="left" style="text-align:center">{$val['closetime_tip']}</td>
		<td><a href='plugin.php?plugin=money&action=edit_ad&pid={$val[pid]}'>修改</a> | <a onclick="return makeSure()" href='plugin.php?plugin=money&action=delete_ad&pid={$val[pid]}'>删除</a></td>
	</tr>
	<!--{/loop}-->
	<!--{else}-->
	<tr align="center">
		<td style="padding:15px;text-align:center" colspan="8">当前广告位下还没有广告，<a href="plugin.php?plugin=money&action=add_ad&id={$id}">点击添加广告</a></td>
	</tr>
	<!--{/if}-->	
</table>	
</form>
<!--{/if}-->


<!--{if $action=='add_ad' || $action == 'edit_ad'}-->
<form name="myform" id="myform" method="post" action="plugin.php?plugin=money&action={$action}&id={$id}" onsubmit="return doCheck();">
<table cellpadding="2" cellspacing="1" class="tableborder">
	<tr>
		<th colspan=2>添加广告</th>
	</tr>
	<tr>
		<td width="150" class="tablerowl"><font color="red">广告名称</font></td>
		<td class="tablerow">
			<input class="f-text" name="subject" id="ad_subject" type="text" size="30" value="{$_output['subject']}" />
			<font color="green">方便管理人员自己记忆</font>
		</td>
	</tr>
	<tr>
		<td class="tablerowl"><font color="red">广告类型</font></td>
		<td class="tablerow">
			<select name="type" id="ad_type" onchange="showAdField(this.value);">
				<option value="word"<!--{if $_output['type'] == 'word'}--> selected<!--{/if}-->>文字链</option>
				<option value="img"<!--{if $_output['type'] == 'img'}--> selected<!--{/if}-->>图片广告</option>
				<option value="flash"<!--{if $_output['type'] == 'flash'}--> selected<!--{/if}-->>FLash广告</option>
				<option value="code"<!--{if $_output['type'] == 'code'}--> selected<!--{/if}-->>HTML代码</option>
				<option value="iframe"<!--{if $_output['type'] == 'iframe'}--> selected<!--{/if}-->>IFRAME广告</option>
				<option value="newwin"<!--{if $_output['type'] == 'newwin'}--> selected<!--{/if}-->>弹窗广告</option>
			</select>
		</td>
	</tr>
	<tr id="view-word">
		<td class="tablerowl"><font color="red">文字链内容</font></td>
		<td class="tablerow">
			<input class="f-text" name="word" id="ad_word" type="text" size="60" value="{$_output['word']}" />
		</td>
	</tr>
	<tr id="view-link">
		<td class="tablerowl"><font color="red">链接地址/新窗口地址</font></td>
		<td class="tablerow">
			<input class="f-text" name="link" id="ad_link" type="text" size="60" value="{$_output['link']}" />
		</td>
	</tr>	
	<tr id="view-src">
		<td class="tablerowl"><font color="red">图片/Flash地址</font></td>
		<td class="tablerow">
			<input class="f-text" name="src" id="ad_src" type="text" size="60" value="{$_output['src']}" />
			<input type='button' onclick="uploadSelect()" value=" 上传 " />
		</td>
	</tr>	
	<tr id="view-width">
		<td class="tablerowl"><font color="red">宽度</font></td>
		<td class="tablerow">
			<input class="f-text" name="width" id="ad_width" type="text" size="6" value="{$_output['width']}" /> px
		</td>
	</tr>	
	<tr id="view-height">
		<td class="tablerowl"><font color="red">高度</font></td>
		<td class="tablerow">
			<input class="f-text" name="height" id="ad_height" type="text" size="6" value="{$_output['height']}" /> px
		</td>
	</tr>	
	<tr id="view-code">
		<td class="tablerowl"><font color="red">广告代码</font></td>
		<td class="tablerow">
			<div style="position:relative;">
				<textarea id="ad_code" class="text-data" name="code" style="width:500px;height:200px" wrap="off" oncontextmenu="return false">{$_output['code']}</textarea>
				<textarea id="ad_index" style="width:35px;height:200px;" readonly="true" class="text-index"></textarea>
				<div style="width:42px;height:202px;"class="text-index-parent"></div>
			</div>
		</td>
	</tr>	
	<tr>
		<td class="tablerowl">广告状态</td>
		<td class="tablerow">
			<input type="checkbox" name="status" id="ad_status" value="1"<!--{if $_output['status']}--> checked<!--{/if}--> /> <label for="ad_status">正常投放</label>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">广告排序</td>
		<td class="tablerow">
			<input class="f-text" name="ordering" id="ad_ordering" type="text" size="6" value="{$_output['ordering']}" />
			<font color="green">数字越大，越向前排</font>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">截止时间</td>
		<td class="tablerow">
			<input class="f-text" name="closetime" id="ad_closetime" type="text" size="15" value="{$_output['closetime']}" />
			<font color="green">填0表示永不过期</font>
		</td>
	</tr>	
	<tr>
		<td class="tablerowl">投放频道</td>
		<td class="tablerow">
			<select name="channelid">
				<option value="0">所有频道</option>
				<!--{loop $channel $val}-->
				<option value="{$val['channelid']}"<!--{if $_output['channelid'] == $val['channelid']}--> selected<!--{/if}-->>{$val['channelname']}</option>
				<!--{/loop}-->
			</select>
		</td>
	</tr>	
	<tr>
		<td class="tablerowl">匹配条件</td>
		<td class="tablerow">
			<select name="filter_type"><option value="0"<!--{if $_output['filter_type'] == 0}--> selected<!--{/if}-->>网址含有</option><option value="1"<!--{if $_output['filter_type'] > 0}--> selected<!--{/if}-->>网址不含有</option></select> <input name="filter_val" type="text" class="f-text" value="{$_output['filter_val']}" size="40" />
			<font color="green">不填表示不限制</font>
		</td>
	</tr>	
	<tr>
		<td class="tablerowl" colspan=2>
			<input type='hidden' name='pid' value="{$_output['pid']}" />
			<input type='hidden' name='myFormAc' value='update' />
			<input type="submit" id='submit' value=" 确定 " class="f-button" > &nbsp;
		</td>
	</tr>
</table>
</form>
<script type="text/javascript">
var localf = {word:['word','link'], img:['src','link','width','height'], flash:['src','link','width','height'], code:['code','width','height'], newwin:['link','width','height'], iframe:['link','width','height']};
function uploadSelect(){
	if($('ad_type').value == 'img'){
		qmeCms.dialogView.iframe('上传图片','system.php?sys=upload&id=ad_src&path=attachment/money',{type:'abs'});
	}else{
		qmeCms.dialogView.iframe('上传Flash','system.php?sys=upload&file_type=flash&id=ad_src&path=attachment/money',{type:'abs'});
	}
}
function doCheck(){
	if(!$('ad_subject').value.trim()){
		alert('请填写广告名称');
		return false;
	}
	var e = $('ad_type').value.trim();
	var d = localf[e];
	for(var i=0;i<d.length;i++){
		if(!$('ad_'+d[i]).value.trim()){
			alert('请认真填写广告数据');
			return false;
		}
	}
	$('submit').disabled = true;
	return true;
}
function showAdField(v){
	var a = ['word','src','link','width','height','code'];
	var d = localf[v];
	for(var i=0;i<a.length;i++){
		$('view-'+a[i]).style.display = 'none';
	}
	for(var i=0;i<d.length;i++){
		$('view-'+d[i]).style.display = '';
	}	
};
showAdField($('ad_type').value);
domReady(function(){
	new qmeCms.Calendar("ad_closetime");
});
new qmeCms.areaIndex('ad_code', 'ad_index');
</script>
<!--{/if}-->

<!--{template 'foot'}-->
