ecshop は、仮想商品に販売済みおよび未販売のエクスポートを追加します。 製品販売記録のリストは、reply_list.htm に送信されます。
Refresh_list.htm ファイルの最後の部分には、pageheader.htm というインポート ファイルがあります。このファイルが使用されます。デフォルトのテンプレートで補充の「商品ボタン」を出力するには ボタン
virtual_card.php ファイルの約 180 行に、
<span style="color: #800080;">$smarty</span>->assign('action_link', <span style="color: #0000ff;">array</span>('text' => <span style="color: #800080;">$_LANG</span>['replenish'], 'href' => 'virtual_card.php?act=replenish&goods_id='.<span style="color: #800080;">$_REQUEST</span>['goods_id']));$_LANG['Notforsale'] = '非売品エクスポートxls';
$_LANG['Hasforsale'] = 'Sold export xls';
180 行目に関する文の下に次の行を追加します (主に、データの処理に使用される act 後のパラメーターを変更するため)ファイル内)
より重要なのは 2 つのパラメータ forsale=has と forsale=not で、販売済みか未販売かを区別するために使用されます
<span style="color: #800080;">$smarty</span>->assign('Notforsale', <span style="color: #0000ff;">array</span>('text' => <span style="color: #800080;">$_LANG</span>['Notforsale'], 'href' => 'virtual_card.php?act=forsale&forsale=not&goods_id='.<span style="color: #800080;">$_REQUEST</span>['goods_id'<span style="color: #000000;">]));</span><span style="color: #800080;">$smarty</span>->assign('Hasforsale', <span style="color: #0000ff;">array</span>('text' => <span style="color: #800080;">$_LANG</span>['Hasforsale'], 'href' => 'virtual_card.php?act=forsale&forsale=has&goods_id='.<span style="color: #800080;">$_REQUEST</span>['goods_id']));
<span style="color: #008000;">/*</span><span style="color: #008000;">------------------------------------------------------ </span><span style="color: #008000;">*/</span><span style="color: #008000;">//</span><span style="color: #008000;">-- 导出未出售或已出售的虚拟商品到xls</span><span style="color: #008000;">/*</span><span style="color: #008000;">------------------------------------------------------ </span><span style="color: #008000;">*/</span><span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$_REQUEST</span>['act'] == 'forsale'<span style="color: #000000;">){ </span><span style="color: #800080;">$forsale</span> = <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$_REQUEST</span>['forsale']) ? "" : <span style="color: #008080;">trim</span>(<span style="color: #800080;">$_REQUEST</span>['forsale'<span style="color: #000000;">]); </span><span style="color: #008000;">//</span><span style="color: #008000;">首先判断$forsale是否有值被传入</span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$forsale</span> != ""<span style="color: #000000;">){ </span><span style="color: #800080;">$fielname</span> = ""<span style="color: #000000;">; </span><span style="color: #800080;">$goods_id</span> = <span style="color: #0000ff;">empty</span>(<span style="color: #800080;">$_REQUEST</span>['goods_id']) ? 0 : <span style="color: #008080;">intval</span>(<span style="color: #800080;">$_REQUEST</span>['goods_id'<span style="color: #000000;">]); </span><span style="color: #008000;">//</span><span style="color: #008000;">has为已出售,not为未出售</span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$forsale</span> == 'has'<span style="color: #000000;">){ </span><span style="color: #800080;">$fielname</span> = "已出售商品"<span style="color: #000000;">; </span><span style="color: #800080;">$getCurrentGoodsListsql</span> = "SELECT card_id, goods_id, card_sn, card_password, end_date, is_saled, order_sn, crc32 FROM " . <span style="color: #800080;">$GLOBALS</span>['ecs']->table('virtual_card') . " WHERE goods_id = " . <span style="color: #800080;">$goods_id</span> . " and is_saled = 1"<span style="color: #000000;"> ; } </span><span style="color: #0000ff;">else</span> <span style="color: #0000ff;">if</span>(<span style="color: #800080;">$forsale</span> == 'not'<span style="color: #000000;">){ </span><span style="color: #800080;">$fielname</span> = "未出售商品"<span style="color: #000000;">; </span><span style="color: #800080;">$getCurrentGoodsListsql</span> = "SELECT card_id, goods_id, card_sn, card_password, end_date, is_saled, order_sn, crc32 FROM " . <span style="color: #800080;">$GLOBALS</span>['ecs']->table('virtual_card') . " WHERE goods_id = " . <span style="color: #800080;">$goods_id</span> . " and is_saled = 0"<span style="color: #000000;"> ; } </span><span style="color: #800080;">$currentGoodsList</span> = <span style="color: #800080;">$GLOBALS</span>['db']->getAll(<span style="color: #800080;">$getCurrentGoodsListsql</span><span style="color: #000000;">); </span><span style="color: #800080;">$arr</span> = <span style="color: #0000ff;">array</span><span style="color: #000000;">(); </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$currentGoodsList</span> <span style="color: #0000ff;">AS</span> <span style="color: #800080;">$key</span> => <span style="color: #800080;">$row</span><span style="color: #000000;">) { </span><span style="color: #0000ff;">if</span> (<span style="color: #800080;">$row</span>['crc32'] == 0 || <span style="color: #800080;">$row</span>['crc32'] == <span style="color: #008080;">crc32</span><span style="color: #000000;">(AUTH_KEY)) { </span><span style="color: #800080;">$row</span>['card_sn'] = decrypt(<span style="color: #800080;">$row</span>['card_sn'<span style="color: #000000;">]); </span><span style="color: #800080;">$row</span>['card_password'] = decrypt(<span style="color: #800080;">$row</span>['card_password'<span style="color: #000000;">]); } </span><span style="color: #0000ff;">elseif</span> (<span style="color: #800080;">$row</span>['crc32'] == <span style="color: #008080;">crc32</span><span style="color: #000000;">(OLD_AUTH_KEY)) { </span><span style="color: #800080;">$row</span>['card_sn'] = decrypt(<span style="color: #800080;">$row</span>['card_sn'],<span style="color: #000000;"> OLD_AUTH_KEY); </span><span style="color: #800080;">$row</span>['card_password'] = decrypt(<span style="color: #800080;">$row</span>['card_password'],<span style="color: #000000;"> OLD_AUTH_KEY); } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> { </span><span style="color: #800080;">$row</span>['card_sn'] = '***'<span style="color: #000000;">; </span><span style="color: #800080;">$row</span>['card_password'] = '***'<span style="color: #000000;">; } </span><span style="color: #800080;">$row</span>['end_date'] = <span style="color: #800080;">$row</span>['end_date'] == 0 ? '' : <span style="color: #008080;">date</span>(<span style="color: #800080;">$GLOBALS</span>['_CFG']['date_format'], <span style="color: #800080;">$row</span>['end_date'<span style="color: #000000;">]); </span><span style="color: #800080;">$arr</span>[] = <span style="color: #800080;">$row</span><span style="color: #000000;">; } </span><span style="color: #008080;">header</span>("Content-Type: application/vnd.ms-execl"); <span style="color: #008000;">//</span><span style="color: #008000;">定义文件的内容类型</span> <span style="color: #008080;">header</span>("Content-Disposition: attachment; filename={<span style="color: #800080;">$fielname</span>}.xls"<span style="color: #000000;">); </span><span style="color: #008080;">header</span>("Pragma: no-cache"); <span style="color: #008000;">//</span><span style="color: #008000;">不缓存</span> <span style="color: #008080;">header</span>("Expires: 0");<span style="color: #008000;">//</span><span style="color: #008000;">将内容输出到第一个工作簿</span> <span style="color: #800080;">$data</span> = "数据库编号\t商品编号\t卡片序号\t卡片密码\t截止使用日期\t是否已经出售(1:已经出售0:未出售)\t订单号\t加密编码(客户无用,可删除)\t\n"<span style="color: #000000;">; </span><span style="color: #0000ff;">foreach</span>(<span style="color: #800080;">$arr</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$key</span>=><span style="color: #800080;">$val</span><span style="color: #000000;">){ </span><span style="color: #0000ff;">foreach</span> (<span style="color: #800080;">$val</span> <span style="color: #0000ff;">as</span> <span style="color: #800080;">$k</span> => <span style="color: #800080;">$v</span><span style="color: #000000;">) { </span><span style="color: #800080;">$data</span> .= <span style="color: #800080;">$v</span> . "\t"<span style="color: #000000;">; } </span><span style="color: #800080;">$data</span> .= "\n"<span style="color: #000000;">; } </span><span style="color: #0000ff;">echo</span> <span style="color: #008080;">iconv</span>("UTF-8","GB2312//IGNORE",<span style="color: #800080;">$data</span><span style="color: #000000;">); </span><span style="color: #008000;">//</span><span style="color: #008000;">echo "<pre class="brush:php;toolbar:false">";var_dump($data);echo "";exit(); } }