ecshop库存报警插件程序
2009-12-29 17:53 来源:www.chinab4c.com 作者:admin
1:alter table ecs_goods add column base_number int(1) default 0;
2:admin/goods.php的insert中。增加基础库存
$sql = "INSERT INTO " . $ecs->table('goods') . " (goods_name, goods_name_style, goods_sn, " .
"cat_id, brand_id, shop_price, market_price, is_promote, promote_price, " .
"promote_start_date, promote_end_date, goods_img,cat_img, goods_thumb, original_img, keywords, goods_brief, " .
"seller_note, goods_weight, goods_number, warn_number, integral, give_integral, is_best, is_new, is_hot, " .
"is_on_sale, is_alone_sale, goods_desc, add_time, last_update, goods_type, rank_integral,base_number)" .
"VALUES ('$_POST[goods_name]', '$goods_name_style', '$goods_sn', '$catgory_id', " .
"'$brand_id', '$shop_price', '$market_price', '$is_promote','$promote_price', ".
"'$promote_start_date', '$promote_end_date', '$goods_img','$cat_img', '$goods_thumb', '$original_img', ".
"'$_POST[keywords]', '$_POST[goods_brief]', '$_POST[seller_note]', '$goods_weight', '$goods_number',".
" '$warn_number', '$_POST[integral]', '$give_integral', '$is_best', '$is_new', '$is_hot', '$is_on_sale', '$is_alone_sale', ".
" '$_POST[goods_desc]', '" . gmtime() . "', '". gmtime() ."', '$goods_type', '$rank_integral','$goods_number')";
3:admin/includes/lib_goods.php中增加一点东西,检索base_number
$sql = "SELECT goods_id, goods_name, goods_sn, shop_price, is_on_sale, is_best, warn_number, base_number, is_new, is_hot, sort_order, goods_number, integral, " .
" (promote_price > 0 AND promote_start_date <= '$today' AND promote_end_date >= '$today') AS is_promote ".
" FROM " . $GLOBALS['ecs']->table('goods') . " AS g WHERE is_delete='$is_delete' $where" .
" ORDER BY $filter[sort_by] $filter[sort_order] ".
" LIMIT " . $filter['start'] . ",$filter[page_size]";
4:列表商品中,做以下处理
foreach($goods_list[goods] as $k => $v){
$sql = "select sum(og.goods_number) gn from ".$ecs->table('order_goods')." og , ".$ecs->table('order_info')." o where o.order_id = og.order_id and og.goods_id = $v[goods_id] and o.order_status = 1 and o.shipping_status <>1";//这里统计要发货的商品总数
$goods_list[goods][$k][ogc] = $db -> getOne($sql);//统计要发货的结果
if($goods_list[goods][$k][goods_number] < $goods_list[goods][$k][ogc]){//如果要发货数量大大于库存。表示缺少无误
$goods_list[goods][$k][quehuo] = $goods_list[goods][$k][ogc]-$goods_list[goods][$k][goods_number] ;//计算该商品缺少货数量
}else{
$goods_list[goods][$k][quehuo] = 0;//不缺货
}
$goods_list[goods][$k][bu] = $goods_list[goods][$k][quehuo] + $goods_list[goods][$k][base_number];//该补货的数量
}
5:admin/templates/goods_list.htm
<table cellpadding="3" cellspacing="1">
<tr>
<th>
<input onclick='listTable.selectAll(this, "checkboxes")' type="checkbox" />
<a href="javascript:listTable.sort('goods_id'); ">{$lang.record_id}</a>{$sort_goods_id}
</th>
<th><a href="javascript:listTable.sort('goods_name'); ">{$lang.goods_name}</a>{$sort_goods_name}</th>
<th><a href="javascript:listTable.sort('goods_sn'); ">{$lang.goods_sn}</a>{$sort_goods_sn}</th>
<th><a href="javascript:listTable.sort('shop_price'); ">{$lang.shop_price}</a>{$sort_shop_price}</th>
<th><a href="javascript:listTable.sort('is_on_sale'); ">{$lang.is_on_sale}</a>{$sort_is_on_sale}</th>
<th><a href="javascript:listTable.sort('is_best'); ">{$lang.is_best}</a>{$sort_is_best}</th>
<th><a href="javascript:listTable.sort('is_new'); ">{$lang.is_new}</a>{$sort_is_new}</th>
<th><a href="javascript:listTable.sort('is_hot'); ">{$lang.is_hot}</a>{$sort_is_hot}</th>
<th><a href="javascript:listTable.sort('sort_order'); ">{$lang.sort_order}</a>{$sort_sort_order}</th>
<th>安全库存</th>
<th>基础库存</th>
<th>该补货量</th>
<th>确认但未发货量</th>
<th>缺货量</th>
{if $use_storage}
<th><a href="javascript:listTable.sort('goods_number'); ">{$lang.goods_number}</a>{$sort_goods_number}</th>
{/if}
<th>{$lang.handler}</th>
<tr >
{foreach from=$goods_list item=goods}
<!--如果缺货,显示整行红色。如果库存等于警告库存,那么正行显示黄色-->
<tr {if $goods.quehuo gt "0"}style="color:#FF0000;"{elseif $goods.warn_number == $goods.goods_number}style="color:#b7a72c;"{else} {/if}>
<td style="background:{$color}"> <input type="checkbox" name="checkboxes[]" value="{$goods.goods_id}" />{$goods.goods_id}</td>
<td class="first-cell" style="background:{$color};{if $goods.is_promote}color:red;{/if}"><span onclick="listTable.edit(this, 'edit_goods_name', {$goods.goods_id})">{$goods.goods_name|escape:html}</span></td>
<td style="background:{$color}"><span onclick="listTable.edit(this, 'edit_goods_sn', {$goods.goods_id})">{$goods.goods_sn}</span></td>
<td style="background:{$color}" align="right"><span onclick="listTable.edit(this, 'edit_goods_price', {$goods.goods_id})">{$goods.shop_price}</span></td>
<td style="background:{$color}" align="center"><img src="images/{if $goods.is_on_sale}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_on_sale', {$goods.goods_id})" /></td>
<td style="background:{$color}" align="center"><img src="images/{if $goods.is_best}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_best', {$goods.goods_id})" /></td>
<td style="background:{$color}" align="center"><img src="images/{if $goods.is_new}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_new', {$goods.goods_id})" /></td>
<td style="background:{$color}" align="center"><img src="images/{if $goods.is_hot}yes{else}no{/if}.gif" onclick="listTable.toggle(this, 'toggle_hot', {$goods.goods_id})" /></td>
<td style="background:{$color}" align="center"><span onclick="listTable.edit(this, 'edit_sort_order', {$goods.goods_id})">{$goods.sort_order}</span></td>
<td style="background:{$color}" align="center"><span onclick="listTable.edit(this, 'edit_warn_number', {$goods.goods_id})">
{if $goods.warn_number == $goods.goods_number}{$goods.warn_number}{else}{$goods.warn_number}{/if}
</span></td>
<td style="background:{$color}" align="center"><span onclick="listTable.edit(this, 'edit_base_number', {$goods.goods_id})">{$goods.base_number}</span></td>
<td style="background:{$color}" align="center">{if $goods.quehuo>0}{$goods.bu}{else}0{/if}</td>
<td style="background:{$color}" align="center">{if $goods.ogc}{$goods.ogc}{else}0{/if}</td>
<td style="background:{$color}" align="center">{if $goods.quehuo > 0}{$goods.quehuo}{else}0{/if}</td>
{if $use_storage}
<td style="background:{$color}" align="right">{if $code eq 'virtual_card'}{$goods.goods_number}{else}<span onclick="listTable.edit(this, 'edit_goods_number', {$goods.goods_id})">{$goods.goods_number}</span>{/if}</td>
{/if}
<td style="background:{$color}" align="center">
<a href="../goods.php?id={$goods.goods_id}" target="_blank" title="{$lang.view}"><img src="images/icon_view.gif" width="16" height="16" border="0" /></a>
<a href="goods.php?act=edit&goods_id={$goods.goods_id}{if $code neq 'real_goods'}&extension_code={$code}{/if}" title="{$lang.edit}"><img src="images/icon_edit.gif" width="16" height="16" border="0" /></a>
<a href="goods.php?act=copy&goods_id={$goods.goods_id}{if $code neq 'real_goods'}&extension_code={$code}{/if}" title="{$lang.copy}"><img src="images/icon_copy.gif" width="16" height="16" border="0" /></a>
<a href="javascript:;" onclick="listTable.remove({$goods.goods_id}, '{$lang.trash_goods_confirm}')" title="{$lang.trash}"><img src="images/icon_trash.gif" width="16" height="16" border="0" /></a>
{if $add_handler}
|
{foreach from=$add_handler item=handler}
<a href="{$handler.url}&goods_id={$goods.goods_id}" title="{$handler.title}"><img src="images/{$handler.img}" width="16" height="16" border="0" /></a>
{/foreach}
{/if}
</td>
</tr>
{foreachelse}
<tr><td class="no-records" colspan="10">{$lang.no_records}</td></tr>
{/foreach}
</table>
最近更新
常用插件
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...