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

Revision 21570, 7.9 KB checked in by Seasoft, 12 years ago (diff)

#1439 (「お届け先の指定」に戻った際に、選択した状態を引き継いでいない)

  • rv r21567 (PostgreSQL でエラーが発生するため、一旦差し戻しをさせて頂きます。)
  • 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-2011 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
25require_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 */
34class LC_Page_Shopping_Deliv extends LC_Page_Ex {
35
36    // }}}
37    // {{{ functions
38
39    /**
40     * Page を初期化する.
41     *
42     * @return void
43     */
44    function init() {
45        parent::init();
46        $masterData = new SC_DB_MasterData();
47        $this->arrPref = $masterData->getMasterData('mtb_pref');
48        $this->tpl_title = 'お届け先の指定';
49        $this->httpCacheControl('nocache');
50    }
51
52    /**
53     * Page のプロセス.
54     *
55     * @return void
56     */
57    function process() {
58        parent::process();
59        $this->action();
60        $this->sendResponse();
61    }
62
63    /**
64     * Page のプロセス.
65     *
66     * @return void
67     */
68    function action() {
69        $objSiteSess = new SC_SiteSession_Ex();
70        $objCartSess = new SC_CartSession_Ex();
71        $objCustomer = new SC_Customer_Ex();
72        $objPurchase = new SC_Helper_Purchase_Ex();
73        $objFormParam = new SC_FormParam_Ex();
74        $objCookie = new SC_Cookie_Ex(COOKIE_EXPIRE);
75
76        $this->tpl_uniqid = $objSiteSess->getUniqId();
77        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
78
79        $this->cartKey = $objCartSess->getKey();
80
81        // ログインチェック
82        if (!$objCustomer->isLoginSuccess(true)) {
83            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
84        }
85
86        // ダウンロード商品の場合は、支払方法画面に転送
87        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
88            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
89            $objPurchase->saveShippingTemp($sqlval);
90            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
91            $objSiteSess->setRegistFlag();
92            SC_Response_Ex::sendRedirect('payment.php');
93            exit;
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            exit;
103        }
104
105        $arrForm = $objFormParam->getHashArray();
106
107        switch ($this->getMode()) {
108            // 削除
109            case 'delete':
110                $this->doDelete($arrForm['other_deliv_id']);
111                break;
112
113            // 会員登録住所に送る
114            case 'customer_addr':
115                $objPurchase->unsetShippingTemp();
116
117                if ($this->registerDeliv($arrForm['deliv_check'], $this->tpl_uniqid,
118                                         $objPurchase, $objCustomer)) {
119                    $objSiteSess->setRegistFlag();
120                    SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
121                    exit;
122
123                } else {
124                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
125                }
126                break;
127
128            // 前のページに戻る
129            case 'return':
130                // 確認ページへ移動
131                SC_Response_Ex::sendRedirect(CART_URLPATH);
132                exit;
133                break;
134
135            // お届け先複数指定
136            case 'multiple':
137                // 複数配送先指定が無効な場合はエラー
138                if (USE_MULTIPLE_SHIPPING === false) {
139                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
140                    exit;
141                }
142
143                SC_Response_Ex::sendRedirect('multiple.php');
144                exit;
145                break;
146            default:
147                break;
148        }
149
150        // 登録済み住所を取得
151        $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
152        $this->tpl_addrmax = count($this->arrAddr);
153    }
154
155    /**
156     * デストラクタ.
157     *
158     * @return void
159     */
160    function destroy() {
161        parent::destroy();
162    }
163
164    /**
165     * パラメーター情報の初期化を行う.
166     *
167     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
168     * @return void
169     */
170    function lfInitParam(&$objFormParam) {
171        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
172        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
173    }
174
175    /**
176     * その他のお届け先情報を削除する.
177     *
178     * @param integer $other_deliv_id その他のお届け先ID
179     * @return void
180     */
181    function doDelete($other_deliv_id) {
182        $objQuery =& SC_Query_Ex::getSingletonInstance();
183        $where = 'other_deliv_id = ?';
184        $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id));
185    }
186
187    /**
188     * お届け先チェックの値に応じて, お届け先情報を保存する.
189     *
190     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
191     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
192     * お届け先チェックの値が不正な場合は false を返す.
193     *
194     * @param integer $deliv_check お届け先チェック
195     * @param string $uniqid 受注一時テーブルのユニークID
196     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
197     * @param SC_Customer $objCustomer SC_Customer インスタンス
198     * @return boolean お届け先チェックの値が妥当な場合 true
199     */
200    function registerDeliv($deliv_check, $uniqid, &$objPurchase, &$objCustomer) {
201        $this->log('register deliv. deliv_check=' . $deliv_check, 'Debug');
202        $arrValues = array();
203        // 会員登録住所がチェックされている場合
204        if ($deliv_check == '-1') {
205            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
206            $objPurchase->saveShippingTemp($arrValues);
207            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
208            return true;
209        }
210        // 別のお届け先がチェックされている場合
211        elseif ($deliv_check >= 1) {
212            $objQuery =& SC_Query_Ex::getSingletonInstance();
213            $arrOtherDeliv = $objQuery->getRow('*', 'dtb_other_deliv',
214                                               'customer_id = ? AND other_deliv_id = ?',
215                                               array($objCustomer->getValue('customer_id'), $deliv_check));
216            if (SC_Utils_Ex::isBlank($arrOtherDeliv)) {
217                return false;
218            }
219
220            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
221            $objPurchase->saveShippingTemp($arrValues);
222            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
223            return true;
224        }
225        // お届け先チェックが不正な場合
226        else {
227            return false;
228        }
229    }
230}
Note: See TracBrowser for help on using the repository browser.