{include "header.inc.html"}
<div class="content_box">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.brand.name}</strong><br />
		<span class="english">{$lang.admin.brand.name_en}</span> </span> </div>
	</div>
<div class="tool tool-brand">
{if $smarty.get.act=="list" || $smarty.get.act==""}<a id="deleteChecked">删除所选</a>{/if}
<form action="{$adminUrl}brand" method="get" class="form" style="width:600px;display:inline;">
<input type="text" name="key" value="{$smarty.get.key}" /><input type="submit" class="btn_sub" value="搜索" />
</form>
<div class="clr"></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">品牌名称：</label><div class="element"><input type="text" class="text w200" name="name" value="{$brandInfo.name}" /></div>
</div>
<div class="form-line">
<label class="label">主营商品分类：</label><div class="element"><select name="catId"><option value="0">可不选择</option>
{foreach from=$category item=item}
<option value="{$item.id}"{if $brandInfo.catId==$item.id || $smarty.post.catId==$item.id} selected{/if}>{for $foo=1 to $item.grade*4}&nbsp;{/for}{$item.name}</option>
{/foreach}
</select></div>
</div>
<div class="form-line">
<label class="label">排序：</label><div class="element"><input type="text" class="text w200" name="sortId" value="{$brandInfo.sortId|default:50}" /></div>
</div>
<div class="form-line">
<label class="label">网站：</label><div class="element"><input type="text" class="text w200" name="website" value="{$brandInfo.website}" /></div>
</div>
<div class="form-line">
<label class="label">自定义URL：</label><div class="element"><input type="text" class="text w200" name="seoUrl" value="{$brandInfo.seoUrl}" /></div>
</div>
<div class="form-line">
<label class="label">介绍页模板：</label><div class="element"><input type="text" class="text w200" name="templateView" value="{$brandInfo.templateView}" /></div>
</div>
<div class="form-line">
<label class="label">图标：</label><div class="element"><input type="hidden" name="thumbId" id="thumbId" value="{$brandInfo.thumbId}" />
{if  $brandInfo.thumbId}
{attachment id=$brandInfo.thumbId limit=1}
<img id="img-thumb" src="{$item.url}" />
{/attachment}
{else}
<img id="img-thumb" src="{$baseUrl}static/images/default.png" />
{/if}<br><span id="uploadBtn"></span>
</div>
</div>
<div class="form-line"><label class="label">品牌介绍：</label><div class="element">{editor content=$brandInfo.content name="content"}</div></div>
<div class="form-line">
<label class="label"></label><div class="element"><input type="submit" class="btn_sub" value="{$lang.form.submit}" /></div>
</div>
</form>
</div>
 {else}
 <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>自定义链接</th><th>介绍页模板</th><th class="w50">排序</th><th class="w100">分类</th><th class="w100">添加时间</th><th class="w100">操作</th>
 </tr>
{brand limit=15 pager="true"}
<tr>
<td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.id}</td><td>{$item.name}</td><td>{$item.seoUrl}</td><td>{$item.templateView}</td><td>{$item.sortId}</td><td>{$item.catName}	</td><td>{$item.posttime|date_format:"Y-m-d"}</td><td><a href="/qkadmin/brand/act/edit/id/{$item.id}" class="modBtn">{$lang.edit}</a> <a href="javascript:void(0)" class="delBtn">{$lang.del}</a></td>
</tr>
{/brand}
</table>
<div class="page">
	<div class="pagin fr">{pager allCount=$allCount url='/qkadmin/brand/page/' number="false"}</div>
</div>


<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}brand",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});			
			}
		});
		
	});
	$(".delBtn").click(function(){
		if(!confirm(lang[4])){ return false; }
			var tr = $(this).parent("td").parent("tr");
			var id = tr.find("td").eq(1).text();
			if(parseInt(id,10)){
				var sdata = "inajax=1&act=del&id="+id;
				$.ajax({
					type:"POST",
					url:"{$adminUrl}brand",
					data:sdata,
					dataType:"json",
					success:function(data){
						if(data.success){
							tr.fadeOut("slow").remove();
						}else{
							alert(data.message);
						}
					}
				});
			}
		return false;
	});
})
</script>



{/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);
		}
}
$("#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='name'],input[name='website'],input[name='seoUrl'],input[name='templateView'],input[name='thumbId']").val(''); $("#img-thumb").attr('src','{$baseUrl}static/images/default.png'); } },error:function(){ alert('系统错误，请联系技术人员'); } })
});
</script>
{/if}
</div><!--.content_box-->

{include "footer.inc.html"}