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

Revision 20041, 7.1 KB checked in by eccuore, 13 years ago (diff)

#642(共通ロジックの機能向上) mode 取得用の関数を利用するように修正(switchリファクタリングは未対応)

  • Property svn:eol-style set to LF
  • 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-2010 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_REALDIR . "pages/admin/LC_Page_Admin.php");
26require_once(CLASS_REALDIR . "SC_Fpdf.php");
27
28/**
29 * 帳票出力 のページクラス.
30 *
31 * @package Page
32 * @author LOCKON CO.,LTD.
33 * @version $Id$
34 */
35class LC_Page_Admin_Order_Pdf extends LC_Page_Admin {
36
37    // }}}
38    // {{{ functions
39
40    /**
41     * Page を初期化する.
42     *
43     * @return void
44     */
45    function init() {
46        parent::init();
47        $this->tpl_mainpage = 'order/pdf_input.tpl';
48        $this->tpl_subnavi = 'order/subnavi.tpl';
49        $this->tpl_mainno = 'order';
50        $this->tpl_subno = 'pdf';
51        $this->tpl_subtitle = '帳票出力';
52
53        $this->SHORTTEXT_MAX = STEXT_LEN;
54        $this->MIDDLETEXT_MAX = MTEXT_LEN;
55        $this->LONGTEXT_MAX = LTEXT_LEN;
56
57        $this->arrType[0]  = "納品書";
58
59        $this->arrDownload[0] = "ブラウザに開く";
60        $this->arrDownload[1] = "ファイルに保存";
61    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function process() {
69        $this->action();
70        $this->sendResponse();
71    }
72
73    /**
74     * Page のアクション.
75     *
76     * @return void
77     */
78    function action() {
79        $objDb = new SC_Helper_DB_Ex();
80        $objSess = new SC_Session();
81
82        $objDate = new SC_Date(1901);
83        $objDate->setStartYear(RELEASE_YEAR);
84        $this->arrYear = $objDate->getYear();
85        $this->arrMonth = $objDate->getMonth();
86        $this->arrDay = $objDate->getDay();
87
88        // 認証可否の判定
89        SC_Utils_Ex::sfIsSuccess($objSess);
90
91        // 画面遷移の正当性チェック用にuniqidを埋め込む
92        $objPage->tpl_uniqid = $objSess->getUniqId();
93
94        // パラメータ管理クラス
95        $this->objFormParam = new SC_FormParam();
96        // パラメータ情報の初期化
97        $this->lfInitParam();
98        $this->objFormParam->setParam($_POST);
99
100        if (!isset($arrRet)) $arrRet = array();
101
102        switch($this->getMode()) {
103        case "confirm":
104            // 入力値の変換
105            $this->objFormParam->convParam();
106            $this->arrErr = $this->lfCheckError($arrRet);
107            $arrRet = $this->objFormParam->getHashArray();
108            $this->arrForm = $arrRet;
109            // エラー入力なし
110            if (count($this->arrErr) == 0) {
111                $objFpdf = new SC_Fpdf($arrRet['download'], $arrRet['title']);
112                foreach ($arrRet['order_id'] AS $key => $val) {
113                    $arrPdfData = $arrRet;
114                    $arrPdfData['order_id'] = $val;
115                    $objFpdf->setData($arrPdfData);
116                }
117                $objFpdf->createPdf();
118                exit;
119            }
120            break;
121        default:
122            // タイトルをセット
123            $arrForm['title'] = "お買上げ明細書(納品書)";
124
125            // 今日の日付をセット
126            $arrForm['year']  = date("Y");
127            $arrForm['month'] = date("m");
128            $arrForm['day']   = date("d");
129
130            // メッセージ
131            $arrForm['msg1'] = 'このたびはお買上げいただきありがとうございます。';
132            $arrForm['msg2'] = '下記の内容にて納品させていただきます。';
133            $arrForm['msg3'] = 'ご確認くださいますよう、お願いいたします。';
134
135            // 注文番号があったら、セットする
136            if(SC_Utils_Ex::sfIsInt($_GET['order_id'])) {
137                  $arrForm['order_id'][0] = $_GET['order_id'];
138            } elseif (is_array($_POST['pdf_order_id'])) {
139                sort($_POST['pdf_order_id']);
140                foreach ($_POST['pdf_order_id'] AS $key=>$val) {
141                      $arrForm['order_id'][] = $val;
142                }
143            }
144
145            $this->arrForm = $arrForm;
146            break;
147        }
148        $this->setTemplate($this->tpl_mainpage);
149    }
150
151    /**
152     * デストラクタ.
153     *
154     * @return void
155     */
156    function destroy() {
157        parent::destroy();
158    }
159
160    /* パラメータ情報の初期化 */
161    function lfInitParam() {
162        $this->objFormParam->addParam("注文番号", "order_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
163        $this->objFormParam->addParam("発行日", "year", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
164        $this->objFormParam->addParam("発行日", "month", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
165        $this->objFormParam->addParam("発行日", "day", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
166        $this->objFormParam->addParam("帳票の種類", "type", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
167        $this->objFormParam->addParam("ダウンロード方法", "download", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
168        $this->objFormParam->addParam("帳票タイトル", "title", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
169        $this->objFormParam->addParam("帳票メッセージ1行目", "msg1", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
170        $this->objFormParam->addParam("帳票メッセージ2行目", "msg2", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
171        $this->objFormParam->addParam("帳票メッセージ3行目", "msg3", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
172        $this->objFormParam->addParam("備考1行目", "etc1", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
173        $this->objFormParam->addParam("備考2行目", "etc2", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
174        $this->objFormParam->addParam("備考3行目", "etc3", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
175        $this->objFormParam->addParam("ポイント表記", "disp_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
176    }
177
178    /* 入力内容のチェック */
179    function lfCheckError() {
180        // 入力データを渡す。
181        $arrRet =  $this->objFormParam->getHashArray();
182        $objErr = new SC_CheckError($arrRet);
183        $objErr->arrErr = $this->objFormParam->checkError();
184
185        // 特殊項目チェック
186        $objErr->doFunc(array("発行日", "year", "month", "day"), array("CHECK_DATE"));
187
188        return $objErr->arrErr;
189    }
190
191
192}
193
194?>
Note: See TracBrowser for help on using the repository browser.