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

Revision 20538, 7.4 KB checked in by Seasoft, 13 years ago (diff)

#627(ソース整形・ソースコメントの改善)
#628(未使用処理・定義などの削除)

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