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

Revision 23605, 9.4 KB checked in by kimoto, 10 years ago (diff)

#2448 typo修正・ソース整形・ソースコメントの改善 for 2.13.3

Scrutinizer Auto-Fixes

This patch was automatically generated as part of the following inspection:
 https://scrutinizer-ci.com/g/nobuhiko/EC-CUBE/inspections/d8722894-69a6-4b1b-898d-43618035c60d

Enabled analysis tools:

  • PHP Analyzer
  • PHP PDepend
  • PHP Similarity Analyzer
  • PHP Change Tracking Analyzer
  • 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-2014 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
24require_once CLASS_EX_REALDIR . 'page_extends/LC_Page_Ex.php';
25
26/**
27 * お届け先の指定 のページクラス.
28 *
29 * @package Page
30 * @author LOCKON CO.,LTD.
31 * @version $Id$
32 */
33class LC_Page_Shopping_Deliv extends LC_Page_Ex
34{
35    /**
36     * Page を初期化する.
37     *
38     * @return void
39     */
40    public function init()
41    {
42        parent::init();
43        $masterData = new SC_DB_MasterData_Ex();
44        $this->arrPref = $masterData->getMasterData('mtb_pref');
45        $this->arrCountry = $masterData->getMasterData('mtb_country');
46        $this->tpl_title = 'お届け先の指定';
47        $this->httpCacheControl('nocache');
48    }
49
50    /**
51     * Page のプロセス.
52     *
53     * @return void
54     */
55    public function process()
56    {
57        parent::process();
58        $this->action();
59        $this->sendResponse();
60    }
61
62    /**
63     * Page のプロセス.
64     *
65     * @return void
66     */
67    public function action()
68    {
69        //決済処理中ステータスのロールバック
70        $objPurchase = new SC_Helper_Purchase_Ex();
71        $objPurchase->cancelPendingOrder(PENDING_ORDER_CANCEL_FLAG);
72
73        $objSiteSess = new SC_SiteSession_Ex();
74        $objCartSess = new SC_CartSession_Ex();
75        $objCustomer = new SC_Customer_Ex();
76        $objFormParam = new SC_FormParam_Ex();
77        $objAddress = new SC_Helper_Address_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            SC_Response_Ex::sendRedirect('payment.php');
97            SC_Response_Ex::actionExit();
98        }
99
100        $this->lfInitParam($objFormParam);
101        $objFormParam->setParam($_POST);
102        $objFormParam->convParam();
103        $arrErr = $objFormParam->checkError();
104        if (!SC_Utils_Ex::isBlank($arrErr)) {
105            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
106            SC_Response_Ex::actionExit();
107        }
108
109        $arrForm = $objFormParam->getHashArray();
110
111        switch ($this->getMode()) {
112            // 削除
113            case 'delete':
114                if (!$objAddress->deleteAddress($arrForm['other_deliv_id'], $objCustomer->getValue('customer_id'))) {
115                    SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先を削除できませんでした。');
116                    SC_Response_Ex::actionExit();
117                }
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, $objAddress);
126                if (!$success) {
127                    SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, '', true);
128                }
129
130                $objPurchase->setShipmentItemTempForSole($objCartSess, $shipping_id);
131                $objSiteSess->setRegistFlag();
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_URL);
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                if (!SC_Utils_Ex::isBlank($shippingData)) {
161                    $arrShippingId = array_keys($shippingData);
162                }
163                if (isset($arrShippingId[0])) {
164                    $this->arrForm['deliv_check']['value'] = $arrShippingId[0] == 0 ? -1 : $arrShippingId[0];
165                }
166                break;
167        }
168
169        // 登録済み住所を取得
170        $addr = array(
171            array(
172                'other_deliv_id'    => NULL,
173                'customer_id'       => $objCustomer->getValue('customer_id'),
174                'name01'            => $objCustomer->getValue('name01'),
175                'name02'            => $objCustomer->getValue('name02'),
176                'kana01'            => $objCustomer->getValue('kana01'),
177                'kana02'            => $objCustomer->getValue('kana02'),
178                'company_name'      => $objCustomer->getValue('company_name'),
179                'country_id'           => $objCustomer->getValue('country_id'),
180                'zipcode'           => $objCustomer->getValue('zipcode'),
181                'zip01'             => $objCustomer->getValue('zip01'),
182                'zip02'             => $objCustomer->getValue('zip02'),
183                'pref'              => $objCustomer->getValue('pref'),
184                'addr01'            => $objCustomer->getValue('addr01'),
185                'addr02'            => $objCustomer->getValue('addr02'),
186                'tel01'             => $objCustomer->getValue('tel01'),
187                'tel02'             => $objCustomer->getValue('tel02'),
188                'tel03'             => $objCustomer->getValue('tel03'),
189            )
190        );
191        $this->arrAddr = array_merge($addr, $objAddress->getList($objCustomer->getValue('customer_id')));
192        $this->tpl_addrmax = count($this->arrAddr) - 1; // 会員の住所をカウントしない
193
194    }
195
196    /**
197     * パラメーター情報の初期化を行う.
198     *
199     * @param  SC_FormParam $objFormParam SC_FormParam インスタンス
200     * @return void
201     */
202    public function lfInitParam(&$objFormParam)
203    {
204        $objFormParam->addParam('その他のお届け先ID', 'other_deliv_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK'));
205        $objFormParam->addParam('お届け先チェック', 'deliv_check', INT_LEN, 'n', array('MAX_LENGTH_CHECK'));
206    }
207
208    /**
209     * お届け先チェックの値に応じて, お届け先情報を保存する.
210     *
211     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
212     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
213     * お届け先チェックの値が不正な場合は false を返す.
214     *
215     * @param  integer            $other_deliv_id
216     * @param  string             $uniqid         受注一時テーブルのユニークID
217     * @param  SC_Helper_Purchase $objPurchase    SC_Helper_Purchase インスタンス
218     * @param  SC_Customer        $objCustomer    SC_Customer インスタンス
219     * @param SC_Helper_Address_Ex $objAddress
220     * @return boolean            お届け先チェックの値が妥当な場合 true
221     */
222    public function registerDeliv($other_deliv_id, $uniqid, &$objPurchase, &$objCustomer, $objAddress)
223    {
224        $arrValues = array();
225        // 会員登録住所がチェックされている場合
226        if ($other_deliv_id == 0) {
227            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
228        // 別のお届け先がチェックされている場合
229        } else {
230            $arrOtherDeliv = $objAddress->getAddress($other_deliv_id, $objCustomer->getValue('customer_id'));
231            if (!$arrOtherDeliv) {
232                return false;
233            }
234
235            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');
236        }
237        $objPurchase->saveShippingTemp($arrValues, $other_deliv_id);
238        $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
239
240        return true;
241    }
242}
Note: See TracBrowser for help on using the repository browser.