| 1 | <?php |
---|
| 2 | /* |
---|
| 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
| 5 | * Copyright(c) 2000-2012 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 |
---|
| 25 | require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
| 26 | |
---|
| 27 | /** |
---|
| 28 | * ショッピングログインのページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
| 34 | class LC_Page_Shopping extends LC_Page_Ex { |
---|
| 35 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | $this->tpl_title = t('LC_Page_Shopping_001'); |
---|
| 47 | $masterData = new SC_DB_MasterData_Ex(); |
---|
| 48 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
| 49 | $this->arrSex = $masterData->getMasterData('mtb_sex'); |
---|
| 50 | $this->arrJob = $masterData->getMasterData('mtb_job'); |
---|
| 51 | $this->tpl_onload = 'fnCheckInputDeliv();'; |
---|
| 52 | |
---|
| 53 | $objDate = new SC_Date_Ex(BIRTH_YEAR, date('Y',strtotime('now'))); |
---|
| 54 | $this->arrYear = $objDate->getYear('', START_BIRTH_YEAR, ''); |
---|
| 55 | $this->arrMonth = $objDate->getMonth(true); |
---|
| 56 | $this->arrDay = $objDate->getDay(true); |
---|
| 57 | |
---|
| 58 | $this->httpCacheControl('nocache'); |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | /** |
---|
| 62 | * Page のプロセス. |
---|
| 63 | * |
---|
| 64 | * @return void |
---|
| 65 | */ |
---|
| 66 | function process() { |
---|
| 67 | parent::process(); |
---|
| 68 | $this->action(); |
---|
| 69 | $this->sendResponse(); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | /** |
---|
| 73 | * Page のプロセス. |
---|
| 74 | * |
---|
| 75 | * @return void |
---|
| 76 | */ |
---|
| 77 | function action() { |
---|
| 78 | |
---|
| 79 | $objSiteSess = new SC_SiteSession_Ex(); |
---|
| 80 | $objCartSess = new SC_CartSession_Ex(); |
---|
| 81 | $objCustomer = new SC_Customer_Ex(); |
---|
| 82 | $objCookie = new SC_Cookie_Ex(); |
---|
| 83 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 84 | $objFormParam = new SC_FormParam_Ex(); |
---|
| 85 | |
---|
| 86 | $nonmember_mainpage = 'shopping/nonmember_input.tpl'; |
---|
| 87 | $nonmember_title = t('LC_Page_Shopping_002'); |
---|
| 88 | |
---|
| 89 | $this->tpl_uniqid = $objSiteSess->getUniqId(); |
---|
| 90 | $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); |
---|
| 91 | |
---|
| 92 | $this->cartKey = $objCartSess->getKey(); |
---|
| 93 | |
---|
| 94 | // ログイン済みの場合は次画面に遷移 |
---|
| 95 | if ($objCustomer->isLoginSuccess(true)) { |
---|
| 96 | |
---|
| 97 | SC_Response_Ex::sendRedirect( |
---|
| 98 | $this->getNextlocation($this->cartKey, $this->tpl_uniqid, |
---|
| 99 | $objCustomer, $objPurchase, |
---|
| 100 | $objSiteSess)); |
---|
| 101 | SC_Response_Ex::actionExit(); |
---|
| 102 | } |
---|
| 103 | // 非会員かつ, ダウンロード商品の場合はエラー表示 |
---|
| 104 | else { |
---|
| 105 | if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) { |
---|
| 106 | $msg = t('LC_Page_Shopping_003'); |
---|
| 107 | SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, $objSiteSess, false, $msg); |
---|
| 108 | SC_Response_Ex::actionExit(); |
---|
| 109 | } |
---|
| 110 | } |
---|
| 111 | |
---|
| 112 | switch ($this->getMode()) { |
---|
| 113 | // ログイン実行 |
---|
| 114 | case 'login': |
---|
| 115 | $this->lfInitLoginFormParam($objFormParam); |
---|
| 116 | $objFormParam->setParam($_POST); |
---|
| 117 | $objFormParam->trimParam(); |
---|
| 118 | $objFormParam->convParam(); |
---|
| 119 | $objFormParam->toLower('login_email'); |
---|
| 120 | $this->arrErr = $objFormParam->checkError(); |
---|
| 121 | |
---|
| 122 | // ログイン判定 |
---|
| 123 | if (SC_Utils_Ex::isBlank($this->arrErr) |
---|
| 124 | && $objCustomer->doLogin($objFormParam->getValue('login_email'), |
---|
| 125 | $objFormParam->getValue('login_pass'))) { |
---|
| 126 | |
---|
| 127 | // モバイルサイトで携帯アドレスの登録が無い場合、携帯アドレス登録ページへ遷移 |
---|
| 128 | if (SC_Display_Ex::detectDevice() == DEVICE_TYPE_MOBILE) { |
---|
| 129 | if (!$objCustomer->hasValue('email_mobile')) { |
---|
| 130 | |
---|
| 131 | SC_Response_Ex::sendRedirectFromUrlPath('entry/email_mobile.php'); |
---|
| 132 | SC_Response_Ex::actionExit(); |
---|
| 133 | } |
---|
| 134 | } |
---|
| 135 | // スマートフォンの場合はログイン成功を返す |
---|
| 136 | elseif (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) { |
---|
| 137 | |
---|
| 138 | echo SC_Utils_Ex::jsonEncode(array('success' => |
---|
| 139 | $this->getNextLocation($this->cartKey, $this->tpl_uniqid, |
---|
| 140 | $objCustomer, $objPurchase, |
---|
| 141 | $objSiteSess))); |
---|
| 142 | SC_Response_Ex::actionExit(); |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | SC_Response_Ex::sendRedirect( |
---|
| 146 | $this->getNextLocation($this->cartKey, $this->tpl_uniqid, |
---|
| 147 | $objCustomer, $objPurchase, |
---|
| 148 | $objSiteSess)); |
---|
| 149 | SC_Response_Ex::actionExit(); |
---|
| 150 | } |
---|
| 151 | // ログインに失敗した場合 |
---|
| 152 | else { |
---|
| 153 | // 仮登録の場合 |
---|
| 154 | if (SC_Helper_Customer_Ex::checkTempCustomer($objFormParam->getValue('login_email'))) { |
---|
| 155 | if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) { |
---|
| 156 | echo $this->lfGetErrorMessage(TEMP_LOGIN_ERROR); |
---|
| 157 | SC_Response_Ex::actionExit(); |
---|
| 158 | } else { |
---|
| 159 | SC_Utils_Ex::sfDispSiteError(TEMP_LOGIN_ERROR); |
---|
| 160 | SC_Response_Ex::actionExit(); |
---|
| 161 | } |
---|
| 162 | } else { |
---|
| 163 | if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_SMARTPHONE) { |
---|
| 164 | echo $this->lfGetErrorMessage(SITE_LOGIN_ERROR); |
---|
| 165 | SC_Response_Ex::actionExit(); |
---|
| 166 | } else { |
---|
| 167 | SC_Utils_Ex::sfDispSiteError(SITE_LOGIN_ERROR); |
---|
| 168 | SC_Response_Ex::actionExit(); |
---|
| 169 | } |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | break; |
---|
| 173 | |
---|
| 174 | // お客様情報登録 |
---|
| 175 | case 'nonmember_confirm': |
---|
| 176 | $this->tpl_mainpage = $nonmember_mainpage; |
---|
| 177 | $this->tpl_title = $nonmember_title; |
---|
| 178 | $this->lfInitParam($objFormParam); |
---|
| 179 | $objFormParam->setParam($_POST); |
---|
| 180 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 181 | |
---|
| 182 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 183 | $this->lfRegistData($this->tpl_uniqid, $objPurchase, $objCustomer, $objFormParam); |
---|
| 184 | |
---|
| 185 | $arrParams = $objFormParam->getHashArray(); |
---|
| 186 | $shipping_id = $arrParams['deliv_check'] == '1' ? 1 : 0; |
---|
| 187 | $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id); |
---|
| 188 | |
---|
| 189 | $objSiteSess->setRegistFlag(); |
---|
| 190 | |
---|
| 191 | |
---|
| 192 | SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); |
---|
| 193 | SC_Response_Ex::actionExit(); |
---|
| 194 | } |
---|
| 195 | break; |
---|
| 196 | |
---|
| 197 | // 前のページに戻る |
---|
| 198 | case 'return': |
---|
| 199 | |
---|
| 200 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
| 201 | SC_Response_Ex::actionExit(); |
---|
| 202 | break; |
---|
| 203 | |
---|
| 204 | // 複数配送ページへ遷移 |
---|
| 205 | case 'multiple': |
---|
| 206 | // 複数配送先指定が無効な場合はエラー |
---|
| 207 | if (USE_MULTIPLE_SHIPPING === false) { |
---|
| 208 | SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true); |
---|
| 209 | SC_Response_Ex::actionExit(); |
---|
| 210 | } |
---|
| 211 | |
---|
| 212 | $this->lfInitParam($objFormParam); |
---|
| 213 | $objFormParam->setParam($_POST); |
---|
| 214 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 215 | |
---|
| 216 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 217 | $this->lfRegistData($this->tpl_uniqid, $objPurchase, $objCustomer, $objFormParam, true); |
---|
| 218 | |
---|
| 219 | $objSiteSess->setRegistFlag(); |
---|
| 220 | |
---|
| 221 | |
---|
| 222 | SC_Response_Ex::sendRedirect(MULTIPLE_URLPATH); |
---|
| 223 | SC_Response_Ex::actionExit(); |
---|
| 224 | } |
---|
| 225 | $this->tpl_mainpage = $nonmember_mainpage; |
---|
| 226 | $this->tpl_title = $nonmember_title; |
---|
| 227 | break; |
---|
| 228 | |
---|
| 229 | // お客様情報入力ページの表示 |
---|
| 230 | case 'nonmember': |
---|
| 231 | $this->tpl_mainpage = $nonmember_mainpage; |
---|
| 232 | $this->tpl_title = $nonmember_title; |
---|
| 233 | $this->lfInitParam($objFormParam); |
---|
| 234 | // ※breakなし |
---|
| 235 | |
---|
| 236 | default: |
---|
| 237 | // 前のページから戻ってきた場合は, お客様情報入力ページ |
---|
| 238 | if (isset($_GET['from']) && $_GET['from'] == 'nonmember') { |
---|
| 239 | $this->tpl_mainpage = $nonmember_mainpage; |
---|
| 240 | $this->tpl_title = $nonmember_title; |
---|
| 241 | $this->lfInitParam($objFormParam); |
---|
| 242 | } |
---|
| 243 | // 通常はログインページ |
---|
| 244 | else { |
---|
| 245 | $this->lfInitLoginFormParam($objFormParam); |
---|
| 246 | } |
---|
| 247 | |
---|
| 248 | $this->setFormParams($objFormParam, $objPurchase, $this->tpl_uniqid); |
---|
| 249 | break; |
---|
| 250 | } |
---|
| 251 | |
---|
| 252 | // 記憶したメールアドレスを取得 |
---|
| 253 | $this->tpl_login_email = $objCookie->getCookie('login_email'); |
---|
| 254 | if (!SC_Utils_Ex::isBlank($this->tpl_login_email)) { |
---|
| 255 | $this->tpl_login_memory = '1'; |
---|
| 256 | } |
---|
| 257 | |
---|
| 258 | // 入力値の取得 |
---|
| 259 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
| 260 | |
---|
| 261 | // 携帯端末IDが一致する会員が存在するかどうかをチェックする。 |
---|
| 262 | if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) { |
---|
| 263 | $this->tpl_valid_phone_id = $objCustomer->checkMobilePhoneId(); |
---|
| 264 | } |
---|
| 265 | |
---|
| 266 | } |
---|
| 267 | |
---|
| 268 | /** |
---|
| 269 | * デストラクタ. |
---|
| 270 | * |
---|
| 271 | * @return void |
---|
| 272 | */ |
---|
| 273 | function destroy() { |
---|
| 274 | parent::destroy(); |
---|
| 275 | } |
---|
| 276 | |
---|
| 277 | /** |
---|
| 278 | * お客様情報入力時のパラメーター情報の初期化を行う. |
---|
| 279 | * |
---|
| 280 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 281 | * @return void |
---|
| 282 | */ |
---|
| 283 | function lfInitParam(&$objFormParam) { |
---|
| 284 | |
---|
| 285 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_LASTNAME'), 'order_name01', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 286 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_FIRSTNAME'), 'order_name02', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 287 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_LASTKANA'), 'order_kana01', STEXT_LEN, 'KVCa', array('EXIST_CHECK', 'KANA_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 288 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_FIRSTKANA'), 'order_kana02', STEXT_LEN, 'KVCa', array('EXIST_CHECK', 'KANA_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 289 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'order_zip01', ZIP01_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 290 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'order_zip02', ZIP02_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 291 | $objFormParam->addParam(t('PARAM_LABEL_ZIP'), 'order_zipcode', ZIPCODE_LEN, 'n', array('EXIST_CHECK', 'NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 292 | $objFormParam->addParam(t('PARAM_LABEL_PREF'), 'order_pref', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 293 | $objFormParam->addParam(t('PARAM_LABEL_ADDR1'), 'order_addr01', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 294 | $objFormParam->addParam(t('PARAM_LABEL_ADDR2'), 'order_addr02', MTEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 295 | $objFormParam->addParam(t('PARAM_LABEL_TEL1'), 'order_tel01', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 296 | $objFormParam->addParam(t('PARAM_LABEL_TEL2'), 'order_tel02', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 297 | $objFormParam->addParam(t('PARAM_LABEL_TEL3'), 'order_tel03', TEL_ITEM_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 298 | $objFormParam->addParam(t('PARAM_LABEL_FAX1'), 'order_fax01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 299 | $objFormParam->addParam(t('PARAM_LABEL_FAX2'), 'order_fax02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 300 | $objFormParam->addParam(t('PARAM_LABEL_FAX3'), 'order_fax03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 301 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL'), 'order_email', null, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'NO_SPTAB', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
| 302 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL_CONFIRM'), 'order_email02', null, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'NO_SPTAB', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK'), '', false); |
---|
| 303 | $objFormParam->addParam(t('PARAM_LABEL_YEAR'), 'year', INT_LEN, 'n', array('MAX_LENGTH_CHECK'), '', false); |
---|
| 304 | $objFormParam->addParam(t('PARAM_LABEL_MONTH'), 'month', INT_LEN, 'n', array('MAX_LENGTH_CHECK'), '', false); |
---|
| 305 | $objFormParam->addParam(t('PARAM_LABEL_DAY'), 'day', INT_LEN, 'n', array('MAX_LENGTH_CHECK'), '', false); |
---|
| 306 | $objFormParam->addParam(t('PARAM_LABEL_SEX'), 'order_sex', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 307 | $objFormParam->addParam(t('PARAM_LABEL_JOB'), 'order_job', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 308 | $objFormParam->addParam(t('PARAM_LABEL_OTHER_DELIV'), 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 309 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_LASTNAME'), 'shipping_name01', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 310 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_FIRSTNAME'), 'shipping_name02', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 311 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_LASTKANA'), 'shipping_kana01', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 312 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_FIRSTKANA'), 'shipping_kana02', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 313 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'shipping_zip01', ZIP01_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 314 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'shipping_zip02', ZIP02_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 315 | $objFormParam->addParam(t('PARAM_LABEL_ZIP'), 'shipping_zipcode', ZIPCODE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 316 | $objFormParam->addParam(t('PARAM_LABEL_PREF'), 'shipping_pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 317 | $objFormParam->addParam(t('PARAM_LABEL_ADDR1'), 'shipping_addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 318 | $objFormParam->addParam(t('PARAM_LABEL_ADDR2'), 'shipping_addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 319 | $objFormParam->addParam(t('PARAM_LABEL_TEL1'), 'shipping_tel01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 320 | $objFormParam->addParam(t('PARAM_LABEL_TEL2'), 'shipping_tel02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 321 | $objFormParam->addParam(t('PARAM_LABEL_TEL3'), 'shipping_tel03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 322 | $objFormParam->addParam(t('PARAM_LABEL_MAILMAGAZINE'), 'mail_flag', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 323 | } |
---|
| 324 | |
---|
| 325 | /** |
---|
| 326 | * ログイン時のパラメーター情報の初期化を行う. |
---|
| 327 | * |
---|
| 328 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 329 | * @return void |
---|
| 330 | */ |
---|
| 331 | function lfInitLoginFormParam(&$objFormParam) { |
---|
| 332 | $objFormParam->addParam(t('PARAM_LABEL_MEMORY'), 'login_memory', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 333 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL'), 'login_email', STEXT_LEN, 'a', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 334 | $objFormParam->addParam(t('PARAM_LABEL_PASSWORD'), 'login_pass', PASSWORD_MAX_LEN, '', array('EXIST_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 335 | } |
---|
| 336 | |
---|
| 337 | /** |
---|
| 338 | * ログイン済みの場合の遷移先を取得する. |
---|
| 339 | * |
---|
| 340 | * 商品種別IDが, ダウンロード商品の場合は, 会員情報を受注一時情報に保存し, |
---|
| 341 | * 支払方法選択画面のパスを返す. |
---|
| 342 | * それ以外は, お届け先選択画面のパスを返す. |
---|
| 343 | * |
---|
| 344 | * @param integer $product_type_id 商品種別ID |
---|
| 345 | * @param string $uniqid 受注一時テーブルのユニークID |
---|
| 346 | * @param SC_Customer $objCustomer SC_Customer インスタンス |
---|
| 347 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 348 | * @param SC_SiteSession $objSiteSess SC_SiteSession インスタンス |
---|
| 349 | * @return string 遷移先のパス |
---|
| 350 | */ |
---|
| 351 | function getNextLocation($product_type_id, $uniqid, &$objCustomer, &$objPurchase, &$objSiteSess) { |
---|
| 352 | switch ($product_type_id) { |
---|
| 353 | case PRODUCT_TYPE_DOWNLOAD: |
---|
| 354 | $objPurchase->saveOrderTemp($uniqid, array(), $objCustomer); |
---|
| 355 | $objSiteSess->setRegistFlag(); |
---|
| 356 | return 'payment.php'; |
---|
| 357 | |
---|
| 358 | case PRODUCT_TYPE_NORMAL: |
---|
| 359 | default: |
---|
| 360 | return 'deliv.php'; |
---|
| 361 | } |
---|
| 362 | } |
---|
| 363 | |
---|
| 364 | /** |
---|
| 365 | * データの一時登録を行う. |
---|
| 366 | * |
---|
| 367 | * 非会員向けの処理 |
---|
| 368 | * @param integer $uniqid 受注一時テーブルのユニークID |
---|
| 369 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 370 | * @param SC_Customer $objCustomer SC_Customer インスタンス |
---|
| 371 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 372 | * @param boolean $isMultiple 複数配送の場合 true |
---|
| 373 | */ |
---|
| 374 | function lfRegistData($uniqid, &$objPurchase, &$objCustomer, &$objFormParam, $isMultiple = false) { |
---|
| 375 | $arrParams = $objFormParam->getHashArray(); |
---|
| 376 | |
---|
| 377 | // 注文者をお届け先とする配列を取得 |
---|
| 378 | $arrShippingOwn = array(); |
---|
| 379 | $objPurchase->copyFromOrder($arrShippingOwn, $arrParams); |
---|
| 380 | |
---|
| 381 | // 都度入力されたお届け先 |
---|
| 382 | $arrShipping = $objPurchase->extractShipping($arrParams); |
---|
| 383 | |
---|
| 384 | if ($isMultiple) { |
---|
| 385 | $objPurchase->unsetOneShippingTemp(0); |
---|
| 386 | $objPurchase->unsetOneShippingTemp(1); |
---|
| 387 | $objPurchase->saveShippingTemp($arrShippingOwn, 0); |
---|
| 388 | if ($arrParams['deliv_check'] == '1') { |
---|
| 389 | $objPurchase->saveShippingTemp($arrShipping, 1); |
---|
| 390 | } |
---|
| 391 | } else { |
---|
| 392 | $objPurchase->unsetAllShippingTemp(true); |
---|
| 393 | if ($arrParams['deliv_check'] == '1') { |
---|
| 394 | $objPurchase->saveShippingTemp($arrShipping, 1); |
---|
| 395 | } else { |
---|
| 396 | $objPurchase->saveShippingTemp($arrShippingOwn, 0); |
---|
| 397 | } |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | $arrValues = $objFormParam->getDbArray(); |
---|
| 401 | |
---|
| 402 | // 登録データの作成 |
---|
| 403 | $arrValues['order_birth'] = SC_Utils_Ex::sfGetTimestamp($arrParams['year'], $arrParams['month'], $arrParams['day']); |
---|
| 404 | $arrValues['update_date'] = 'CURRENT_TIMESTAMP'; |
---|
| 405 | $arrValues['customer_id'] = '0'; |
---|
| 406 | $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer); |
---|
| 407 | } |
---|
| 408 | |
---|
| 409 | /** |
---|
| 410 | * 入力内容のチェックを行う. |
---|
| 411 | * |
---|
| 412 | * 追加の必須チェック, 相関チェックを行うため, SC_CheckError を使用する. |
---|
| 413 | * |
---|
| 414 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 415 | * @return array エラー情報の配 |
---|
| 416 | */ |
---|
| 417 | function lfCheckError(&$objFormParam) { |
---|
| 418 | // 入力値の変換 |
---|
| 419 | $objFormParam->convParam(); |
---|
| 420 | $objFormParam->toLower('order_mail'); |
---|
| 421 | $objFormParam->toLower('order_mail_check'); |
---|
| 422 | |
---|
| 423 | $arrParams = $objFormParam->getHashArray(); |
---|
| 424 | $objErr = new SC_CheckError_Ex($arrParams); |
---|
| 425 | $objErr->arrErr = $objFormParam->checkError(); |
---|
| 426 | |
---|
| 427 | // 別のお届け先チェック |
---|
| 428 | if (isset($arrParams['deliv_check']) && $arrParams['deliv_check'] == '1') { |
---|
| 429 | $objErr->doFunc(array(t('PARAM_LABEL_CUSTOMER_LASTNAME'), 'shipping_name01'), array('EXIST_CHECK')); |
---|
| 430 | $objErr->doFunc(array(t('PARAM_LABEL_CUSTOMER_FIRSTNAME'), 'shipping_name02'), array('EXIST_CHECK')); |
---|
| 431 | $objErr->doFunc(array(t('PARAM_LABEL_CUSTOMER_LASTKANA'), 'shipping_kana01'), array('EXIST_CHECK')); |
---|
| 432 | $objErr->doFunc(array(t('PARAM_LABEL_CUSTOMER_FIRSTKANA'), 'shipping_kana02'), array('EXIST_CHECK')); |
---|
| 433 | // $objErr->doFunc(array(t('PARAM_LABEL_ZIP01'), 'shipping_zip01'), array('EXIST_CHECK')); |
---|
| 434 | // $objErr->doFunc(array(t('PARAM_LABEL_ZIP02'), 'shipping_zip02'), array('EXIST_CHECK')); |
---|
| 435 | $objErr->doFunc(array(t('PARAM_LABEL_ZIP'), 'shipping_zipcode'), array('EXIST_CHECK')); |
---|
| 436 | $objErr->doFunc(array(t('PARAM_LABEL_PREF'), 'shipping_pref'), array('EXIST_CHECK')); |
---|
| 437 | $objErr->doFunc(array(t('PARAM_LABEL_ADDR1'), 'shipping_addr01'), array('EXIST_CHECK')); |
---|
| 438 | $objErr->doFunc(array(t('PARAM_LABEL_ADDR2'), 'shipping_addr02'), array('EXIST_CHECK')); |
---|
| 439 | $objErr->doFunc(array(t('PARAM_LABEL_TEL1'), 'shipping_tel01'), array('EXIST_CHECK')); |
---|
| 440 | $objErr->doFunc(array(t('PARAM_LABEL_TEL2'), 'shipping_tel02'), array('EXIST_CHECK')); |
---|
| 441 | $objErr->doFunc(array(t('PARAM_LABEL_TEL3'), 'shipping_tel03'), array('EXIST_CHECK')); |
---|
| 442 | } |
---|
| 443 | |
---|
| 444 | // 複数項目チェック |
---|
| 445 | $objErr->doFunc(array(t('PARAM_LABEL_TEL'), 'order_tel01', 'order_tel02', 'order_tel03'), array('TEL_CHECK')); |
---|
| 446 | $objErr->doFunc(array(t('PARAM_LABEL_FAX'), 'order_fax01', 'order_fax02', 'order_fax03'), array('TEL_CHECK')); |
---|
| 447 | // $objErr->doFunc(array(t('PARAM_LABEL_ZIP'), 'order_zip01', 'order_zip02'), array('ALL_EXIST_CHECK')); |
---|
| 448 | $objErr->doFunc(array(t('PARAM_LABEL_TEL'), 'shipping_tel01', 'shipping_tel02', 'shipping_tel03'), array('TEL_CHECK')); |
---|
| 449 | // $objErr->doFunc(array(t('PARAM_LABEL_ZIP'), 'shipping_zip01', 'shipping_zip02'), array('ALL_EXIST_CHECK')); |
---|
| 450 | $objErr->doFunc(array(t('PARAM_LABEL_BIRTHDAY'), 'year', 'month', 'day'), array('CHECK_BIRTHDAY')); |
---|
| 451 | $objErr->doFunc(array(t('PARAM_LABEL_EMAIL'), t('PARAM_LABEL_EMAIL_CONFIRM'), 'order_email', 'order_email02'), array('EQUAL_CHECK')); |
---|
| 452 | |
---|
| 453 | return $objErr->arrErr; |
---|
| 454 | } |
---|
| 455 | |
---|
| 456 | /** |
---|
| 457 | * 入力済みの購入情報をフォームに設定する. |
---|
| 458 | * |
---|
| 459 | * 受注一時テーブル, セッションの配送情報から入力済みの購入情報を取得し, |
---|
| 460 | * フォームに設定する. |
---|
| 461 | * |
---|
| 462 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 463 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 464 | * @param integer $uniqid 購入一時情報のユニークID |
---|
| 465 | * @return void |
---|
| 466 | */ |
---|
| 467 | function setFormParams(&$objFormParam, &$objPurchase, $uniqid) { |
---|
| 468 | $arrOrderTemp = $objPurchase->getOrderTemp($uniqid); |
---|
| 469 | if (SC_Utils_Ex::isBlank($arrOrderTemp)) { |
---|
| 470 | $arrOrderTemp = array( |
---|
| 471 | 'order_email' => '', |
---|
| 472 | 'order_birth' => '', |
---|
| 473 | ); |
---|
| 474 | } |
---|
| 475 | $arrShippingTemp = $objPurchase->getShippingTemp(); |
---|
| 476 | |
---|
| 477 | $objFormParam->setParam($arrOrderTemp); |
---|
| 478 | /* |
---|
| 479 | * count($arrShippingTemp) > 1 は複数配送であり, |
---|
| 480 | * $arrShippingTemp[0] は注文者が格納されている |
---|
| 481 | */ |
---|
| 482 | if (count($arrShippingTemp) > 1) { |
---|
| 483 | $objFormParam->setParam($arrShippingTemp[1]); |
---|
| 484 | } else { |
---|
| 485 | $objFormParam->setParam($arrShippingTemp[0]); |
---|
| 486 | } |
---|
| 487 | $objFormParam->setValue('order_email02', $arrOrderTemp['order_email']); |
---|
| 488 | $objFormParam->setDBDate($arrOrderTemp['order_birth']); |
---|
| 489 | } |
---|
| 490 | |
---|
| 491 | /** |
---|
| 492 | * エラーメッセージを JSON 形式で返す. |
---|
| 493 | * |
---|
| 494 | * TODO リファクタリング |
---|
| 495 | * この関数は主にスマートフォンで使用します. |
---|
| 496 | * |
---|
| 497 | * @param integer エラーコード |
---|
| 498 | * @return string JSON 形式のエラーメッセージ |
---|
| 499 | * @see LC_PageError |
---|
| 500 | */ |
---|
| 501 | function lfGetErrorMessage($error) { |
---|
| 502 | switch ($error) { |
---|
| 503 | case TEMP_LOGIN_ERROR: |
---|
| 504 | $msg = t('LC_Page_Shopping_004'); |
---|
| 505 | break; |
---|
| 506 | case SITE_LOGIN_ERROR: |
---|
| 507 | default: |
---|
| 508 | $msg = t('LC_Page_Shopping_005'); |
---|
| 509 | } |
---|
| 510 | return SC_Utils_Ex::jsonEncode(array('login_error' => $msg)); |
---|
| 511 | } |
---|
| 512 | } |
---|