Home > Backend Development > PHP Tutorial > ecshop adds sold and unsold export xlc to virtual goods, ecshopxlc_PHP tutorial

ecshop adds sold and unsold export xlc to virtual goods, ecshopxlc_PHP tutorial

WBOY
Release: 2016-07-13 09:58:57
Original
1160 people have browsed it

ecshop adds sold and unsold export xlc to virtual goods, ecshopxlc

Find $_REQUEST['act'] == 'card' in the admin/virtral_card.php file
Here is a list used to display the sales records of a certain virtual product, which will be sent to replenish_list.htm
In the final part of the replenish_list.htm file, there is an imported file called pageheader.htm. The file here is used The "Supply Button" button
in the output default template is found in approximately line 180 of the virtual_card.php file

<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']));
Copy after login

According to ecshop’s custom, you need to modify the language pack file (the name of the language pack file is the same as the corresponding php file name, just in the language pack directory)

$_LANG['Notforsale'] = 'Not sold export xls';
$_LANG['Hasforsale'] = 'Sold export xls';

Add the following below the sentence about line 180 (mainly to modify the parameters after act, which are used to process data in the file)
The more important ones are the two parameters forsale=has and forsale=not , will be used to distinguish whether to export sold or unsold

<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']));
Copy after login

The specific code is as follows:

<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 "
";exit(); } }
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/976450.htmlTechArticleecshop adds sold and unsold export xlc to virtual goods, ecshopxlc is found in the admin/virtral_card.php file $ _REQUEST['act'] == 'card' This is used to display a certain virtual product...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template