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

Revision 21596, 9.0 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_start', 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                $success = $this->registerDeliv($arrForm['deliv_check'], $this->tpl_uniqid, $objPurchase, $objCustomer);
125                if (!$success) {
126                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
127                }
128
129                $objPurchase->setShipmentItemTempForSole($objCartSess);
130                $objSiteSess->setRegistFlag();
131                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
132                exit;
133                break;
134
135            // 前のページに戻る
136            case 'return':
137                // フックポイント.
138                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
139                $objPlugin->doAction('lc_page_shopping_deliv_action_return', array($this));
140
141                // 確認ページへ移動
142                SC_Response_Ex::sendRedirect(CART_URLPATH);
143                exit;
144                break;
145
146            // お届け先複数指定
147            case 'multiple':
148                // 複数配送先指定が無効な場合はエラー
149                if (USE_MULTIPLE_SHIPPING === false) {
150                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
151                    exit;
152                }
153                // フックポイント.
154                $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
155                $objPlugin->doAction('lc_page_shopping_deliv_action_multiple', array($this));
156
157                SC_Response_Ex::sendRedirect('multiple.php');
158                exit;
159                break;
160            default:
161                break;
162        }
163
164        // 登録済み住所を取得
165        $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
166        $this->tpl_addrmax = count($this->arrAddr);
167
168        // フックポイント.
169        $objPlugin = SC_Helper_Plugin_Ex::getSingletonInstance($this->plugin_activate_flg);
170        $objPlugin->doAction('lc_page_shopping_deliv_action_end', array($this));
171    }
172
173    /**
174     * デストラクタ.
175     *
176     * @return void
177     */
178    function destroy() {
179        parent::destroy();
180    }
181
182    /**
183     * パラメーター情報の初期化を行う.
184     *
185     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
186     * @return void
187     */
188    function lfInitParam(&$objFormParam) {
189        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
190        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
191    }
192
193    /**
194     * その他のお届け先情報を削除する.
195     *
196     * @param integer $other_deliv_id その他のお届け先ID
197     * @return void
198     */
199    function doDelete($other_deliv_id) {
200        $objQuery =& SC_Query_Ex::getSingletonInstance();
201        $where = 'other_deliv_id = ?';
202        $objQuery->delete('dtb_other_deliv', $where, array($other_deliv_id));
203    }
204
205    /**
206     * お届け先チェックの値に応じて, お届け先情報を保存する.
207     *
208     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
209     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
210     * お届け先チェックの値が不正な場合は false を返す.
211     *
212     * @param integer $deliv_check お届け先チェック
213     * @param string $uniqid 受注一時テーブルのユニークID
214     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
215     * @param SC_Customer $objCustomer SC_Customer インスタンス
216     * @return boolean お届け先チェックの値が妥当な場合 true
217     */
218    function registerDeliv($deliv_check, $uniqid, &$objPurchase, &$objCustomer) {
219        GC_Utils_Ex::gfDebugLog('register deliv. deliv_check=' . $deliv_check);
220        $arrValues = array();
221        // 会員登録住所がチェックされている場合
222        if ($deliv_check == '-1') {
223            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
224            $objPurchase->saveShippingTemp($arrValues);
225            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
226            return true;
227        }
228        // 別のお届け先がチェックされている場合
229        elseif ($deliv_check >= 1) {
230            $objQuery =& SC_Query_Ex::getSingletonInstance();
231            $arrOtherDeliv = $objQuery->getRow('*', 'dtb_other_deliv',
232                                               'customer_id = ? AND other_deliv_id = ?',
233                                               array($objCustomer->getValue('customer_id'), $deliv_check));
234            if (SC_Utils_Ex::isBlank($arrOtherDeliv)) {
235                return false;
236            }
237
238            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
239            $objPurchase->saveShippingTemp($arrValues);
240            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
241            return true;
242        }
243        // お届け先チェックが不正な場合
244        else {
245            return false;
246        }
247    }
248}
Note: See TracBrowser for help on using the repository browser.