[15304] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[20764] | 5 | * Copyright(c) 2000-2011 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 |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15304] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 支払方法設定 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20543] | 34 | class LC_Page_Admin_Basis_PaymentInput extends LC_Page_Admin_Ex { |
---|
[15304] | 35 | |
---|
| 36 | // {{{ properties |
---|
| 37 | |
---|
| 38 | /** SC_UploadFile インスタンス */ |
---|
| 39 | var $objUpFile; |
---|
| 40 | |
---|
| 41 | // }}} |
---|
| 42 | // {{{ functions |
---|
| 43 | |
---|
| 44 | /** |
---|
| 45 | * Page を初期化する. |
---|
| 46 | * |
---|
| 47 | * @return void |
---|
| 48 | */ |
---|
| 49 | function init() { |
---|
| 50 | parent::init(); |
---|
| 51 | $this->tpl_mainpage = 'basis/payment_input.tpl'; |
---|
[20664] | 52 | $this->tpl_mainno = 'basis'; |
---|
| 53 | $this->tpl_subno = 'payment'; |
---|
[20911] | 54 | $this->tpl_maintitle = '基本情報管理'; |
---|
[15304] | 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() { |
---|
[21592] | 74 | |
---|
[20501] | 75 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20339] | 76 | $mode = $this->getMode(); |
---|
[20624] | 77 | $this->lfInitParam($mode, $objFormParam); |
---|
[20339] | 78 | |
---|
[15304] | 79 | // ファイル管理クラス |
---|
[19805] | 80 | $this->objUpFile = new SC_UploadFile(IMAGE_TEMP_REALDIR, IMAGE_SAVE_REALDIR); |
---|
[15304] | 81 | // ファイル情報の初期化 |
---|
| 82 | $this->objUpFile = $this->lfInitFile(); |
---|
| 83 | // Hiddenからのデータを引き継ぐ |
---|
| 84 | $this->objUpFile->setHiddenFileList($_POST); |
---|
| 85 | |
---|
[21441] | 86 | switch ($mode) { |
---|
[21526] | 87 | case 'edit': |
---|
| 88 | $objFormParam->setParam($_REQUEST); |
---|
| 89 | $objFormParam->convParam(); |
---|
| 90 | $post = $objFormParam->getHashArray(); |
---|
| 91 | $this->arrErr = $this->lfCheckError($post, $objFormParam); |
---|
| 92 | $this->charge_flg = $post['charge_flg']; |
---|
| 93 | if (count($this->arrErr) == 0) { |
---|
| 94 | $this->lfRegistData($post['payment_id'], $_SESSION['member_id'], $objFormParam); |
---|
| 95 | $this->objUpFile->moveTempFile(); |
---|
| 96 | $this->tpl_onload = "location.href = './payment.php'; return;"; |
---|
| 97 | } |
---|
| 98 | $this->tpl_payment_id = $post['payment_id']; |
---|
| 99 | break; |
---|
| 100 | // 画像のアップロード |
---|
| 101 | case 'upload_image': |
---|
| 102 | $objFormParam->setParam($_REQUEST); |
---|
| 103 | $objFormParam->convParam(); |
---|
| 104 | $post = $objFormParam->getHashArray(); |
---|
| 105 | // ファイル存在チェック |
---|
| 106 | $this->arrErr = $this->objUpFile->checkEXISTS($post['image_key']); |
---|
| 107 | // 画像保存処理 |
---|
| 108 | $this->arrErr[$post['image_key']] = $this->objUpFile->makeTempFile($post['image_key']); |
---|
| 109 | $this->tpl_payment_id = $post['payment_id']; |
---|
| 110 | break; |
---|
| 111 | // 画像の削除 |
---|
| 112 | case 'delete_image': |
---|
| 113 | $objFormParam->setParam($_REQUEST); |
---|
| 114 | $objFormParam->convParam(); |
---|
| 115 | $this->arrErr = $objFormParam->checkError(); |
---|
| 116 | $post = $objFormParam->getHashArray(); |
---|
| 117 | if (count($this->arrErr) == 0) { |
---|
| 118 | $this->objUpFile->deleteFile($post['image_key']); |
---|
| 119 | } |
---|
| 120 | $this->tpl_payment_id = $post['payment_id']; |
---|
| 121 | break; |
---|
[20166] | 122 | |
---|
[21526] | 123 | case 'pre_edit': |
---|
| 124 | $objFormParam->setParam($_REQUEST); |
---|
| 125 | $objFormParam->convParam(); |
---|
| 126 | $this->arrErr = $objFormParam->checkError(); |
---|
| 127 | $post = $objFormParam->getHashArray(); |
---|
| 128 | if (count($this->arrErr) == 0) { |
---|
| 129 | $arrRet = $this->lfGetData($post['payment_id']); |
---|
[20540] | 130 | |
---|
[21526] | 131 | $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 132 | $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21810] | 133 | $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21526] | 134 | $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 135 | $objFormParam->addParam('固定', 'fix'); |
---|
| 136 | $objFormParam->setParam($arrRet); |
---|
[20339] | 137 | |
---|
[21526] | 138 | $this->charge_flg = $arrRet['charge_flg']; |
---|
| 139 | $this->objUpFile->setDBFileList($arrRet); |
---|
| 140 | } |
---|
| 141 | $this->tpl_payment_id = $post['payment_id']; |
---|
| 142 | break; |
---|
| 143 | default: |
---|
| 144 | break; |
---|
[15304] | 145 | } |
---|
| 146 | |
---|
[20339] | 147 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[15304] | 148 | |
---|
| 149 | // FORM表示用配列を渡す。 |
---|
[19943] | 150 | $this->arrFile = $this->objUpFile->getFormFileList(IMAGE_TEMP_URLPATH, IMAGE_SAVE_URLPATH); |
---|
[15304] | 151 | // HIDDEN用に配列を渡す。 |
---|
| 152 | $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objUpFile->getHiddenFileList()); |
---|
[21591] | 153 | |
---|
[15304] | 154 | } |
---|
| 155 | |
---|
| 156 | /** |
---|
| 157 | * デストラクタ. |
---|
| 158 | * |
---|
| 159 | * @return void |
---|
| 160 | */ |
---|
| 161 | function destroy() { |
---|
| 162 | parent::destroy(); |
---|
| 163 | } |
---|
| 164 | |
---|
| 165 | /* ファイル情報の初期化 */ |
---|
| 166 | function lfInitFile() { |
---|
[21525] | 167 | $this->objUpFile->addFile('ロゴ画像', 'payment_image', array('gif','jpeg','jpg','png'), IMAGE_SIZE, false, CLASS_IMAGE_WIDTH, CLASS_IMAGE_HEIGHT); |
---|
[15304] | 168 | return $this->objUpFile; |
---|
| 169 | } |
---|
| 170 | |
---|
[20970] | 171 | /* パラメーター情報の初期化 */ |
---|
[20339] | 172 | function lfInitParam($mode, &$objFormParam) { |
---|
| 173 | |
---|
| 174 | switch ($mode) { |
---|
[20538] | 175 | case 'edit': |
---|
[21514] | 176 | $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 177 | $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21810] | 178 | $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21514] | 179 | $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 180 | $objFormParam->addParam('固定', 'fix'); |
---|
[20339] | 181 | $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 182 | $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 183 | |
---|
| 184 | break; |
---|
[21481] | 185 | case 'upload_image': |
---|
| 186 | case 'delete_image': |
---|
[20664] | 187 | $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21514] | 188 | $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 189 | $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21810] | 190 | $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21514] | 191 | $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 192 | $objFormParam->addParam('固定', 'fix'); |
---|
| 193 | $objFormParam->addParam('画像キー', 'image_key', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[20339] | 194 | |
---|
| 195 | break; |
---|
[21481] | 196 | case 'pre_edit': |
---|
[20339] | 197 | $objFormParam->addParam('支払いID', 'payment_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 198 | $objFormParam->addParam('課金フラグ', 'charge_flg', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 199 | break; |
---|
| 200 | |
---|
| 201 | default: |
---|
[21514] | 202 | $objFormParam->addParam('支払方法', 'payment_method', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 203 | $objFormParam->addParam('手数料', 'charge', PRICE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21810] | 204 | $objFormParam->addParam('利用条件(~円以上)', 'rule_max', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[21514] | 205 | $objFormParam->addParam('利用条件(~円以下)', 'upper_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 206 | $objFormParam->addParam('固定', 'fix'); |
---|
[20624] | 207 | |
---|
[20339] | 208 | break; |
---|
| 209 | } |
---|
[15304] | 210 | } |
---|
| 211 | |
---|
| 212 | /* DBからデータを読み込む */ |
---|
| 213 | function lfGetData($payment_id) { |
---|
[20507] | 214 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[21514] | 215 | $where = 'payment_id = ?'; |
---|
| 216 | $arrRet = $objQuery->select('*', 'dtb_payment', $where, array($payment_id)); |
---|
[15304] | 217 | return $arrRet[0]; |
---|
| 218 | } |
---|
| 219 | |
---|
| 220 | /* DBへデータを登録する */ |
---|
[21514] | 221 | function lfRegistData($payment_id = '', $member_id, &$objFormParam) { |
---|
[15304] | 222 | |
---|
[20507] | 223 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20339] | 224 | $sqlval = $objFormParam->getHashArray(); |
---|
[20562] | 225 | $arrRet = $this->objUpFile->getDBFileList(); // ファイル名の取得 |
---|
[15304] | 226 | $sqlval = array_merge($sqlval, $arrRet); |
---|
[21185] | 227 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[15304] | 228 | |
---|
[21441] | 229 | if ($sqlval['fix'] != '1') { |
---|
[20562] | 230 | $sqlval['fix'] = 2; // 自由設定 |
---|
[15304] | 231 | } |
---|
| 232 | |
---|
| 233 | // 新規登録 |
---|
[21514] | 234 | if ($payment_id == '') { |
---|
[15304] | 235 | // INSERTの実行 |
---|
[20297] | 236 | $sqlval['creator_id'] = $member_id; |
---|
[21481] | 237 | $sqlval['rank'] = $objQuery->max('rank', 'dtb_payment') + 1; |
---|
[21185] | 238 | $sqlval['create_date'] = 'CURRENT_TIMESTAMP'; |
---|
[18788] | 239 | $sqlval['payment_id'] = $objQuery->nextVal('dtb_payment_payment_id'); |
---|
[21481] | 240 | $objQuery->insert('dtb_payment', $sqlval); |
---|
[15304] | 241 | // 既存編集 |
---|
| 242 | } else { |
---|
[21514] | 243 | $where = 'payment_id = ?'; |
---|
[21481] | 244 | $objQuery->update('dtb_payment', $sqlval, $where, array($payment_id)); |
---|
[15304] | 245 | } |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | /* 利用条件の数値チェック */ |
---|
| 249 | |
---|
| 250 | /* 入力内容のチェック */ |
---|
[20931] | 251 | function lfCheckError($post, $objFormParam) { |
---|
[15304] | 252 | |
---|
| 253 | // DBのデータを取得 |
---|
[20297] | 254 | $arrPaymentData = $this->lfGetData($post['payment_id']); |
---|
[15304] | 255 | |
---|
| 256 | // 手数料を設定できない場合には、手数料を0にする |
---|
[21684] | 257 | if ($arrPaymentData['charge_flg'] == 2) { |
---|
| 258 | $objFormParam->setValue('charge', '0'); |
---|
| 259 | } |
---|
[15304] | 260 | |
---|
| 261 | // 入力データを渡す。 |
---|
[20929] | 262 | $arrRet = $objFormParam->getHashArray(); |
---|
[20503] | 263 | $objErr = new SC_CheckError_Ex($arrRet); |
---|
[20929] | 264 | $objErr->arrErr = $objFormParam->checkError(); |
---|
[15304] | 265 | |
---|
| 266 | // 利用条件(下限)チェック |
---|
[21810] | 267 | if ($arrRet['rule_max'] < $arrPaymentData['rule_min'] and $arrPaymentData['rule_min'] != '') { |
---|
[21515] | 268 | $objErr->arrErr['rule'] = '利用条件(下限)は' . $arrPaymentData['rule_min'] .'円以上にしてください。<br>'; |
---|
[15304] | 269 | } |
---|
| 270 | |
---|
| 271 | // 利用条件(上限)チェック |
---|
[21515] | 272 | if ($arrRet['upper_rule'] > $arrPaymentData['upper_rule_max'] and $arrPaymentData['upper_rule_max'] != '') { |
---|
| 273 | $objErr->arrErr['upper_rule'] = '利用条件(上限)は' . $arrPaymentData['upper_rule_max'] .'円以下にしてください。<br>'; |
---|
[15304] | 274 | } |
---|
| 275 | |
---|
| 276 | // 利用条件チェック |
---|
[21810] | 277 | $objErr->doFunc(array('利用条件(~円以上)', '利用条件(~円以下)', 'rule_max', 'upper_rule'), array('GREATER_CHECK')); |
---|
[15304] | 278 | |
---|
| 279 | return $objErr->arrErr; |
---|
| 280 | } |
---|
| 281 | } |
---|