<div class="headbar">
	<div class="position"><span>商品</span><span>></span><span>品牌管理</span><span>></span><span>品牌列表</span></div>
	<div class="operating">
		<a href="javascript:;"><button class="operating_btn" type="button" onclick="window.location='{url:/brand/brand_edit}'"><span class="addition">添加品牌</span></button></a>
	</div>
</div>

<div class="content">
	<table id="list_table" class="list_table">
		<colgroup>
			<col width="100px" />
			<col width="150px" />
			<col width="200px" />
			<col width="200px" />
			<col width="150px" />
		</colgroup>

		<thead>
			<tr>
				<th>排序</th>
				<th>品牌名称</th>
				<th>网址</th>
				<th>品牌分类</th>
				<th>操作</th>
			</tr>
		</thead>

		<tbody>
			{set:$catAll = array()}
			{query: name = brand_category}
				{set:$catAll[$item['id']] = $item['name']}
			{/query}

			{query: name=brand order=sort asc}
			<tr>
				<td><input class="tiny" id="sort{$item['id']}" type="text" onblur="toSort({$item['id']});" value="{$item['sort']}" pattern='int' /></td>
				<td><a href="{url:/site/brand_zone/id/$item['id']}" target="_blank">{$item['name']}</a></td>
				<td>{$item['url']}</td>
				<td>
				{foreach:items = explode(',',$item['category_ids']) item = $val}
				{$catAll[$val]} &nbsp;
				{/foreach}
				</td>
				<td><a href="{url:/brand/brand_edit/bid/$item[id]}"><img class="operator" src="{skin:images/admin/icon_edit.gif}" alt="修改" /></a><a href="javascript:void(0)" onclick="delModel({link:'{url:/brand/brand_del/bid/$item[id]}'})"><img class="operator" src="{skin:images/admin/icon_del.gif}" alt="删除" /></a></td>
			</tr>
			{/query}
		</tbody>
	</table>
</div>

<script language="javascript">
//排序
function toSort(id)
{
	if(id!='')
	{
		var va = $('#sort'+id).val();
		var part = /^\d+$/i;
		if(va!='' && va!=undefined && part.test(va))
		{
			$.get("{url:/goods/brand_sort}",{'id':id,'sort':va}, function(data)
			{
				if(data=='1')
				{
					alert('修改商品品牌排序成功!');
				}else
				{
					alert('修改商品品牌排序错误!');
				}
			});
		}
	}
}
</script>