#!/bin/sh
#This script is created by ssparser automatically. The parser first created by MaoShouyan
printf "Content-type: text/html
Cache-Control: no-cache

"
echo -n "";
. ../common/common.sh
myself="/cgi-bin/Setup/`basename $0`"

echo -n "
<script type=\"text/javascript\" src=\"/img/common.js\"></script>
<script language=\"javascript\">
function modifyTime(args)
{
	window.location.href = \"/cgi-bin/Setup/conlimit_settime?\" + args;
}
function onAddTime()
{
	window.location.href = \"/cgi-bin/Setup/conlimit_addtime\";
}
function deleteTime(tid) 
{
	if (confirm(\"ȷҪɾʱ?\")) 
		window.location.href = \"/cgi-bin/Setup/conlimit_listime?action=delete&id=\" + tid;
}
</script>
";
if [ "${CGI_action}" = "delete" ]; then
	errmsg=`${FLOWEYE} conlimit rmvtime id=${CGI_id}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
	fi
fi
if [ "${CGI_action}" = "defgrp" ]; then
	errmsg=`${FLOWEYE} conlimit setdefgrp name=${CGI_defgrp}`
	if [ "$?" != "0" ]; then
		afm_dialog_msg "ִ:${errmsg}"
	else
		afm_dialog_msg "ɹ!"
	fi
fi

echo -n "
<body>
<script type=\"text/javascript\" src=\"/img/wz_tooltip.js\"></script>
<span id=\"hlpdefgrp\" style=\"display:none\">ûƥ䵽ʱбеκʱʱ,ϵͳʹȱʡ</span>
<span id=\"hlpactive\" style=\"display:none\">ǵǰЧʱ</span>
"; cgi_show_title "ӿ->Ե" 
echo -n "
<br>
<table style=\"width:800; border-bottom:1px #787882 solid; font:bold  14px; color:#0000ff\">
<tr>
	<td style=\"font:14px\"><b>һЩ˵</b></td>
	<td style=\"font:12px;\" align=right width=\"*\"></td>
</tr>
</table>
<br>
<table width=800 border=0 cellspacing=1 cellpadding=1 bgcolor=\"#ffffff\">
<tr id=row1>
	<td width=60></td>
	<td width=* style=\"color:#0000ff;font:13px\">1. һʱֻ̣һЧ</td>
</tr>
<tr id=row1>
	<td width=60></td>
	<td width=* style=\"color:#0000ff;font:13px\">2. ϵͳƥԵȱûƥ䵽ʹȱʡ</td>
</tr>
</table>
<br>
<table style=\"width:800; font:bold 14px; color:#CE6C04\">
<tr><td align=left>ȱʡ</td></tr>
</table>
<table width=\"800\" border=0 cellspacing=0 cellpadding=1>
<tr id=tblhdr height=22>
<form method=post action=\"${myself}\">
	<td width=75><a onmouseover=\"TagToTip('hlpdefgrp')\" onmouseout=\"UnTip()\">ȱʡ</a></td>
	<td width=* class=cssTDArial align=left>
	"; CGI_defgrp=`${FLOWEYE} conlimit getdefgrp | cut -d' ' -f1` 
echo -n "
        <select name=defgrp value=\"${CGI_defgrp}\" style=\"width:360;height:22\">
        ";
                ${FLOWEYE} conlimit listgrp | while read pid name
                do
			selected=""
			[ ${CGI_defgrp} -eq ${pid} ] && selected="selected"
                        echo "<option value=\"${pid}\" ${selected}>${name}</option>"
                done
		if [ ${CGI_defgrp} -eq 0 ]; then
                	echo "<option value=\"0\" selected>ղ</option>"
		else
                	echo "<option value=\"0\">ղ</option>"
		fi
        
echo -n "
        </select>
	<input type=hidden name=action value=defgrp></input>&nbsp;
        <input type=submit style=\"width:100;height:21\" value=\"޸ȱʡ\"></input>
	</td>
</form>
</tr>
</table>
<br>
<table style=\"width:800; font:bold 14px; color:#CE6C04\">
<tr><td align=left>Եȱ</td></tr>
</table>
<table width=800 border=0 cellspacing=1 cellpadding=1>
<tr id=tblhdr height=22>
	<td width=100 align=center></td>
	<td width=100 align=center>ǷЧ</td>
	<td width=100 align=center>û</td>
	<td width=120 align=center></td>
	<td width=120 align=center>ʱ</td>
	<td width=120 align=center></td>
	<td width=* align=center>
		<input type=button style=\"width:110px;height:21\" value=\"ʱ>>\" onclick=\"onAddTime()\"></input>
	</td>
</tr>
";
idname="row1"
${FLOWEYE} conlimit listtime | \
while read id active disabled month startday endday starthour startmin startsec endhour endmin endsec polid polname ipmin ipmax theothers
do
	if [ "${active}" = "active" ]; then
	    echo "<tr style=\"font:12px,bold;color:#0000ff\" onmouseover=\"TagToTip('hlpactive')\" onmouseout=\"UnTip()\">"
	else
	    echo "<tr id=${idname}>"
	fi
	sday="${startday}"
	eday="${endday}"
	echo "<td align=center>${id}</td>"
	if [ "${disabled}" = "yes" ]; then
		echo "<td align=center style=\"color:#ff0000\">Ч</td>"
	else
		echo "<td align=center>Ч</td>"
	fi
	if [ ${ipmin} -eq 0 -a ${ipmax} -eq 0 ]; then
		echo "<td align=center></td>"
	else
		echo "<td align=center>${ipmin}&nbsp;-&nbsp;${ipmax}</td>"
	fi
	if [ "${month}" = "0" ]; then
		case "${startday}" in
		"1")
			startday="һ"
			;;
		"2")
			startday=""
			;;
		"3")
			startday=""
			;;
		"4")
			startday=""
			;;
		"5")
			startday=""
			;;
		"6")
			startday=""
			;;
		"7")
			startday=""
			;;
		esac
		case "${endday}" in
		"1")
			endday="һ"
			;;
		"2")
			endday=""
			;;
		"3")
			endday=""
			;;
		"4")
			endday=""
			;;
		"5")
			endday=""
			;;
		"6")
			endday=""
			;;
		"7")
			endday=""
			;;
		esac
		echo "<td align=center>ÿ:${startday}~${endday}</td>"
	else
		echo "<td align=center>${month}${startday}~${endday}</td>"
	fi
	echo "<td align=center>${starthour}:${startmin}:${startsec} ~ ${endhour}:${endmin}:${endsec}</td>"
	echo "<td align=center>${polname}</td>"
	
	echo "<td align=center>"
	echo "<a href=\"javascript:modifyTime('status=${disabled}&schid=${id}&month=${month}&startday=${sday}&endday=${eday}&starthour=${starthour}&startmin=${startmin}&startsec=${startsec}&endhour=${endhour}&endmin=${endmin}&endsec=${endsec}&policygrp=${polid}&ipmin=${ipmin}&ipmax=${ipmax}')\">༭&nbsp;</a>"
	echo "<a href=\"javascript:deleteTime('${id}')\">&nbsp;&nbsp;ɾ&nbsp;&nbsp;</a></td>"
	echo "</tr>"
	if [ "${idname}" = "row1" ]; then
		idname="row2"
	else
		idname="row1"
	fi
done

echo -n "
</table>
</body>
</html>
";