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

Revision 21734, 9.3 KB checked in by Seasoft, 12 years ago (diff)

#1613 (typo修正・ソース整形・ソースコメントの改善)

  • 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        // フックポイント.
70        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
71        $objPlugin->doAction('LC_Page_Shopping_Deliv_action_before', array($this));
72
73        $objSiteSess = new SC_SiteSession_Ex();
74        $objCartSess = new SC_CartSession_Ex();
75        $objCustomer = new SC_Customer_Ex();
76        $objPurchase = new SC_Helper_Purchase_Ex();
77        $objFormParam = new SC_FormParam_Ex();
78
79        $this->tpl_uniqid = $objSiteSess->getUniqId();
80        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
81
82        $this->cartKey = $objCartSess->getKey();
83
84        // ログインチェック
85        if (!$objCustomer->isLoginSuccess(true)) {
86            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
87        }
88
89        // ダウンロード商品の場合は、支払方法画面に転送
90        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
91            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
92            $objPurchase->saveShippingTemp($sqlval);
93            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
94            $objSiteSess->setRegistFlag();
95            // フックポイント.
96            $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
97            $objPlugin->doAction('LC_Page_Shopping_Deliv_action_download', array($this));
98
99            SC_Response_Ex::sendRedirect('payment.php');
100            exit;
101        }
102
103        $this->lfInitParam($objFormParam);
104        $objFormParam->setParam($_POST);
105        $objFormParam->convParam();
106        $arrErr = $objFormParam->checkError();
107        if (!SC_Utils_Ex::isBlank($arrErr)) {
108            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
109            exit;
110        }
111
112        $arrForm = $objFormParam->getHashArray();
113
114        switch ($this->getMode()) {
115            // 削除
116            case 'delete':
117                $this->doDelete($arrForm['other_deliv_id']);
118                break;
119
120            // 会員登録住所に送る
121            case 'customer_addr':
122                $objPurchase->unsetShippingTemp();
123
124                $shipping_id = $arrForm['deliv_check'] == -1 ? 0 : $arrForm['deliv_check'];
125                $success = $this->registerDeliv($shipping_id, $this->tpl_uniqid, $objPurchase, $objCustomer);
126                if (!$success) {
127                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
128                }
129
130                $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id);
131                $objSiteSess->setRegistFlag();
132
133                // フックポイント.
134                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
135                $objPlugin->doAction('LC_Page_Shopping_Deliv_action_customeraddr', array($this));
136
137                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
138                exit;
139                break;
140
141            // 前のページに戻る
142            case 'return':
143                // フックポイント.
144                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
145                $objPlugin->doAction('LC_Page_Shopping_Deliv_action_return', array($this));
146
147                // 確認ページへ移動
148                SC_Response_Ex::sendRedirect(CART_URLPATH);
149                exit;
150                break;
151
152            // お届け先複数指定
153            case 'multiple':
154                // 複数配送先指定が無効な場合はエラー
155                if (USE_MULTIPLE_SHIPPING === false) {
156                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
157                    exit;
158                }
159                // フックポイント.
160                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
161                $objPlugin->doAction('LC_Page_Shopping_Deliv_action_multiple', array($this));
162
163                SC_Response_Ex::sendRedirect('multiple.php');
164                exit;
165                break;
166
167            default:
168                // 配送IDの取得
169                $shippingData = $objPurchase->getShippingTemp();
170                $arrShippingId = array_keys($shippingData);
171                if (isset($arrShippingId[0])) {
172                    $this->arrForm['deliv_check']['value'] = $arrShippingId[0] == 0 ? -1 : $arrShippingId[0];
173                }
174                break;
175        }
176
177        // 登録済み住所を取得
178        $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
179        $this->tpl_addrmax = count($this->arrAddr);
180
181        // フックポイント.
182        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
183        $objPlugin->doAction('LC_Page_Shopping_Deliv_action_after', array($this));
184    }
185
186    /**
187     * デストラクタ.
188     *
189     * @return void
190     */
191    function destroy() {
192        parent::destroy();
193    }
194
195    /**
196     * パラメーター情報の初期化を行う.
197     *
198     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
199     * @return void
200     */
201    function lfInitParam(&$objFormParam) {
202        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
203        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
204    }
205
206    /**
207     * その他のお届け先情報を削除する.
208     *
209     * @param integer $other_deliv_id その他のお届け先ID
210     * @return void
211     */
212    function doDelete($other_deliv_id) {
213        $objQuery =& SC_Query_Ex::getSingletonInstance();
214        $where = 'other_deliv_id = ?';
215        $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id));
216    }
217
218    /**
219     * お届け先チェックの値に応じて, お届け先情報を保存する.
220     *
221     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
222     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
223     * お届け先チェックの値が不正な場合は false を返す.
224     *
225     * @param integer $other_deliv_id
226     * @param string $uniqid 受注一時テーブルのユニークID
227     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
228     * @param SC_Customer $objCustomer SC_Customer インスタンス
229     * @return boolean お届け先チェックの値が妥当な場合 true
230     */
231    function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer) {
232        GC_Utils_Ex::gfDebugLog('register deliv. deliv_check=' . $deliv_check);
233        $arrValues = array();
234        // 会員登録住所がチェックされている場合
235        if ($other_deliv_id == 0) {
236            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
237        }
238        // 別のお届け先がチェックされている場合
239        else {
240            $objQuery =& SC_Query_Ex::getSingletonInstance();
241            $arrOtherDeliv = $objQuery->getRow('*', 'dtb_other_deliv',
242                                               'customer_id = ? AND other_deliv_id = ?',
243                                               array($objCustomer->getValue('customer_id'), $other_deliv_id));
244            if (empty($arrOtherDeliv)) {
245                return false;
246            }
247
248            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
249        }
250        $objPurchase->saveShippingTemp($arrValues, $other_deliv_id);
251        $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
252        return true;
253    }
254}
Note: See TracBrowser for help on using the repository browser.