功能:

点击页面右边的两个按钮,切换下面的<div class="form-div">和表格里的内容

思路:

  1. 控制器里把$action_link 和 $action_link2赋值到模板里(变量里带连接和标题名字)
  2. 控制器里把$filter.sn_type的值(1或者2) 赋值到模板里
  3. 模板里判断$filter.sn_type eq 1还是$filter.sn_type eq 2 来切换显示的内容

效果:

pageheader_list.htm里

D:\phpStudy\WWW\work\wdm\trunk\www.wdmcake.cn\www\admin\templates\pageheader_list.htm

{/if}
<h1>
{if $action_link}
<span class="action-span"><a href="{$action_link.href}">{$action_link.text}</a></span>
{/if}
{if $action_link2}
<span class="action-span"><a href="{$action_link2.href}">{$action_link2.text}</a>&nbsp;&nbsp;</span>
{/if}
<span class="action-span1"><a href="index.php?act=main">{$lang.cp_home}</a> </span><span id="search_id" class="action-span1">{if $ur_here} - {$ur_here} {/if}</span>
<div style="clear:both"></div>
</h1>

product_sn_list.htm模板里

D:\phpStudy\WWW\work\wdm\trunk\www.wdmcake.cn\www\admin\templates\product_sn_list.htm

{include file="pageheader_list.htm"} <!--  引入头模板 -->

