質問 > 管理機能 > 商品管理で商品情報を出力したい |
管理機能
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | 下へ |
投稿者 | スレッド |
---|---|
moimoii |
投稿日時: 2013/5/29 0:03
対応状況: −−−
|
半人前 登録日: 2013/5/12 居住地: 投稿: 12 |
商品管理で商品情報を出力したい いつも参考にさせていただいております。
どうか教えてください。 商品情報を仕様書のような形式でPDF出力したいです。 受注管理で設置されている帳票のPDF出力機能を商品管理のページで利用できないかと考え、 data/Smarty/templetes/admin/products/index.tpl にPDF出力ボタンを追加し、 data/Smarty/templetes/admin/order/から pdf_input.tplをコピーし、同じように data/class/pages/admin/products/LC_Page_Admin_products_Pdf.php data/class_extends/page_extends/admin/products/LC_Page_Admin_Products_Pdf_Ex.php html/admin/products/pdf.php を作成、 data/class/SC_Fpdf2.phpを商品情報出力用に設置したのですがエラーになってしまいます。 エラー内容は Fatal error: Call to undefined method SC_Query_Ex::setProductData() in /virtual/xxx/home/xxx/data/class/SC_Fpdf2.php on line 289 SC_Fpdf2.phpのソースを張ります。 ------------------------------------------------------------- <?php /* * This file is part of EC-CUBE * * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. * * http://www.lockon.co.jp/ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * PDF 仕様書を出力する * * TODO ページクラスとすべき要素を多々含んでいるように感じる。 */ define('PDF_TEMPLATE_REALDIR', TEMPLATE_ADMIN_REALDIR . 'pdf/'); class SC_Fpdf2 extends SC_Helper_FPDI { function __construct($download, $title, $tpl_pdf = 'shiyosho.pdf') { $this->FPDF(); // デフォルトの設定 $this->tpl_pdf = PDF_TEMPLATE_REALDIR . $tpl_pdf; // テンプレートファイル $this->pdf_download = $download; // PDFのダウンロード形式(0:表示、1:ダウンロード) $this->tpl_title = $title; $this->tpl_dispmode = 'real'; // 表示モード $masterData = new SC_DB_MasterData_Ex(); $this->arrPref = $masterData->getMasterData('mtb_pref'); $this->width_cell = array(110.3,12,21.7,24.5); $this->label_cell[] = '商品名 / 商品コード / [ 規格 ]'; $this->label_cell[] = '数量'; $this->label_cell[] = '単価'; $this->label_cell[] = '金額(税込)'; $this->arrMessage = array( 'テスト1テスト1テスト1', 'テスト2テスト2テスト2', 'テスト3テスト3テスト3' ); // SJISフォント $this->AddSJISFont(); $this->SetFont('SJIS'); //ページ総数取得 $this->AliasNbPages(); // マージン設定 $this->SetMargins(15, 20); // PDFを読み込んでページ数を取得 $this->pageno = $this->setSourceFile($this->tpl_pdf); } function setData($arrData) { $this->arrData = $arrData; // ページ番号よりIDを取得 $tplidx = $this->ImportPage(1); // ページを追加(新規) $this->AddPage(); //表示倍率(100%) $this->SetDisplayMode($this->tpl_dispmode); if (SC_Utils_Ex::sfIsInt($arrData['product_id'])) { $this->disp_mode = true; } // テンプレート内容の位置、幅を調整 ※useTemplateに引数を与えなければ100%表示がデフォルト $this->useTemplate($tplidx); $this->setShopData(); $this->setMessageData(); $this->setProductData(); $this->setEtcData(); } function setShopData() { // ショップ情報 $objDb = new SC_Helper_DB_Ex(); $arrInfo = $objDb->sfGetBasisData(); // ショップ名 $this->lfText(125, 60, $arrInfo['shop_name'], 8, 'B'); // URL $this->lfText(125, 63, $arrInfo['law_url'], 8); // 会社名 $this->lfText(125, 68, $arrInfo['law_company'], 8); // 郵便番号 $text = '〒 ' . $arrInfo['law_zip01'] . ' - ' . $arrInfo['law_zip02']; $this->lfText(125, 71, $text, 8); // 都道府県+所在地 $text = $this->arrPref[$arrInfo['law_pref']] . $arrInfo['law_addr01']; $this->lfText(125, 74, $text, 8); $this->lfText(125, 77, $arrInfo['law_addr02'], 8); $text = 'TEL: '.$arrInfo['law_tel01'].'-'.$arrInfo['law_tel02'].'-'.$arrInfo['law_tel03']; //FAX番号が存在する場合、表示する if (strlen($arrInfo['law_fax01']) > 0) { $text .= ' FAX: '.$arrInfo['law_fax01'].'-'.$arrInfo['law_fax02'].'-'.$arrInfo['law_fax03']; } $this->lfText(125, 80, $text, 8); //TEL・FAX if (strlen($arrInfo['law_email']) > 0) { $text = 'Email: '.$arrInfo['law_email']; $this->lfText(125, 83, $text, 8); //Email } //ロゴ画像 $logo_file = PDF_TEMPLATE_REALDIR . 'logo.png'; $this->Image($logo_file, 124, 46, 40); } function setMessageData() { // メッセージ $this->lfText(27, 70, $this->arrData['msg1'], 8); //メッセージ1 $this->lfText(27, 74, $this->arrData['msg2'], 8); //メッセージ2 $this->lfText(27, 78, $this->arrData['msg3'], 8); //メッセージ3 $text = '作成日: '.$this->arrData['year'].'年'.$this->arrData['month'].'月'.$this->arrData['day'].'日'; $this->lfText(158, 288, $text, 8); //作成日 } function setProductData() { $arrProducts = array(); // DBから商品情報を読み込む $this->lfGetProductData($this->arrData['product_id']); // 商品情報 $text = ' '.$this->arrDisp['process_status']; $this->lfText(23, 43, $text, 10); //加工状態 $text = $this->arrDisp['process01']; $this->lfText(27, 47, $text, 10); //加工詳細1 $this->lfText(27, 51, $this->arrDisp['process02'], 10); //加工詳細2 $text = $this->arrDisp['process03']; $this->lfText(27, 59, $text, 11); //加工詳細3 // 購入商品情報 for ($i = 0; $i < count($this->arrDisp['quantity']); $i++) { // 購入数量 $data[0] = $this->arrDisp['quantity'][$i]; // 税込金額(単価) $data[1] = SC_Helper_DB_Ex::sfCalcIncTax($this->arrDisp['price'][$i]); // 小計(商品毎) $data[2] = $data[0] * $data[1]; $arrOrder[$i][0] = $this->arrDisp['product_name'][$i].' / '; $arrOrder[$i][0] .= $this->arrDisp['product_code'][$i].' / '; if ($this->arrDisp['classcategory_name1'][$i]) { $arrOrder[$i][0] .= ' [ '.$this->arrDisp['classcategory_name1'][$i]; if ($this->arrDisp['classcategory_name2'][$i] == '') { $arrOrder[$i][0] .= ' ]'; } else { $arrOrder[$i][0] .= ' * '.$this->arrDisp['classcategory_name2'][$i].' ]'; } } $arrOrder[$i][1] = number_format($data[0]); $arrOrder[$i][2] = number_format($data[1]).$monetary_unit; $arrOrder[$i][3] = number_format($data[2]).$monetary_unit; } $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = ''; $arrOrder[$i][3] = ''; $i++; $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '商品合計'; $arrOrder[$i][3] = number_format($this->arrDisp['subtotal']).$monetary_unit; $i++; $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '送料'; $arrOrder[$i][3] = number_format($this->arrDisp['deliv_fee']).$monetary_unit; $i++; $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '手数料'; $arrOrder[$i][3] = number_format($this->arrDisp['charge']).$monetary_unit; $i++; $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '値引き'; $arrOrder[$i][3] = '- '.number_format(($this->arrDisp['use_point'] * POINT_VALUE) + $this->arrDisp['discount']).$monetary_unit; $i++; $arrOrder[$i][0] = ''; $arrOrder[$i][1] = ''; $arrOrder[$i][2] = '請求金額'; $arrOrder[$i][3] = number_format($this->arrDisp['payment_total']).$monetary_unit; $this->FancyTable($this->label_cell, $arrOrder, $this->width_cell); } function setEtcData() { $this->Cell(0, 10, '', 0, 1, 'C', 0, ''); $this->SetFont('Gothic', 'B', 9); $this->MultiCell(0, 6, '< 備 考 >', 'T', 2, 'L', 0, ''); //備考 $this->Ln(); $this->SetFont('SJIS', '', 8); $this->MultiCell(0, 4, $this->arrData['etc1']."\n".$this->arrData['etc2']."\n".$this->arrData['etc3'], '', 2, 'L', 0, ''); //備考 } function createPdf() { // PDFをブラウザに送信 ob_clean(); if ($this->pdf_download == 1) { if ($this->PageNo() == 1) { $filename = 'No'.$this->arrData['product_code'].'.pdf'; } else { $filename = 'No'.$this->arrData['product_id'].'.pdf'; } $this->Output($this->lfConvSjis($filename), 'D'); } else { $this->Output(); } // 入力してPDFファイルを閉じる $this->Close(); } // PDF_Japanese::Text へのパーサー function lfText($x, $y, $text, $size = 0, $style = '') { // 退避 $bak_font_style = $this->FontStyle; $bak_font_size = $this->FontSizePt; $this->SetFont('', $style, $size); $this->Text($x, $y, $text); // 復元 $this->SetFont('', $bak_font_style, $bak_font_size); } // 商品データの取得 function lfGetProductData($product_id) { if (SC_Utils_Ex::sfIsInt($product_id)) { // DBから商品情報を読み込む $objQuery =& SC_Query_Ex::getSingletonInstance(); $where = 'product_id = ?'; $arrRet = $objQuery->select('*', 'dtb_products', $where, array($product_id)); // 商品詳細データの取得 $arrRet = $this->lfGETProductDetail($product_id); $arrRet = SC_Utils_Ex::sfSwapArray($arrRet); $this->arrDisp = array_merge($this->arrDisp, $arrRet); // その他支払い情報を表示 if ($this->arrDisp['memo02'] != '') { $this->arrDisp['payment_info'] = unserialize($this->arrDisp['memo02']); } $this->arrDisp['payment_type'] = 'お支払い'; } } // 商品詳細データの取得 function lfGetProductDetail($product_id) { $objQuery =& SC_Query_Ex::getSingletonInstance(); $col = 'product_id, product_code, name, classcategory_id1, classcategory_id2, price'; $where = 'product_id = ?'; $objQuery->setProduct('product_id'); $arrRet = $objQuery->select($col, 'dtb_products', $where, array($product_id)); return $arrRet; } } ------------------------------------------------------------- 原因は商品情報のデータベース取得の書き方が間違っているためとは思うのですが、どうかアドバイスをお願いいたします。 ------------------------------------------------------------------------------------------ [EC-CUBE] 2.12.1 [レンタルサーバ] WebARENA [OS] windows XP [PHP] PHP Version 5.1.6 [データベース] MySQL5.1.36 ------------------------------------------------------------------------------------------ |
yuh |
投稿日時: 2013/5/29 12:18
対応状況: −−−
|
神 登録日: 2013/1/9 居住地: 大阪 投稿: 1819 |
Re: 商品管理で商品情報を出力したい エラーの内容とソースがあっていないように見えます。
エラーが出た後にソースを書き換えてませんか? $objQuery->setProduct('product_id'); が原因です。 必要ないので消してください。 自分で作成したソースのデバッグは自分でやった方がいいと思います。 |
moimoii |
投稿日時: 2013/5/29 13:26
対応状況: 解決済
|
半人前 登録日: 2013/5/12 居住地: 投稿: 12 |
Re: 商品管理で商品情報を出力したい >yuh様
いつもありがとうございます。 うまくいきました。 ありがとうございます。 引用:
まちがえて古い方のソースを張っていました。 お手数をおかけして申し訳ありません。 自分で解決できるようもっと勉強いたします。 ありがとうございました。 |
スレッド表示 | 新しいものから | 前のトピック | 次のトピック | トップ |