<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{echo: lp{m_u_center};/}</title>
<link rel="stylesheet" type="text/css" href="skin/{echo: $SYSINFO['templates'];/}/css/modules.css">
<link rel="stylesheet" type="text/css" href="skin/{echo: $SYSINFO['templates'];/}/css/layout.css">
<link rel="stylesheet" type="text/css" href="skin/{echo: $SYSINFO['templates'];/}/css/style.css">
<script type="text/javascript" src="skin/{echo: $SYSINFO['templates'];/}/js/changeStyle.js"></script>
<script type="text/javascript" src="skin/{echo: $SYSINFO['templates'];/}/js/userchangeStyle.js"></script>

<style type="text/css">

</style>
</head>
<body onload="menu_style_change('shop_category');changeMenu();">
	{inc: require("shop/index_header.php");/}
	<div class="site_map">
	  {echo:lp{m_current_position};/}<A href="index.php">{echo:$SYSINFO['sys_name'];/}</A>/<a href="modules.php">{echo:lp{m_u_center};/}</a>/&nbsp;&nbsp;{echo:lp{m_shop_category};/}</div>
    <div class="clear"></div>
    	{inc: require("modules/left_menu.php");/}
        <div class="main_right">
           <div class="right_top"></div>
            <div class="cont">
                <div class="cont_title">{echo: lp{m_shop_category};/}<span class="tr_op"><a href="modules.php?app=shop_category_add" >{echo: lp{m_shop_category_add};/}</a></span>
			</div>
                <hr />
				<table width="100%" border="0" cellspacing="0">
					<tr class=""><th align="left">{echo: lp{m_category_name};/}</th>
					 <th width="60"></th>
						<th width="40">{echo: lp{m_sort};/}</th><th width="200">{echo: lp{m_manage};/}</th></tr>
					{sta:if(empty($category_list_new))[exc]}
					<tr class="center"><td colspan="4">{echo: lp{m_nocat_addnow};/}</td></tr>
					{sta:	} else {
						$category_0 = get_sub_category($category_list_new,0);
						foreach($category_0 as $v) [loop]}
					<tr>
						<td><img src="skin/default/images/menu_minus.gif" style="margin-left:1em" />
						<span><a href="#?{echo: $v['shop_cat_id'];/}">{echo: $v['shop_cat_name'];/}</a></span>
						</td>
						 <td class="center edit" id="unit_id_{echo: $v['shop_cat_id'];/}"><span onclick="edit_unit(this,{echo: $v['shop_cat_id'];/})">&nbsp;&nbsp;</span></td>
						<td class="center edit" id="cat_id_{echo: $v['shop_cat_id'];/}"><span onclick="edit_sort(this,{echo: $v['shop_cat_id'];/})">&nbsp;{echo: $v['sort_order'];/}&nbsp;</span></td>
						<td class="center"><a href="modules.php?app=shop_category_add&id={echo: $v['shop_cat_id'];/}">{echo: lp{m_add_subcategory};/}</a> <a href="modules.php?app=shop_category_edit&id={echo: $v['shop_cat_id'];/}">{echo: lp{m_edit};/}</a> <a href="javascript:del_cat('{echo: $v['shop_cat_id'];/}')">{echo: lp{m_del};/}</a></td>
					</tr>
					{sta:
							$category_sub = get_sub_category($category_list_new,$v['shop_cat_id']);
							if(!empty($category_sub)){
								foreach($category_sub as $value) [loop]}
							<tr>
								<td><img src="skin/default/images/menu_minus.gif" style="margin-left:2em" />
								<span><a href="#?{echo: $value['shop_cat_id'];/}">{echo: $value['shop_cat_name'];/}</a></span>
								</td>
								 <td class="center edit" id="unit_id_{echo: $value['shop_cat_id'];/}"><span onclick="edit_unit(this,{echo: $value['shop_cat_id'];/})">&nbsp;&nbsp;</span></td> 
								<td class="center edit" id="cat_id_{echo: $value['shop_cat_id'];/}"><span onclick="edit_sort(this,{echo: $value['shop_cat_id'];/})">&nbsp;{echo: $value['sort_order'];/}&nbsp;</span></td>
								<td class="center"><a href="modules.php?app=shop_category_edit&id={echo: $value['shop_cat_id'];/}">{echo: lp{m_edit};/}</a> <a href="javascript:del_cat('{echo: $value['shop_cat_id'];/}')">{echo: lp{m_del};/}</a></td>
							</tr>
							 {end:foreach/}
							{end:if/}
						{end:foreach/}
					{end:if/}
					<tr><td colspan="4">&nbsp;&nbsp;{echo: lp{m_remark_edit};/}</td></tr>
				</table>
            </div>
			<div class="clear"></div>
			<div class="right_bottom"></div>
			<div class="back_top"><a href="#"></a></div>
        </div>
{inc: require("shop/index_footer.php");/}
<script language="JavaScript" src="servtools/ajax_client/ajax.js"></script>
<script language="JavaScript">
<!--
var sort_value,unit_value;
function edit_sort(span,id) {
	obj = document.getElementById("cat_id_"+id);
	sort_value = span.innerHTML;
	sort_value = sort_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_cat_id_' + id + '" value="' + sort_value + '" onblur="edit_sort_post(this,' + id + ')" maxlength="2"  />';
	document.getElementById("input_cat_id_"+id).focus();
}

function edit_sort_post(input,id) {
	var obj = document.getElementById("cat_id_"+id);
	if(isNaN(input.value)) {
		alert("{echo: lp{m_input_num};/}");
		obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
		return ;
	}
	if(sort_value==input.value) {
		obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=shop_catsort_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_sort(this,' + id + ')">&nbsp;' + sort_value + '&nbsp;</span>';
			}
		});
	}
}

function edit_unit(span,id){
	obj = document.getElementById("unit_id_"+id);
	unit_value = span.innerHTML;
	unit_value = unit_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_unit_id_' + id + '" value="' + unit_value + '" onblur="edit_unit_post(this,' + id + ')" maxlength="8" />';
	document.getElementById("input_unit_id_"+id).focus();
}

function edit_unit_post(input,id) {
	var obj = document.getElementById("unit_id_"+id);
	if(unit_value==input.value) {
		obj.innerHTML = '<span onclick="edit_unit(this,' + id + ')">&nbsp;' + unit_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=shop_catunit_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				obj.innerHTML = '<span onclick="edit_unit(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_unit(this,' + id + ')">&nbsp;' + unit_value + '&nbsp;</span>';
			}
		});
	}
}

function del_cat(id){
	if(confirm("{echo: lp{m_sure_delcat};/}")) {
		location.href="do.php?act=shop_category_del&id="+id;
	}
}
//-->
</script>
</body>
</html>