<!--{template 'head'}-->
<script type="text/javascript">
setSubject("系统设置");
</script>
<table width='100%' border='0' align='center' cellpadding='2' cellspacing='0' class='tableborder'>
<tr>
	<td  class="tablerow"><strong>管理：</strong><a href="system.php?sys=cron&action=manage">任务管理</a> | <a href="system.php?sys=cron&action=add">添加任务</a></td>
</tr>
</table>

<!--{if $action == 'manage'}-->
<script type="text/javascript">
function runCron(id){
	if(makeSure()){
		var url = "system.php?sys=cron&action=run&id="+id;
		qmeCms.dialogView.form("计划任务", "<p class='loading'>计划任务执行中，请等待....</p>", {width:400});
		AJAX.request(url,{method:'get',onComplete:function(resp){
			var json = evaljson(resp);
			if(json['status'] == 200){
				qmeCms.dialogView.setMessage('执行成功');
			}else{
				qmeCms.dialogView.setMessage(json.message);
			}
		}});	
	}
	return false;
}
</script>
<style>
#mytable td{padding:5px 0}
</style>
<table cellpadding="0" cellspacing="0" class="tableborder bg" id="mytable">
	<tr align="center">
		<td width="30" class="tablerowhighlight"></td>
		<td class="tablerowhighlight">名称</td>
		<td width="150" class="tablerowhighlight">文件名</td>
		<td width="60" class="tablerowhighlight">状态</td>
		<td width="120" class="tablerowhighlight">上次执行时间</td>
		<td width="120" class="tablerowhighlight">执行规则</td>
		<td width="120" class="tablerowhighlight">操作</td>
	</tr>
	<!--{if $data}-->
	<!--{loop $data $val}-->
	<tr align="center" class="item" id="item-{$val['id']}">
		<td><input type="checkbox" name="id[]" id="ids_{$val[id]}" value="{$val[id]}"></td>
		<td align="left" style="padding-left:10px;">{$val[title]}</td>
		<td align="left" style="padding-left:10px;">{$val[name]}</td>
		<td><!--{if $val['status']}-->运行<!--{else}-->停止<!--{/if}--></td>
		<td><!--{echo qbase::formatTime('Y-n-d H:i', $val['lasttime'])}--></td>
		<td>{$val['filter']}</td>
		<td><a href='###' onclick="return runCron({$val[id]})">执行</a> | <a href='system.php?sys=cron&action=modify&id={$val[id]}'>修改</a> | <a href='system.php?sys=cron&action=delete&id={$val[id]}' onclick="return makeSure()">删除</a></td>
	</tr>
	<!--{/loop}-->
	<!--{else}-->
	<tr>
		<td class="tablerowl" colspan="7">
			<p style="padding:12px">没有计划任务，<a href="system.php?sys=cron&action=add">点击添加</a></p>
		</td>
	</tr>
	<!--{/if}-->
</table>
<!--{/if}-->

<!--{if $action == 'add' || $action == 'modify'}-->
<form action="system.php?sys=cron&action={$action}&id={$id}" method="post" onsubmit="$('submit-act').disabled=true;return true;">
	<table cellpadding="2" cellspacing="1" class="tableborder bg border">
		<tr>
		  <th colspan=2><strong>系统计划任务更改</strong></th>
		</tr>
		<tr>
			<td class="tablerowl" width="200">名称</td>
			<td class="tablerow">
				<input type="text" name="title" value="{$_output['title']}" size="40" class="f-text" />
				<p style="color:green;padding-top:5px;">仅仅用于自己记忆，没有其它用途</p>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">文件名</td>
			<td class="tablerow">
				<input type="text" name="name" value="{$_output['name']}" size="40" class="f-text" />
				<p style="color:green;padding-top:5px;">执行脚本php文件名(该文件必须放在 include/cron/ 目录里面, 不能含有特殊字符)</p>
			</td>
		</tr>	
		<tr>
			<td class="tablerowl">状态</td>
			<td class="tablerow">
				<input type="checkbox" name="status" id="status" value="1" <!--{if $_output['status']}--> checked<!--{/if}--> /> <label for="status">运行</label>
			</td>
		</tr>
		<tr>
			<td class="tablerowl">执行规则</td>
			<td class="tablerow" align="left">
				<table border="0" cellpadding='0' cellspacing='0' width="200">
					<tr>
						<td height="24" width="50" align="center">分钟</td>
						<td width="50" align="center" style="padding-left:5px;">小时</td>
						<td width="50" align="center" style="padding-left:5px;">天</td>
						<td width="50" align="center" style="padding-left:5px;">周</td>
					</tr>
					<tr>
						<td width="50" align="center"><input type="text" name="filter[m]" value="<!--{echo $_output['filter']['m']}-->" class="f-text" size="5" style="text-align:center" /></td>
						<td width="50" align="center" style="padding-left:5px;"><input type="text" name="filter[h]" value="<!--{echo $_output['filter']['h']}-->" class="f-text" size="5" style="text-align:center" /></td>
						<td width="50" align="center" style="padding-left:5px;"><input type="text" name="filter[d]" value="<!--{echo $_output['filter']['d']}-->" class="f-text" size="5" style="text-align:center" /></td>
						<td width="50" align="center" style="padding-left:5px;"><input type="text" name="filter[w]" value="<!--{echo $_output['filter']['w']}-->" class="f-text" size="5" style="text-align:center" /></td>
					</tr>
				</table>
				<div style="color:green;padding-top:5px;">
					<ul>
						<li><font color="red">*</font> : 任意时间</li>
						<li><font color="red">n</font> : 第n分钟... </li>
						<li><font color="red">*/n</font> : 每n分钟...</li>
						<li>*/3 * * * 表示每隔3分钟执行一次</li>
						<li>*/3 6 * * 表示每天的凌晨6点钟里，每隔3分钟执行一次</li>
						<li>*/3 6 */3 * 表示每3天的凌晨6点钟里，每隔3分钟执行一次</li>
						<li>*/3 6 */3 */2 表示每周的偶数并且每3天的凌晨6点钟里，每隔3分钟执行一次</li>
					</ul>
				</div>
			</td>
		</tr>
		<tr>
			<td class="tablerow" colspan="2" style="padding-left:210px;">
				<input type="hidden" name="myFormAc" value="update" />
				<input type="submit" id="submit-act" value=" 提交 " class="f-button" />
			</td>
		</tr>		
	</table>
</form>
<!--{/if}-->

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