<!--{template 'head'}-->
<table cellpadding="2" cellspacing="1" border="0" align=center class="tableborder" width=100%>
	<tr>
		<td class="tablerow"><b>管理选项：</b><a href="plugin.php?plugin=vote&action=add">添加投票</a> | <a href="plugin.php?plugin=vote&action=manage">管理投票</a></td>
	</tr>
</table>
<script language="javascript">
function doCheck()
{
	if (document.myform.subject.value=="") 
	{
		alert("请输入主题！");
		return false;
	}
	$('submit').disabled = true ;
}
</script>
<!--{if $action=='add'}-->
<script language="javascript">
function doCheck()
{
	if (document.myform.subject.value=="") 
	{
		alert("请输入主题！");
		return false;
	}
	$('submit').disabled = true ;
}
function AddItem()
{
	var x = $("table_l");
	var y = x.insertRow(  x.rows.length-4);
	var a = y.insertCell(0);
		a.className = "tablerowl";
		a.width = "20%";
		a.innerHTML = "新增选项";
	var b = y.insertCell(1);
		b.className = "tablerow";
		b.innerHTML = "<input  type=\"text\" class='f-text' name=\"option[]\" size=\"50\" maxlength=\"100\"> <input type=\"button\" value=\"删除选项\"  onclick=\"return $('table_l').deleteRow(this.parentNode.parentNode.rowIndex);\" />";
}
</script>
<form method="post" name="myform" action="plugin.php?plugin=vote&action=add" onsubmit="return doCheck();">
<table cellpadding="0" cellspacing="1" class="tableborder border"  id="table_l">
	<tr>
		<th colspan=2>添加投票</th>
	</tr>
	<tr>
		<td class="tablerowl" width="20%">投票主题</td>
		<td class="tablerow" width="80%"><input class="f-text" name="subject" size="50"  maxlength="50"><font color="#FF0000"> *</font></td>
	</tr>
	<tr>
		<td class="tablerowl">投票类型</td>
		<td class="tablerow">
			<input name="type" id="type_0" type="radio" value="0" checked> <label for="type_0">单选</label>
			<input type="radio" id="type_1"  name="type" value="1"> <label for="type_1">多选</label>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">投票选项</td>
		<td class="tablerow">
			<input type="button" value="添加选项" name="addoption" onClick="AddItem();">
		</td>
	</tr>
	<tr id="flag">
		<td class="tablerowl" width="20%">投票选项</td>
		<td class="tablerow" width="80%">
			<input name="option[]" type="text" size="50"  class="f-text"  maxlength="50">
			<input type=button value="删除选项" disabled />
		</td>
	</tr>
	<tr>
		<td class="tablerowl">截止日期</td>
		<td class="tablerow">
			<input type="text" id="totime" name="totime" value="{$over}"  class="f-text" >
			<font color="#FF0000">*</font> 填0为不限制, 格式：yyyy-mm-dd
		</td>
	</tr>
	<tr>
		<td class="tablerowl">启用IP限制</td>
		<td class="tablerow">
			<input name="checkip" id="checkip" type="checkbox" value="1"  /> <label for="checkip">是</label>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">立即发布</td>
		<td class="tablerow">
			<input name="passed" id="passed_1" type="checkbox" value="1" checked /> <label for="passed_1">是</label>
		</td>
	</tr>
	<tr>
		<td class="tablerowl" colspan=2>
			<input type=hidden name=insert value=1 />
			<input type="submit" value=" 确定 "  class="f-button" name="submit" id="submit">
		</td>
	</tr>
</table>
</form>
<script type="text/javascript">
	new qmeCms.Calendar("totime");
