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

Revision 22567, 8.7 KB checked in by shutta, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.12.4)
Zend Framework PHP 標準コーディング規約のコーディングスタイルへ準拠。
classおよびfunctionの開始波括弧「{」のスタイルを修正。

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