[15307] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15307] | 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. |
---|
[15307] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15307] | 26 | |
---|
| 27 | /** |
---|
| 28 | * ポイント設定 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[22567] | 34 | class LC_Page_Admin_Basis_Point extends LC_Page_Admin_Ex |
---|
| 35 | { |
---|
[15307] | 36 | |
---|
| 37 | // }}} |
---|
| 38 | // {{{ functions |
---|
| 39 | |
---|
| 40 | /** |
---|
| 41 | * Page を初期化する. |
---|
| 42 | * |
---|
| 43 | * @return void |
---|
| 44 | */ |
---|
[22567] | 45 | function init() |
---|
| 46 | { |
---|
[15307] | 47 | parent::init(); |
---|
| 48 | $this->tpl_mainpage = 'basis/point.tpl'; |
---|
| 49 | $this->tpl_subno = 'point'; |
---|
| 50 | $this->tpl_mainno = 'basis'; |
---|
[20911] | 51 | $this->tpl_maintitle = '基本情報管理'; |
---|
[15307] | 52 | $this->tpl_subtitle = 'ポイント設定'; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | /** |
---|
| 56 | * Page のプロセス. |
---|
| 57 | * |
---|
| 58 | * @return void |
---|
| 59 | */ |
---|
[22567] | 60 | function process() |
---|
| 61 | { |
---|
[19661] | 62 | $this->action(); |
---|
| 63 | $this->sendResponse(); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | /** |
---|
| 67 | * Page のアクション. |
---|
| 68 | * |
---|
| 69 | * @return void |
---|
| 70 | */ |
---|
[22567] | 71 | function action() |
---|
| 72 | { |
---|
[21591] | 73 | |
---|
[20171] | 74 | $objDb = new SC_Helper_DB_Ex(); |
---|
[20970] | 75 | // パラメーター管理クラス |
---|
[20501] | 76 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20970] | 77 | // パラメーター情報の初期化 |
---|
[20339] | 78 | $this->lfInitParam($objFormParam); |
---|
[15307] | 79 | // POST値の取得 |
---|
[20339] | 80 | $objFormParam->setParam($_POST); |
---|
[15307] | 81 | |
---|
[21376] | 82 | if ($objDb->sfGetBasisExists()) { |
---|
[20538] | 83 | $this->tpl_mode = 'update'; |
---|
[15307] | 84 | } else { |
---|
[20538] | 85 | $this->tpl_mode = 'insert'; |
---|
[15307] | 86 | } |
---|
[20166] | 87 | |
---|
[21441] | 88 | if (!empty($_POST)) { |
---|
[15307] | 89 | // 入力値の変換 |
---|
[20339] | 90 | $objFormParam->convParam(); |
---|
| 91 | $this->arrErr = $objFormParam->checkError(); |
---|
[15307] | 92 | |
---|
[21441] | 93 | if (count($this->arrErr) == 0) { |
---|
| 94 | switch ($this->getMode()) { |
---|
[21526] | 95 | case 'update': |
---|
| 96 | $this->lfUpdateData($objFormParam->getHashArray()); // 既存編集 |
---|
| 97 | break; |
---|
| 98 | case 'insert': |
---|
| 99 | $this->lfInsertData($objFormParam->getHashArray()); // 新規作成 |
---|
| 100 | break; |
---|
| 101 | default: |
---|
| 102 | break; |
---|
[15307] | 103 | } |
---|
| 104 | // 再表示 |
---|
| 105 | $this->tpl_onload = "window.alert('ポイント設定が完了しました。');"; |
---|
| 106 | } |
---|
| 107 | } else { |
---|
[20339] | 108 | $arrCol = $objFormParam->getKeyList(); // キー名一覧を取得 |
---|
[20166] | 109 | $col = SC_Utils_Ex::sfGetCommaList($arrCol); |
---|
[20171] | 110 | $arrRet = $objDb->sfGetBasisData(true, $col); |
---|
[20339] | 111 | $objFormParam->setParam($arrRet); |
---|
[15307] | 112 | } |
---|
[20339] | 113 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[21591] | 114 | |
---|
[15307] | 115 | } |
---|
| 116 | |
---|
| 117 | /** |
---|
| 118 | * デストラクタ. |
---|
| 119 | * |
---|
| 120 | * @return void |
---|
| 121 | */ |
---|
[22567] | 122 | function destroy() |
---|
| 123 | { |
---|
[15307] | 124 | parent::destroy(); |
---|
| 125 | } |
---|
| 126 | |
---|
[20970] | 127 | /* パラメーター情報の初期化 */ |
---|
[22567] | 128 | function lfInitParam(&$objFormParam) |
---|
| 129 | { |
---|
[21514] | 130 | $objFormParam->addParam('ポイント付与率', 'point_rate', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 131 | $objFormParam->addParam('会員登録時付与ポイント', 'welcome_point', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
[15307] | 132 | } |
---|
| 133 | |
---|
[22567] | 134 | function lfUpdateData($post) |
---|
| 135 | { |
---|
[15307] | 136 | // 入力データを渡す。 |
---|
[20297] | 137 | $sqlval = $post; |
---|
[21185] | 138 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20507] | 139 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[15307] | 140 | // UPDATEの実行 |
---|
[21481] | 141 | $ret = $objQuery->update('dtb_baseinfo', $sqlval); |
---|
[15307] | 142 | } |
---|
| 143 | |
---|
[22567] | 144 | function lfInsertData($post) |
---|
| 145 | { |
---|
[15307] | 146 | // 入力データを渡す。 |
---|
[20297] | 147 | $sqlval = $post; |
---|
[21810] | 148 | $sqlval['id'] = 1; |
---|
[21185] | 149 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[20507] | 150 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[15307] | 151 | // INSERTの実行 |
---|
[21481] | 152 | $ret = $objQuery->insert('dtb_baseinfo', $sqlval); |
---|
[15307] | 153 | } |
---|
| 154 | } |
---|