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

Revision 20534, 8.3 KB checked in by Seasoft, 13 years ago (diff)

#627(ソース整形・ソースコメントの改善)
#628(未使用処理・定義などの削除)

  • 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-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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.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_Ex {
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        $objDate = new SC_Date_Ex(1901);
81        $objDate->setStartYear(RELEASE_YEAR);
82        $this->arrYear = $objDate->getYear();
83        $this->arrMonth = $objDate->getMonth();
84        $this->arrDay = $objDate->getDay();
85
86        // パラメータ管理クラス
87        $this->objFormParam = new SC_FormParam_Ex();
88        // パラメータ情報の初期化
89        $this->lfInitParam($this->objFormParam);
90        $this->objFormParam->setParam($_POST);
91        // 入力値の変換
92        $this->objFormParam->convParam();
93       
94        // どんな状態の時に isset($arrRet) == trueになるんだ? これ以前に$arrRet無いが、、、、
95        if (!isset($arrRet)) $arrRet = array();
96        switch($this->getMode()) {
97            case "confirm":
98                $status = $this->createPdf($this->objFormParam);
99                if($status === true){
100                    exit;
101                }else{
102                    $this->arrErr = $status;
103                }
104                break;
105            default:
106                $this->arrForm = $this->createFromValues($_GET['order_id'],$_POST['pdf_order_id']);
107                break;
108        }
109        $this->setTemplate($this->tpl_mainpage);
110    }
111
112    /**
113     *
114     * PDF作成フォームのデフォルト値の生成
115     */
116    function createFromValues($order_id,$pdf_order_id){
117        // ここが$arrFormの初登場ということを明示するため宣言する。
118        $arrForm = array();
119        // タイトルをセット
120        $arrForm['title'] = "お買上げ明細書(納品書)";
121
122        // 今日の日付をセット
123        $arrForm['year']  = date("Y");
124        $arrForm['month'] = date("m");
125        $arrForm['day']   = date("d");
126
127        // メッセージ
128        $arrForm['msg1'] = 'このたびはお買上げいただきありがとうございます。';
129        $arrForm['msg2'] = '下記の内容にて納品させていただきます。';
130        $arrForm['msg3'] = 'ご確認くださいますよう、お願いいたします。';
131
132        // 注文番号があったら、セットする
133        if(SC_Utils_Ex::sfIsInt($order_id)) {
134            $arrForm['order_id'][0] = $order_id;
135        } elseif (is_array($pdf_order_id)) {
136            sort($pdf_order_id);
137            foreach ($pdf_order_id AS $key=>$val) {
138                $arrForm['order_id'][] = $val;
139            }
140        }
141
142        return $arrForm;
143    }
144
145    /**
146     *
147     * PDFの作成
148     * @param SC_FormParam $objFormParam
149     */
150    function createPdf(&$objFormParam){
151       
152        $arrErr = $this->lfCheckError($objFormParam);
153        $arrRet = $objFormParam->getHashArray();
154
155        $this->arrForm = $arrRet;
156        // エラー入力なし
157        if (count($arrErr) == 0) {
158            $objFpdf = new SC_Fpdf($arrRet['download'], $arrRet['title']);
159            foreach ($arrRet['order_id'] AS $key => $val) {
160                $arrPdfData = $arrRet;
161                $arrPdfData['order_id'] = $val;
162                $objFpdf->setData($arrPdfData);
163            }
164            $objFpdf->createPdf();
165            return true;
166        }else{
167            return $arrErr;
168        }
169    }
170
171
172
173    /**
174     * デストラクタ.
175     *
176     * @return void
177     */
178    function destroy() {
179        parent::destroy();
180    }
181
182    /**
183     *  パラメータ情報の初期化
184     *  @param SC_FormParam
185     */
186    function lfInitParam(&$objFormParam) {
187        $objFormParam->addParam("注文番号", "order_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
188        $objFormParam->addParam("注文番号", "pdf_order_id", INT_LEN, "n", array( "MAX_LENGTH_CHECK", "NUM_CHECK"));
189        $objFormParam->addParam("発行日", "year", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
190        $objFormParam->addParam("発行日", "month", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
191        $objFormParam->addParam("発行日", "day", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
192        $objFormParam->addParam("帳票の種類", "type", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
193        $objFormParam->addParam("ダウンロード方法", "download", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"));
194        $objFormParam->addParam("帳票タイトル", "title", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
195        $objFormParam->addParam("帳票メッセージ1行目", "msg1", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
196        $objFormParam->addParam("帳票メッセージ2行目", "msg2", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
197        $objFormParam->addParam("帳票メッセージ3行目", "msg3", STEXT_LEN*3/5, "KVa", array("MAX_LENGTH_CHECK"));
198        $objFormParam->addParam("備考1行目", "etc1", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
199        $objFormParam->addParam("備考2行目", "etc2", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
200        $objFormParam->addParam("備考3行目", "etc3", STEXT_LEN, "KVa", array("MAX_LENGTH_CHECK"));
201        $objFormParam->addParam("ポイント表記", "disp_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
202    }
203
204    /**
205     *  入力内容のチェック
206     *  @var SC_FormParam
207     */
208
209    function lfCheckError(&$objFormParam) {
210        // 入力データを渡す。
211        $arrRet = $objFormParam->getHashArray();
212        $arrErr = $objFormParam->checkError();
213
214        $year = $objFormParam->getValue('year');
215        if(!is_numeric($year)){
216            $arrErr['year'] = "発行年は数値で入力してください。";
217        }
218
219        $month = $objFormParam->getValue('month');
220        if(!is_numeric($month)){
221            $arrErr['month'] = "発行月は数値で入力してください。";
222        }else if(0 >= $month && 12 < $month){
223                   
224            $arrErr['month'] = "発行月は1〜12の間で入力してください。";
225        }
226       
227        $day = $objFormParam->getValue('day');
228        if(!is_numeric($day)){
229            $arrErr['day'] = "発行日は数値で入力してください。";
230        }else if(0 >= $day && 31 < $day){
231                   
232            $arrErr['day'] = "発行日は1〜31の間で入力してください。";
233        }
234
235        return $arrErr;
236    }
237
238
239}
240
Note: See TracBrowser for help on using the repository browser.