{if $filter.sn_type eq 1}
<div class="form-div">
<form action="javascript:searchproduct();" name="addForm" id="addForm">
<!-- 分类 -->
选择城市
<select name="city" id="city" onchange="get_city();">
<option value="-1">所在城市</option>
{html_options options=$goods_city}
</select>
<select name="sn_gid" id="sn_gid" onchange="get_products();" style="width:135px;">
<option value="0">请选择商品</option>
{foreach from=$goods_list item=goods}
<option value="{$goods.goods_id}">{$goods.goods_sn} {$goods.goods_name}</option>
{/foreach}
</select>
<!-- 商品:<input type="text" name="sn_name" value="" size="12" /> --> <select name="sn_pid" id="sn_pid">
<option value="0">请选择规格</option>
{foreach from=$products item=product}
<option value="{$product.product_id}">{$product.product_name}</option>
{/foreach}
</select> <select name="sn_pizi" id="sn_pizi">
<option value="0">请选择坯子</option>
{foreach from=$pizi_list item=pizi}
<option value="{$pizi.title}">{$pizi.title}</option>
{/foreach}
</select> <!-- sn_type --><input type="hidden" name="sn_type" id="sn_type" value="1" size="15" />
<!-- 半成品品号 --><input type="hidden" name="semi_sn" value="" size="5" />
<!-- 半成品品名 --><input type="hidden" name="sn_name" value="" size="5" />
成品品号<input type="text" name="sn_sn" value="" size="15" />
<!-- 新货品 --><input type="hidden" name="sn_newsn" value="" size="5" />
货品价格<input type="text" name="sn_price" value="" size="5" />
<input type="button" value="添加成品" class="button" onclick="add_sn();" />
<input type="submit" value="搜索" class="button"/>
</form>
<!-- 批量导入对应关系 -->
<!-- <form action="product_sn.php?act=batchAddGoods_relate" method="post" enctype="multipart/form-data" name="excel" target="_blank">
<input type="file" name="file" value="">
<input type="submit" value="Excel导入批量导入对应关系" class="button" />
</form> -->
<!-- 批量导入对应关系 -->
</div>
<!-- 添加货品 -->
{/if}
{if $filter.sn_type eq 2}
<div class="form-div">
<form action="javascript:searchproduct();" name="addForm" id="addForm">
<!-- 分类 -->
选择城市<select name="city" id="city" onchange="get_city();">
<option value="-1">所在城市</option>
{html_options options=$goods_city}
</select>
<select name="sn_gid" id="sn_gid" onchange="get_products();" style="width:135px;">
<option value="0">请选择商品</option>
{foreach from=$goods_list item=goods}
<option value="{$goods.goods_id}">{$goods.goods_sn} {$goods.goods_name}</option>
{/foreach}
</select> <select name="sn_pid" id="sn_pid">
<option value="0">请选择规格</option>
{foreach from=$products item=product}
<option value="{$product.product_id}">{$product.product_name}</option>
{/foreach}
</select> <select name="sn_pizi" id="sn_pizi">
<option value="0">请选择坯子</option>
{foreach from=$pizi_list item=pizi}
<option value="{$pizi.title}">{$pizi.title}</option>
{/foreach}
</select>
<!-- sn_type --><input type="hidden" name="sn_type" id="sn_type" value="2" size="15" />
<!-- 半成品品号 --><input type="hidden" name="semi_sn" id="semi_sn" value="" size="15" />
半成品品名<input type="text" name="sn_name" id="sn_name" value="" size="15" />
半成品品号<input type="text" name="sn_sn" id="sn_sn" value="" size="15" />
<!-- 新货品 --><input type="hidden" name="sn_newsn" value="" size="5" />
<!-- 货品价格 --><input type="hidden" name="sn_price" value="" size="5" />
<input type="button" value="添加半成品" class="button" id="add_semi_sn" />
<input type="submit" value="搜索" class="button"/>
</form>
<form action="product_sn.php?act=batchAddGoodsSemi_sn" method="post" enctype="multipart/form-data" name="excel" target="_blank">
<input type="file" name="file" value="">
<input type="submit" value="Excel导入批量新建半成品" class="button" />
<span>
<a href="http://www.wdmcake.cn/data/demo_batchAddGoodsSemi_sn.xlsx" alt="" target="">导入模板下载</a>
</span>
</form> </div>
<!-- 添加货品 -->
{/if} {/if}
<div class="list-div" style="margin-bottom: 5px; margin-top: 10px;" id="listDiv">
<form method="post" action="goods.php" name="listForm" id="listForm" > {if $filter.sn_type eq 1}
<table width="100%" cellpadding="3" cellspacing="1" id="table_list">
<tr>
<td class="label_2" style="width: 5%">ID</td>
<td class="label_2" style="width: 20%">产品名</td>
<td class="label_2" style="width: 10%">规格</td>
<td class="label_2" style="width: 10%">坯子</td>
<td class="label_2" style="width: 8%">品号</td>
<td class="label_2" style="width: 150px;" id="newgoodsn">关联半成品</td>
<td class="label_2" style="width: 5%">品号价格</td>
<td class="label_2" style="width: 5%">{$lang.handler}</td>
</tr> {foreach from=$product_list item=sn}
<tr>
<td class="td_1">{$sn.id}</td>
<td class="td_1">{$sn.goods_name} {$sn.goods_sn}</td>
<td class="td_1">{$sn.product_name} </td>
<td class="td_1">{$sn.pizi}</td>
<td class="td_1"><span onclick="listTable.edit(this, 'edit_sn', {$sn.id})">{$sn.sn}</span></td>
<!-- <td class="td_1"><span onclick="listTable.edit(this, 'edit_newsn', {$sn.id})">{$sn.newsn|default:点击修改}</span></td> --> <td class="td_1 add_semi_sn">
<div class="select2div"></div>
<select class="js-example-basic-multiple add_semi_sn_relate" name="sn_type[]" sn_id="{$sn.id}" multiple="multiple">
{foreach from=$semi_sninfo item=v}
<option value="{$v.sn}" {if in_array($v.sn,$sn['semi_sn_arr'])}selected="selected"{/if} >{$v.sn_name}</option>
{/foreach}
<!-- <option value="111" >111</option>
<option value="222" >2222</option>
<option value="333" >333</option> --> </select>
</td> <td class="td_1"><span onclick="listTable.edit(this, 'edit_sn_price', {$sn.id})">{$sn.sn_price}</span></td>
<td align="center">
<span> <a href="javascript:;" onclick="listTable.remove({$sn.id}, '删除品号?', 'remove')" title="{$lang.remove}"><img src="images/icon_drop.gif" border="0" height="16" width="16"></a>
</span>
</td>
</tr>
{/foreach}
<tr>&nbsp;
<td align="right" nowrap="true" colspan="8">{include file="page.htm"}</td>
</tr>
</table>
{/if}
{if $filter.sn_type eq 2}
<table width="100%" cellpadding="3" cellspacing="1" id="table_list">
<tr>
<td class="label_2">ID</td>
<td class="label_2">半成品品名</td>
<td class="label_2">半成品品号sn</td>
<td class="label_2">商品号goods_sn</td>
<td class="label_2">{$lang.handler}</td>
</tr> {foreach from=$product_list item=sn}
<tr>
<td class="td_1">{$sn.id}</td>
<td class="td_1">{$sn.goods_name}</td>
<td class="td_1"><span onclick="listTable.edit(this, 'edit_sn', {$sn.id})">{$sn.sn}</span></td>
<td class="td_1">{$sn.goods_sn}</td>
<!-- <td class="td_1"><span onclick="listTable.edit(this, 'edit_newsn', {$sn.id})">{$sn.newsn|default:点击修改}</span></td> --> <!-- <td class="td_1"><span onclick="listTable.edit(this, 'edit_sn_price', {$sn.id})">{$sn.sn_price}</span></td> -->
<td align="center">
<span> <a href="javascript:;" onclick="listTable.remove({$sn.id}, '删除品号?', 'remove')" title="{$lang.remove}"><img src="images/icon_drop.gif" border="0" height="16" width="16"></a>
</span>
</td>
</tr>
{/foreach}
<tr>&nbsp;
<td align="right" nowrap="true" colspan="8">{include file="page.htm"}</td>
</tr>
</table>
{/if} </form>
{if $full_page}
{include file="pagefooter.htm"}
{/if}
</div>
<!-- end 添加货品 -->

