<!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/userchangeStyle.js"></script>
<script type="text/javascript" src="skin/{echo: $SYSINFO['templates'];/}/js/changeStyle.js"></script>
<style type="text/css">
.edit span{background:#FFF2E6;}
.search {margin:5px; height:30px; background:#fff; width:90%; padding-left:0px; text-align:left;}
.search input {color:#444;}
td{text-align:left;}
td div.goodsname{line-height:18px;  font-weight:bold;}
td span.category{color:#FF6600;}
</style>
</head>
<body onload="menu_style_change('goods_list');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_goods_list};/}
	</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">
            	<span class="tr_op">
            	<a href="modules.php?app=csv_export">{echo:lp{m_csv_export};/}</a>
            	<a href="modules.php?app=csv_import">{echo:lp{m_csv_import};/}</a>
					<a href="modules.php?app=goods_csv_taobao">{echo:lp{m_import_taobao};/}</a><a href="modules.php?app=goods_add">{echo: lp{m_add_goods};/}</a>
				</span>{echo: lp{m_goods_list};/}
			</div>
            <hr />
			<div class="search">
				<form action="modules.php" method="get" name="search_form" style="float:left;">
					<select name="ucat_id">
						<option value="0">{echo: lp{m_ucategory};/}</option>
						{echo: $html_shop_category;/}
					</select>
					<input type="text" name="k" value="{sta: if(empty($k)) { echo lp{m_goods_keyword}; } else { echo $k; if/}"
					onfocus="javascript:if(this.value=='{echo: lp{m_goods_keyword};/}'){this.value=''}"
					onblur="javascript:if(this.value==''){this.value='{echo: lp{m_goods_keyword};/}'}" />
					<input type="hidden" value="goods_list" name="app" />
					<input type="submit" name="submit" value="{echo: lp{m_search_goods};/}" />
				</form>
			</div>
			<form action="do.php?act=goods_list" method="post" onsubmit="return submitform();">
				<table width="100%" class="">
					<tr class="">
						<th width="40"><input type="checkbox" name="c" value="" onclick="checkall(this)" /></th>
						<th width="82"></th>
						<th>{echo: lp{m_goods_name};/}</th>
						<th width="90" align="left">{echo: lp{m_price};/}</th>
						<th width="35">{echo: lp{m_on_sale};/}</th>
						<th width="50">{echo: lp{m_sort};/}</th>
						<th width="60">{echo: lp{m_goods_number};/}</th>
						<th width="60" align="center">{echo: lp{m_manage};/}</th>
				   </tr>
					{sta:
					if(!empty($result['result'])) {
						foreach($result['result'] as $v) [loop]}
					<tr class="trcolor">
						<td class="center" width="40"><input type="checkbox" name="checkbox[]" value="{echo: $v['goods_id'];/}" /></td>
						<td class="center"><a href="goods.php?id={echo: $v['goods_id'];/}" target="_blank"><img src="{echo: $v['goods_thumb'];/}" width="80" height="80" onerror="this.src='skin/default/images/nopic.gif'"/></a></td>
						<td align="left" valign="top">
							<div class="goodsname"><a href="goods.php?id={echo: $v['goods_id'];/}" target="_blank">{echo: $v['goods_name'];/}</a></div>
							{echo: lp{m_custom_categories};/}：<span class="category">{sta:if(isset($shop_category_info[$v['ucat_id']]))[exc]}{echo:$shop_category_info[$v['ucat_id']];/}{sta: } else [exc]}{echo: lp{m_undefinition};/}{end:if/}</span> &nbsp; {echo: lp{m_goods_type};/}：<span class="category">{echo: $typeinfo[$v['type_id']];/}</span> <br />
							{sta:if($v['lock_flg']==0) [exc]}
							{echo: lp{m_best};/}:{sta:if($v['is_best'])[exc]}<img src="skin/default/images/yes.gif" onclick="toggle_show(this,'best','{echo: $v['goods_id'];/}')" />{sta: } else [exc]}<img src="skin/default/images/no.gif" onclick="toggle_show(this,'best','{echo: $v['goods_id'];/}')" />{end:if/} &nbsp;
							{echo: lp{m_promote};/}:{sta:if($v['is_promote'])[exc]}<img src="skin/default/images/yes.gif" onclick="toggle_show(this,'promote','{echo: $v['goods_id'];/}')" />{sta: } else [exc]}<img src="skin/default/images/no.gif" onclick="toggle_show(this,'promote','{echo: $v['goods_id'];/}')" />{end:if/} &nbsp;
							{echo: lp{m_new};/}:{sta:if($v['is_new']) [exc]}<img src="skin/default/images/yes.gif" onclick="toggle_show(this,'new','{echo: $v['goods_id'];/}')" />{sta: } else [exc]}<img src="skin/default/images/no.gif" onclick="toggle_show(this,'new','{echo: $v['goods_id'];/}')" />{end:if/} &nbsp;
							{echo: lp{m_hot};/}:{sta:if($v['is_hot']) [exc]}<img src="skin/default/images/yes.gif" onclick="toggle_show(this,'hot','{echo: $v['goods_id'];/}')" />{sta: } else [exc]}<img src="skin/default/images/no.gif" onclick="toggle_show(this,'hot','{echo: $v['goods_id'];/}')" />{end:if/}
							{end:if/}
						</td>
						<td align="left" title="{echo: lp{m_click_editcontent};/}"
							id="goodspriceid_{echo: $v['goods_id'];/}"><span onclick="edit_price(this,{echo: $v['goods_id'];/})">{echo: $v['goods_price'];/}</span></td>
						<td style="text-align:center;">
						{sta:if($v['lock_flg']==0) [exc]}
						{sta:if($v['is_on_sale']) [exc]}
						<img src="skin/default/images/yes.gif" onclick="toggle_show(this,'on_sale','{echo: $v['goods_id'];/}')" />
						{sta: } else [exc]}
						<img src="skin/default/images/no.gif" onclick="toggle_show(this,'on_sale','{echo: $v['goods_id'];/}')" />
						{end:if/}
						{sta: } else [exc]}
						<span color="red">{echo: lp{m_lock};/}</span>
						{end:if/}
						</td>
						<td style="text-align:center;" title="{echo: lp{m_click_editcontent};/}" id="goodssortid_{echo: $v['goods_id'];/}">
							<span onclick="edit_sort(this,{echo: $v['goods_id'];/})">&nbsp;{echo: $v['sort_order'];/}&nbsp;</span></td>
						<td style="text-align:center;" title="{echo: lp{m_click_editcontent};/}" id="goodsnumberid_{echo: $v['goods_id'];/}">
							<span onclick="edit_number(this,{echo: $v['goods_id'];/})">&nbsp;{echo: $v['goods_number'];/}&nbsp;</span></td>
						<td style="text-align:center;">
							{sta:if($v['lock_flg']==0) [exc]}
							<a href="modules.php?app=goods_edit&id={echo: $v['goods_id'];/}">{echo: lp{m_edit};/}</a><br /><a href="modules.php?app=goods_gallery&id={echo: $v['goods_id'];/}" {sta:if($v['is_set_image']==0) { echo '';if/} title="{echo: lp{m_image_upload};/}">{echo: lp{m_goods_photo};/}</a>{end:if/}<br /><a href="do.php?act=goods_del&id={echo: $v['goods_id'];/}" onclick="return confirm('{echo: lp{m_sure_delgoods};/}');">{echo: lp{m_del};/}</a></td>
					</tr>
					{end:foreach/}
					<tr><td colspan="8" class="page">{inc: require("modules/page.php");/}</td></tr>
					<tr><td colspan="8">
						<input class="submit" type="submit" name="down" value="{echo: lp{m_goods_ushelves};/}" />
						<input class="submit" type="submit" name="up" value="{echo: lp{m_goods_dshelves};/}" />
					</td></tr>
					{sta: } else [exc]}
					<tr><td colspan="8" class="center">{echo: lp{m_nogoods};/}</td></tr>
					{end:if/}
				</table>
			</form>
		</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 inputs = document.getElementsByTagName("input");
