[15291] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[21867] | 5 | * Copyright(c) 2000-2012 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15291] | 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. |
---|
[15291] | 22 | */ |
---|
| 23 | |
---|
| 24 | // {{{ requires |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php'; |
---|
[15291] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 店舗基本情報 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20345] | 34 | class LC_Page_Admin_Basis extends LC_Page_Admin_Ex { |
---|
[15291] | 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | $this->tpl_mainpage = 'basis/index.tpl'; |
---|
| 47 | $this->tpl_subno = 'index'; |
---|
| 48 | $this->tpl_mainno = 'basis'; |
---|
| 49 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[19773] | 50 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[21481] | 51 | $this->arrTAXRULE = $masterData->getMasterData('mtb_taxrule'); |
---|
[22100] | 52 | $this->tpl_maintitle = t('TPL_MAINTITLE_006'); |
---|
| 53 | $this->tpl_subtitle = t('LC_Page_Admin_Basis_002');; |
---|
[17623] | 54 | |
---|
| 55 | //定休日用配列 |
---|
[22100] | 56 | $this->arrRegularHoliday[0] = t('LC_Page_Admin_Basis_003'); |
---|
| 57 | $this->arrRegularHoliday[1] = t('LC_Page_Admin_Basis_004'); |
---|
| 58 | $this->arrRegularHoliday[2] = t('LC_Page_Admin_Basis_005'); |
---|
| 59 | $this->arrRegularHoliday[3] = t('LC_Page_Admin_Basis_006'); |
---|
| 60 | $this->arrRegularHoliday[4] = t('LC_Page_Admin_Basis_007'); |
---|
| 61 | $this->arrRegularHoliday[5] = t('LC_Page_Admin_Basis_008'); |
---|
| 62 | $this->arrRegularHoliday[6] = t('LC_Page_Admin_Basis_009'); |
---|
[15291] | 63 | } |
---|
| 64 | |
---|
| 65 | /** |
---|
| 66 | * Page のプロセス. |
---|
| 67 | * |
---|
| 68 | * @return void |
---|
| 69 | */ |
---|
| 70 | function process() { |
---|
[19661] | 71 | $this->action(); |
---|
| 72 | $this->sendResponse(); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | /** |
---|
| 76 | * Page のアクション. |
---|
| 77 | * |
---|
| 78 | * @return void |
---|
| 79 | */ |
---|
| 80 | function action() { |
---|
[21592] | 81 | |
---|
[20171] | 82 | $objDb = new SC_Helper_DB_Ex(); |
---|
[15291] | 83 | |
---|
[21376] | 84 | if ($objDb->sfGetBasisExists()) { |
---|
[20538] | 85 | $this->tpl_mode = 'update'; |
---|
[15291] | 86 | } else { |
---|
[20538] | 87 | $this->tpl_mode = 'insert'; |
---|
[15291] | 88 | } |
---|
[20166] | 89 | |
---|
[21441] | 90 | if (!empty($_POST)) { |
---|
[15291] | 91 | |
---|
[20501] | 92 | $objFormParam = new SC_FormParam_Ex(); |
---|
[20339] | 93 | $this->lfInitParam($objFormParam, $_POST); |
---|
| 94 | $objFormParam->setParam($_POST); |
---|
| 95 | $objFormParam->convParam(); |
---|
[15291] | 96 | |
---|
[21883] | 97 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
[20339] | 98 | $post = $objFormParam->getHashArray(); |
---|
| 99 | |
---|
| 100 | $this->arrForm = $post; |
---|
| 101 | |
---|
[21441] | 102 | if (count($this->arrErr) == 0) { |
---|
| 103 | switch ($this->getMode()) { |
---|
[20562] | 104 | // 既存編集 |
---|
| 105 | case 'update': |
---|
| 106 | $this->lfUpdateData($this->arrForm); |
---|
| 107 | break; |
---|
| 108 | // 新規作成 |
---|
| 109 | case 'insert': |
---|
| 110 | $this->lfInsertData($this->arrForm); |
---|
| 111 | break; |
---|
| 112 | default: |
---|
| 113 | break; |
---|
[15291] | 114 | } |
---|
[22100] | 115 | $this->tpl_onload = "fnCheckLimit('downloadable_days', 'downloadable_days_unlimited', '" . DISABLED_RGB . "'); window.alert(" . t('LC_Page_Admin_Basis_011') .");"; |
---|
[15291] | 116 | } |
---|
[21442] | 117 | if (empty($this->arrForm['regular_holiday_ids'])) { |
---|
[17623] | 118 | $this->arrSel = array(); |
---|
| 119 | } else { |
---|
| 120 | $this->arrSel = $this->arrForm['regular_holiday_ids']; |
---|
| 121 | } |
---|
[15291] | 122 | } else { |
---|
| 123 | $arrCol = $this->lfGetCol(); |
---|
[20168] | 124 | $col = SC_Utils_Ex::sfGetCommaList($arrCol); |
---|
[20171] | 125 | $arrRet = $objDb->sfGetBasisData(true, $col); |
---|
| 126 | $this->arrForm = $arrRet; |
---|
[17623] | 127 | |
---|
| 128 | $regular_holiday_ids = explode('|', $this->arrForm['regular_holiday_ids']); |
---|
| 129 | $this->arrForm['regular_holiday_ids'] = $regular_holiday_ids; |
---|
[18777] | 130 | $this->tpl_onload = "fnCheckLimit('downloadable_days', 'downloadable_days_unlimited', '" . DISABLED_RGB . "');"; |
---|
[15291] | 131 | } |
---|
[21743] | 132 | |
---|
[15291] | 133 | } |
---|
| 134 | |
---|
| 135 | /** |
---|
| 136 | * デストラクタ. |
---|
| 137 | * |
---|
| 138 | * @return void |
---|
| 139 | */ |
---|
| 140 | function destroy() { |
---|
| 141 | parent::destroy(); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | // 基本情報用のカラムを取り出す。 |
---|
| 145 | function lfGetCol() { |
---|
| 146 | $arrCol = array( |
---|
[21481] | 147 | 'company_name', |
---|
| 148 | 'company_kana', |
---|
| 149 | 'shop_name', |
---|
| 150 | 'shop_kana', |
---|
| 151 | 'shop_name_eng', |
---|
[22205] | 152 | // 'zip01', |
---|
| 153 | // 'zip02', |
---|
| 154 | 'zipcode', |
---|
[20538] | 155 | 'pref', |
---|
[21481] | 156 | 'addr01', |
---|
| 157 | 'addr02', |
---|
| 158 | 'tel01', |
---|
| 159 | 'tel02', |
---|
| 160 | 'tel03', |
---|
| 161 | 'fax01', |
---|
| 162 | 'fax02', |
---|
| 163 | 'fax03', |
---|
| 164 | 'business_hour', |
---|
| 165 | 'email01', |
---|
| 166 | 'email02', |
---|
| 167 | 'email03', |
---|
| 168 | 'email04', |
---|
[20538] | 169 | 'tax', |
---|
[21481] | 170 | 'tax_rule', |
---|
| 171 | 'free_rule', |
---|
| 172 | 'good_traded', |
---|
[20538] | 173 | 'message', |
---|
[21481] | 174 | 'regular_holiday_ids', |
---|
[20538] | 175 | 'latitude', |
---|
| 176 | 'longitude', |
---|
[21481] | 177 | 'downloadable_days', |
---|
| 178 | 'downloadable_days_unlimited' |
---|
[15291] | 179 | ); |
---|
| 180 | return $arrCol; |
---|
| 181 | } |
---|
| 182 | |
---|
| 183 | function lfUpdateData($array) { |
---|
[20507] | 184 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[15291] | 185 | $arrCol = $this->lfGetCol(); |
---|
[21441] | 186 | foreach ($arrCol as $val) { |
---|
[17623] | 187 | //配列の場合は、パイプ区切りの文字列に変換 |
---|
[21441] | 188 | if (is_array($array[$val])) { |
---|
[21514] | 189 | $sqlval[$val] = implode('|', $array[$val]); |
---|
[17623] | 190 | } else { |
---|
| 191 | $sqlval[$val] = $array[$val]; |
---|
| 192 | } |
---|
[15291] | 193 | } |
---|
[21185] | 194 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[15291] | 195 | // UPDATEの実行 |
---|
[21481] | 196 | $ret = $objQuery->update('dtb_baseinfo', $sqlval); |
---|
[21027] | 197 | |
---|
[22100] | 198 | GC_Utils_Ex::gfPrintLog(t('LC_Page_Admin_Basis_012')); |
---|
[15291] | 199 | } |
---|
| 200 | |
---|
| 201 | function lfInsertData($array) { |
---|
[20507] | 202 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[15291] | 203 | $arrCol = $this->lfGetCol(); |
---|
[21441] | 204 | foreach ($arrCol as $val) { |
---|
[15291] | 205 | $sqlval[$val] = $array[$val]; |
---|
| 206 | } |
---|
[21810] | 207 | $sqlval['id'] = 1; |
---|
[21185] | 208 | $sqlval['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
[15291] | 209 | // INSERTの実行 |
---|
[21481] | 210 | $ret = $objQuery->insert('dtb_baseinfo', $sqlval); |
---|
[21027] | 211 | |
---|
[22100] | 212 | GC_Utils_Ex::gfPrintLog(t('LC_Page_Admin_Basis_013')); |
---|
[15291] | 213 | } |
---|
[19859] | 214 | |
---|
[20339] | 215 | function lfInitParam(&$objFormParam, $post) { |
---|
[22100] | 216 | $objFormParam->addParam(t('PARAM_LABEL_COMPANY_NAME'), 'company_name', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 217 | $objFormParam->addParam(t('PARAM_LABEL_COMPANY_KANA'), 'company_kana', STEXT_LEN, 'KVC', array('KANA_CHECK','MAX_LENGTH_CHECK')); |
---|
[20041] | 218 | |
---|
[22100] | 219 | $objFormParam->addParam(t('PARAM_LABEL_SHOP_NAME'), 'shop_name', STEXT_LEN, 'KVa', array('EXIST_CHECK','MAX_LENGTH_CHECK')); |
---|
| 220 | $objFormParam->addParam(t('PARAM_LABEL_SHOP_KANA'), 'shop_kana', STEXT_LEN, 'KVC', array('KANA_CHECK','MAX_LENGTH_CHECK')); |
---|
| 221 | $objFormParam->addParam(t('PARAM_LABEL_SHOP_NAME_ENG'), 'shop_name_eng',MTEXT_LEN, 'a', array('GRAPH_CHECK','MAX_LENGTH_CHECK')); |
---|
[20339] | 222 | // 郵便番号チェック |
---|
[22205] | 223 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK','NUM_COUNT_CHECK')); |
---|
| 224 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK','NUM_COUNT_CHECK')); |
---|
| 225 | $objFormParam->addParam(t('PARAM_LABEL_ZIP'), 'zipcode', ZIPCODE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK','MAX_LENGTH_CHECK')); |
---|
| 226 | |
---|
[21719] | 227 | // 所在地チェック |
---|
[22179] | 228 | $objFormParam->addParam(t('PARAM_LABEL_PREF'), 'pref', '', 'n'); |
---|
[22100] | 229 | $objFormParam->addParam(t('PARAM_LABEL_ADDR01'), 'addr01', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 230 | $objFormParam->addParam(t('PARAM_LABEL_ADDR02'), 'addr02', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[20339] | 231 | // メールチェック |
---|
[22100] | 232 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL01'), 'email01', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
| 233 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL02'), 'email02', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
| 234 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL03'), 'email03', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
| 235 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL04'), 'email04', null, 'a', array('EXIST_CHECK', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
[15291] | 236 | |
---|
[20339] | 237 | // 電話番号 |
---|
[22100] | 238 | $objFormParam->addParam(t('PARAM_LABEL_TEL01'), 'tel01', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 239 | $objFormParam->addParam(t('PARAM_LABEL_TEL02'), 'tel02', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 240 | $objFormParam->addParam(t('PARAM_LABEL_TEL03'), 'tel03', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[15291] | 241 | |
---|
[20339] | 242 | // FAX番号 |
---|
[22100] | 243 | $objFormParam->addParam(t('PARAM_LABEL_FAX01'), 'fax01', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 244 | $objFormParam->addParam(t('PARAM_LABEL_FAX02'), 'fax02', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 245 | $objFormParam->addParam(t('PARAM_LABEL_FAX03'), 'fax03', TEL_ITEM_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[20339] | 246 | |
---|
| 247 | // その他 |
---|
[22100] | 248 | $objFormParam->addParam(t('PARAM_LABEL_TAX'), 'tax', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 249 | $objFormParam->addParam(t('PARAM_LABEL_TAX_RULE'), 'tax_rule', PERCENTAGE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 250 | $objFormParam->addParam(t('PARAM_LABEL_FREE_RULE'), 'free_rule', PRICE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 251 | $objFormParam->addParam(t('PARAM_LABEL_BUSINESS_HOUR'), 'business_hour', STEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
[20339] | 252 | |
---|
[22100] | 253 | $objFormParam->addParam(t('PARAM_LABEL_GOOD_TRADED'), 'good_traded', LLTEXT_LEN, '', array('MAX_LENGTH_CHECK')); |
---|
| 254 | $objFormParam->addParam(t('PARAM_LABEL_MESSAGE'), 'message', LLTEXT_LEN, '', array('MAX_LENGTH_CHECK')); |
---|
[20339] | 255 | |
---|
[21481] | 256 | if (!isset($post['downloadable_days_unlimited']) && $post['downloadable_days_unlimited'] != '1') { |
---|
[22100] | 257 | $objFormParam->addParam(t('PARAM_LABEL_DOWNLOADABLE_DAYS'), 'downloadable_days', DOWNLOAD_DAYS_LEN, 'n', array('EXIST_CHECK', 'ZERO_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[20339] | 258 | } else { |
---|
[22100] | 259 | $objFormParam->addParam(t('PARAM_LABEL_DOWNLOADABLE_DAYS_UNLIMITED'), 'downloadable_days_unlimited', array('EXIST_CHECK')); |
---|
[20339] | 260 | } |
---|
[22100] | 261 | $objFormParam->addParam(t('PARAM_LABEL_LATITUDE'), 'latitude', STEXT_LEN, '', array('MAX_LENGTH_CHECK')); |
---|
| 262 | $objFormParam->addParam(t('PARAM_LABEL_LONGITUDE'), 'longitude', STEXT_LEN, '', array('MAX_LENGTH_CHECK')); |
---|
[20339] | 263 | |
---|
[22100] | 264 | $objFormParam->addParam(t('PARAM_LABEL_REGULAR_HOLIDAY'), 'regular_holiday_ids', INT_LEN, 'n', array('MAX_LENGTH_CHECK')); |
---|
[15291] | 265 | } |
---|
| 266 | |
---|
| 267 | // 入力エラーチェック |
---|
[21883] | 268 | function lfCheckError(&$objFormParam) { |
---|
[20339] | 269 | $arrErr = $objFormParam->checkError(); |
---|
| 270 | $post = $objFormParam->getHashArray(); |
---|
[15291] | 271 | |
---|
[20503] | 272 | $objErr = new SC_CheckError_Ex($post); |
---|
[22205] | 273 | // $objErr->doFunc(array(t('PARAM_LABEL_ZIP'), 'zip01', 'zip02'), array('ALL_EXIST_CHECK')); |
---|
[19856] | 274 | |
---|
[15291] | 275 | // 電話番号チェック |
---|
[22100] | 276 | $objErr->doFunc(array(t('PARAM_LABEL_TEL'), 'tel01', 'tel02', 'tel03'), array('TEL_CHECK')); |
---|
| 277 | $objErr->doFunc(array(t('PARAM_LABEL_FAX_NUMBER'), 'fax01', 'fax02', 'fax03'), array('TEL_CHECK')); |
---|
[15291] | 278 | |
---|
[22100] | 279 | $objErr->doFunc(array(t('PARAM_LABEL_LATITUDE'), 'latitude', STEXT_LEN), array('NUM_POINT_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 280 | $objErr->doFunc(array(t('PARAM_LABEL_LONGITUDE'), 'longitude', STEXT_LEN), array('NUM_POINT_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[20339] | 281 | |
---|
[21659] | 282 | return array_merge((array)$arrErr, (array)$objErr->arrErr); |
---|
[15291] | 283 | } |
---|
| 284 | } |
---|