source: branches/version-2_13-dev/data/class/pages/shopping/LC_Page_Shopping_Deliv.php @ 22926

Revision 22926, 8.5 KB checked in by Seasoft, 11 years ago (diff)

#2287 (環境によりデストラクタが正しく動作しないケースがある)
#2288 (リクエスト単位で実行されるべきログ出力がブロックにも適用されている)
#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 不明確な仕様にコメントを残した。
  • 親デストラクタを呼ぶだけの記述は可読性が悪くなると考え削除した。(上述のチケットで OS の仕様に依存したデストラクタとなるため、敢えてアプリケーション側で記述しておく意義は薄れたという認識のもと。)
  • 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
Line 
1<?php
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * お届け先の指定 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Shopping_Deliv extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    function init()
41    {
42        parent::init();
43        $masterData = new SC_DB_MasterData_Ex();
44        $this->arrPref = $masterData->getMasterData('mtb_pref');
45        $this->tpl_title = 'お届け先の指定';
46        $this->httpCacheControl('nocache');
47    }
48
49    /**
50     * Page のプロセス.
51     *
52     * @return void
53     */
54    function process()
55    {
56        parent::process();
57        $this->action();
58        $this->sendResponse();
59    }
60
61    /**
62     * Page のプロセス.
63     *
64     * @return void
65     */
66    function action()
67    {
68        $objSiteSess = new SC_SiteSession_Ex();
69        $objCartSess = new SC_CartSession_Ex();
70        $objCustomer = new SC_Customer_Ex();
71        $objPurchase = new SC_Helper_Purchase_Ex();
72        $objFormParam = new SC_FormParam_Ex();
73        $objAddress = new SC_Helper_Address_Ex();
74
75        $this->tpl_uniqid = $objSiteSess->getUniqId();
76        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
77
78        $this->cartKey = $objCartSess->getKey();
79
80        // ログインチェック
81        if (!$objCustomer->isLoginSuccess(true)) {
82            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
83        }
84
85        // ダウンロード商品の場合は、支払方法画面に転送
86        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
87            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
88            $objPurchase->saveShippingTemp($sqlval);
89            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
90            $objSiteSess->setRegistFlag();
91
92            SC_Response_Ex::sendRedirect('payment.php');
93            SC_Response_Ex::actionExit();
94        }
95
96        $this->lfInitParam($objFormParam);
97        $objFormParam->setParam($_POST);
98        $objFormParam->convParam();
99        $arrErr = $objFormParam->checkError();
100        if (!SC_Utils_Ex::isBlank($arrErr)) {
101            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
102            SC_Response_Ex::actionExit();
103        }
104
105        $arrForm = $objFormParam->getHashArray();
106
107        switch ($this->getMode()) {
108            // 削除
109            case 'delete':
110                $objAddress->deleteAddress($arrForm['other_deliv_id']);
111                break;
112
113            // 会員登録住所に送る
114            case 'customer_addr':
115                $objPurchase->unsetShippingTemp();
116
117                $shipping_id = $arrForm['deliv_check'] == -1 ? 0 : $arrForm['deliv_check'];
118                $success = $this->registerDeliv($shipping_id, $this->tpl_uniqid, $objPurchase, $objCustomer, $objAddress);
119                if (!$success) {
120                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
121                }
122
123                $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id);
124                $objSiteSess->setRegistFlag();
125
126                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
127                SC_Response_Ex::actionExit();
128                break;
129
130            // 前のページに戻る
131            case 'return':
132
133                // 確認ページへ移動
134                SC_Response_Ex::sendRedirect(CART_URLPATH);
135                SC_Response_Ex::actionExit();
136                break;
137
138            // お届け先複数指定
139            case 'multiple':
140                // 複数配送先指定が無効な場合はエラー
141                if (USE_MULTIPLE_SHIPPING === false) {
142                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
143                    SC_Response_Ex::actionExit();
144                }
145
146                SC_Response_Ex::sendRedirect('multiple.php');
147                SC_Response_Ex::actionExit();
148                break;
149
150            default:
151                // 配送IDの取得
152                $shippingData = $objPurchase->getShippingTemp();
153                $arrShippingId = array_keys($shippingData);
154                if (isset($arrShippingId[0])) {
155                    $this->arrForm['deliv_check']['value'] = $arrShippingId[0] == 0 ? -1 : $arrShippingId[0];
156                }
157                break;
158        }
159
160        // 登録済み住所を取得
161        $addr = array(
162            array(
163                'other_deliv_id'    => NULL,
164                'customer_id'       => $objCustomer->getValue('customer_id'),
165                'name01'            => $objCustomer->getValue('name01'),
166                'name02'            => $objCustomer->getValue('name02'),
167                'kana01'            => $objCustomer->getValue('kana01'),
168                'kana02'            => $objCustomer->getValue('kana02'),
169                'zip01'             => $objCustomer->getValue('zip01'),
170                'zip02'             => $objCustomer->getValue('zip02'),
171                'pref'              => $objCustomer->getValue('pref'),
172                'addr01'            => $objCustomer->getValue('addr01'),
173                'addr02'            => $objCustomer->getValue('addr02'),
174                'tel01'             => $objCustomer->getValue('tel01'),
175                'tel02'             => $objCustomer->getValue('tel02'),
176                'tel03'             => $objCustomer->getValue('tel03'),
177            )
178        );
179        $this->arrAddr = array_merge($addr, $objAddress->getList($objCustomer->getValue('customer_id')));
180        $this->tpl_addrmax = count($this->arrAddr) - 1; // 会員の住所をカウントしない
181
182
183    }
184
185    /**
186     * パラメーター情報の初期化を行う.
187     *
188     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
189     * @return void
190     */
191    function lfInitParam(&$objFormParam)
192    {
193        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
194        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
195    }
196
197    /**
198     * お届け先チェックの値に応じて, お届け先情報を保存する.
199     *
200     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
201     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
202     * お届け先チェックの値が不正な場合は false を返す.
203     *
204     * @param integer $other_deliv_id
205     * @param string $uniqid 受注一時テーブルのユニークID
206     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
207     * @param SC_Customer $objCustomer SC_Customer インスタンス
208     * @return boolean お届け先チェックの値が妥当な場合 true
209     */
210    function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer, $objAddress)
211    {
212        GC_Utils_Ex::gfDebugLog('register deliv. deliv_check=' . $deliv_check);
213        $arrValues = array();
214        // 会員登録住所がチェックされている場合
215        if ($other_deliv_id == 0) {
216            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
217        }
218        // 別のお届け先がチェックされている場合
219        else {
220            $arrOtherDeliv = $objAddress->getAddress($other_deliv_id);
221            if (!$arrOtherDeliv) {
222                return false;
223            }
224
225            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
226        }
227        $objPurchase->saveShippingTemp($arrValues, $other_deliv_id);
228        $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
229
230        return true;
231    }
232}
Note: See TracBrowser for help on using the repository browser.