function submitform() {
	var status = document.getElementsByName("checkbox");
	var checknum = 0;
	for(var i=0; i<inputs.length; i++) {
		if(inputs[i].type=='checkbox') {
			if(inputs[i].checked) {
				checknum++;
			}
		}
	}
	if(checknum==0) {
		alert("{echo: lp{m_selceted_one};/}");
		return false;
	}
	return true;
}

function checkall(obj) {
	if(obj.checked) {
		for(var i=0; i<inputs.length; i++) {
			if(inputs[i].type=='checkbox') {
				inputs[i].checked = true;
			}
		}
	} else {
		for(var i=0; i<inputs.length; i++) {
			if(inputs[i].type=='checkbox') {
				inputs[i].checked = false;
			}
		}
	}
}

function toggle_show(obj,name,id) {
	var re = /yes/i;
	var src = obj.src;
	var s = 1;
	var searchv = src.search(re);
	if(searchv > 0) {
		s = 0;
	}
	var d = new Date();
	var t = d.getTime();
	ajax("do.php?act=goods_toggle&t="+t,"POST","id="+id+"&s="+s+"&name="+name,function(data){
		if(data=='-1'){
			alert("{echo: lp{m_over_setnum};/}");
		}else if(data=='-2'){
			alert('{echo:lp{m_shop_close};/}');
		}else if(data=='-3'){
			alert("{echo: lp{s_goods_locked};/}");
			window.location.reload();
		}else if(data=='-4'){
			alert("{echo: lp{m_user_locked};/}");
			top.location.href="login.php";
		}else if(data) {
			obj.src = 'skin/default/images/'+data+'.gif';
		}
	});
}


