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

Revision 21866, 8.1 KB checked in by h_yoshimoto, 12 years ago (diff)

#1831 Copyrightを更新を誤っているので戻します

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