{include "header.inc.html"}
<div class="tuanForm">
<form class="form" action="" method="post">
 {if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<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">团购标题：</label><div class="element"><input type="text" class="text w500" name="title" value="{$tuanInfo.title}" /></div>
</div>
<div class="form-line">
<label class="label">市场价格：</label><div class="element"><input type="text" class="text w200" name="marketPrice" value="{$tuanInfo.marketPrice}" /></div>
</div>
<div class="form-line">
<label class="label">团购价格：</label><div class="element"><input type="text" class="text w200" name="price" value="{$tuanInfo.price}" /></div>
</div>
<div class="form-line">
<label class="label">团购外部链接：</label><div class="element"><input type="text" class="text w400" name="externalLink" value="{$tuanInfo.externalLink}" /></div>
</div>
<div class="form-line">
<label class="label">展示图片：</label><div class="element"><input type="hidden" name="thumbId" id="thumbId" value="{$tuanInfo.thumbId}" />
{if  $tuanInfo}
{attachment id=$tuanInfo.thumbId limit=1}
<img id="img-thumb" src="/{$item.url}" />
{/attachment}
{else}
<img id="img-thumb" src="/static/images/default.png" />
{/if}大小277px*185px <span id="uploadBtn"></span>
</div>
</div>
<div class="form-line">
<label class="label">排序：</label><div class="element"><input type="text" class="text w200" name="sortId" value="{$tuanInfo.sortId|default:50}" /></div>
</div>
<div class="form-line">
<label class="label"></label><div class="element"><input type="submit" value="提交" /></div>
</div>
</form>
</div>
 {else}
 <table class="table-ca">
 <tr>
<th class="w60">编号</th><th>团购标题</th><th class="w50">是否有效</th><th class="w50">排序</th><th class="w50">团购价格</th><th class="w50">市场价格</th><th class="w100">添加时间</th><th class="w100">操作</th>
 </tr>
{tuan limit=15}
<tr>
<td>{$item.id}</td><td>{$item.title}</td><td><img class="smodtoggle" name="iStatus" sid="{$item.id}" src="/admin/images/{if $item.iStatus==1}yes{else}no{/if}.gif"></td><td>{$item.sortId}</td><td>{$item.price}	</td><td>{$item.marketPrice}	</td><td>{$item.posttime|date_format:"Y-m-d"}</td><td><a href="http://rurl.biz/{$item.externalLink}" target="_blank">查看</a> <a href="/admin/tuan/act/edit/id/{$item.id}">修改</a> <a href="/admin/tuan/act/del/id/{$item.id}" class="delBtn">删除</a></td>
</tr>
{/tuan}
</table>
<div class="page">
	<div class="pagin fr">{pager allCount=$allCount url='/admin/tuan/page/page' number="false"}</div>
</div>
{/if}

{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<script type="text/javascript" src="/plugins/swfupload/swfupload.js"></script>
<script type="text/javascript">
$(function(){
swfu_settings.button_placeholder_id = "uploadBtn";
swfu = new SWFUpload(swfu_settings);
swfu.uploadSuccess = function(obj,data,resp){
		var data = eval('('+data+')');
		if(data.success){
			var url = decodeURIComponent(data.url);
			swfu.setButtonText("<span class='redText'>上传成功</span>");
			swfu.setButtonDisabled(false);
			$("#img-thumb").attr("src","/"+url);
			$("#thumbId").val(data.id);
		}
}
});
{else if $smarty.get.act=="list"}
{literal}
<script type="text/javascript">
$(function(){
	$(".delBtn").click(function(){
			if(!confirm("删除后不可恢复，是否确认删除？")){return false;}
			var tr = $(this).parent("td").parent("tr");
			var id = tr.find("td").eq(0).text();
			if(parseInt(id,10)){
				var sdata = "inajax=1&act=del&id="+id;
				$.ajax({
					type:"POST",
					url:".",
					data:sdata,
					dataType:"json",
					success:function(data){
						alert(data.message);
						if(data.success){
							tr.fadeOut("slow").remove();
						}
					}
				});
			}
		return false;
	});

});
</script>
{/literal}
{/if}
</script>
{include "footer.inc.html"}