控制器里

D:\phpStudy\WWW\work\wdm\trunk\www.wdmcake.cn\www\admin\product_sn.php

/* 取商品的货品 */
$product = product_sn_list(); $smarty->assign('ur_here', $product['filter']['sn_type']==1?'成品品号列表':'半成品品号列表');
$smarty->assign('action_link2', array('href' => 'product_sn.php?act=list&sn_type=1', 'text' =>'成品品号列表'));
$smarty->assign('action_link', array('href' => 'product_sn.php?act=list&sn_type=2', 'text' => '半成品品号列表')); $smarty->assign('product_list', $product['list']);
$smarty->assign('goods_id', $goods_id);
$smarty->assign('filter', $product['filter']);
$smarty->assign('full_page', 1);
$smarty->assign('record_count', $product['record_count']);
$smarty->assign('page_count', $product['page_count']); /**
* 获取货号列表信息
*
* @access public
* @param
*
* @return void
*/
function product_sn_list()
{
$result = get_filter();
wdmlog('第'.__LINE__.'行','product_sn','product_sn_list');
wdmlog($result,'product_sn','product_sn_list');
if ($result === false)
{
/* 过滤信息 */
$filter['gid'] = isset($_REQUEST['gid']) ? intval($_REQUEST['gid']) : 0;
$filter['sort_by'] = empty($_REQUEST['sort_by']) ? 'id' : trim($_REQUEST['sort_by']);
$filter['sort_order'] = empty($_REQUEST['sort_order']) ? 'DESC' : trim($_REQUEST['sort_order']);
$filter['pizi'] = isset($_REQUEST['pizi']) ? intval($_REQUEST['pizi']) : 0;
$filter['sn'] = empty($_REQUEST['sn']) ? '' : trim($_REQUEST['sn']);
$filter['newsn'] = empty($_REQUEST['newsn']) ? '' : trim($_REQUEST['newsn']);
$filter['sn_price'] = empty($_REQUEST['sn_price']) ? '0' : trim($_REQUEST['sn_price']);
$filter['sn_name'] = empty($_REQUEST['sn_name']) ? '' : trim($_REQUEST['sn_name']);
$filter['goods_city'] = isset($_REQUEST['goods_city']) ? intval($_REQUEST['goods_city']) : -1; $filter['sn_type'] = isset($_REQUEST['sn_type']) ? intval($_REQUEST['sn_type']) : 1; $where = ''; if ($filter['gid'])
{
$where .= " AND s.goods_id ='" . $filter['gid'] . "'";
}
if ($filter['pizi'])
{
$where .= " AND s.pizi ='" . $filter['pizi'] . "'";
}
if ($filter['sn'])
{
$where .= " AND s.sn ='" . $filter['sn'] . "'";
}
if ($filter['newsn'])
{
$where .= " AND s.newsn ='" . $filter['newsn'] . "'";
}
if ($filter['sn_price'])
{
$where .= " AND s.sn_price ='" . $filter['sn_price'] . "'";
}
if ($filter['sn_name'])
{
$where .= " AND g.goods_name like '%" . $filter['sn_name'] . "%'";
}
if ($filter['goods_city'] != -1)
{
$where .= " AND g.goods_city ='" . $filter['goods_city'] . "'";
} if(isset($_SESSION['city_id']) && $_SESSION['city_id'] >0 )
{
$where .= " AND g.goods_city='$_SESSION[city_id]'";
} if ($filter['sn_type'])
{
$where .= " AND s.sn_type ='" . $filter['sn_type'] . "'";
} /* 分页大小 */
$filter['page'] = empty($_REQUEST['page']) || (intval($_REQUEST['page']) <= 0) ? 1 : intval($_REQUEST['page']); if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0)
{
$filter['page_size'] = intval($_REQUEST['page_size']);
}
elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0)
{
$filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']);
}
else
{
$filter['page_size'] = 15;
} /* 记录总数 */
$sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('product_sn') . " AS s left join " . $GLOBALS['ecs']->table('goods') . " as g on g.goods_id =s.goods_id left join " . $GLOBALS['ecs']->table('products') . " as p on p.product_id =s.product_id where 1 $where ";
$filter['record_count'] = $GLOBALS['db']->getOne($sql);
$filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1; /* 查询 */
$sql = "SELECT s.*, g.goods_name, g.goods_sn, p.product_sn, p.product_name FROM " . $GLOBALS['ecs']->table('product_sn') . " AS s left join " . $GLOBALS['ecs']->table('goods') . " as g on g.goods_id =s.goods_id left join " . $GLOBALS['ecs']->table('products') . " as p on p.product_id =s.product_id where 1 $where ORDER BY $filter[sort_by] $filter[sort_order] LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",$filter[page_size]"; set_filter($filter, $sql);
}
else
{
$sql = $result['sql'];
$filter = $result['filter'];
}
$rows = $GLOBALS['db']->getAll($sql); foreach($rows as $k=>$v){
$rows[$k]['semi_sn_arr'] = array();
if(!empty($v['semi_sn'])){
$rows[$k]['semi_sn_arr'] = explode(',',$v['semi_sn']);
} }
wdmlog('第'.__LINE__.'行','product_sn','rows');
wdmlog($rows,'product_sn','rows'); $list = array('list' => $rows, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']);
return $list;
}

