程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> ecshop給虛擬商品添加出售和未出售的導出xlc,ecshopxlc

ecshop給虛擬商品添加出售和未出售的導出xlc,ecshopxlc

編輯:關於PHP編程

ecshop給虛擬商品添加出售和未出售的導出xlc,ecshopxlc


在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 "<pre>";var_dump($data);echo "</pre>";exit();
   
    }
   
}
        

 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved