source: branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Pdf.php @ 21693

Revision 21693, 8.9 KB checked in by h_yoshimoto, 12 years ago (diff)

#1692 フックポイント名を変更

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23
24// {{{ requires
25require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
26
27/**
28 * 帳票出力 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Order_Pdf extends LC_Page_Admin_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $this->tpl_mainpage = 'order/pdf_input.tpl';
47        $this->tpl_mainno = 'order';
48        $this->tpl_subno = 'pdf';
49        $this->tpl_maintitle = '受注管理';
50        $this->tpl_subtitle = '帳票出力';
51
52        $this->SHORTTEXT_MAX = STEXT_LEN;
53        $this->MIDDLETEXT_MAX = MTEXT_LEN;
54        $this->LONGTEXT_MAX = LTEXT_LEN;
55
56        $this->arrType[0]  = '納品書';
57
58        $this->arrDownload[0] = 'ブラウザに開く';
59        $this->arrDownload[1] = 'ファイルに保存';
60    }
61
62    /**
63     * Page のプロセス.
64     *
65     * @return void
66     */
67    function process() {
68        $this->action();
69        $this->sendResponse();
70    }
71
72    /**
73     * Page のアクション.
74     *
75     * @return void
76     */
77    function action() {
78        // フックポイント.
79        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
80        $objPlugin->doAction('LC_Page_Admin_Order_Pdf_action_before', array($this));
81
82        $objDb = new SC_Helper_DB_Ex();
83        $objDate = new SC_Date_Ex(1901);
84        $objDate->setStartYear(RELEASE_YEAR);
85        $this->arrYear = $objDate->getYear();
86        $this->arrMonth = $objDate->getMonth();
87        $this->arrDay = $objDate->getDay();
88
89        // パラメーター管理クラス
90        $this->objFormParam = new SC_FormParam_Ex();
91        // パラメーター情報の初期化
92        $this->lfInitParam($this->objFormParam);
93        $this->objFormParam->setParam($_POST);
94        // 入力値の変換
95        $this->objFormParam->convParam();
96
97        // どんな状態の時に isset($arrRet) == trueになるんだ? これ以前に$arrRet無いが、、、、
98        if (!isset($arrRet)) $arrRet = array();
99        switch ($this->getMode()) {
100            case 'confirm':
101                // フックポイント.
102                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
103                $objPlugin->doAction('LC_Page_Admin_Order_Pdf_action_confirm', array($this));
104
105                $status = $this->createPdf($this->objFormParam);
106                if ($status === true) {
107                    exit;
108                } else {
109                    $this->arrErr = $status;
110                }
111                break;
112            default:
113                $this->arrForm = $this->createFromValues($_GET['order_id'],$_POST['pdf_order_id']);
114                break;
115        }
116        $this->setTemplate($this->tpl_mainpage);
117
118        // フックポイント.
119        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
120        $objPlugin->doAction('LC_Page_Admin_Order_Pdf_action_after', array($this));
121    }
122
123    /**
124     *
125     * PDF作成フォームのデフォルト値の生成
126     */
127    function createFromValues($order_id,$pdf_order_id) {
128        // ここが$arrFormの初登場ということを明示するため宣言する。
129        $arrForm = array();
130        // タイトルをセット
131        $arrForm['title'] = 'お買上げ明細書(納品書)';
132
133        // 今日の日付をセット
134        $arrForm['year']  = date('Y');
135        $arrForm['month'] = date('m');
136        $arrForm['day']   = date('d');
137
138        // メッセージ
139        $arrForm['msg1'] = 'このたびはお買上げいただきありがとうございます。';
140        $arrForm['msg2'] = '下記の内容にて納品させていただきます。';
141        $arrForm['msg3'] = 'ご確認くださいますよう、お願いいたします。';
142
143        // 注文番号があったら、セットする
144        if (SC_Utils_Ex::sfIsInt($order_id)) {
145            $arrForm['order_id'][0] = $order_id;
146        } elseif (is_array($pdf_order_id)) {
147            sort($pdf_order_id);
148            foreach ($pdf_order_id AS $key=>$val) {
149                $arrForm['order_id'][] = $val;
150            }
151        }
152
153        return $arrForm;
154    }
155
156    /**
157     *
158     * PDFの作成
159     * @param SC_FormParam $objFormParam
160     */
161    function createPdf(&$objFormParam) {
162
163        $arrErr = $this->lfCheckError($objFormParam);
164        $arrRet = $objFormParam->getHashArray();
165
166        $this->arrForm = $arrRet;
167        // エラー入力なし
168        if (count($arrErr) == 0) {
169            $objFpdf = new SC_Fpdf($arrRet['download'], $arrRet['title']);
170            foreach ($arrRet['order_id'] AS $key => $val) {
171                $arrPdfData = $arrRet;
172                $arrPdfData['order_id'] = $val;
173                $objFpdf->setData($arrPdfData);
174            }
175            $objFpdf->createPdf();
176            return true;
177        } else {
178            return $arrErr;
179        }
180    }
181
182    /**
183     * デストラクタ.
184     *
185     * @return void
186     */
187    function destroy() {
188        parent::destroy();
189    }
190
191    /**
192     *  パラメーター情報の初期化
193     *  @param SC_FormParam
194     */
195    function lfInitParam(&$objFormParam) {
196        $objFormParam->addParam('注文番号', 'order_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
197        $objFormParam->addParam('注文番号', 'pdf_order_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'));
198        $objFormParam->addParam('発行日', 'year', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
199        $objFormParam->addParam('発行日', 'month', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
200        $objFormParam->addParam('発行日', 'day', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
201        $objFormParam->addParam('帳票の種類', 'type', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
202        $objFormParam->addParam('ダウンロード方法', 'download', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'));
203        $objFormParam->addParam('帳票タイトル', 'title', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
204        $objFormParam->addParam('帳票メッセージ1行目', 'msg1', STEXT_LEN*3/5, 'KVa', array('MAX_LENGTH_CHECK'));
205        $objFormParam->addParam('帳票メッセージ2行目', 'msg2', STEXT_LEN*3/5, 'KVa', array('MAX_LENGTH_CHECK'));
206        $objFormParam->addParam('帳票メッセージ3行目', 'msg3', STEXT_LEN*3/5, 'KVa', array('MAX_LENGTH_CHECK'));
207        $objFormParam->addParam('備考1行目', 'etc1', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
208        $objFormParam->addParam('備考2行目', 'etc2', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
209        $objFormParam->addParam('備考3行目', 'etc3', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK'));
210        $objFormParam->addParam('ポイント表記', 'disp_point', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
211    }
212
213    /**
214     *  入力内容のチェック
215     *  @var SC_FormParam
216     */
217
218    function lfCheckError(&$objFormParam) {
219        // 入力データを渡す。
220        $arrRet = $objFormParam->getHashArray();
221        $arrErr = $objFormParam->checkError();
222
223        $year = $objFormParam->getValue('year');
224        if (!is_numeric($year)) {
225            $arrErr['year'] = '発行年は数値で入力してください。';
226        }
227
228        $month = $objFormParam->getValue('month');
229        if (!is_numeric($month)) {
230            $arrErr['month'] = '発行月は数値で入力してください。';
231        } else if (0 >= $month && 12 < $month) {
232
233            $arrErr['month'] = '発行月は1〜12の間で入力してください。';
234        }
235
236        $day = $objFormParam->getValue('day');
237        if (!is_numeric($day)) {
238            $arrErr['day'] = '発行日は数値で入力してください。';
239        } else if (0 >= $day && 31 < $day) {
240
241            $arrErr['day'] = '発行日は1〜31の間で入力してください。';
242        }
243
244        return $arrErr;
245    }
246
247}
Note: See TracBrowser for help on using the repository browser.