在admin/virtral_card.php文件中找到$_REQUEST['act'] == 'card'這里是用來(lái)顯示某一個(gè)虛擬商品的出售記錄的列表將會(huì)發(fā)送到replenish_list.htm在replenish_list.htm 文件中最定部分有個(gè)引入的文件叫pageheader.htm的文件這里是用于輸出默認(rèn)模版里的補(bǔ)“貨按”鈕在virtral_card.php文件大約180行有
$smarty->assign('action_link', array('text' => $_LANG['replenish'], 'href' => 'virtual_card.php?act=replenish&goods_id='.$_REQUEST['goods_id']));按照ecshop的習(xí)慣,需要修改語(yǔ)言包文件(語(yǔ)言包文件名和對(duì)應(yīng)的這個(gè)php文件名相同,只是在語(yǔ)言包目錄下)
$_LANG['Notforsale'] = '未出售導(dǎo)出xls';$_LANG['Hasforsale'] = '已出售導(dǎo)出xls';
在大約180行那句話下面添加如下(主要是修改一下act后的參數(shù),用于到文件中來(lái)處理數(shù)據(jù))比較重要的是forsale=has和forsale=not這兩個(gè)參數(shù),將用來(lái)區(qū)別是要導(dǎo)出已經(jīng)出售還是要導(dǎo)出未出售的
$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']));具體代碼如下:
/*------------------------------------------------------ *///-- 導(dǎo)出未出售或已出售的虛擬商品到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"); //定義文件的內(nèi)容類型 header("Content-Disposition: attachment; filename={$fielname}.xls"); header("PRagma: no-cache"); //不緩存 header("Expires: 0");//將內(nèi)容輸出到第一個(gè)工作簿 $data = "數(shù)據(jù)庫(kù)編號(hào)/t商品編號(hào)/t卡片序號(hào)/t卡片密碼/t截止使用日期/t是否已經(jīng)出售(1:已經(jīng)出售0:未出售)/t訂單號(hào)/t加密編碼(客戶無(wú)用,可刪除)/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(); } } 新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注