给ecshop后台增加管理功能页面
打开language\zh_cn\admin\commn.php
例如新菜单要加在报表统计下,添加如下代码:
$_LANG['report_profit'] = '利润统计报表';
$_LANG['report_logistics'] = '物流费用统计报表';
然后打开admin\includes\modules\inc_menu.php
为新菜单添加动作/链接
插入以下代码:
$modules['06_stats']['report_profit'] = 'report_profit.php?act=list';
$modules['06_stats']['report_logistics'] = 'report_logistics.php?act=list';
到这步后,清空缓存,后台左侧菜单列表中,就已经有了刚刚添加的菜单,如果不需要权限分配到这里就可以用了。
现在为新添加的菜单加入权限控制的功能
打开language\zh_cn\admin\priv_action.php
找到订单管理部分权限说明,在下面添加:
$_LANG['sale_order_report1'] = '查看利润统计报表';
$_LANG['sale_order_report2'] = '查看物流费用统计报表';
然后打开admin\includes\inc_priv.php
添加:
$purview['report_profit'] = 'sale_order_report1';
$purview['report_logistics'] = 'sale_order_report2';
最后,在数据库中添加权限记录:
在esc_admin_action表中插入新的一条记录
如下图这样
插入的代码参考:
INSERT INTO `ecshop`.`ecs_admin_action` (
`action_id` ,
`parent_id` ,
`action_code` ,
`relevance`
)
VALUES (
'136' , '6' , 'sale_order_report1' , ''
) ;
parent_id就是所属大菜单的ID,这里以订单管理举例就写6。action_id按照已有的id加一排下去。
到这里所有的工作已经结束了,如果没有生效的话可以再清理缓存刷新一下。
$modules['06_stats']['report_profit'] = 'report_profit.php?act=list';
$modules['06_stats']['report_logistics'] = 'report_logistics.php?act=list';
/* 物流费用统计 */
$_LANG['order_id'] = '序列';
$_LANG['logistics_name'] = '物流名称';
$_LANG['logistics_cost'] = '运费';
$_LANG['download_logistics'] = '下载运费明细报表';
$_LANG['all_logistics_cost'] = '总运费';
$_LANG['logistics_reingewinn'] = '物流利润';
/* 利润统计 */
$_LANG['profit_name'] = '利润';
$_LANG['suoshu_order_sn'] = '所属订单';
$_LANG['goods_kosten'] = '成本';
$_LANG['all_goods_kosten'] = '总成本';
$_LANG['all_goods_price'] = '总售价';
$_LANG['goods_reingewinn'] = '净利润';
$_LANG['download_profit'] = '下载利润统计报表';
/* 检查权限 */
check_authz_json('sale_order_report1');
/* 检查权限 */
check_authz_json('sale_order_report2');
$sql = 'SELECT og.goods_id, og.goods_sn, og.goods_name, og.goods_number AS goods_num, oi.shipping_fee '.
'AS logistics_price, oi.add_time AS sales_time, oi.order_id, oi.order_sn , oi.shipping_name '.
"FROM " . $GLOBALS['ecs']->table('order_goods')." AS og, ".$GLOBALS['ecs']->table('order_info')." AS oi ".
$where. " ORDER BY sales_time DESC, goods_num DESC";
<tr>
<th>{$lang.goods_name}</th>
<th>{$lang.order_sn}</th>
<th>{$lang.logistics_name}</th>
<th>{$lang.amount}</th>
<th>{$lang.logistics_cost}</th>
<th>{$lang.sell_date}</th>
</tr>
{foreach from=$goods_sales_list item=list}
<tr align="center">
<td align="left"><a href="../goods.php?id={$list.goods_id}" target="_blank">{$list.goods_name}</a></td>
<td><a href="order.php?act=info&order_id={$list.order_id}">{$list.order_sn}</a></td>
<td align="right">{$list.shipping_name}</td>
<td align="right">{$list.goods_num}</td>
<td align="right">{$list.logistics_price}</td>
<td>{$list.sales_time}</td>
</tr>
/* 文件标题 */
echo ecs_iconv(EC_CHARSET, 'GB2312', $_REQUEST['start_date']. $_LANG['to'] .$_REQUEST['end_date']. $_LANG['sales_list']) . "\t\n";
/* 序列,订单号,物流名称,数量,运费,销售日期 */
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_id']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['order_sn']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['logistics_name']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['amount']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['logistics_cost']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $_LANG['sell_date']) . "\t\n";
$i = 0;
foreach ($goods_sales_list['sale_list_data'] AS $key => $value)
{
$i++;
echo $i . "\t";
//echo ecs_iconv(EC_CHARSET, 'GB2312', $i . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', '[ ' . $value['order_sn'] . ' ]') . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['shipping_name']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['goods_num']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['logistics_price']) . "\t";
echo ecs_iconv(EC_CHARSET, 'GB2312', $value['sales_time']) . "\t";
echo "\n";
}
文章转载:http://www.gehut.cn/