var sort_value,number_value,price_value;
function edit_sort(span,id) {
	obj = document.getElementById("goodssortid_"+id);
	sort_value = span.innerHTML;
	sort_value = sort_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_goodssortid_' + id + '" value="' + sort_value + '" onblur="edit_sort_post(this,' + id + ')"  maxlength="2" />';
	document.getElementById("input_goodssortid_"+id).focus();
}

function edit_sort_post(input,id) {
	var obj = document.getElementById("goodssortid_"+id);
	if(isNaN(input.value)) {
		alert("{echo:lp{m_input_numpl};/}");
		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=goods_sort_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_number(span,id){
	obj = document.getElementById("goodsnumberid_"+id);
	number_value = span.innerHTML;
	number_value = number_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:35px" type="text" id="input_goodsnumberid_' + id + '" value="' + number_value + '" onblur="edit_number_post(this,' + id + ')" maxlength="5" />';
	document.getElementById("input_goodsnumberid_"+id).focus();
}

function edit_number_post(input,id) {
	var obj = document.getElementById("goodsnumberid_"+id);
	if(isNaN(input.value)) {
		alert("{echo:lp{m_input_numpl};/}");
		obj.innerHTML = '<span onclick="edit_number(this,' + id + ')">&nbsp;' + number_value + '&nbsp;</span>';
		return ;
	}
	if(number_value==input.value) {
		obj.innerHTML = '<span onclick="edit_number(this,' + id + ')">&nbsp;' + number_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=goods_number_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				obj.innerHTML = '<span onclick="edit_number(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_number(this,' + id + ')">&nbsp;' + number_value + '&nbsp;</span>';
			}
		});
	}
}

function edit_price(span,id){
	obj = document.getElementById("goodspriceid_"+id);
	price_value = span.innerHTML;
	price_value = price_value.replace(/&nbsp;/ig,"");
	obj.innerHTML = '<input style="width:55px" type="text" id="input_goodspriceid_' + id + '" value="' + price_value + '" onblur="edit_price_post(this,' + id + ')" maxlength="8" />';
	document.getElementById("input_goodspriceid_"+id).focus();
}

function edit_price_post(input,id) {
	var obj = document.getElementById("goodspriceid_"+id);
	if(isNaN(input.value)) {
		alert("{echo:lp{m_input_numpl};/}");
		obj.innerHTML = '<span onclick="edit_price(this,' + id + ')">&nbsp;' + price_value + '&nbsp;</span>';
		return ;
	}
	if(price_value==input.value) {
		obj.innerHTML = '<span onclick="edit_price(this,' + id + ')">&nbsp;' + price_value + '&nbsp;</span>';
	} else {
		ajax("do.php?act=goods_price_edit","POST","id="+id+"&v="+input.value,function(data){
			if(data==1) {
				obj.innerHTML = '<span onclick="edit_price(this,' + id + ')">&nbsp;' + input.value + '&nbsp;</span>';
			} else {
				obj.innerHTML = '<span onclick="edit_price(this,' + id + ')">&nbsp;' + price_value + '&nbsp;</span>';
			}
		});
	}
}
//-->
</script>
</body>
</html>