{include "header.inc.html"}
{$eventLang = $lang.admin.eventgoods.form}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.event.name}</strong><br />
		<span class="english">{$lang.admin.event.name_en}</span> </span>
		<div class="toolbar_menu">
			<a href="{$adminUrl}event/goods?act=add">报名新商品</a>
		</div>
		 </div>
	</div>
{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<div class="brandForm">
<form class="form" action="" method="post" id="fm-form"><input type="hidden" name="inajax" value="1" /><input type="hidden" name="act" value="{$smarty.get.act}" />
{if $smarty.get.act=="edit"}
<input type="hidden" name="id" value="{$smarty.get.id}" />
{/if}
<div class="form-line"><label class="label">活动ID：</label><div class="element"><input type="text" class="fm-text w60" name="eventId" value="{$eventGoodsInfo.eventId}" /></div></div>
<div class="form-line"><label class="label">报名商品ID：</label><div class="element"><input type="text" class="fm-text w60" name="goodsId" value="{$eventGoodsInfo.goodsId}" /></div></div>
<div class="form-line">
<label class="label">{$lang.form.sort}：</label><div class="element"><input type="text" class="text w200" name="sortId" value="{$eventGoodsInfo.sortId|default:50}" /></div>
</div>
<div class="form-line">
<label class="label">{$lang.form.iStatus}：</label><div class="element"><input type="radio" name="iStatus" value="1"{if $eventGoodsInfo.iStatus==1} checked{/if} /> 有效 <input type="radio" name="iStatus" value="0"{if $eventGoodsInfo.iStatus==0} checked{/if} /> 无效</div>
</div>

<div class="form-line">
<label class="label"></label><div class="element"><input class="btn_sub" type="submit" value="{$lang.form.submit}"></div>
</div>
</form>
</div>
 {else}
 	<div class="tool">
{if $smarty.get.act=="list" || $smarty.get.act==""}<a id="deleteChecked" class="ui-btn">删除所选</a>{/if}
</div>
 <table class="table-ca table_1" id="tInfo">
 <tr>
<th class="w30"><input type="checkbox" value="1" name="allid" id="checkall" /></th><th class="w60">编号</th><th>活动名称</th><th>{$eventLang.goods}</th><th class="w50">排序</th><th class="w50">{$lang.form.iStatus}</th><th class="w120">报名时间</th><th class="w100">操作</th>
 </tr>
{eventgoods limit=15 pager="true"}
<tr sid="{$item.id}">
<td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.id}</td><td>{$item.eventName}</td><td>{$item.goodsName}</td><td>{$item.sortId}</td>
<td><img class="smodtoggles" name="iStatus" sid="{$item.id}" src="{$baseUrl}static/images/{if $item.iStatus==1}yes{else}no{/if}.gif"></td>
<td>{$item.posttime|date_format:"Y-m-d"}</td><td><a href="{$adminUrl}event/goods?act=edit&id={$item.id}" class="modBtn">{$lang.edit}</a> <a href="javascript:void(0)" class="delLink delBtn">{$lang.del}</a></td>
</tr>
{/eventgoods}
</table>
<div class="page">
	<div class="pagin fr">{pager allCount=$allCount url='/admin/brand/page/page' number="false"}</div>
</div>
{/if}

<script type="text/javascript">
$(function(){
	$("a#deleteChecked").button().click(function(){
		if(!confirm(lang[4])){ return false; }		
		var id = [];
		$("input[name='id[]']:checkbox:checked").each(function(index){
			id[index] = $(this).val();
			var sid = $(this).val();
			if(sid){
				var tr = $(this).parent("td").parent("tr");
				var sdata = "inajax=1&act=del&id="+sid;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}event/goods",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});			
			}
		});
	});
	$(".delBtn").click(function(){
		if(!confirm("确认删除？")){ return false; }
		var tr = $(this).parent("td").parent("tr");
		var id = tr.attr('sid');
		if(id){ $.ajax({ type:"POST",data:"inajax=1&act=del&id="+id,cache:false,dataType:"json",success:function(data){ if(data.success){ tr.remove(); }else{ alert("删除失败："+data.message); } } }); }
	});
$("#fm-form").ajaxForm({ dataType:'json',success:function(json){ alert(json.message); if(json.success && $("#fm-form").find("input[name='act']").val()=='add'){ $("#fm-form").find("input[name='goodsId']").val(''); } },error:function(){ alert('系统错误，请联系技术人员'); } })
});
</script>

</div><!--.content_box-->
{include "footer.inc.html"}