source: branches/version-2_13_0/data/class/pages/admin/basis/LC_Page_Admin_Basis_PaymentInput.php @ 23126

Revision 23126, 10.8 KB checked in by m_uehara, 11 years ago (diff)

#2348 r23116 - r23125 をマージ

  • 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-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
25
26/**
27 * 支払方法設定 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Admin_Basis_PaymentInput extends LC_Page_Admin_Ex
34{
35    /** SC_UploadFile インスタンス */
36    public $objUpFile;
37
38    /**
39     * Page を初期化する.
40     *
41     * @return void
42     */
43    public function init()
44    {
45        parent::init();
46        $this->tpl_mainpage = 'basis/payment_input.tpl';
47        $this->tpl_mainno = 'basis';
48        $this->tpl_subno = 'payment';
49        $this->tpl_maintitle = '基本情報管理';
50        $this->tpl_subtitle = '支払方法設定';
51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
58    public function process()
59    {
60        $this->action();
61        $this->sendResponse();
62    }
63
64    /**
65     * Page のアクション.
66     *
67     * @return void
68     */
69    public function action()
70    {
71        $objPayment = new SC_Helper_Payment_Ex();
72        $objFormParam = new SC_FormParam_Ex();
73        $mode = $this->getMode();
74        $this->lfInitParam($mode, $objFormParam);
75
76        // ファイル管理クラス
77        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR);
78        // ファイル情報の初期化
79        $this->objUpFile = $this->lfInitFile();
80        // Hiddenからのデータを引き継ぐ
81        $this->objUpFile->setHiddenFileList($_POST);
82
83        switch ($mode) {
84            case 'edit':
85                $objFormParam->setParam($_REQUEST);
86                $objFormParam->convParam();
87                $post = $objFormParam->getHashArray();
88                $this->arrErr = $this->lfCheckError($post, $objFormParam, $objPayment);
89                $this->charge_flg = $post['charge_flg'];
90                if (count($this->arrErr) == 0) {
91                    $this->lfRegistData($objFormParam, $objPayment, $_SESSION['member_id'], $post['payment_id']);
92                    $this->objUpFile->moveTempFile();
93                    $this->tpl_onload = "location.href = './payment.php'; return;";
94                }
95                $this->tpl_payment_id = $post['payment_id'];
96                break;
97            // 画像のアップロード
98            case 'upload_image':
99                $objFormParam->setParam($_REQUEST);
100                $objFormParam->convParam();
101                $post = $objFormParam->getHashArray();
102                // ファイル存在チェック
103                $this->arrErr = $this->objUpFile->checkExists($post['image_key']);
104                // 画像保存処理
105                $this->arrErr[$post['image_key']] = $this->objUpFile->makeTempFile($post['image_key']);
106                $this->tpl_payment_id = $post['payment_id'];
107                break;
108            // 画像の削除
109            case 'delete_image':
110                $objFormParam->setParam($_REQUEST);
111                $objFormParam->convParam();
112                $this->arrErr = $objFormParam->checkError();
113                $post = $objFormParam->getHashArray();
114                if (count($this->arrErr) == 0) {
115                    $this->objUpFile->deleteFile($post['image_key']);
116                }
117                $this->tpl_payment_id = $post['payment_id'];
118                break;
119
120            case 'pre_edit':
121                $objFormParam->setParam($_REQUEST);
122                $objFormParam->convParam();
123                $this->arrErr = $objFormParam->checkError();
124                $post = $objFormParam->getHashArray();
125                if (count($this->arrErr) == 0) {
126                    $arrRet = $objPayment->get($post['payment_id']);
127
128                    $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
129                    $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
130                    $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
131                    $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
132                    $objFormParam->addParam('固定', 'fix');
133                    $objFormParam->setParam($arrRet);
134
135                    $this->charge_flg = $arrRet['charge_flg'];
136                    $this->objUpFile->setDBFileList($arrRet);
137                }
138                $this->tpl_payment_id = $post['payment_id'];
139                break;
140            default:
141                break;
142        }
143
144        $this->arrForm = $objFormParam->getFormParamList();
145
146        // FORM表示用配列を渡す。
147        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH);
148        // HIDDEN用に配列を渡す。
149        $this->arrHidden = array_merge((array) $this->arrHidden, (array) $this->objUpFile->getHiddenFileList());
150    }
151
152    /* ファイル情報の初期化 */
153    public function lfInitFile()
154    {
155        $this->objUpFile->addFile('ロゴ画像', 'payment_image', array('gif','jpeg','jpg','png'), IMAGE_SIZE, false, CLASS_IMAGE_WIDTH, CLASS_IMAGE_HEIGHT);
156
157        return $this->objUpFile;
158    }
159
160    /* パラメーター情報の初期化 */
161    public function lfInitParam($mode, &$objFormParam)
162    {
163        switch ($mode) {
164            case 'edit':
165                $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
166                $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
167                $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
168                $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
169                $objFormParam->addParam('固定', 'fix');
170                $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
171                $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
172
173                break;
174            case 'upload_image':
175            case 'delete_image':
176                $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
177                $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
178                $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
179                $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
180                $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
181                $objFormParam->addParam('固定', 'fix');
182                $objFormParam->addParam('画像キー', 'image_key', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
183
184                break;
185            case 'pre_edit':
186                $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
187                $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
188                break;
189
190            default:
191                $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK'));
192                $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK'));
193                $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
194                $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
195                $objFormParam->addParam('固定', 'fix');
196
197                break;
198        }
199    }
200
201    /* DBへデータを登録する */
202    public function lfRegistData(&$objFormParam, SC_Helper_Payment_Ex $objPayment, $member_id, $payment_id = '')
203    {
204        $sqlval = array_merge($objFormParam->getHashArray(), $this->objUpFile->getDBFileList());
205        $sqlval['payment_id'] = $payment_id;
206        $sqlval['creator_id'] = $member_id;
207
208        if ($sqlval['fix'] != '1') {
209            $sqlval['fix'] = 2; // 自由設定
210        }
211
212        $objPayment->save($sqlval);
213    }
214
215    /* 利用条件の数値チェック */
216
217    /* 入力内容のチェック */
218    public function lfCheckError($post, $objFormParam, SC_Helper_Payment_Ex $objPayment)
219    {
220        // DBのデータを取得
221        $arrPaymentData = $objPayment->get($post['payment_id']);
222
223        // 手数料を設定できない場合には、手数料を0にする
224        if ($arrPaymentData['charge_flg'] == 2) {
225            $objFormParam->setValue('charge', '0');
226        }
227
228        // 入力データを渡す。
229        $arrRet =  $objFormParam->getHashArray();
230        $objErr = new SC_CheckError_Ex($arrRet);
231        $objErr->arrErr = $objFormParam->checkError();
232
233        // 利用条件(下限)チェック
234        if ($arrRet['rule_max'] < $arrPaymentData['rule_min'] and $arrPaymentData['rule_min'] != '') {
235            $objErr->arrErr['rule'] = '利用条件(下限)は' . $arrPaymentData['rule_min'] .'円以上にしてください。<br>';
236        }
237
238        // 利用条件(上限)チェック
239        if ($arrRet['upper_rule'] > $arrPaymentData['upper_rule_max'] and $arrPaymentData['upper_rule_max'] != '') {
240            $objErr->arrErr['upper_rule'] = '利用条件(上限)は' . $arrPaymentData['upper_rule_max'] .'円以下にしてください。<br>';
241        }
242
243        // 利用条件チェック
244        $objErr->doFunc(array('利用条件(~円以上)', '利用条件(~円以下)', 'rule_max', 'upper_rule'), array('GREATER_CHECK'));
245
246        return $objErr->arrErr;
247    }
248}
Note: See TracBrowser for help on using the repository browser.