Maison > php教程 > php手册 > ecshop给虚拟商品添加出售和未出售的导出xlc,ecshopxlc

ecshop给虚拟商品添加出售和未出售的导出xlc,ecshopxlc

WBOY
Libérer: 2016-06-13 09:08:34
original
1016 Les gens l'ont consulté

ecshop给虚拟商品添加出售和未出售的导出xlc,ecshopxlc

在admin/virtral_card.php文件中找到$_REQUEST['act'] == 'card'
这里是用来显示某一个虚拟商品的出售记录的列表将会发送到replenish_list.htm
在replenish_list.htm 文件中最定部分有个引入的文件叫pageheader.htm的文件这里是用于输出默认模版里的补“货按”钮
在virtral_card.php文件大约180行有

<span>$smarty</span>->assign('action_link',  <span>array</span>('text'    => <span>$_LANG</span>['replenish'],
                                            'href'  => 'virtual_card.php?act=replenish&goods_id='.<span>$_REQUEST</span>['goods_id']));
Copier après la connexion

按照ecshop的习惯,需要修改语言包文件(语言包文件名和对应的这个php文件名相同,只是在语言包目录下)

$_LANG['Notforsale'] = '未出售导出xls';
$_LANG['Hasforsale'] = '已出售导出xls';

在大约180行那句话下面添加如下(主要是修改一下act后的参数,用于到文件中来处理数据)
比较重要的是forsale=has和forsale=not这两个参数,将用来区别是要导出已经出售还是要导出未出售的

<span>$smarty</span>->assign('Notforsale',  <span>array</span>('text'    => <span>$_LANG</span>['Notforsale'],
                                            'href'  => 'virtual_card.php?act=forsale&forsale=not&goods_id='.<span>$_REQUEST</span>['goods_id'<span>]));
</span><span>$smarty</span>->assign('Hasforsale',  <span>array</span>('text'    => <span>$_LANG</span>['Hasforsale'],
                                            'href'  => 'virtual_card.php?act=forsale&forsale=has&goods_id='.<span>$_REQUEST</span>['goods_id']));
Copier après la connexion

具体代码如下:

<span>/*</span><span>------------------------------------------------------ </span><span>*/</span>
<span>//</span><span>-- 导出未出售或已出售的虚拟商品到xls</span><span>
/*</span><span>------------------------------------------------------ </span><span>*/</span>
<span>elseif</span> (<span>$_REQUEST</span>['act'] == 'forsale'<span>)
{
    </span><span>$forsale</span> = <span>empty</span>(<span>$_REQUEST</span>['forsale']) ? "" : <span>trim</span>(<span>$_REQUEST</span>['forsale'<span>]);
    </span><span>//</span><span>首先判断$forsale是否有值被传入</span>
   
    <span>if</span>(<span>$forsale</span> != ""<span>){
        </span><span>$fielname</span> = ""<span>;
        </span><span>$goods_id</span> = <span>empty</span>(<span>$_REQUEST</span>['goods_id']) ? 0 : <span>intval</span>(<span>$_REQUEST</span>['goods_id'<span>]);
        </span><span>//</span><span>has为已出售,not为未出售</span>
        <span>if</span>(<span>$forsale</span> == 'has'<span>){
            </span><span>$fielname</span> = "已出售商品"<span>;
            </span><span>$getCurrentGoodsListsql</span> = "SELECT card_id, goods_id, card_sn, card_password, end_date, is_saled, order_sn, crc32 FROM " . <span>$GLOBALS</span>['ecs']->table('virtual_card') . " WHERE goods_id = " . <span>$goods_id</span> . " and is_saled = 1"<span> ;
        }
        </span><span>else</span> <span>if</span>(<span>$forsale</span> == 'not'<span>){
            </span><span>$fielname</span> = "未出售商品"<span>;
            </span><span>$getCurrentGoodsListsql</span> = "SELECT card_id, goods_id, card_sn, card_password, end_date, is_saled, order_sn, crc32 FROM " . <span>$GLOBALS</span>['ecs']->table('virtual_card') . " WHERE goods_id = " . <span>$goods_id</span> . " and is_saled = 0"<span> ;
        }
        </span><span>$currentGoodsList</span> = <span>$GLOBALS</span>['db']->getAll(<span>$getCurrentGoodsListsql</span><span>);
        </span><span>$arr</span> = <span>array</span><span>();
        </span><span>foreach</span> (<span>$currentGoodsList</span> <span>AS</span> <span>$key</span> => <span>$row</span><span>)
        {
            </span><span>if</span> (<span>$row</span>['crc32'] == 0 || <span>$row</span>['crc32'] == <span>crc32</span><span>(AUTH_KEY))
            {
                </span><span>$row</span>['card_sn']       = decrypt(<span>$row</span>['card_sn'<span>]);
                </span><span>$row</span>['card_password'] = decrypt(<span>$row</span>['card_password'<span>]);
            }
            </span><span>elseif</span> (<span>$row</span>['crc32'] == <span>crc32</span><span>(OLD_AUTH_KEY))
            {
                </span><span>$row</span>['card_sn']       = decrypt(<span>$row</span>['card_sn'],<span> OLD_AUTH_KEY);
                </span><span>$row</span>['card_password'] = decrypt(<span>$row</span>['card_password'],<span> OLD_AUTH_KEY);
            }
            </span><span>else</span><span>
            {
                </span><span>$row</span>['card_sn']       = '***'<span>;
                </span><span>$row</span>['card_password'] = '***'<span>;
            }

            </span><span>$row</span>['end_date'] = <span>$row</span>['end_date'] == 0 ? '' : <span>date</span>(<span>$GLOBALS</span>['_CFG']['date_format'], <span>$row</span>['end_date'<span>]);

            </span><span>$arr</span>[] = <span>$row</span><span>;
        }
        </span><span>header</span>("Content-Type: application/vnd.ms-execl"); <span>//</span><span>定义文件的内容类型</span>
        <span>header</span>("Content-Disposition: attachment; filename={<span>$fielname</span>}.xls"<span>); 
        </span><span>header</span>("Pragma: no-cache");  <span>//</span><span>不缓存</span>
        <span>header</span>("Expires: 0");<span>//</span><span>将内容输出到第一个工作簿</span>
        <span>$data</span> = "数据库编号\t商品编号\t卡片序号\t卡片密码\t截止使用日期\t是否已经出售(1:已经出售0:未出售)\t订单号\t加密编码(客户无用,可删除)\t\n"<span>;
        </span><span>foreach</span>(<span>$arr</span> <span>as</span> <span>$key</span>=><span>$val</span><span>){
            </span><span>foreach</span> (<span>$val</span> <span>as</span> <span>$k</span> => <span>$v</span><span>) {
                </span><span>$data</span> .= <span>$v</span> . "\t"<span>;
            }
            </span><span>$data</span> .= "\n"<span>;
        }
        </span><span>echo</span> <span>iconv</span>("UTF-8","GB2312//IGNORE",<span>$data</span><span>);
        </span><span>//</span><span>echo "<pre class="brush:php;toolbar:false">";var_dump($data);echo "
Copier après la connexion
";exit(); } }

 

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Recommandations populaires
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal