<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CMSOK</title>
	<atom:link href="http://www.cmsok.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.cmsok.com</link>
	<description>PHP应用程序开发</description>
	<lastBuildDate>Sat, 05 Nov 2011 03:15:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>ECShop自定义模块 &#8211; 会员录入场馆功能</title>
		<link>http://www.cmsok.com/archives/35</link>
		<comments>http://www.cmsok.com/archives/35#comments</comments>
		<pubDate>Sat, 05 Nov 2011 02:16:39 +0000</pubDate>
		<dc:creator>307150302</dc:creator>
				<category><![CDATA[ECShop]]></category>

		<guid isPermaLink="false">http://www.cmsok.com/?p=35</guid>
		<description><![CDATA[ECShop二次开发的时候我会使用到一些自己编写的函数，通常我都将这些函数放在 includes/lib_common.php 文件末尾。 这次的例子中使用到两个函数 data_insert和data_update，他们的做用是插入和更新数据库记录 打开：includes/lib_common.php 文件，在默认添加下列代码 步骤一：添加建立数据库 步骤二：修改user.php文件 修改一：给user.php文件中的$ui_arr数组中添加两个值：&#8217;court_list&#8217;, &#8216;court_add&#8217; 修改二：user.php文件中添加处理代码：添加，编辑，列表 步骤三：在themes\default目录下添加三个模板文件，注意下面三个模板的样式可能与默认模板不同，请自行修改。 文件一：user_court_add.dwt 文件二：user_court_edit.dwt 文件三：user_court_list.dwt 步骤四：在themes/default/library/user_menu.lbi文件中添加下面的链接地址，default是当前模板目录 步骤五：打开admin/includes/inc_menu.php文件，添加后台管理导航链接。在末尾添加一行代码： 步骤六：打开languages/zh_cn/admin/common.php文件，在末尾添加语言选项。 完成步骤五和步骤六以后进入后台，你会在左侧导航的最下面发现新增加的“自定义模块”。 步骤七：在admin目录下添加文件：new_court.php 步骤八：在admin/templates目录下添加两个文件： new_court_list.htm 和 new_court_info.htm new_court_list.htm new_court_info.htm 到这里我们添加的自定义模块已经基本可以使用了，这个例子比较简单，只包含会员录入数据，管理员编辑审核的功能，可以更具这个例子修改为你想要的功能和样式。 本例子还有可以升级的地方，比如上传图片生成缩略图，调用FCK编辑器，会员后台列表分页功能，删除数据功能等等，这些暂时不添加。]]></description>
			<content:encoded><![CDATA[<p>ECShop二次开发的时候我会使用到一些自己编写的函数，通常我都将这些函数放在 includes/lib_common.php 文件末尾。<br />
这次的例子中使用到两个函数 data_insert和data_update，他们的做用是插入和更新数据库记录</p>
<p>打开：includes/lib_common.php 文件，在默认添加下列代码</p>
<pre class="brush: php; title: ; notranslate">
/**
 * 添加数据
 * @param string $tablename 数据表名称(不带前缀)
 * @param array $info 要添加到数据表中的字段和值，格式：array('字段名称'=&gt;'字段值')
 *
 * return int $insertid 当前记录ID
*/
function data_insert($tablename,$info=array())
{
	$sp1 = $sp2 = '';
	if (is_array($info))
	{
		foreach ($info as $key=&gt;$value)
		{
			$sp1 .= &quot;`$key`, &quot;;
			$sp2 .= &quot;'$value', &quot;;
		}
		$sp1 = substr($sp1,0,-2);
		$sp2 = substr($sp2,0,-2);
	}
	$GLOBALS['db']-&gt;query(&quot;insert into &quot;.$GLOBALS['ecs']-&gt;table($tablename).&quot; ($sp1) values ($sp2)&quot;);
	$insertid = $GLOBALS['db']-&gt;insert_id();
	return $insertid;
}

/**
 * 编辑数据
 * @param string $tablename 数据表名称(不带前缀)
 * @param array $info 数据表中的字段和值，格式：array('字段名称'=&gt;'字段值')
 * @param int $id 当前操作记录ID
 * @param string $idname 当前数据表中主键名称
 *
 * return
*/
function data_update($tablename,$info=array(),$id,$idname='id')
{
	$sp = '';
	if (is_array($info))
	{
		foreach ($info as $key=&gt;$value)
		{
			$sp .= &quot;`$key` = '$value', &quot;;
		}
		$sp = substr($sp,0,-2);
	}
	$GLOBALS['db']-&gt;query(&quot;update &quot;.$GLOBALS['ecs']-&gt;table($tablename).&quot; set $sp where $idname = '$id'&quot;);
}
</pre>
<p>步骤一：添加建立数据库</p>
<pre class="brush: php; title: ; notranslate">
CREATE TABLE IF NOT EXISTS `ecs_court` (
  `court_id` mediumint(8) NOT NULL auto_increment,
  `title` varchar(250) NOT NULL,
  `company` varchar(250) NOT NULL,
  `types` varchar(100) NOT NULL,
  `province` varchar(250) NOT NULL,
  `citys` varchar(100) NOT NULL,
  `areas` varchar(100) NOT NULL,
  `charge` varchar(250) NOT NULL,
  `opens` varchar(250) NOT NULL,
  `address` varchar(250) NOT NULL,
  `tel` varchar(250) NOT NULL,
  `add_time` int(10) NOT NULL default '0',
  `user_id` mediumint(8) NOT NULL default '0',
  `is_check` tinyint(1) NOT NULL default '1',
  PRIMARY KEY  (`court_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=115 ;
</pre>
<p>步骤二：修改user.php文件</p>
<p>修改一：给user.php文件中的$ui_arr数组中添加两个值：&#8217;court_list&#8217;, &#8216;court_add&#8217;</p>
<p>修改二：user.php文件中添加处理代码：添加，编辑，列表</p>
<pre class="brush: php; title: ; notranslate">
//列表，这里为简单起见，不添加分页功能
elseif ($action == 'court_list')
{
	$items = $db-&gt;GetAll(&quot;SELECT * FROM ecs_court WHERE user_id = $user_id&quot;);

	$smarty-&gt;assign('items', $items);
	$smarty-&gt;display('user_court_list.dwt');
}

//添加
elseif ($action == 'court_add')
{
	if ($_POST['do'] == 'save')
	{
		$info = $_POST['info'];
		$info['user_id'] = $user_id;
		$info['is_check'] = 0;
		$info['add_time'] = gmtime();

		data_insert('court', $info);
		show_message('操作成功', '返回列表', 'user.php?act=court_list');
	}
	else
	{
		$smarty-&gt;display('user_court_add.dwt');
	}
}

//编辑
elseif ($action == 'court_edit')
{
	if ($_POST['do'] == 'save')
	{
		$info = $_POST['info'];
		$info['user_id'] = $user_id;
		$info['is_check'] = 0;
		$info['add_time'] = gmtime();
		data_update('court', $info, $_POST['id'], 'court_id');
		show_message('操作成功', '返回列表', 'user.php?act=court_list');
	}
	else
	{
		$article = $db-&gt;GetRow(&quot;SELECT * FROM ecs_court WHERE court_id = $_GET[id]&quot;);
		$smarty-&gt;assign('article', $article);
		$smarty-&gt;display('user_court_edit.dwt');
	}
}
</pre>
<p>步骤三：在themes\default目录下添加三个模板文件，注意下面三个模板的样式可能与默认模板不同，请自行修改。<br />
文件一：user_court_add.dwt</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;{$keywords}&quot; /&gt;
&lt;meta name=&quot;Description&quot; content=&quot;{$description}&quot; /&gt;
&lt;!-- TemplateBeginEditable name=&quot;doctitle&quot; --&gt;
&lt;title&gt;{$page_title}&lt;/title&gt;
&lt;!-- TemplateEndEditable --&gt;&lt;!-- TemplateBeginEditable name=&quot;head&quot; --&gt;&lt;!-- TemplateEndEditable --&gt;
&lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot; /&gt;
&lt;link rel=&quot;icon&quot; href=&quot;animated_favicon.gif&quot; type=&quot;image/gif&quot; /&gt;
&lt;link href=&quot;{$ecs_css_path}&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
{* 包含脚本文件 *}
{insert_scripts files='transport.js,common.js,user.js'}
&lt;script&gt;
function getbyid(id) {return document.getElementById(id);}
function check_court()
{
	if (getbyid(&quot;title&quot;).value == '')
	{
		alert(&quot;请输入场馆名称！&quot;);
		getbyid(&quot;title&quot;).focus();
		return false;
	}

	if (getbyid(&quot;types&quot;).value == '')
	{
		alert(&quot;请输入场馆类型！&quot;);
		getbyid(&quot;types&quot;).focus();
		return false;
	}

	if (getbyid(&quot;citys&quot;).value == '')
	{
		alert(&quot;请输入所在城市！&quot;);
		getbyid(&quot;citys&quot;).focus();
		return false;
	}

	if (getbyid(&quot;areas&quot;).value == '')
	{
		alert(&quot;请输入场地数量！&quot;);
		getbyid(&quot;areas&quot;).focus();
		return false;
	}

	if (getbyid(&quot;charge&quot;).value == '')
	{
		alert(&quot;请输入收费标准！&quot;);
		getbyid(&quot;charge&quot;).focus();
		return false;
	}

	if (getbyid(&quot;opens&quot;).value == '')
	{
		alert(&quot;请输入开放时间！&quot;);
		getbyid(&quot;opens&quot;).focus();
		return false;
	}

	if (getbyid(&quot;address&quot;).value == '')
	{
		alert(&quot;请输入地址！&quot;);
		getbyid(&quot;address&quot;).focus();
		return false;
	}

	if (getbyid(&quot;tel&quot;).value == '')
	{
		alert(&quot;请输入电话！&quot;);
		getbyid(&quot;tel&quot;).focus();
		return false;
	}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- #BeginLibraryItem &quot;/library/page_header.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;
&lt;div class=&quot;user_here&quot;&gt;&lt;!-- #BeginLibraryItem &quot;/library/ur_here.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;&lt;/div&gt;

&lt;div class=&quot;clearfix&quot;&gt;
	&lt;div class=&quot;AreaL&quot;&gt;&lt;!-- #BeginLibraryItem &quot;/library/user_menu.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;&lt;/div&gt;

	&lt;div class=&quot;AreaR&quot;&gt;
		&lt;div class=&quot;box&quot;&gt;&lt;div class=&quot;box_1&quot;&gt;&lt;div class=&quot;userCenterBox boxCenterList clearfix&quot; style=&quot;_height:1%;&quot;&gt;
			&lt;h5&gt;&lt;span&gt;添加场馆&lt;/span&gt;&lt;/h5&gt;

			&lt;form action=&quot;user.php?act=court_add&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; onsubmit=&quot;return check_court()&quot;&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;do&quot; value=&quot;save&quot; /&gt;
				&lt;table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;table_info&quot;&gt;
					&lt;tr&gt;
						&lt;th&gt;场馆名称&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[title]&quot; id=&quot;title&quot; size=&quot;60&quot; value=&quot;{$article.title|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;场馆类型&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[types]&quot; id=&quot;types&quot; size=&quot;60&quot; value=&quot;{$article.types|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;所在城市&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[citys]&quot; id=&quot;citys&quot; size=&quot;60&quot; value=&quot;{$article.citys|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;场地数量&lt;/th&gt;
						&lt;td&gt;&lt;textarea name=&quot;info[areas]&quot; id=&quot;areas&quot; cols=&quot;50&quot; rows=&quot;3&quot;&gt;{$article.areas|escape}&lt;/textarea&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;收费标准&lt;/th&gt;
						&lt;td&gt;&lt;textarea name=&quot;info[charge]&quot; id=&quot;charge&quot; cols=&quot;50&quot; rows=&quot;3&quot;&gt;{$article.charge|escape}&lt;/textarea&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;开放时间&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[opens]&quot; id=&quot;opens&quot; size=&quot;60&quot; value=&quot;{$article.opens|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;地址&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[address]&quot; id=&quot;address&quot; size=&quot;60&quot; value=&quot;{$article.address|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;电话&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[tel]&quot; id=&quot;tel&quot; size=&quot;60&quot; value=&quot;{$article.tel|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;&lt;/th&gt;
						&lt;td height=&quot;50&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;Submit&quot;  class=&quot;bnt_blue_1&quot; style=&quot;border:none;&quot;  value=&quot; 提交 &quot; /&gt;&lt;/td&gt;
					&lt;/tr&gt;
				&lt;/table&gt;
			&lt;/form&gt;
		&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;!-- #BeginLibraryItem &quot;/library/page_footer.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>文件二：user_court_edit.dwt</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;{$keywords}&quot; /&gt;
&lt;meta name=&quot;Description&quot; content=&quot;{$description}&quot; /&gt;
&lt;!-- TemplateBeginEditable name=&quot;doctitle&quot; --&gt;
&lt;title&gt;{$page_title}&lt;/title&gt;
&lt;!-- TemplateEndEditable --&gt;&lt;!-- TemplateBeginEditable name=&quot;head&quot; --&gt;&lt;!-- TemplateEndEditable --&gt;
&lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot; /&gt;
&lt;link rel=&quot;icon&quot; href=&quot;animated_favicon.gif&quot; type=&quot;image/gif&quot; /&gt;
&lt;link href=&quot;{$ecs_css_path}&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
{* 包含脚本文件 *}
{insert_scripts files='transport.js,common.js,user.js'}
&lt;script&gt;
function getbyid(id) {return document.getElementById(id);}
function check_court()
{
	if (getbyid(&quot;title&quot;).value == '')
	{
		alert(&quot;请输入场馆名称！&quot;);
		getbyid(&quot;title&quot;).focus();
		return false;
	}

	if (getbyid(&quot;types&quot;).value == '')
	{
		alert(&quot;请输入场馆类型！&quot;);
		getbyid(&quot;types&quot;).focus();
		return false;
	}

	if (getbyid(&quot;citys&quot;).value == '')
	{
		alert(&quot;请输入所在城市！&quot;);
		getbyid(&quot;citys&quot;).focus();
		return false;
	}

	if (getbyid(&quot;areas&quot;).value == '')
	{
		alert(&quot;请输入场地数量！&quot;);
		getbyid(&quot;areas&quot;).focus();
		return false;
	}

	if (getbyid(&quot;charge&quot;).value == '')
	{
		alert(&quot;请输入收费标准！&quot;);
		getbyid(&quot;charge&quot;).focus();
		return false;
	}

	if (getbyid(&quot;opens&quot;).value == '')
	{
		alert(&quot;请输入开放时间！&quot;);
		getbyid(&quot;opens&quot;).focus();
		return false;
	}

	if (getbyid(&quot;address&quot;).value == '')
	{
		alert(&quot;请输入地址！&quot;);
		getbyid(&quot;address&quot;).focus();
		return false;
	}

	if (getbyid(&quot;tel&quot;).value == '')
	{
		alert(&quot;请输入电话！&quot;);
		getbyid(&quot;tel&quot;).focus();
		return false;
	}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!-- #BeginLibraryItem &quot;/library/page_header.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;
&lt;div class=&quot;user_here&quot;&gt;&lt;!-- #BeginLibraryItem &quot;/library/ur_here.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;&lt;/div&gt;

&lt;div class=&quot;clearfix&quot;&gt;
	&lt;div class=&quot;AreaL&quot;&gt;&lt;!-- #BeginLibraryItem &quot;/library/user_menu.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;&lt;/div&gt;

	&lt;div class=&quot;AreaR&quot;&gt;
		&lt;div class=&quot;box&quot;&gt;&lt;div class=&quot;box_1&quot;&gt;&lt;div class=&quot;userCenterBox boxCenterList clearfix&quot; style=&quot;_height:1%;&quot;&gt;
			&lt;h5&gt;&lt;span&gt;编辑场馆&lt;/span&gt;&lt;/h5&gt;
			&lt;form action=&quot;user.php?act=court_edit&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; onsubmit=&quot;return check_court()&quot;&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;do&quot; value=&quot;save&quot; /&gt;
				&lt;input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;{$article.court_id}&quot; /&gt;
				&lt;table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; class=&quot;table_info&quot;&gt;
					&lt;tr&gt;
						&lt;th&gt;场馆名称&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[title]&quot; id=&quot;title&quot; size=&quot;60&quot; value=&quot;{$article.title|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;场馆类型&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[types]&quot; id=&quot;types&quot; size=&quot;60&quot; value=&quot;{$article.types|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;所在城市&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[citys]&quot; id=&quot;citys&quot; size=&quot;60&quot; value=&quot;{$article.citys|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;场地数量&lt;/th&gt;
						&lt;td&gt;&lt;textarea name=&quot;info[areas]&quot; id=&quot;areas&quot; cols=&quot;50&quot; rows=&quot;3&quot;&gt;{$article.areas|escape}&lt;/textarea&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;收费标准&lt;/th&gt;
						&lt;td&gt;&lt;textarea name=&quot;info[charge]&quot; id=&quot;charge&quot; cols=&quot;50&quot; rows=&quot;3&quot;&gt;{$article.charge|escape}&lt;/textarea&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;开放时间&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[opens]&quot; id=&quot;opens&quot; size=&quot;60&quot; value=&quot;{$article.opens|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;地址&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[address]&quot; id=&quot;address&quot; size=&quot;60&quot; value=&quot;{$article.address|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;电话&lt;/th&gt;
						&lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;info[tel]&quot; id=&quot;tel&quot; size=&quot;60&quot; value=&quot;{$article.tel|escape}&quot; /&gt; (必填)&lt;/td&gt;
					&lt;/tr&gt;
					&lt;tr&gt;
						&lt;th&gt;&lt;/th&gt;
						&lt;td height=&quot;50&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;Submit&quot;  class=&quot;bnt_blue_1&quot; style=&quot;border:none;&quot;  value=&quot; 提交 &quot; /&gt;&lt;/td&gt;
					&lt;/tr&gt;
				&lt;/table&gt;
			&lt;/form&gt;
		&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;!-- #BeginLibraryItem &quot;/library/page_footer.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>文件三：user_court_list.dwt</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
&lt;meta name=&quot;Keywords&quot; content=&quot;{$keywords}&quot; /&gt;
&lt;meta name=&quot;Description&quot; content=&quot;{$description}&quot; /&gt;
&lt;!-- TemplateBeginEditable name=&quot;doctitle&quot; --&gt;
&lt;title&gt;{$page_title}&lt;/title&gt;
&lt;!-- TemplateEndEditable --&gt;&lt;!-- TemplateBeginEditable name=&quot;head&quot; --&gt;&lt;!-- TemplateEndEditable --&gt;
&lt;link rel=&quot;shortcut icon&quot; href=&quot;favicon.ico&quot; /&gt;
&lt;link rel=&quot;icon&quot; href=&quot;animated_favicon.gif&quot; type=&quot;image/gif&quot; /&gt;
&lt;link href=&quot;{$ecs_css_path}&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;
{* 包含脚本文件 *}
{insert_scripts files='transport.js,common.js,user.js'}
&lt;/head&gt;
&lt;body&gt;
&lt;!-- #BeginLibraryItem &quot;/library/page_header.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;
&lt;div class=&quot;user_here&quot;&gt;&lt;!-- #BeginLibraryItem &quot;/library/ur_here.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;&lt;/div&gt;

&lt;div class=&quot;clearfix&quot;&gt;
	&lt;div class=&quot;AreaL&quot;&gt;&lt;!-- #BeginLibraryItem &quot;/library/user_menu.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;&lt;/div&gt;

	&lt;div class=&quot;AreaR&quot;&gt;
		&lt;div class=&quot;box&quot;&gt;&lt;div class=&quot;box_1&quot;&gt;&lt;div class=&quot;userCenterBox boxCenterList clearfix&quot; style=&quot;_height:1%;&quot;&gt;
			&lt;h5&gt;&lt;span&gt;我的场馆&lt;/span&gt;&lt;/h5&gt;
			&lt;table width=&quot;100%&quot; border=&quot;0&quot; cellspacing=&quot;1&quot; cellpadding=&quot;0&quot; class=&quot;table_list&quot;&gt;
				&lt;tr&gt;
					&lt;th&gt;场馆名称&lt;/th&gt;
					&lt;th width=&quot;70&quot; align=&quot;center&quot;&gt;状态&lt;/th&gt;
					&lt;th width=&quot;50&quot; align=&quot;center&quot;&gt;编辑&lt;/th&gt;
				&lt;/tr&gt;
				&lt;!--{foreach from=$items item=value}--&gt;
				&lt;tr&gt;
					&lt;td&gt;{$value.title}&lt;/td&gt;
					&lt;td align=&quot;center&quot;&gt;{if $value.is_check eq 1}审核通过{else}&lt;span style=&quot;color:#f00&quot;&gt;等待审核&lt;/span&gt;{/if}&lt;/td&gt;
					&lt;td align=&quot;center&quot;&gt;&lt;a href=&quot;user.php?act=court_edit&amp;id={$value.court_id}&quot;&gt;编辑&lt;/a&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;!--{/foreach}--&gt;
			&lt;/table&gt;
		&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;!-- #BeginLibraryItem &quot;/library/page_footer.lbi&quot; --&gt;&lt;!-- #EndLibraryItem --&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>步骤四：在themes/default/library/user_menu.lbi文件中添加下面的链接地址，default是当前模板目录</p>
<pre class="brush: xml; title: ; notranslate">
&lt;a href=&quot;user.php?act=court_add&quot;{if $action eq 'court_add'}class=&quot;curs&quot;{/if}&gt;添加场馆&lt;/a&gt;
&lt;a href=&quot;user.php?act=court_list&quot;{if $action eq 'court_list' || $action eq 'court_edit'}class=&quot;curs&quot;{/if}&gt;我的场馆&lt;/a&gt;
</pre>
<p>步骤五：打开admin/includes/inc_menu.php文件，添加后台管理导航链接。在末尾添加一行代码：</p>
<pre class="brush: php; title: ; notranslate">
$modules['17_diymodule']['new_court']               = 'new_court.php?act=list';
</pre>
<p>步骤六：打开languages/zh_cn/admin/common.php文件，在末尾添加语言选项。</p>
<pre class="brush: php; title: ; notranslate">
/* 自定义模块 */
$_LANG['17_diymodule'] = '自定义模块';
$_LANG['01_new_court'] = '场馆管理';
</pre>
<p>完成步骤五和步骤六以后进入后台，你会在左侧导航的最下面发现新增加的“自定义模块”。</p>
<p>步骤七：在admin目录下添加文件：new_court.php</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

/*初始化数据交换对象 */
$exc   = new exchange($ecs-&gt;table(&quot;court&quot;), $db, 'court_id', 'title');

/*------------------------------------------------------ */
//-- 场馆列表
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'list')
{
    /* 取得过滤条件 */
    $filter = array();
    $smarty-&gt;assign('ur_here',      $_LANG['new_court']);
    $smarty-&gt;assign('action_link',  array('text' =&gt; '添加新场馆', 'href' =&gt; 'new_court.php?act=add'));
    $smarty-&gt;assign('full_page',    1);
    $smarty-&gt;assign('filter',       $filter);

    $article_list = get_articleslist();

    $smarty-&gt;assign('article_list',    $article_list['arr']);
    $smarty-&gt;assign('filter',          $article_list['filter']);
    $smarty-&gt;assign('record_count',    $article_list['record_count']);
    $smarty-&gt;assign('page_count',      $article_list['page_count']);

    $sort_flag  = sort_flag($article_list['filter']);
    $smarty-&gt;assign($sort_flag['tag'], $sort_flag['img']);

    assign_query_info();
    $smarty-&gt;display('new_court_list.htm');
}

/*------------------------------------------------------ */
//-- 翻页，排序
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'query')
{
    check_authz_json('article_manage');

    $article_list = get_articleslist();

    $smarty-&gt;assign('article_list',    $article_list['arr']);
    $smarty-&gt;assign('filter',          $article_list['filter']);
    $smarty-&gt;assign('record_count',    $article_list['record_count']);
    $smarty-&gt;assign('page_count',      $article_list['page_count']);

    $sort_flag  = sort_flag($article_list['filter']);
    $smarty-&gt;assign($sort_flag['tag'], $sort_flag['img']);

    make_json_result($smarty-&gt;fetch('new_court_list.htm'), '',
        array('filter' =&gt; $article_list['filter'], 'page_count' =&gt; $article_list['page_count']));
}

/*------------------------------------------------------ */
//-- 添加场馆
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'add')
{
    /*初始化*/
    $article = array();

    if (isset($_GET['id']))
    {
        $smarty-&gt;assign('cur_id',  $_GET['id']);
    }
    $smarty-&gt;assign('article',     $article);
    $smarty-&gt;assign('ur_here',     '添加新场馆');
    $smarty-&gt;assign('action_link', array('text' =&gt; '场馆列表', 'href' =&gt; 'new_court.php?act=list'));
    $smarty-&gt;assign('form_action', 'insert');

    assign_query_info();
    $smarty-&gt;display('new_court_info.htm');
}

/*------------------------------------------------------ */
//-- 添加场馆
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'insert')
{
    /*插入数据*/
    $add_time = gmtime();
    $sql = &quot;INSERT INTO &quot;.$ecs-&gt;table('court').&quot;(title, types, citys, areas, charge, &quot;.
                &quot;opens, address, tel, add_time) &quot;.
            &quot;VALUES ('$_POST[title]', '$_POST[types]', '$_POST[citys]', '$_POST[areas]', &quot;.
                &quot;'$_POST[charge]', '$_POST[opens]', '$_POST[address]', '$_POST[tel]', &quot;.
                &quot;'$add_time')&quot;;
    $db-&gt;query($sql);
	$court_id = $db-&gt;insert_id();

    $link[0]['text'] = '继续添加场馆';
    $link[0]['href'] = 'new_court.php?act=add';

    $link[1]['text'] = '返回场馆列表';
    $link[1]['href'] = 'new_court.php?act=list';

    admin_log($_POST['title'],'add','场馆');

    clear_cache_files(); // 清除相关的缓存文件

    sys_msg('添加成功',0, $link);
}

/*------------------------------------------------------ */
//-- 编辑
/*------------------------------------------------------ */
if ($_REQUEST['act'] == 'edit')
{
    /* 取场馆数据 */
    $article = $db-&gt;GetRow(&quot;SELECT * FROM &quot; .$ecs-&gt;table('court'). &quot; WHERE court_id='$_REQUEST[id]'&quot;);

    $smarty-&gt;assign('article',     $article);
    $smarty-&gt;assign('ur_here',     '编辑场馆');
    $smarty-&gt;assign('action_link', array('text' =&gt; '场馆列表', 'href' =&gt; 'new_court.php?act=list&amp;' . list_link_postfix()));
    $smarty-&gt;assign('form_action', 'update');

    assign_query_info();
    $smarty-&gt;display('new_court_info.htm');
}

if ($_REQUEST['act'] =='update')
{
    if ($exc-&gt;edit(&quot;title='$_POST[title]', types='$_POST[types]', citys='$_POST[citys]', areas='$_POST[areas]', charge='$_POST[charge]', opens='$_POST[opens]', address ='$_POST[address]', tel ='$_POST[tel]', is_check='$_POST[is_check]'&quot;, $_POST['id']))
    {
        $link[0]['text'] = '返回列表';
        $link[0]['href'] = 'new_court.php?act=list&amp;' . list_link_postfix();

        $link[1]['text'] = '继续编辑';
        $link[1]['href'] = 'new_court.php?act=edit&amp;id=' . $_POST['id'];

        $note = sprintf('场馆编辑成功', stripslashes($_POST['title']));
        admin_log($_POST['title'], 'edit', 'article');

        clear_cache_files();

        sys_msg($note, 0, $link);
    }
    else
    {
        die($db-&gt;error());
    }
}

/*------------------------------------------------------ */
//-- 编辑场馆名称
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'edit_title')
{
    $id    = intval($_POST['id']);
    $title = json_str_iconv(trim($_POST['val']));

	if ($exc-&gt;edit(&quot;title = '$title'&quot;, $id))
	{
		clear_cache_files();
		admin_log($title, 'edit', 'article');
		make_json_result(stripslashes($title));
	}
	else
	{
		make_json_error($db-&gt;error());
	}
}

/*------------------------------------------------------ */
//-- 删除场馆
/*------------------------------------------------------ */
elseif ($_REQUEST['act'] == 'remove')
{
    $id = intval($_GET['id']);
	$db-&gt;query(&quot;DELETE FROM &quot; . $ecs-&gt;table('court') . &quot; WHERE &quot; . &quot;court_id = $id&quot;);
    $url = 'new_court.php?act=query&amp;' . str_replace('act=remove', '', $_SERVER['QUERY_STRING']);
    ecs_header(&quot;Location: $url\n&quot;);
    exit;
}

/*------------------------------------------------------ */
//-- 批量操作
/*------------------------------------------------------ */

elseif ($_REQUEST['act'] == 'batch')
{
    /* 批量删除 */
    if (isset($_POST['type']))
    {
        if ($_POST['type'] == 'button_remove')
        {
            if (!isset($_POST['checkboxes']) || !is_array($_POST['checkboxes']))
            {
                sys_msg($_LANG['no_select_article'], 1);
            }

            foreach ($_POST['checkboxes'] AS $key =&gt; $id)
            {
				$db-&gt;query(&quot;DELETE FROM &quot; . $ecs-&gt;table('court') . &quot; WHERE &quot; . &quot;court_id = $id&quot;);
            }
        }
    }

    /* 清除缓存 */
    clear_cache_files();
    $lnk[] = array('text' =&gt; '返回列表', 'href' =&gt; 'new_court.php?act=list');
    sys_msg($_LANG['batch_handle_ok'], 0, $lnk);
}

/* 获得场馆列表 */
function get_articleslist()
{
    $result = get_filter();
    if ($result === false)
    {
        $filter = array();
        $filter['keyword']    = empty($_REQUEST['keyword']) ? '' : trim($_REQUEST['keyword']);
        if (isset($_REQUEST['is_ajax']) &amp;&amp; $_REQUEST['is_ajax'] == 1)
        {
            $filter['keyword'] = json_str_iconv($filter['keyword']);
        }
        $filter['cat_id'] = empty($_REQUEST['cat_id']) ? 0 : intval($_REQUEST['cat_id']);
        $filter['sort_by']    = empty($_REQUEST['sort_by']) ? 'a.court_id' : trim($_REQUEST['sort_by']);
        $filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);

        $where = '';
        if (!empty($filter['keyword']))
        {
            $where = &quot; AND a.title LIKE '%&quot; . mysql_like_quote($filter['keyword']) . &quot;%'&quot;;
        }

        /* 场馆总数 */
        $sql = 'SELECT COUNT(*) FROM ' .$GLOBALS['ecs']-&gt;table('court'). ' AS a '.
               'WHERE 1 ' .$where;
        $filter['record_count'] = $GLOBALS['db']-&gt;getOne($sql);

        $filter = page_and_size($filter);

        /* 获取场馆数据 */
        $sql = 'SELECT a.* '.
               'FROM ' .$GLOBALS['ecs']-&gt;table('court'). ' AS a '.
               'WHERE 1 ' .$where. ' ORDER by '.$filter['sort_by'].' '.$filter['sort_order'];

        $filter['keyword'] = stripslashes($filter['keyword']);
        set_filter($filter, $sql);
    }
    else
    {
        $sql    = $result['sql'];
        $filter = $result['filter'];
    }
    $arr = array();
    $res = $GLOBALS['db']-&gt;selectLimit($sql, $filter['page_size'], $filter['start']);

    while ($rows = $GLOBALS['db']-&gt;fetchRow($res))
    {
        $rows['date'] = local_date(&quot;Y-m-d&quot;, $rows['add_time']);

        $arr[] = $rows;
    }
    return array('arr' =&gt; $arr, 'filter' =&gt; $filter, 'page_count' =&gt; $filter['page_count'], 'record_count' =&gt; $filter['record_count']);
}
?&gt;
</pre>
<p>步骤八：在admin/templates目录下添加两个文件： new_court_list.htm 和 new_court_info.htm<br />
new_court_list.htm</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- $Id: article_list.htm 16783 2009-11-09 09:59:06Z liuhui $ --&gt;

{if $full_page}
{include file=&quot;pageheader.htm&quot;}
{insert_scripts files=&quot;../js/utils.js,listtable.js&quot;}
&lt;div class=&quot;form-div&quot;&gt;
  &lt;form action=&quot;javascript:searchArticle()&quot; name=&quot;searchForm&quot; &gt;
    &lt;img src=&quot;images/icon_search.gif&quot; width=&quot;26&quot; height=&quot;22&quot; border=&quot;0&quot; alt=&quot;SEARCH&quot; /&gt;
	名称：
    {$lang.title} &lt;input type=&quot;text&quot; name=&quot;keyword&quot; id=&quot;keyword&quot; /&gt;
    &lt;input type=&quot;submit&quot; value=&quot;{$lang.button_search}&quot; class=&quot;button&quot; /&gt;
  &lt;/form&gt;
&lt;/div&gt;

&lt;form method=&quot;POST&quot; action=&quot;new_court.php?act=batch_remove&quot; name=&quot;listForm&quot;&gt;
&lt;!-- start cat list --&gt;
&lt;div class=&quot;list-div&quot; id=&quot;listDiv&quot;&gt;
{/if}

&lt;table cellspacing='1' cellpadding='3' id='list-table'&gt;
  &lt;tr&gt;
    &lt;th align=&quot;left&quot;&gt;&lt;input onclick='listTable.selectAll(this, &quot;checkboxes&quot;)' type=&quot;checkbox&quot;&gt;
      &lt;a href=&quot;javascript:listTable.sort('court_id'); &quot;&gt;编号&lt;/a&gt;{$sort_court_id}&lt;/th&gt;
    &lt;th&gt;&lt;a href=&quot;javascript:listTable.sort('title'); &quot;&gt;场馆名称&lt;/a&gt;{$sort_title}&lt;/th&gt;
    &lt;th&gt;&lt;a href=&quot;javascript:listTable.sort('types'); &quot;&gt;场馆类型&lt;/a&gt;{$sort_types}&lt;/th&gt;
    &lt;th&gt;&lt;a href=&quot;javascript:listTable.sort('citys'); &quot;&gt;所在城市&lt;/a&gt;{$sort_citys}&lt;/th&gt;
    &lt;th&gt;&lt;a href=&quot;javascript:listTable.sort('is_check'); &quot;&gt;审核状态&lt;/a&gt;{$sort_is_check}&lt;/th&gt;
    &lt;th&gt;&lt;a href=&quot;javascript:listTable.sort('add_time'); &quot;&gt;添加时间&lt;/a&gt;{$sort_add_time}&lt;/th&gt;
    &lt;th&gt;{$lang.handler}&lt;/th&gt;
  &lt;/tr&gt;
  {foreach from=$article_list item=list}
  &lt;tr&gt;
    &lt;td&gt;&lt;span&gt;&lt;input name=&quot;checkboxes[]&quot; type=&quot;checkbox&quot; value=&quot;{$list.court_id}&quot;/&gt;{$list.court_id}&lt;/span&gt;&lt;/td&gt;
    &lt;td class=&quot;first-cell&quot;&gt;
    &lt;span onclick=&quot;javascript:listTable.edit(this, 'edit_title', {$list.court_id})&quot;&gt;{$list.title|escape:html}&lt;/span&gt;&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;{$list.types}&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;{$list.citys}&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;{if $list.is_check eq 1}审核通过{else}&lt;span style=&quot;color:#F00&quot;&gt;等待审核&lt;/span&gt;{/if}&lt;/td&gt;
    &lt;td align=&quot;center&quot;&gt;&lt;span&gt;{$list.date}&lt;/span&gt;&lt;/td&gt;
    &lt;td align=&quot;center&quot; nowrap=&quot;true&quot;&gt;&lt;span&gt;
      &lt;a href=&quot;new_court.php?act=edit&amp;id={$list.court_id}&quot; title=&quot;{$lang.edit}&quot;&gt;&lt;img src=&quot;images/icon_edit.gif&quot; border=&quot;0&quot; height=&quot;16&quot; width=&quot;16&quot; /&gt;&lt;/a&gt;&amp;nbsp;
     &lt;a href=&quot;javascript:;&quot; onclick=&quot;listTable.remove({$list.court_id}, '{$lang.drop_confirm}')&quot; title=&quot;{$lang.remove}&quot;&gt;&lt;img src=&quot;images/icon_drop.gif&quot; border=&quot;0&quot; height=&quot;16&quot; width=&quot;16&quot;&gt;&lt;/a&gt;&lt;/span&gt;
    &lt;/td&gt;
   &lt;/tr&gt;
   {foreachelse}
    &lt;tr&gt;&lt;td class=&quot;no-records&quot; colspan=&quot;10&quot;&gt;{$lang.no_article}&lt;/td&gt;&lt;/tr&gt;
  {/foreach}
  &lt;tr&gt;&amp;nbsp;
    &lt;td align=&quot;right&quot; nowrap=&quot;true&quot; colspan=&quot;8&quot;&gt;{include file=&quot;page.htm&quot;}&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

{if $full_page}
&lt;/div&gt;

&lt;div&gt;
  &lt;input type=&quot;hidden&quot; name=&quot;act&quot; value=&quot;batch&quot; /&gt;
  &lt;select name=&quot;type&quot; id=&quot;selAction&quot; onchange=&quot;changeAction()&quot;&gt;
    &lt;option value=&quot;&quot;&gt;{$lang.select_please}&lt;/option&gt;
    &lt;option value=&quot;button_remove&quot;&gt;批量删除&lt;/option&gt;
  &lt;/select&gt;
  &lt;select name=&quot;target_cat&quot; style=&quot;display:none&quot;&gt;
    &lt;option value=&quot;0&quot;&gt;{$lang.select_please}&lt;/option&gt;
    {$cat_select}
  &lt;/select&gt;

  &lt;input type=&quot;submit&quot; value=&quot;{$lang.button_submit}&quot; id=&quot;btnSubmit&quot; name=&quot;btnSubmit&quot; class=&quot;button&quot; disabled=&quot;true&quot; /&gt;
&lt;/div&gt;
&lt;/form&gt;
&lt;!-- end cat list --&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;JavaScript&quot;&gt;
  listTable.recordCount = {$record_count};
  listTable.pageCount = {$page_count};

  {foreach from=$filter item=item key=key}
  listTable.filter.{$key} = '{$item}';
  {/foreach}
  {literal}

  onload = function()
  {
    // 开始检查订单
    startCheckOrder();
  }
	/**
   * @param: bool ext 其他条件：用于转移分类
   */
  function confirmSubmit(frm, ext)
  {
      if (frm.elements['type'].value == 'button_remove')
      {
          return confirm(drop_confirm);
      }
      else if (frm.elements['type'].value == 'not_on_sale')
      {
          return confirm(batch_no_on_sale);
      }
      else if (frm.elements['type'].value == 'move_to')
      {
          ext = (ext == undefined) ? true : ext;
          return ext &amp;&amp; frm.elements['target_cat'].value != 0;
      }
      else if (frm.elements['type'].value == '')
      {
          return false;
      }
      else
      {
          return true;
      }
  }
	 function changeAction()
  {

      var frm = document.forms['listForm'];

      // 切换分类列表的显示
      frm.elements['target_cat'].style.display = frm.elements['type'].value == 'move_to' ? '' : 'none';

      if (!document.getElementById('btnSubmit').disabled &amp;&amp;
          confirmSubmit(frm, false))
      {
          frm.submit();
      }
  }

 /* 搜索文章 */
 function searchArticle()
 {
    listTable.filter.keyword = Utils.trim(document.forms['searchForm'].elements['keyword'].value);
    listTable.filter.page = 1;
    listTable.loadList();
 }

 {/literal}
&lt;/script&gt;
{include file=&quot;pagefooter.htm&quot;}
{/if}
</pre>
<p>new_court_info.htm</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!-- $Id: article_info.htm 16780 2009-11-09 09:28:30Z sxc_shop $ --&gt;
{include file=&quot;pageheader.htm&quot;}
{insert_scripts files=&quot;../js/utils.js,selectzone.js,validator.js&quot;}
&lt;!-- start goods form --&gt;
&lt;div class=&quot;tab-div&quot;&gt;

  &lt;div id=&quot;tabbody-div&quot;&gt;
    &lt;form  action=&quot;new_court.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot; name=&quot;theForm&quot; onsubmit=&quot;return validate();&quot;&gt;
    &lt;table width=&quot;90%&quot; id=&quot;general-table&quot;&gt;
      &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;场馆名称&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;title&quot; size =&quot;40&quot; maxlength=&quot;60&quot; value=&quot;{$article.title|escape}&quot; /&gt;{$lang.require_field}&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;场馆类型&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;types&quot; value=&quot;{$article.types|escape}&quot; /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;所在城市&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;citys&quot; value=&quot;{$article.citys|escape}&quot; /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;场地数量&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;areas&quot; value=&quot;{$article.areas|escape}&quot; /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;收费标准&lt;/td&gt;
        &lt;td&gt;&lt;textarea name=&quot;charge&quot; id=&quot;charge&quot; cols=&quot;40&quot; rows=&quot;5&quot;&gt;{$article.charge|escape}&lt;/textarea&gt;&lt;/td&gt;
      &lt;/tr&gt;
	  &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;开放时间&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;opens&quot; value=&quot;{$article.opens|escape}&quot; /&gt;&lt;/td&gt;
      &lt;/tr&gt;
	  &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;地址&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;address&quot; value=&quot;{$article.address|escape}&quot; /&gt;&lt;/td&gt;
      &lt;/tr&gt;
	  &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;电话&lt;/td&gt;
        &lt;td&gt;&lt;input type=&quot;text&quot; name=&quot;tel&quot; value=&quot;{$article.tel|escape}&quot; /&gt;&lt;/td&gt;
      &lt;/tr&gt;

	  &lt;tr&gt;
        &lt;td class=&quot;narrow-label&quot;&gt;状态&lt;/td&gt;
        &lt;td&gt;
			&lt;input type=&quot;radio&quot; name=&quot;is_check&quot; value=&quot;1&quot; {if $article.is_check eq 1}checked=&quot;checked&quot;{/if}  /&gt;审核通过
			&lt;input type=&quot;radio&quot; name=&quot;is_check&quot; value=&quot;0&quot; {if $article.is_check eq 0}checked=&quot;checked&quot;{/if}  /&gt;等待审核
		&lt;/td&gt;
      &lt;/tr&gt;

    &lt;/table&gt;

    &lt;div class=&quot;button-div&quot;&gt;
      &lt;input type=&quot;hidden&quot; name=&quot;act&quot; value=&quot;{$form_action}&quot; /&gt;
      &lt;input type=&quot;hidden&quot; name=&quot;old_title&quot; value=&quot;{$article.title}&quot;/&gt;
      &lt;input type=&quot;hidden&quot; name=&quot;id&quot; value=&quot;{$article.court_id}&quot; /&gt;
      &lt;input type=&quot;submit&quot; value=&quot;{$lang.button_submit}&quot; class=&quot;button&quot;  /&gt;
      &lt;input type=&quot;reset&quot; value=&quot;{$lang.button_reset}&quot; class=&quot;button&quot; /&gt;
    &lt;/div&gt;
    &lt;/form&gt;
  &lt;/div&gt;

&lt;/div&gt;
&lt;!-- end goods form --&gt;
&lt;script language=&quot;JavaScript&quot;&gt;

var articleId = {$article.article_id|default:0};
var elements  = document.forms['theForm'].elements;
var sz        = new SelectZone(1, elements['source_select'], elements['target_select'], '');

{literal}
onload = function()
{
  // 开始检查订单
  startCheckOrder();
}

function validate()
{
  var validator = new Validator('theForm');
  validator.required('title', no_title);
{/literal}
{if $article.cat_id &gt;= 0}
  validator.isNullOption('article_cat',no_cat);
{/if}
{literal}

  return validator.passed();
}

function showNotice(objId)
{
    var obj = document.getElementById(objId);

    if (obj)
    {
        if (obj.style.display != &quot;block&quot;)
        {
            obj.style.display = &quot;block&quot;;
        }
        else
        {
            obj.style.display = &quot;none&quot;;
        }
    }
}

function searchGoods()
{
    var elements  = document.forms['theForm'].elements;
    var filters   = new Object;

    filters.cat_id = elements['cat_id'].value;
    filters.brand_id = elements['brand_id'].value;
    filters.keyword = Utils.trim(elements['keyword'].value);

    sz.loadOptions('get_goods_list', filters);
}
{/literal}
&lt;/script&gt;
{include file=&quot;pagefooter.htm&quot;}
</pre>
<p>到这里我们添加的自定义模块已经基本可以使用了，这个例子比较简单，只包含会员录入数据，管理员编辑审核的功能，可以更具这个例子修改为你想要的功能和样式。</p>
<p>本例子还有可以升级的地方，比如上传图片生成缩略图，调用FCK编辑器，会员后台列表分页功能，删除数据功能等等，这些暂时不添加。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsok.com/archives/35/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ECShop订单导出excel功能 可以关联搜索条件 导出国家地区等</title>
		<link>http://www.cmsok.com/archives/28</link>
		<comments>http://www.cmsok.com/archives/28#comments</comments>
		<pubDate>Wed, 02 Nov 2011 09:02:18 +0000</pubDate>
		<dc:creator>307150302</dc:creator>
				<category><![CDATA[ECShop]]></category>

		<guid isPermaLink="false">http://www.cmsok.com/?p=28</guid>
		<description><![CDATA[订单导出Excel的功能是很实用，本文只是一个例子，可供新手参考。 步骤一： 修改原程序中的：admin/templates/order_list.htm文件 找到如下代码： 在后面增加一句代码： 在该页面尾部添加JS处理函数： 步骤二： 新建php文件：plugins/order_to_excel/index.php，写入下面的代码，注意区分GBK和UTF8版本。 GBK： UTF-8：]]></description>
			<content:encoded><![CDATA[<p>订单导出Excel的功能是很实用，本文只是一个例子，可供新手参考。</p>
<p><strong>步骤一：</strong><br />
修改原程序中的：admin/templates/order_list.htm文件</p>
<p>找到如下代码：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;a href=&quot;order.php?act=list&amp;composite_status={$cs_await_ship}&quot;&gt;{$lang.cs.$cs_await_ship}&lt;/a&gt;
</pre>
<p>在后面增加一句代码：</p>
<pre class="brush: xml; title: ; notranslate">
&lt;a href=&quot;javascript:;&quot;&gt;导出excel&lt;/a&gt;
</pre>
<p>在该页面尾部添加JS处理函数：</p>
<pre class="brush: jscript; title: ; notranslate">
function order_to_excel()
{
	var order_sn = document.getElementById('order_sn').value;
	var c**ignee = document.getElementById('c**ignee').value;
	var status = document.getElementById('status').value;
	window.location.href='../plugins/order_to_excel/index.php?order_sn='+order_sn+'&amp;c**ignee='+c**ignee+'&amp;status='+status;
}
</pre>
<p><strong>步骤二：</strong><br />
新建php文件：plugins/order_to_excel/index.php，写入下面的代码，注意区分GBK和UTF8版本。</p>
<p>GBK：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 * ECSHOP 导出订单插件
 * ============================================================================
 * 作者: cmsok
 *   QQ: 307150302
 * 网站: http://www.cmsok.com
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/../../includes/init.php');
include_once(ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/admin/order.php');
include_once(ROOT_PATH . 'includes/lib_order.php');

$order_sn = trim($_GET['order_sn']);
$consignee = trim($_GET['consignee']);
$status = intval($_GET['status']);

if (!empty($order_sn))
{
	$where .= &quot; AND o.order_sn like '%$order_sn%'&quot;;
}
if (!empty($consignee))
{
	$where .= &quot; AND o.consignee like '%$consignee%'&quot;;
}

switch($status)
{
	case CS_AWAIT_PAY :
		$where .= order_query_sql('await_pay','o.');
		break;

	case CS_AWAIT_SHIP :
		$where .= order_query_sql('await_ship','o.');
		break;

	case CS_FINISHED :
		$where .= order_query_sql('finished','o.');
		break;

	case PS_PAYING :
		if ($status != -1)
		{
			$where .= &quot; AND o.pay_status = '$status' &quot;;
		}
		break;

	default:
		if ($status != -1)
		{
			$where .= &quot; AND o.order_status = '$status' &quot;;
		}
}

$sql = &quot;SELECT o.*, ( o.goods_amount + o.tax + o.shipping_fee + o.insure_fee + o.pay_fee + o.pack_fee + o.card_fee ) AS total_fee, &quot;.
		&quot;ra.region_name AS country_name, &quot;.
		&quot;rb.region_name AS province_name, &quot;.
		&quot;rc.region_name AS city_name, &quot;.
		&quot;rd.region_name AS district_name &quot;.
		&quot;FROM &quot; .$GLOBALS['ecs']-&gt;table('order_info'). &quot; AS o &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS ra ON ra.region_id=o.country &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS rb ON rb.region_id=o.province &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS rc ON rc.region_id=o.city &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS rd ON rd.region_id=o.district &quot;.
		&quot;WHERE 1 $where ORDER BY o.order_id DESC&quot;;

header(&quot;Content-type:application/vnd.ms-excel&quot;);
header(&quot;Accept-Ranges:bytes&quot;);
header(&quot;Content-Disposition:filename=&quot;.time().&quot;.xls&quot;);
header(&quot;Pragma: no-cache&quot;);

echo '
	&lt;html xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot;
	xmlns:x=&quot;urn:schemas-microsoft-com:office:excel&quot;
	xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;
	&lt;head&gt;
	&lt;meta http-equiv=&quot;expires&quot; content=&quot;Mon, 06 Jan 1999 00:00:01 GMT&quot;&gt;
	&lt;meta http-equiv=Content-Type content=&quot;text/html; charset=gb2312&quot;&gt;
	&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
	&lt;x:ExcelWorkbook&gt;
	&lt;x:ExcelWorksheets&gt;
	&lt;x:ExcelWorksheet&gt;
	&lt;x:Name&gt;&lt;/x:Name&gt;
	&lt;x:WorksheetOptions&gt;
	&lt;x:DisplayGridlines/&gt;
	&lt;/x:WorksheetOptions&gt;
	&lt;/x:ExcelWorksheet&gt;
	&lt;/x:ExcelWorksheets&gt;
	&lt;/x:ExcelWorkbook&gt;
	&lt;/xml&gt;&lt;![endif]--&gt;
	&lt;/head&gt;
';

echo '&lt;table&gt;';
echo '&lt;tr&gt;';
echo '&lt;td&gt;订单号&lt;/td&gt;';
echo '&lt;td&gt;下单时间&lt;/td&gt;';
echo '&lt;td&gt;收货人&lt;/td&gt;';
echo '&lt;td&gt;国家&lt;/td&gt;';
echo '&lt;td&gt;省&lt;/td&gt;';
echo '&lt;td&gt;市&lt;/td&gt;';
echo '&lt;td&gt;区&lt;/td&gt;';
echo '&lt;td&gt;地址&lt;/td&gt;';
echo '&lt;td&gt;邮政编码&lt;/td&gt;';
echo '&lt;td&gt;电话&lt;/td&gt;';
echo '&lt;td&gt;手机&lt;/td&gt;';
echo '&lt;td&gt;Email&lt;/td&gt;';
echo '&lt;td&gt;总金额&lt;/td&gt;';
echo '&lt;td&gt;应付金额&lt;/td&gt;';
echo '&lt;td&gt;订单状态&lt;/td&gt;';
echo '&lt;td&gt;付款状态&lt;/td&gt;';
echo '&lt;td&gt;发货状态&lt;/td&gt;';
echo '&lt;/tr&gt;';

$res = $GLOBALS['db']-&gt;query($sql);
while ($row = $GLOBALS['db']-&gt;fetchRow($res))
{
	echo '&lt;tr&gt;';
	echo &quot;&lt;td style='vnd.ms-excel.numberformat:@'&gt;$row[order_sn]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.date(&quot;Y-m-d H:i:s&quot;,$row['add_time']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[consignee]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[country_name]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[province_name]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[city_name]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[district_name]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[address]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[zipcode]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[tel]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[mobile]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[email]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[total_fee]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[order_amount]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.$_LANG['cs'][$row['order_status']].&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.$_LANG['ps'][$row['pay_status']].&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.$_LANG['ss'][$row['shipping_status']].&quot;&lt;/td&gt;&quot;;
	echo '&lt;/tr&gt;';
}

echo '&lt;/table&gt;';
?&gt;
</pre>
<p>UTF-8：</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
/**
 * ECSHOP 导出订单插件
 * ============================================================================
 * 插件开发: http://www.cmsok.com
 * QQ: 307150302
*/
define('IN_ECS', true);
require(dirname(__FILE__) . '/../../includes/init.php');
include_once(ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/admin/order.php');
include_once(ROOT_PATH . 'includes/lib_order.php');

$order_sn = trim($_GET['order_sn']);
$consignee = trim($_GET['consignee']);
$status = intval($_GET['status']);

if (!empty($order_sn))
{
	$where .= &quot; AND o.order_sn like '%$order_sn%'&quot;;
}
if (!empty($consignee))
{
	$where .= &quot; AND o.consignee like '%$consignee%'&quot;;
}

switch($status)
{
	case CS_AWAIT_PAY :
		$where .= order_query_sql('await_pay','o.');
		break;

	case CS_AWAIT_SHIP :
		$where .= order_query_sql('await_ship','o.');
		break;

	case CS_FINISHED :
		$where .= order_query_sql('finished','o.');
		break;

	case PS_PAYING :
		if ($status != -1)
		{
			$where .= &quot; AND o.pay_status = '$status' &quot;;
		}
		break;

	default:
		if ($status != -1)
		{
			$where .= &quot; AND o.order_status = '$status' &quot;;
		}
}

$sql = &quot;SELECT o.*, ( o.goods_amount + o.tax + o.shipping_fee + o.insure_fee + o.pay_fee + o.pack_fee + o.card_fee ) AS total_fee, &quot;.
		&quot;ra.region_name AS country_name, &quot;.
		&quot;rb.region_name AS province_name, &quot;.
		&quot;rc.region_name AS city_name, &quot;.
		&quot;rd.region_name AS district_name &quot;.
		&quot;FROM &quot; .$GLOBALS['ecs']-&gt;table('order_info'). &quot; AS o &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS ra ON ra.region_id=o.country &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS rb ON rb.region_id=o.province &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS rc ON rc.region_id=o.city &quot;.
		&quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('region'). &quot; AS rd ON rd.region_id=o.district &quot;.
		&quot;WHERE 1 $where ORDER BY o.order_id DESC&quot;;

header(&quot;Content-type:application/vnd.ms-excel&quot;);
header(&quot;Accept-Ranges:bytes&quot;);
header(&quot;Content-Disposition:filename=&quot;.time().&quot;.xls&quot;);
header(&quot;Pragma: no-cache&quot;);

echo '
	&lt;html xmlns:o=&quot;urn:schemas-microsoft-com:office:office&quot;
	xmlns:x=&quot;urn:schemas-microsoft-com:office:excel&quot;
	xmlns=&quot;http://www.w3.org/TR/REC-html40&quot;&gt;
	&lt;head&gt;
	&lt;meta http-equiv=&quot;expires&quot; content=&quot;Mon, 06 Jan 1999 00:00:01 GMT&quot;&gt;
	&lt;meta http-equiv=Content-Type content=&quot;text/html; charset=gb2312&quot;&gt;
	&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
	&lt;x:ExcelWorkbook&gt;
	&lt;x:ExcelWorksheets&gt;
	&lt;x:ExcelWorksheet&gt;
	&lt;x:Name&gt;&lt;/x:Name&gt;
	&lt;x:WorksheetOptions&gt;
	&lt;x:DisplayGridlines/&gt;
	&lt;/x:WorksheetOptions&gt;
	&lt;/x:ExcelWorksheet&gt;
	&lt;/x:ExcelWorksheets&gt;
	&lt;/x:ExcelWorkbook&gt;
	&lt;/xml&gt;&lt;![endif]--&gt;
	&lt;/head&gt;
';

echo '&lt;table&gt;';
echo '&lt;tr&gt;';
echo '&lt;td&gt;'.gstr('订单号').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('下单时间').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('收货人').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('国家').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('省').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('市').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('区').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('地址').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('邮政编码').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('电话').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('手机').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('Email').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('总金额').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('应付金额').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('订单状态').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('付款状态').'&lt;/td&gt;';
echo '&lt;td&gt;'.gstr('发货状态').'&lt;/td&gt;';
echo '&lt;/tr&gt;';

$res = $GLOBALS['db']-&gt;query($sql);
while ($row = $GLOBALS['db']-&gt;fetchRow($res))
{
	echo '&lt;tr&gt;';
	echo &quot;&lt;td style='vnd.ms-excel.numberformat:@'&gt;$row[order_sn]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.date(&quot;Y-m-d H:i:s&quot;,$row['add_time']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['consignee']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['country_name']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['province_name']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['city_name']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['district_name']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['address']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[zipcode]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['tel']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['mobile']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($row['email']).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[total_fee]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;$row[order_amount]&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($_LANG['cs'][$row['order_status']]).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($_LANG['ps'][$row['pay_status']]).&quot;&lt;/td&gt;&quot;;
	echo &quot;&lt;td&gt;&quot;.gstr($_LANG['ss'][$row['shipping_status']]).&quot;&lt;/td&gt;&quot;;
	echo '&lt;/tr&gt;';
}

echo '&lt;/table&gt;';

function gstr($str)
{
	return iconv('UTF-8', 'GB2312', $str);
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsok.com/archives/28/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ECShop后台商品属性按分组显示功能</title>
		<link>http://www.cmsok.com/archives/6</link>
		<comments>http://www.cmsok.com/archives/6#comments</comments>
		<pubDate>Mon, 31 Oct 2011 04:28:08 +0000</pubDate>
		<dc:creator>307150302</dc:creator>
				<category><![CDATA[ECShop]]></category>

		<guid isPermaLink="false">http://www.cmsok.com/?p=6</guid>
		<description><![CDATA[录入商品属性的时候，如果碰到笔记本，手机等属性非常多的商品时。能按照分组显示属性可有效防止头晕。 修改后显示样式如下： 实现方法很简单，只需要修改两个函数就行。 打开文件：admin\includes\lib_goods.php 找到以下代码： 替换为： 查找以下代码： 替换为：]]></description>
			<content:encoded><![CDATA[<p>录入商品属性的时候，如果碰到笔记本，手机等属性非常多的商品时。能按照分组显示属性可有效防止头晕。</p>
<p>修改后显示样式如下：<br />
<a href="http://www.cmsok.com/wp-content/uploads/2011/10/1.gif"><img class="alignnone size-full wp-image-7" title="1" src="http://www.cmsok.com/wp-content/uploads/2011/10/1.gif" alt="" width="716" height="654" /></a></p>
<p>实现方法很简单，只需要修改两个函数就行。<br />
打开文件：admin\includes\lib_goods.php</p>
<p>找到以下代码：</p>
<pre class="brush: php; title: ; notranslate">
function get_attr_list($cat_id, $goods_id = 0)
{
    if (empty($cat_id))
    {
        return array();
    }
    // 查询属性值及商品的属性值
    $sql = &quot;SELECT a.attr_id, a.attr_name, a.attr_input_type, a.attr_type, a.attr_values, v.attr_value, v.attr_price &quot;.
            &quot;FROM &quot; .$GLOBALS['ecs']-&gt;table('attribute'). &quot; AS a &quot;.
            &quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&gt;table('goods_attr'). &quot; AS v &quot;.
            &quot;ON v.attr_id = a.attr_id AND v.goods_id = '$goods_id' &quot;.
            &quot;WHERE a.cat_id = &quot; . intval($cat_id) .&quot; OR a.cat_id = 0 &quot;.
            &quot;ORDER BY a.sort_order, a.attr_type, a.attr_id, v.attr_price, v.goods_attr_id&quot;;
    $row = $GLOBALS['db']-&gt;GetAll($sql);
    return $row;
}
</pre>
<p>替换为：</p>
<pre class="brush: php; title: ; notranslate">
function get_attr_list($cat_id, $goods_id = 0)
{
    if (empty($cat_id))
    {
        return array();
    }
    // 查询属性值及商品的属性值
    $sql = &quot;SELECT a.attr_id, a.attr_name, a.attr_input_type, a.attr_type, a.attr_values, v.attr_value, v.attr_price, a.attr_group &quot;.
            &quot;FROM &quot; .$GLOBALS['ecs']-&amp;gt;table('attribute'). &quot; AS a &quot;.
            &quot;LEFT JOIN &quot; .$GLOBALS['ecs']-&amp;gt;table('goods_attr'). &quot; AS v &quot;.
            &quot;ON v.attr_id = a.attr_id AND v.goods_id = '$goods_id' &quot;.
            &quot;WHERE a.cat_id = &quot; . intval($cat_id) .&quot; OR a.cat_id = 0 &quot;.
            &quot;ORDER BY a.sort_order, a.attr_type, a.attr_id, v.attr_price, v.goods_attr_id&quot;;
    $row = $GLOBALS['db']-&amp;gt;GetAll($sql);
    return $row;
}
</pre>
<p>查找以下代码：</p>
<pre class="brush: php; title: ; notranslate">
function build_attr_html($cat_id, $goods_id = 0)
{
$attr = get_attr_list($cat_id, $goods_id);
$html = '&lt;/pre&gt;
&lt;table id=&quot;attrTable&quot; width=&quot;100%&quot;&gt;'; $spec = 0; foreach ($attr AS $key =&amp;gt; $val) { $html .= &quot;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;label&quot;&gt;&quot;; if ($val['attr_type'] == 1 || $val['attr_type'] == 2) { $html .= ($spec != $val['attr_id']) ? &quot;&lt;a onclick=&quot;addSpec(this)&quot; href=&quot;javascript:;&quot;&gt;[+]&lt;/a&gt;&quot; : &quot;&lt;a onclick=&quot;removeSpec(this)&quot; href=&quot;javascript:;&quot;&gt;[-]&lt;/a&gt;&quot;; $spec = $val['attr_id']; } $html .= &quot;$val[attr_name]&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;hidden&quot; name=&quot;attr_id_list[]&quot; value=&quot;$val[attr_id]&quot; /&gt;&quot;; if ($val['attr_input_type'] == 0) { $html .= '&lt;input type=&quot;text&quot; name=&quot;attr_value_list[]&quot; value=&quot;' .htmlspecialchars($val['attr_value']). '&quot; size=&quot;40&quot; /&gt; '; } elseif ($val['attr_input_type'] == 2) { $html .= '&lt;textarea name=&quot;attr_value_list[]&quot; rows=&quot;3&quot; cols=&quot;40&quot;&gt;' .htmlspecialchars($val['attr_value']). '&lt;/textarea&gt;'; } else { $html .= '
&lt;select name=&quot;attr_value_list[]&quot;&gt;'; $html .= '&lt;option value=&quot;&quot;&gt;' .$GLOBALS['_LANG']['select_please']. '&lt;/option&gt;'; $attr_values = explode(&quot;\n&quot;, $val['attr_values']); foreach ($attr_values AS $opt) { $opt = trim(htmlspecialchars($opt)); $html .= ($val['attr_value'] != $opt) ? '&lt;option value=&quot;' . $opt . '&quot;&gt;' . $opt . '&lt;/option&gt;' : '&lt;option selected=&quot;selected&quot; value=&quot;' . $opt . '&quot;&gt;' . $opt . '&lt;/option&gt;'; } $html .= '&lt;/select&gt;'; } $html .= ($val['attr_type'] == 1 || $val['attr_type'] == 2) ? $GLOBALS['_LANG']['spec_price'].' &lt;input type=&quot;text&quot; name=&quot;attr_price_list[]&quot; value=&quot;' . $val['attr_price'] . '&quot; size=&quot;5&quot; maxlength=&quot;10&quot; /&gt;' : ' &lt;input type=&quot;hidden&quot; name=&quot;attr_price_list[]&quot; value=&quot;0&quot; /&gt;'; $html .= '&lt;/td&gt;
&lt;/tr&gt;
'; } $html .= '&lt;/tbody&gt;
&lt;/table&gt;
'; return $html;
}
</pre>
<p>替换为：</p>
<pre class="brush: php; title: ; notranslate">
function build_attr_html($cat_id, $goods_id = 0)
{
$attr = get_attr_list($cat_id, $goods_id);
$html = '&lt;/pre&gt;
&lt;table id=&quot;attrTable&quot; width=&quot;100%&quot;&gt;'; $spec = 0; $attr_groups = get_attr_groups($cat_id); if (count($attr_groups) &amp;gt; 1) { foreach ($attr as $value) { $attrs[$value['attr_group']][] = $value; } foreach ($attrs as $cid =&amp;gt; $attr) { $html .= &quot;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td class=&quot;label&quot; style=&quot;color: #f00; padding-top: 20px;&quot;&gt;&quot;.$attr_groups[$cid].&quot;&lt;/td&gt;
&lt;td&gt; &lt;/td&gt;
&lt;/tr&gt;
&quot;; foreach ($attr AS $key =&amp;gt; $val) { $html .= &quot;
&lt;tr&gt;
&lt;td class=&quot;label&quot;&gt;&quot;; if ($val['attr_type'] == 1 || $val['attr_type'] == 2) { $html .= ($spec != $val['attr_id']) ? &quot;&lt;a onclick=&quot;addSpec(this)&quot; href=&quot;javascript:;&quot;&gt;[+]&lt;/a&gt;&quot; : &quot;&lt;a onclick=&quot;removeSpec(this)&quot; href=&quot;javascript:;&quot;&gt;[-]&lt;/a&gt;&quot;; $spec = $val['attr_id']; } $html .= &quot;$val[attr_name]&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;hidden&quot; name=&quot;attr_id_list[]&quot; value=&quot;$val[attr_id]&quot; /&gt;&quot;; if ($val['attr_input_type'] == 0) { $html .= '&lt;input type=&quot;text&quot; name=&quot;attr_value_list[]&quot; value=&quot;' .htmlspecialchars($val['attr_value']). '&quot; size=&quot;40&quot; /&gt; '; } elseif ($val['attr_input_type'] == 2) { $html .= '&lt;textarea name=&quot;attr_value_list[]&quot; rows=&quot;3&quot; cols=&quot;40&quot;&gt;' .htmlspecialchars($val['attr_value']). '&lt;/textarea&gt;'; } else { $html .= '
&lt;select name=&quot;attr_value_list[]&quot;&gt;'; $html .= '&lt;option value=&quot;&quot;&gt;' .$GLOBALS['_LANG']['select_please']. '&lt;/option&gt;'; $attr_values = explode(&quot;\n&quot;, $val['attr_values']); foreach ($attr_values AS $opt) { $opt = trim(htmlspecialchars($opt)); $html .= ($val['attr_value'] != $opt) ? '&lt;option value=&quot;' . $opt . '&quot;&gt;' . $opt . '&lt;/option&gt;' : '&lt;option selected=&quot;selected&quot; value=&quot;' . $opt . '&quot;&gt;' . $opt . '&lt;/option&gt;'; } $html .= '&lt;/select&gt;'; } $html .= ($val['attr_type'] == 1 || $val['attr_type'] == 2) ? $GLOBALS['_LANG']['spec_price'].' &lt;input type=&quot;text&quot; name=&quot;attr_price_list[]&quot; value=&quot;' . $val['attr_price'] . '&quot; size=&quot;5&quot; maxlength=&quot;10&quot; /&gt;' : ' &lt;input type=&quot;hidden&quot; name=&quot;attr_price_list[]&quot; value=&quot;0&quot; /&gt;'; $html .= '&lt;/td&gt;
'; } } } else { foreach ($attr AS $key =&amp;gt; $val) { $html .= &quot;
&lt;td class=&quot;label&quot;&gt;&quot;; if ($val['attr_type'] == 1 || $val['attr_type'] == 2) { $html .= ($spec != $val['attr_id']) ? &quot;&lt;a onclick=&quot;addSpec(this)&quot; href=&quot;javascript:;&quot;&gt;[+]&lt;/a&gt;&quot; : &quot;&lt;a onclick=&quot;removeSpec(this)&quot; href=&quot;javascript:;&quot;&gt;[-]&lt;/a&gt;&quot;; $spec = $val['attr_id']; } $html .= &quot;$val[attr_name]&lt;/td&gt;
&lt;td&gt;&lt;input type=&quot;hidden&quot; name=&quot;attr_id_list[]&quot; value=&quot;$val[attr_id]&quot; /&gt;&quot;; if ($val['attr_input_type'] == 0) { $html .= '&lt;input type=&quot;text&quot; name=&quot;attr_value_list[]&quot; value=&quot;' .htmlspecialchars($val['attr_value']). '&quot; size=&quot;40&quot; /&gt; '; } elseif ($val['attr_input_type'] == 2) { $html .= '&lt;textarea name=&quot;attr_value_list[]&quot; rows=&quot;3&quot; cols=&quot;40&quot;&gt;' .htmlspecialchars($val['attr_value']). '&lt;/textarea&gt;'; } else { $html .= '
&lt;select name=&quot;attr_value_list[]&quot;&gt;'; $html .= '&lt;option value=&quot;&quot;&gt;' .$GLOBALS['_LANG']['select_please']. '&lt;/option&gt;'; $attr_values = explode(&quot;\n&quot;, $val['attr_values']); foreach ($attr_values AS $opt) { $opt = trim(htmlspecialchars($opt)); $html .= ($val['attr_value'] != $opt) ? '&lt;option value=&quot;' . $opt . '&quot;&gt;' . $opt . '&lt;/option&gt;' : '&lt;option selected=&quot;selected&quot; value=&quot;' . $opt . '&quot;&gt;' . $opt . '&lt;/option&gt;'; } $html .= '&lt;/select&gt;'; } $html .= ($val['attr_type'] == 1 || $val['attr_type'] == 2) ? $GLOBALS['_LANG']['spec_price'].' &lt;input type=&quot;text&quot; name=&quot;attr_price_list[]&quot; value=&quot;' . $val['attr_price'] . '&quot; size=&quot;5&quot; maxlength=&quot;10&quot; /&gt;' : ' &lt;input type=&quot;hidden&quot; name=&quot;attr_price_list[]&quot; value=&quot;0&quot; /&gt;'; $html .= '&lt;/td&gt;
'; } } $html .= '&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
'; return $html;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.cmsok.com/archives/6/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

