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

Revision 20116, 7.4 KB checked in by nanasess, 13 years ago (diff)
  • svn properties を再設定
  • 再設定用のスクリプト追加
  • 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_REALDIR . "pages/LC_Page.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 {
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        $this->action();
59        $this->sendResponse();
60    }
61
62    /**
63     * Page のプロセス.
64     *
65     * @return void
66     */
67    function action() {
68        $objSiteSess = new SC_SiteSession();
69        $objCartSess = new SC_CartSession();
70        $objCustomer = new SC_Customer();
71        $objPurchase = new SC_Helper_Purchase_Ex();
72        $objFormParam = new SC_FormParam();
73        $objCookie = new SC_Cookie(COOKIE_EXPIRE);
74
75        $this->tpl_uniqid = $objSiteSess->getUniqId();
76        $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess);
77
78        $this->cartKey = $objCartSess->getKey();
79
80        // ログインチェック
81        if (!$objCustomer->isLoginSuccess(true)) {
82            SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR);
83        }
84
85        // ダウンロード商品の場合は、支払方法画面に転送
86        if ($this->cartKey == PRODUCT_TYPE_DOWNLOAD) {
87            $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping');
88            $objPurchase->saveShippingTemp($sqlval);
89            $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer);
90            $objSiteSess->setRegistFlag();
91            SC_Response_Ex::sendRedirect('payment.php');
92            exit;
93        }
94
95        $this->lfInitParam($objFormParam);
96        $objFormParam->setParam($_POST);
97        $objFormParam->convParam();
98        $arrErr = $objFormParam->checkError();
99        if (!SC_Utils_Ex::isBlank($arrErr)) {
100            SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
101            exit;
102        }
103
104        $arrForm = $objFormParam->getHashArray();
105
106        switch($this->getMode()) {
107        // 削除
108        case 'delete':
109            $this->doDelete($arrForm['other_deliv_id']);
110            break;
111
112        // 会員登録住所に送る
113        case 'customer_addr':
114            if ($this->registerDeliv($arrForm['deliv_check'], $this->tpl_uniqid,
115                                     $objPurchase, $objCustomer)) {
116                $objSiteSess->setRegistFlag();
117                SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH);
118                exit;
119
120            } else {
121                SC_Utils_Ex::sfDispSiteError(PAGE_ERROR, "", true);
122            }
123            break;
124
125        // 前のページに戻る
126        case 'return':
127            // 確認ページへ移動
128            SC_Response_Ex::sendRedirect(CART_URLPATH);
129            exit;
130            break;
131
132        // お届け先複数指定
133        case 'multiple':
134            SC_Response_Ex::sendRedirect('multiple.php');
135            exit;
136            break;
137
138        default:
139            $objPurchase->unsetShippingTemp();
140            break;
141        }
142
143        // 登録済み住所を取得
144        $this->arrAddr = $objCustomer->getCustomerAddress($objCustomer->getValue('customer_id'));
145    }
146
147    /**
148     * デストラクタ.
149     *
150     * @return void
151     */
152    function destroy() {
153        parent::destroy();
154    }
155
156    /**
157     * パラメータ情報の初期化を行う.
158     *
159     * @param SC_FormParam $objFormParam SC_FormParam インスタンス
160     * @return void
161     */
162    function lfInitParam(&$objFormParam) {
163        $objFormParam->addParam("その他のお届け先ID", "other_deliv_id", INT_LEN, "n", array("NUM_CHECK", "MAX_LENGTH_CHECK"));
164        $objFormParam->addParam("お届け先チェック", "deliv_check", INT_LEN, "n", array("MAX_LENGTH_CHECK"));
165    }
166
167    /**
168     * その他のお届け先情報を削除する.
169     *
170     * @param integer $other_deliv_id その他のお届け先ID
171     * @return void
172     */
173    function doDelete($other_deliv_id) {
174        $objQuery =& SC_Query::getSingletonInstance();
175        $where = "other_deliv_id = ?";
176        $objQuery->delete("dtb_other_deliv", $where, array($other_deliv_id));
177    }
178
179    /**
180     * お届け先チェックの値に応じて, お届け先情報を保存する.
181     *
182     * 会員住所がチェックされている場合は, 会員情報からお届け先を取得する.
183     * その他のお届け先がチェックされている場合は, その他のお届け先からお届け先を取得する.
184     * お届け先チェックの値が不正な場合は false を返す.
185     *
186     * @param integer $deliv_check お届け先チェック
187     * @param string $uniqid 受注一時テーブルのユニークID
188     * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス
189     * @param SC_Customer $objCustomer SC_Customer インスタンス
190     * @return boolean お届け先チェックの値が妥当な場合 true
191     */
192    function registerDeliv($deliv_check, $uniqid, &$objPurchase, &$objCustomer) {
193        $arrValues = array();
194        // 会員登録住所がチェックされている場合
195        if ($deliv_check == '-1') {
196            $objPurchase->copyFromCustomer($arrValues, $objCustomer, 'shipping');
197            $objPurchase->saveShippingTemp($arrValues);
198            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
199            return true;
200        }
201        // 別のお届け先がチェックされている場合
202        elseif ($deliv_check >= 1) {
203            $objQuery =& SC_Query::getSingletonInstance();
204            $arrOtherDeliv = $objQuery->getRow("*", "dtb_other_deliv",
205                                               "customer_id = ? AND other_deliv_id = ?",
206                                               array($objCustomer->getValue('customer_id'), $deliv_check));
207            if (SC_Utils_Ex::isBlank($arrOtherDeliv)) {
208                return false;
209            }
210
211            $objPurchase->copyFromOrder($arrValues, $arrOtherDeliv, 'shipping', '');;
212            $objPurchase->saveShippingTemp($arrValues);
213            $objPurchase->saveOrderTemp($uniqid, $arrValues, $objCustomer);
214            return true;
215        }
216        // お届け先チェックが不正な場合
217        else {
218            return false;
219        }
220    }
221}
222?>
Note: See TracBrowser for help on using the repository browser.