[15304] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15304] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15304] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[19805] | 25 | require_once(CLASS_REALDIR . "pages/admin/LC_Page_Admin.php"); |
---|
[15304] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 支払方法設定 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[19661] | 34 | class LC_Page_Admin_Basis_Payment_Input extends LC_Page_Admin { |
---|
[15304] | 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() { |
---|
[19661] | 64 | $this->action(); |
---|
| 65 | $this->sendResponse(); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | /** |
---|
| 69 | * Page のアクション. |
---|
| 70 | * |
---|
| 71 | * @return void |
---|
| 72 | */ |
---|
| 73 | function action() { |
---|
[15304] | 74 | $objSess = new SC_Session(); |
---|
| 75 | $objDb = new SC_Helper_DB_Ex(); |
---|
| 76 | |
---|
| 77 | // 認証可否の判定 |
---|
| 78 | SC_Utils_Ex::sfIsSuccess($objSess); |
---|
| 79 | |
---|
| 80 | // ファイル管理クラス |
---|
[19805] | 81 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
[15304] | 82 | // ファイル情報の初期化 |
---|
| 83 | $this->objUpFile = $this->lfInitFile(); |
---|
| 84 | // Hiddenからのデータを引き継ぐ |
---|
| 85 | $this->objUpFile->setHiddenFileList($_POST); |
---|
| 86 | |
---|
| 87 | // パラメータ管理クラス |
---|
| 88 | $this->objFormParam = new SC_FormParam(); |
---|
| 89 | // パラメータ情報の初期化 |
---|
| 90 | $this->lfInitParam(); |
---|
| 91 | // POST値の取得 |
---|
| 92 | $this->objFormParam->setParam($_POST); |
---|
| 93 | |
---|
| 94 | switch($_POST['mode']) { |
---|
| 95 | case 'edit': |
---|
| 96 | // 入力値の変換 |
---|
| 97 | $this->objFormParam->convParam(); |
---|
| 98 | |
---|
| 99 | // エラーチェック |
---|
| 100 | $this->arrErr = $this->lfCheckError(); |
---|
| 101 | $this->charge_flg = $_POST["charge_flg"]; |
---|
| 102 | if(count($this->arrErr) == 0) { |
---|
| 103 | $this->lfRegistData($_POST['payment_id']); |
---|
| 104 | // 一時ファイルを本番ディレクトリに移動する |
---|
| 105 | $this->objUpFile->moveTempFile(); |
---|
| 106 | // 親ウィンドウを更新するようにセットする。 |
---|
| 107 | $this->tpl_onload="fnUpdateParent('".URL_PAYMENT_TOP."'); window.close();"; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | break; |
---|
| 111 | // 画像のアップロード |
---|
| 112 | case 'upload_image': |
---|
| 113 | // ファイル存在チェック |
---|
[17911] | 114 | $this->arrErr = $this->objUpFile->checkEXISTS($_POST['image_key']); |
---|
[15304] | 115 | // 画像保存処理 |
---|
| 116 | $this->arrErr[$_POST['image_key']] = $this->objUpFile->makeTempFile($_POST['image_key']); |
---|
| 117 | break; |
---|
| 118 | // 画像の削除 |
---|
| 119 | case 'delete_image': |
---|
| 120 | $this->objUpFile->deleteFile($_POST['image_key']); |
---|
| 121 | break; |
---|
| 122 | default: |
---|
| 123 | break; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | if($_POST['mode'] == "") { |
---|
| 127 | switch($_GET['mode']) { |
---|
| 128 | case 'pre_edit': |
---|
| 129 | if(SC_Utils_Ex::sfIsInt($_GET['payment_id'])) { |
---|
| 130 | $arrRet = $this->lfGetData($_GET['payment_id']); |
---|
| 131 | $this->objFormParam->setParam($arrRet); |
---|
| 132 | $this->charge_flg = $arrRet["charge_flg"]; |
---|
| 133 | // DBデータから画像ファイル名の読込 |
---|
| 134 | $this->objUpFile->setDBFileList($arrRet); |
---|
| 135 | $this->tpl_payment_id = $_GET['payment_id']; |
---|
| 136 | } |
---|
| 137 | break; |
---|
| 138 | default: |
---|
| 139 | break; |
---|
| 140 | } |
---|
| 141 | } else { |
---|
| 142 | $this->tpl_payment_id = $_POST['payment_id']; |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | $this->arrForm = $this->objFormParam->getFormParamList(); |
---|
| 146 | |
---|
| 147 | // FORM表示用配列を渡す。 |
---|
| 148 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URL, IMAGE_SAVE_URL); |
---|
| 149 | // HIDDEN用に配列を渡す。 |
---|
| 150 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList()); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | /** |
---|
| 154 | * デストラクタ. |
---|
| 155 | * |
---|
| 156 | * @return void |
---|
| 157 | */ |
---|
| 158 | function destroy() { |
---|
| 159 | parent::destroy(); |
---|
| 160 | } |
---|
| 161 | |
---|
| 162 | /* ファイル情報の初期化 */ |
---|
| 163 | function lfInitFile() { |
---|
| 164 | $this->objUpFile->addFile("ロゴ画像", 'payment_image', array('gif'), IMAGE_SIZE, false, CLASS_IMAGE_WIDTH, CLASS_IMAGE_HEIGHT); |
---|
| 165 | return $this->objUpFile; |
---|
| 166 | } |
---|
| 167 | |
---|
| 168 | /* パラメータ情報の初期化 */ |
---|
| 169 | function lfInitParam() { |
---|
| 170 | $this->objFormParam->addParam("支払方法", "payment_method", STEXT_LEN, "KVa", array("EXIST_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 171 | $this->objFormParam->addParam("手数料", "charge", PRICE_LEN, "n", array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[17546] | 172 | $this->objFormParam->addParam("利用条件(~円以上)", "rule", PRICE_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 173 | $this->objFormParam->addParam("利用条件(~円以下)", "upper_rule", PRICE_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK")); |
---|
[15304] | 174 | $this->objFormParam->addParam("固定", "fix"); |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | /* DBからデータを読み込む */ |
---|
| 178 | function lfGetData($payment_id) { |
---|
| 179 | $objQuery = new SC_Query(); |
---|
| 180 | $where = "payment_id = ?"; |
---|
| 181 | $arrRet = $objQuery->select("*", "dtb_payment", $where, array($payment_id)); |
---|
| 182 | return $arrRet[0]; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | /* DBへデータを登録する */ |
---|
| 186 | function lfRegistData($payment_id = "") { |
---|
| 187 | |
---|
| 188 | $objQuery = new SC_Query(); |
---|
| 189 | $sqlval = $this->objFormParam->getHashArray(); |
---|
| 190 | $arrRet = $this->objUpFile->getDBFileList(); // ファイル名の取得 |
---|
| 191 | $sqlval = array_merge($sqlval, $arrRet); |
---|
| 192 | $sqlval['update_date'] = 'Now()'; |
---|
| 193 | |
---|
| 194 | if($sqlval['fix'] != '1') { |
---|
| 195 | $sqlval['fix'] = 2; // 自由設定 |
---|
| 196 | } |
---|
| 197 | |
---|
| 198 | // 新規登録 |
---|
| 199 | if($payment_id == "") { |
---|
| 200 | // INSERTの実行 |
---|
| 201 | $sqlval['creator_id'] = $_SESSION['member_id']; |
---|
[19732] | 202 | $sqlval['rank'] = $objQuery->max("rank", "dtb_payment") + 1; |
---|
[15304] | 203 | $sqlval['create_date'] = 'Now()'; |
---|
[18788] | 204 | $sqlval['payment_id'] = $objQuery->nextVal('dtb_payment_payment_id'); |
---|
[15304] | 205 | $objQuery->insert("dtb_payment", $sqlval); |
---|
| 206 | // 既存編集 |
---|
| 207 | } else { |
---|
| 208 | $where = "payment_id = ?"; |
---|
| 209 | $objQuery->update("dtb_payment", $sqlval, $where, array($payment_id)); |
---|
| 210 | } |
---|
| 211 | } |
---|
| 212 | |
---|
| 213 | /* 利用条件の数値チェック */ |
---|
| 214 | |
---|
| 215 | /* 入力内容のチェック */ |
---|
| 216 | function lfCheckError() { |
---|
| 217 | |
---|
| 218 | // DBのデータを取得 |
---|
| 219 | $arrPaymentData = $this->lfGetData($_POST['payment_id']); |
---|
| 220 | |
---|
| 221 | // 手数料を設定できない場合には、手数料を0にする |
---|
| 222 | if($arrPaymentData["charge_flg"] == 2) $this->objFormParam->setValue("charge", "0"); |
---|
| 223 | |
---|
| 224 | // 入力データを渡す。 |
---|
| 225 | $arrRet = $this->objFormParam->getHashArray(); |
---|
| 226 | $objErr = new SC_CheckError($arrRet); |
---|
| 227 | $objErr->arrErr = $this->objFormParam->checkError(); |
---|
| 228 | |
---|
| 229 | // 利用条件(下限)チェック |
---|
| 230 | if($arrRet["rule"] < $arrPaymentData["rule_min"] and $arrPaymentData["rule_min"] != ""){ |
---|
| 231 | $objErr->arrErr["rule"] = "利用条件(下限)は" . $arrPaymentData["rule_min"] ."円以上にしてください。<br>"; |
---|
| 232 | } |
---|
| 233 | |
---|
| 234 | // 利用条件(上限)チェック |
---|
| 235 | if($arrRet["upper_rule"] > $arrPaymentData["upper_rule_max"] and $arrPaymentData["upper_rule_max"] != ""){ |
---|
| 236 | $objErr->arrErr["upper_rule"] = "利用条件(上限)は" . $arrPaymentData["upper_rule_max"] ."円以下にしてください。<br>"; |
---|
| 237 | } |
---|
| 238 | |
---|
| 239 | // 利用条件チェック |
---|
[17546] | 240 | $objErr->doFunc(array("利用条件(~円以上)", "利用条件(~円以下)", "rule", "upper_rule"), array("GREATER_CHECK")); |
---|
[15304] | 241 | |
---|
| 242 | return $objErr->arrErr; |
---|
| 243 | } |
---|
| 244 | } |
---|
| 245 | ?> |
---|