</script>
<!--{/if}-->
<!--{if  $action=='edit'}-->
<script type="text/javascript">
function delOption( id)
{
	if( confirm("你确定要删除此选项？"))
	{
		linkurl = "plugin.php?plugin=vote&action=ajax&id="+id;
		AJAX.request( linkurl,
		{
			method		: 'get',
			onComplete	: function(json)
			{
				if( json[0] == 1)
				{
					var obj = $("tr_"+id);
					obj.parentNode.deleteRow(obj.rowIndex);
				}
				else
				{
					alert( lang[json[1]]);
				}
			}
		});
	}
}
function AddItem()
{
	var x = $("table_l");
	var y = x.insertRow( x.rows.length-4);
	var a = y.insertCell(0);
		a.className = "tablerowl";
		a.innerHTML = "新增选项";
	var b = y.insertCell(1);
		b.className = "tablerow";
		b.innerHTML = "<input class=\"f-text\" name=\"voteoption_new[]\" type=\"text\" size=\"50\" maxlength=\"100\" value=\"\"> <input type=\"button\" value=\"删除选项\"  onclick=\"return $('table_l').deleteRow(this.parentNode.parentNode.rowIndex);\" />";
}
</script>
<table cellpadding="0" cellspacing="1" class="tableborder border" id="table_l">
	<tr>
		<th colspan=2>编辑投票</th>
	</tr>
	<form method="post" name="myform" onsubmit="return doCheck()" action="plugin.php?plugin=vote&action=edit&voteid={$voteid}">
	<tr>
		<td class="tablerowl" width="20%">投票主题</td>
		<td class="tablerow" width="80%">
			<input class="f-text" name="subject" size="50"  maxlength="50" value="{$subject}">
		</td>
	</tr>
	<tr>
		<td class="tablerowl">投票类型</td>
		<td class="tablerow">
			<input name="type" type="radio" id="type_0" value="0" <!--{if !$type}-->checked<!--{/if}-->> <label for="type_0">单选</label>
			<input type="radio" name="type" id="type_1" value="1" <!--{if $type}-->checked<!--{/if}-->> <label for="type_1">多选</label>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">投票选项</td>
		<td class="tablerow">
			<input type="button" value="添加选项" name="addoption" onClick="AddItem();">
		</td>
	</tr>
	<!--{loop $options   $option}-->
	<tr id="tr_{$option[optionid]}">
		<td class="tablerowl" width="20%">选项{$option[index]}</td>
		<td class="tablerow" width="80%">
			<input class="f-text" name="voteoption[{$option[optionid]}]" type="text" id="voteoption_{$option[optionid]}" size="50" maxlength="100" value="{$option[voteoption]}">
			<input type="button" value="删除选项"  onclick="return delOption({$option[optionid]});" />
		</td>
	</tr>
	<!--{/loop}-->
	<tr>
		<td class="tablerowl">截止日期</td>
		<td class="tablerow">
			<input class="f-text" type="text" id="totime" name="totime" value="{$todate}"><font color="#FF0000">*</font> 填0为不限制, 格式：yyyy-mm-dd
		</td>
	</tr>
	<tr>
		<td class="tablerowl">启用IP限制</td>
		<td class="tablerow">
			<input name="checkip" id="checkip" type="checkbox" value="1" <!--{if $checkip}-->checked<!--{/if}-->  /> <label for="checkip">是</label>
		</td>
	</tr>
	<tr>
		<td class="tablerowl">立即发布</td>
		<td class="tablerow">
			<input name="passed" id="passed_1" type="checkbox" value="1" <!--{if $passed}-->checked<!--{/if}--> /> <label for="passed_1">是</label>
		</td>
	</tr>
	<tr>
		<td colspan=2 class="tablerowl">
			<input type=hidden name=insert value=1>
			<input type="submit" value=" 确定 " name="submit" id="submit" class="f-button" >
		</td>
	</tr>
	</form>
</table>
<script type="text/javascript">
	new qmeCms.Calendar("totime");
</script>
<!--{/if}-->

<!--{if $action=='getcode'}-->
<table cellpadding="0" cellspacing="1" border="0" align=center class="tableborder border">
	<tr align=center>
		<td class="tablerow">
			<textarea style="width:700px;height:500px;">
