ecshop給虛擬商品平添出售和未出售的匯出xlc

來源:互聯網
上載者:User
ecshop給虛擬商品添加出售和未出售的匯出xlc

在admin/virtral_card.php檔案中找到$_REQUEST['act'] == 'card'
這裡是用來顯示某一個虛擬商品的出售記錄的列表將會發送到replenish_list.htm
在replenish_list.htm 檔案中最定部分有個引入的檔案叫pageheader.htm的檔案這裡是用於輸出預設模版裡的補“貨按”鈕
在virtral_card.php檔案大約180行有

$smarty->assign('action_link',  array('text'    => $_LANG['replenish'],                                            'href'  => 'virtual_card.php?act=replenish&goods_id='.$_REQUEST['goods_id']));

按照ecshop的習慣,需要修改語言套件檔案(語言套件檔案名稱和對應的這個php檔案名稱相同,只是在語言套件目錄下)

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

在大約180行那句話下面添加如下(主要是修改一下act後的參數,用於到檔案中來處理資料)
比較重要的是forsale=has和forsale=not這兩個參數,將用來區別是要匯出已經出售還是要匯出未出售的

$smarty->assign('Notforsale',  array('text'    => $_LANG['Notforsale'],                                            'href'  => 'virtual_card.php?act=forsale&forsale=not&goods_id='.$_REQUEST['goods_id']));$smarty->assign('Hasforsale',  array('text'    => $_LANG['Hasforsale'],                                            'href'  => 'virtual_card.php?act=forsale&forsale=has&goods_id='.$_REQUEST['goods_id']));

具體代碼如下:

/*------------------------------------------------------ *///-- 匯出未出售或已出售的虛擬商品到xls/*------------------------------------------------------ */elseif ($_REQUEST['act'] == 'forsale'){    $forsale = empty($_REQUEST['forsale']) ? "" : trim($_REQUEST['forsale']);    //首先判斷$forsale是否有值被傳入       if($forsale != ""){        $fielname = "";        $goods_id = empty($_REQUEST['goods_id']) ? 0 : intval($_REQUEST['goods_id']);        //has為已出售,not為未出售        if($forsale == 'has'){            $fielname = "已出售商品";            $getCurrentGoodsListsql = "SELECT card_id, goods_id, card_sn, card_password, end_date, is_saled, order_sn, crc32 FROM " . $GLOBALS['ecs']->table('virtual_card') . " WHERE goods_id = " . $goods_id . " and is_saled = 1" ;        }        else if($forsale == 'not'){            $fielname = "未出售商品";            $getCurrentGoodsListsql = "SELECT card_id, goods_id, card_sn, card_password, end_date, is_saled, order_sn, crc32 FROM " . $GLOBALS['ecs']->table('virtual_card') . " WHERE goods_id = " . $goods_id . " and is_saled = 0" ;        }        $currentGoodsList = $GLOBALS['db']->getAll($getCurrentGoodsListsql);        $arr = array();        foreach ($currentGoodsList AS $key => $row)        {            if ($row['crc32'] == 0 || $row['crc32'] == crc32(AUTH_KEY))            {                $row['card_sn']       = decrypt($row['card_sn']);                $row['card_password'] = decrypt($row['card_password']);            }            elseif ($row['crc32'] == crc32(OLD_AUTH_KEY))            {                $row['card_sn']       = decrypt($row['card_sn'], OLD_AUTH_KEY);                $row['card_password'] = decrypt($row['card_password'], OLD_AUTH_KEY);            }            else            {                $row['card_sn']       = '***';                $row['card_password'] = '***';            }            $row['end_date'] = $row['end_date'] == 0 ? '' : date($GLOBALS['_CFG']['date_format'], $row['end_date']);            $arr[] = $row;        }        header("Content-Type: application/vnd.ms-execl"); //定義檔案的內容類型        header("Content-Disposition: attachment; filename={$fielname}.xls");         header("Pragma: no-cache");  //不緩衝        header("Expires: 0");//將內容輸出到第一個活頁簿        $data = "資料庫編號\t商品編號\t卡片序號\t卡片密碼\t截止使用日期\t是否已經出售(1:已經出售0:未出售)\t訂單號\t加密編碼(客戶無用,可刪除)\t\n";        foreach($arr as $key=>$val){            foreach ($val as $k => $v) {                $data .= $v . "\t";            }            $data .= "\n";        }        echo iconv("UTF-8","GB2312//IGNORE",$data);        //echo "
";var_dump($data);echo "
";exit(); } }

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.