Ecshop里添加多个h1标题的更多相关文章

  1. ecshop后台添加栏目

    ecshop后台增加模块菜单详细教程 一:ecshop后台管理 admin\includes\inc_menu.php 添加上你要添加的功能admin\includes\inc_priv.php 对应 ...

  2. ECShop 文章添加缩略图功能

    为 ECShop 文章添加缩略图     ECShop 文章不包含缩略图比较遗憾,不过它的文章里包含一个附件上传,而且一般不会用到,这样,我们就可以改动一下,让它成为缩略图. 首先在 includes ...

  3. visual studio 2019工具里添加开发中命令提示符的方法

    最新新装了visual studio 2019,发现默认的没有开发者命令提示符 现将添加步骤描述如下: 从VS2019菜单选择"Tools",然后选择"外部工具" ...

  4. 在Qt Creator 和在 vs2012 里添加信号和槽

    原文地址:http://www.cnblogs.com/li-peng/p/3644812.html 作者:李鹏 出处:http://www.cnblogs.com/li-peng/ 本文版权归作者和 ...

  5. chart.js 里添加图表的清单:

    chart.js 里添加图表的清单: var legend = myDoughnut.generateLegend(); $("#chart_legend").html(legen ...

  6. RCP:利用actionSet在菜单(menu)里添加内容

    eclipse的菜单menu.工具栏toolbar乃至视图的上下文菜单contextmenu都是使用Action或Command实现的. Action即是 org.eclipse.jface.acti ...

  7. ios 向工程里添加Fonts

    ios 向工程里添加Fonts 1.网上搜索字体文件(后缀名为.ttf,或.odf),假如你加入的字体为微软雅黑 2.把字体库导入到工程的resouce中 3.然后在你的工程的Info.plist文件 ...

  8. iOS 向模拟器里添加照片

    iOS 向模拟器里添加照片 模拟器里Photos最开始时是没有照片的,有时我们做Demo时需要Photos里面的照片做测试,这时就需要把Mac上的照片导入到模拟器里.步骤如下: 1,打开模拟器 2,选 ...

  9. iOS 在类别里添加成员变量的方法:objc_setAssociatedObject

    今天在github上查看MJPopupViewController这个项目,发现里面用到了objc_setAssociatedObject,用来为类别添加成员变量. 我百度之后,发现有人是这样说明的: ...

随机推荐

  1. RAID磁盘分区的创建

    RAID(Reduntant Arrays of Independent Disks),即独立冗余磁盘阵列. RAID的级别: Raid 0: 条带 Raid 1: 镜像 Raid 2,3,4,5 等 ...

  2. MapReduce 二次排序

    默认情况下,Map 输出的结果会对 Key 进行默认的排序,但是有时候需要对 Key 排序的同时再对 Value 进行排序,这时候就要用到二次排序了.下面让我们来介绍一下什么是二次排序. 二次排序原理 ...

  3. boot and loader

    boot and loader boot 程序的所有作用 清屏 将光标移到屏幕左上角 显示 Start Boot 提示信息 加载 loader 程序的代码到 0x10000 物理内存地址 将CPU的段 ...

  4. SpringBoot | 第零章:前言

    缘起 前段时间公司领导叫编写一两课关于springboot的基础知识培训课程,说实话,也是今年年初才开始接触了SpringBoot这个脚手架,使用了之后才发现打开了一个新世界.再之后也没有一些系统的学 ...

  5. AnyCAD在医疗中的应用

    void addPoint(List<float> buffer, Vector3 pt) { buffer.Add((float)pt.X); buffer.Add((float)pt. ...

  6. GitHub上易于高效开发的Android开源项目TOP20--适合新手

    1. android-async-http android-async-http是Android上的一个异步.基于回调的HTTP客户端开发包,建立在Apache的HttpClient库上. 2. an ...

  7. Google pieCharts的学习

    在公司项目开发过程中, 尤其是在网站的开发过程中,用到很多的前端的插件,在这里, 我简单介绍下近期Google pieCharts的是使用方法 https://developers.google.co ...

  8. Cocos2d-x v3.1 GUI系统--环境构建(七)

    Cocos2d-x v3.1 GUI系统--环境构建(七) 在使用Cocos2d-x的GUI系统时,由于生成的工程默认是没有将GUI系统所需的库导入到项目的,所以我们必须把库导入到工程中并对工程做一些 ...

  9. hihoCoder #1044 : 状态压缩·一 (清垃圾)

    题意: 某车厢有一列座位,共有n个位置,清洁工要在这n个位置上清垃圾,但是不能全部位置都清理,只能选择部分.选择的规则是,连续的m个位置内,不能够清理超过q个,也就是说从第1~m个位置最多可以清q个, ...

  10. HDU3954 线段树(区间更新 + 点更新)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3954 , 一道比较好的线段树题,值得做. 题目是NotOnlySuccess大神出的,借此题来膜拜一下 ...