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 |
---|
25 | require_once(CLASS_REALDIR . "pages/LC_Page.php"); |
---|
26 | |
---|
27 | /** |
---|
28 | * お届け先の指定 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class 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 | $objQuery = SC_Query::getSingletonInstance();; |
---|
73 | $objCookie = new SC_Cookie(COOKIE_EXPIRE); |
---|
74 | $this->tpl_uniqid = $objSiteSess->getUniqId(); |
---|
75 | $objPurchase->verifyChangeCart($this->tpl_uniqid, $objCartSess); |
---|
76 | |
---|
77 | $this->cartKey = $objCartSess->getKey(); |
---|
78 | |
---|
79 | // ログインチェック |
---|
80 | if(!$objCustomer->isLoginSuccess(true)) { |
---|
81 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
82 | } |
---|
83 | |
---|
84 | if($this->cartKey == PRODUCT_TYPE_DOWNLOAD){ |
---|
85 | // 会員情報の住所を受注一時テーブルに書き込む |
---|
86 | $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping'); |
---|
87 | $objPurchase->saveShippingTemp($sqlval); |
---|
88 | $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer); |
---|
89 | // 正常に登録されたことを記録しておく |
---|
90 | $objSiteSess->setRegistFlag(); |
---|
91 | // ダウンロード商品有りの場合は、支払方法画面に転送 |
---|
92 | SC_Response_Ex::sendRedirect('payment.php'); |
---|
93 | exit; |
---|
94 | } |
---|
95 | |
---|
96 | switch($this->getMode()) { |
---|
97 | // 削除 |
---|
98 | case 'delete': |
---|
99 | if (SC_Utils_Ex::sfIsInt($_POST['other_deliv_id'])) { |
---|
100 | $where = "other_deliv_id = ?"; |
---|
101 | $arrRet = $objQuery->delete("dtb_other_deliv", $where, array($_POST['other_deliv_id'])); |
---|
102 | } |
---|
103 | break; |
---|
104 | // 会員登録住所に送る |
---|
105 | case 'customer_addr': |
---|
106 | $sqlval = array(); |
---|
107 | $arrDeliv = $objPurchase->getDeliv($this->cartKey); |
---|
108 | $sqlval['deliv_id'] = $arrDeliv[0]['deliv_id']; |
---|
109 | // 会員登録住所がチェックされている場合 |
---|
110 | if ($_POST['deliv_check'] == '-1') { |
---|
111 | // 会員情報の住所を受注一時テーブルに書き込む |
---|
112 | $objPurchase->copyFromCustomer($sqlval, $objCustomer, 'shipping'); |
---|
113 | $objPurchase->saveShippingTemp($sqlval); |
---|
114 | $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer); |
---|
115 | |
---|
116 | // 正常に登録されたことを記録しておく |
---|
117 | $objSiteSess->setRegistFlag(); |
---|
118 | // お支払い方法選択ページへ移動 |
---|
119 | SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); |
---|
120 | exit; |
---|
121 | // 別のお届け先がチェックされている場合 |
---|
122 | } elseif($_POST['deliv_check'] >= 1) { |
---|
123 | if (SC_Utils_Ex::sfIsInt($_POST['deliv_check'])) { |
---|
124 | $otherDeliv = $objQuery->getRow("*", "dtb_other_deliv","customer_id = ? AND other_deliv_id = ?" |
---|
125 | ,array($objCustomer->getValue('customer_id'), $_POST['deliv_check'])); |
---|
126 | if (SC_Utils_Ex::isBlank($otherDeliv)) { |
---|
127 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
128 | } |
---|
129 | |
---|
130 | $objPurchase->copyFromOrder($sqlval, $otherDeliv, 'shipping', '');; |
---|
131 | $objPurchase->saveShippingTemp($sqlval); |
---|
132 | $objPurchase->saveOrderTemp($this->tpl_uniqid, $sqlval, $objCustomer); |
---|
133 | |
---|
134 | // 正常に登録されたことを記録しておく |
---|
135 | $objSiteSess->setRegistFlag(); |
---|
136 | // お支払い方法選択ページへ移動 |
---|
137 | SC_Response_Ex::sendRedirect(SHOPPING_PAYMENT_URLPATH); |
---|
138 | exit; |
---|
139 | } |
---|
140 | }else{ |
---|
141 | // エラーを返す |
---|
142 | $arrErr['deli'] = '※ お届け先を選択してください。'; |
---|
143 | } |
---|
144 | break; |
---|
145 | // 前のページに戻る |
---|
146 | case 'return': |
---|
147 | // 確認ページへ移動 |
---|
148 | SC_Response_Ex::sendRedirect(CART_URLPATH); |
---|
149 | exit; |
---|
150 | break; |
---|
151 | // お届け先複数指定 |
---|
152 | case 'multiple': |
---|
153 | SC_Response_Ex::sendRedirect('multiple.php'); |
---|
154 | exit; |
---|
155 | break; |
---|
156 | |
---|
157 | default: |
---|
158 | $objPurchase->unsetShippingTemp(); |
---|
159 | |
---|
160 | break; |
---|
161 | } |
---|
162 | |
---|
163 | // 登録済み住所を取得 |
---|
164 | $this->arrAddr = $objCustomer->getCustomerAddress($_SESSION['customer']['customer_id']); |
---|
165 | // 入力値の取得 |
---|
166 | if (!isset($arrErr)) $arrErr = array(); |
---|
167 | $this->arrErr = $arrErr; |
---|
168 | } |
---|
169 | |
---|
170 | /** |
---|
171 | * デストラクタ. |
---|
172 | * |
---|
173 | * @return void |
---|
174 | */ |
---|
175 | function destroy() { |
---|
176 | parent::destroy(); |
---|
177 | } |
---|
178 | } |
---|
179 | ?> |
---|