<form class="vote-form" onsubmit="return checkVote(this, {$subject['voteid']});" method="post" action="{W_P}index.php?ac=vote&action=save&voteid={$subject['voteid']}" name="voteform-{$subject['voteid']}" id="voteform-{$subject['voteid']}">
	<h4>{$subject['subject']}</h4>
	<!--{loop $options $i $option}-->
	<p class='v-opt'>
		<input type="{$type}" name="{$option_type}" value="{$option['optionid']}" id="vote-{$option['voteid']}-{$option['optionid']}" />
		<label for="vote-{$option['voteid']}-{$option['optionid']}">{$option['voteoption']}</label>
	</p>
	<!--{/loop}-->
	<p class='v-act'>
		<input type="hidden" name="voteid" value="{$subject['voteid']}" />
		<input type="submit" id="vote-submit-{$subject['voteid']}" class="f-button" value=" 提交投票 " />
		<a href="{W_P}index.php?ac=vote&action=show&voteid={$subject['voteid']}">查看投票结果</a>
	</p>
</form>
			</textarea>
		</td>
	</tr>
</table>
<br>
<br>
<br>
<br>
<!--{/if}-->

<!--{if $action=='manage'}-->
<form method="post" name="myform">
<table cellpadding="0" cellspacing="0" border="0" align=center class="tableborder" width=100% id="mytable">
	<tr align=center>
		<td width="30" class="tablerowhighlight"></td>
		<td width="60" class="tablerowhighlight">ID</td>
		<td class="tablerowhighlight">投票主题</td>
		<td width="50" class="tablerowhighlight">类型</td>
		<td width="120" class="tablerowhighlight">添加日期</td>
		<td width="120" class="tablerowhighlight">截止日期</td>
		<td width="60" class="tablerowhighlight">投票总数</td>
		<td width="220" class="tablerowhighlight">管理操作</td>
	</tr>
	<!--{if $votes}-->
	<!--{loop $votes $vote}-->
	<tr height=24 align=center class="item">
		<td class="tablerowl">
			<input type="checkbox" name="voteid[]"  id="ids_{$vote[voteid]}" value="{$vote[voteid]}">
		</td>
		<td>{$vote['voteid']}</td>
		<td align=left style="padding-left:12px;">
			<a href='{W_P}index.php?ac=vote&action=show&voteid={$vote[voteid]}' target='_blank' title='{$vote[subject]}'>{$vote[subject]}</a>
		</td>
		<td><!--{if $vote[type]}-->多选<!--{else}-->单选<!--{/if}--></td>
		<td>{$vote[adddate]}</td>
		<td>{$vote[todate]}</td>
		<td>{$vote[num]}</td>
		<td>
			<a href="plugin.php?plugin=vote&action=getcode&voteid={$vote[voteid]}">获取代码</a> | 
			<!--{if $vote['passed']}-->
			<a href="{W_P}index.php?ac=vote&action=show&voteid={$vote[voteid]}" target="_blank">查看</a> | 
			<a href="plugin.php?plugin=vote&action=passed&voteid={$vote[voteid]}&passed=0">取消</a>
			<!--{else}-->
			<a href="plugin.php?plugin=vote&action=passed&voteid={$vote[voteid]}&passed=1">批准</a>
			<!--{/if}--> 
			| <a href="plugin.php?plugin=vote&action=edit&voteid={$vote[voteid]}">修改</a> 
			| <a onclick="return makeSure();" href="plugin.php?plugin=vote&action=delete&voteid={$vote[voteid]}">删除</a>
		</td>
	</tr>
	<!--{/loop}-->
	<!--{else}-->
	<tr>
		<td colspan="8" class="tablerow">
			<p style="padding:25px;text-align:center">没有找到相关数据</p>
		</td>
	</tr>
	<!--{/if}-->
	<tr>
		<td class="tablerowl">
			<input name='chkall' type='checkbox' id='chkall' onclick='checkall(this.form)' value='checkbox'>
		</td>
		<td colspan=7  class="tablerowl" style="text-align:left">
			<input type="submit" name="submit"  class="f-button" value="删除选中投票主题" onClick="document.myform.action='plugin.php?plugin=vote&action=delete'">&nbsp;&nbsp;
		</td>
	</tr>
	<tr>
		<td class="tablerow" colspan=8 align=right>
			<!--{eval new pager($total, $pagesize);}-->
		</td>
	</tr>
</table>
</form>
<!--{/if}-->
<!--{template 'foot'}-->
