source: tmp/version-2_5-test/data/class/pages/admin/basis/LC_Page_Admin_Basis_Payment_Input.php @ 18609

Revision 18609, 8.6 KB checked in by kajiwara, 14 years ago (diff)

正式版にナイトリービルド版をマージしてみるテスト

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id Revision Date
  • 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-2007 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_PATH . "pages/LC_Page.php");
26
27/**
28 * 支払方法設定 のページクラス.
29 *
30 * @package Page
31 * @author LOCKON CO.,LTD.
32 * @version $Id$
33 */
34class LC_Page_Admin_Basis_Payment_Input extends LC_Page {
35
36    // {{{ properties
37
38    /** フォームパラメータの配列 */
39    var $objFormParam;
40
41    /** SC_UploadFile インスタンス */
42    var $objUpFile;
43
44    // }}}
45    // {{{ functions
46
47    /**
48     * Page を初期化する.
49     *
50     * @return void
51     */
52    function init() {
53        parent::init();
54        $this->tpl_mainpage = 'basis/payment_input.tpl';
55        $this->tpl_subtitle = '支払方法設定';
56    }
57
58    /**
59     * Page のプロセス.
60     *
61     * @return void
62     */
63    function process() {
64        $conn = new SC_DBConn();
65        $objView = new SC_AdminView();
66        $objSess = new SC_Session();
67        $objDb = new SC_Helper_DB_Ex();
68
69        // 認証可否の判定
70        SC_Utils_Ex::sfIsSuccess($objSess);
71
72        // ファイル管理クラス
73        $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_DIR, IMAGE_SAVE_DIR);
74        // ファイル情報の初期化
75        $this->objUpFile = $this->lfInitFile();
76        // Hiddenからのデータを引き継ぐ
77        $this->objUpFile->setHiddenFileList($_POST);
78
79        // パラメータ管理クラス
80        $this->objFormParam = new SC_FormParam();
81        // パラメータ情報の初期化
82        $this->lfInitParam();
83        // POST値の取得
84        $this->objFormParam->setParam($_POST);
85
86        switch($_POST['mode']) {
87        case 'edit':
88            // 入力値の変換
89            $this->objFormParam->convParam();
90
91            // エラーチェック
92            $this->arrErr = $this->lfCheckError();
93            $this->charge_flg = $_POST["charge_flg"];
94            if(count($this->arrErr) == 0) {
95                $this->lfRegistData($_POST['payment_id']);
96                // 一時ファイルを本番ディレクトリに移動する
97                $this->objUpFile->moveTempFile();
98                // 親ウィンドウを更新するようにセットする。
99                $this->tpl_onload="fnUpdateParent('".URL_PAYMENT_TOP."'); window.close();";
100            }
101
102            break;
103        // 画像のアップロード
104        case 'upload_image':
105            // ファイル存在チェック
106            $this->arrErr = $this->objUpFile->checkEXISTS($_POST['image_key']);
107            // 画像保存処理
108            $this->arrErr[$_POST['image_key']] = $this->objUpFile->makeTempFile($_POST['image_key']);
109            break;
110        // 画像の削除
111        case 'delete_image':
112            $this->objUpFile->deleteFile($_POST['image_key']);
113            break;
114        default:
115            break;
116        }
117
118        if($_POST['mode'] == "") {
119            switch($_GET['mode']) {
120            case 'pre_edit':
121                if(SC_Utils_Ex::sfIsInt($_GET['payment_id'])) {
122                    $arrRet = $this->lfGetData($_GET['payment_id']);
123                    $this->objFormParam->setParam($arrRet);
124                    $this->charge_flg = $arrRet["charge_flg"];
125                    // DBデータから画像ファイル名の読込
126                    $this->objUpFile->setDBFileList($arrRet);
127                    $this->tpl_payment_id = $_GET['payment_id'];
128                }
129                break;
130            default:
131                break;
132            }
133        } else {
134            $this->tpl_payment_id = $_POST['payment_id'];
135        }
136
137        $this->arrDelivList = $objDb->sfGetIDValueList("dtb_deliv", "deliv_id", "service_name");
138        $this->arrForm = $this->objFormParam->getFormParamList();
139
140        // FORM表示用配列を渡す。
141        $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL);
142        // HIDDEN用に配列を渡す。
143        $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList());
144
145        $objView->assignobj($this);
146        $objView->display($this->tpl_mainpage);
147    }
148
149    /**
150     * デストラクタ.
151     *
152     * @return void
153     */
154    function destroy() {
155        parent::destroy();
156    }
157
158    /* ファイル情報の初期化 */
159    function lfInitFile() {
160        $this->objUpFile->addFile("ロゴ画像", 'payment_image', array('gif'), IMAGE_SIZE, false, CLASS_IMAGE_WIDTH, CLASS_IMAGE_HEIGHT);
161        return $this->objUpFile;
162    }
163
164    /* パラメータ情報の初期化 */
165    function lfInitParam() {
166        $this->objFormParam->addParam("支払方法", "payment_method", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK"));
167        $this->objFormParam->addParam("手数料", "charge", PRICE_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
168        $this->objFormParam->addParam("利用条件(~円以上)", "rule", PRICE_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
169        $this->objFormParam->addParam("利用条件(~円以下)", "upper_rule", PRICE_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
170        $this->objFormParam->addParam("配送サービス", "deliv_id", INT_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK"));
171        $this->objFormParam->addParam("固定", "fix");
172    }
173
174    /* DBからデータを読み込む */
175    function lfGetData($payment_id) {
176        $objQuery = new SC_Query();
177        $where = "payment_id = ?";
178        $arrRet = $objQuery->select("*", "dtb_payment", $where, array($payment_id));
179        return $arrRet[0];
180    }
181
182    /* DBへデータを登録する */
183    function lfRegistData($payment_id = "") {
184
185        $objQuery = new SC_Query();
186        $sqlval = $this->objFormParam->getHashArray();
187        $arrRet = $this->objUpFile->getDBFileList();    // ファイル名の取得
188        $sqlval = array_merge($sqlval, $arrRet);
189        $sqlval['update_date'] = 'Now()';
190
191        if($sqlval['fix'] != '1') {
192            $sqlval['fix'] = 2; // 自由設定
193        }
194
195        // 新規登録
196        if($payment_id == "") {
197            // INSERTの実行
198            $sqlval['creator_id'] = $_SESSION['member_id'];
199            $sqlval['rank'] = $objQuery->max("dtb_payment", "rank") + 1;
200            $sqlval['create_date'] = 'Now()';
201            $objQuery->insert("dtb_payment", $sqlval);
202        // 既存編集
203        } else {
204            $where = "payment_id = ?";
205            $objQuery->update("dtb_payment", $sqlval, $where, array($payment_id));
206        }
207    }
208
209    /* 利用条件の数値チェック */
210
211    /* 入力内容のチェック */
212    function lfCheckError() {
213
214        // DBのデータを取得
215        $arrPaymentData = $this->lfGetData($_POST['payment_id']);
216
217        // 手数料を設定できない場合には、手数料を0にする
218        if($arrPaymentData["charge_flg"] == 2) $this->objFormParam->setValue("charge", "0");
219
220        // 入力データを渡す。
221        $arrRet =  $this->objFormParam->getHashArray();
222        $objErr = new SC_CheckError($arrRet);
223        $objErr->arrErr = $this->objFormParam->checkError();
224
225        // 利用条件(下限)チェック
226        if($arrRet["rule"] < $arrPaymentData["rule_min"] and $arrPaymentData["rule_min"] != ""){
227            $objErr->arrErr["rule"] = "利用条件(下限)は" . $arrPaymentData["rule_min"] ."円以上にしてください。<br>";
228        }
229
230        // 利用条件(上限)チェック
231        if($arrRet["upper_rule"] > $arrPaymentData["upper_rule_max"] and $arrPaymentData["upper_rule_max"] != ""){
232            $objErr->arrErr["upper_rule"] = "利用条件(上限)は" . $arrPaymentData["upper_rule_max"] ."円以下にしてください。<br>";
233        }
234
235        // 利用条件チェック
236        $objErr->doFunc(array("利用条件(~円以上)", "利用条件(~円以下)", "rule", "upper_rule"), array("GREATER_CHECK"));
237
238        return $objErr->arrErr;
239    }
240}
241?>
Note: See TracBrowser for help on using the repository browser.