source: branches/version-2_13-dev/data/class/pages/mypage/LC_Page_Mypage_DeliveryAddr.php @ 23026

Revision 23026, 6.3 KB checked in by AMUAMU, 11 years ago (diff)

#2323 (税率対応)
#2235 (越境ECを想定した機能の追加)
#2234 (非会員お客様情報入力テンプレートと機能の共通化)
#2324 (会員登録、注文フォームに「会社名」フィールドを足す)
#2233 (購入手続きのログイン画面でログイン出来ないユーザーがいる)
などの修正

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
RevLine 
[16093]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.
[16093]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.
[16093]22 */
23
[20534]24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
[16093]25
26/**
27 * お届け先追加 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
[22856]33class LC_Page_Mypage_DeliveryAddr extends LC_Page_Ex
[22567]34{
[16093]35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
[22567]40    function init()
41    {
[16093]42        parent::init();
[21514]43        $this->tpl_title    = 'お届け先の追加・変更';
[20156]44        $masterData         = new SC_DB_MasterData_Ex();
45        $this->arrPref      = $masterData->getMasterData('mtb_pref');
[23026]46        $this->arrCountry   = $masterData->getMasterData('mtb_country');
[18187]47        $this->httpCacheControl('nocache');
[20580]48        $this->validUrl = array(MYPAGE_DELIVADDR_URLPATH,
49                                DELIV_URLPATH,
50                                MULTIPLE_URLPATH);
[16093]51    }
52
53    /**
54     * Page のプロセス.
55     *
56     * @return void
57     */
[22567]58    function process()
59    {
[19661]60        parent::process();
61        $this->action();
62        $this->sendResponse();
63    }
64
65    /**
66     * Page のAction.
67     *
68     * @return void
69     */
[22567]70    function action()
71    {
[20490]72        $objCustomer = new SC_Customer_Ex();
[22065]73        $objAddress  = new SC_Helper_Address_Ex();
[20156]74        $ParentPage  = MYPAGE_DELIVADDR_URLPATH;
[16093]75
76        // GETでページを指定されている場合には指定ページに戻す
77        if (isset($_GET['page'])) {
[20156]78            $ParentPage = htmlspecialchars($_GET['page'], ENT_QUOTES);
79        } else if (isset($_POST['ParentPage'])) {
80            $ParentPage = htmlspecialchars($_POST['ParentPage'], ENT_QUOTES);
[16093]81        }
82        $this->ParentPage = $ParentPage;
[20041]83
[19872]84        /*
85         * ログイン判定 及び 退会判定
86         * 未ログインでも, 複数配送設定ページからのアクセスの場合は表示する
[20156]87         *
88         * TODO 購入遷移とMyPageで別クラスにすべき
[19872]89         */
[21441]90        if (!$objCustomer->isLoginSuccess(true) && $ParentPage != MULTIPLE_URLPATH) {
[18845]91            $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();";
[16093]92        }
93
[21012]94        // other_deliv_id のあるなしで追加か編集か判定しているらしい
95        $_SESSION['other_deliv_id'] = $_REQUEST['other_deliv_id'];
[16093]96
[20970]97        // パラメーター管理クラス,パラメーター情報の初期化
[20501]98        $objFormParam   = new SC_FormParam_Ex();
[22065]99        $objAddress->setFormParam($objFormParam);
[20156]100        $objFormParam->setParam($_POST);
101        $this->arrForm  = $objFormParam->getHashArray();
[16093]102
[20041]103        switch ($this->getMode()) {
[20156]104            // 入力は必ずedit
[17302]105            case 'edit':
[22065]106                $this->arrErr = $objAddress->errorCheck($objFormParam);
[20156]107                // 入力エラーなし
[21441]108                if (empty($this->arrErr)) {
[20156]109                    // TODO ここでやるべきではない
[20580]110                    if (in_array($_POST['ParentPage'], $this->validUrl)) {
[17758]111                        $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();";
112                    } else {
[17905]113                        SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
[17302]114                    }
[20041]115
[19991]116                    if ($objCustomer->isLoginSuccess(true)) {
[22065]117                        $this->lfRegistData($objAddress, $objFormParam, $objCustomer->getValue('customer_id'));
[19872]118                    } else {
[20156]119                        $this->lfRegistDataNonMember($objFormParam);
[19872]120                    }
[19891]121
[21441]122                    if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[19891]123                        // モバイルの場合、元のページに遷移
124                        SC_Response_Ex::sendRedirect($this->getLocation($_POST['ParentPage']));
[21743]125                        SC_Response_Ex::actionExit();
[19891]126                    }
[17302]127                }
128                break;
[20156]129            case 'multiple':
[20697]130                // 複数配送先用
[20156]131                break;
132            default :
133
[21514]134                if ($_GET['other_deliv_id'] != '') {
[22546]135                    $arrOtherDeliv = $objAddress->getAddress($_SESSION['other_deliv_id']);
[20324]136
[20156]137                    //不正アクセス判定
[22065]138                    if (!$objCustomer->isLoginSuccess(true) || !$arrOtherDeliv) {
[20156]139                        SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
140                    }
141
142                    //別のお届け先情報取得
[22065]143                    $this->arrForm = $arrOtherDeliv;
[20156]144                }
145                break;
[17302]146        }
[20156]147
[20484]148        if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) {
[19961]149            $this->tpl_mainpage = 'mypage/delivery_addr.tpl';
150        } else {
151            $this->setTemplate('mypage/delivery_addr.tpl');
152        }
[21743]153
[16093]154    }
155
[20156]156    /* 登録実行 */
[22567]157    function lfRegistData($objAddress, $objFormParam, $customer_id)
158    {
[20156]159        $arrRet     = $objFormParam->getHashArray();
160        $sqlval     = $objFormParam->getDbArray();
[16093]161
[22069]162        $sqlval['other_deliv_id'] = $arrRet['other_deliv_id'];
[20156]163        $sqlval['customer_id'] = $customer_id;
[16093]164
[22546]165        $objAddress->registAddress($sqlval);
[16093]166    }
167
[22567]168    function lfRegistDataNonMember($objFormParam)
169    {
[20156]170        $arrRegistColumn = $objFormParam->getDbArray();
[20697]171        foreach ($arrRegistColumn as $key => $val) {
172            $arrRegist['shipping_' . $key ] = $val;
[19872]173        }
[20697]174        if (count($_SESSION['shipping']) >= DELIV_ADDR_MAX) {
[21514]175            SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先最大登録数に達しています。');
[19872]176        } else {
177            $_SESSION['shipping'][] = $arrRegist;
178        }
179    }
[16093]180}
Note: See TracBrowser for help on using the repository browser.