1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2012 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_EX_REALDIR . 'page_extends/LC_Page_Ex.php'; |
---|
26 | |
---|
27 | /** |
---|
28 | * お届け先追加 のページクラス. |
---|
29 | * |
---|
30 | * @package Page |
---|
31 | * @author LOCKON CO.,LTD. |
---|
32 | * @version $Id$ |
---|
33 | */ |
---|
34 | class LC_Page_Mypage_DeliveryAddr extends LC_Page_Ex { |
---|
35 | |
---|
36 | // }}} |
---|
37 | // {{{ functions |
---|
38 | |
---|
39 | /** |
---|
40 | * Page を初期化する. |
---|
41 | * |
---|
42 | * @return void |
---|
43 | */ |
---|
44 | function init() { |
---|
45 | parent::init(); |
---|
46 | $this->tpl_title = 'お届け先の追加・変更'; |
---|
47 | $masterData = new SC_DB_MasterData_Ex(); |
---|
48 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
49 | $this->httpCacheControl('nocache'); |
---|
50 | $this->validUrl = array(MYPAGE_DELIVADDR_URLPATH, |
---|
51 | DELIV_URLPATH, |
---|
52 | MULTIPLE_URLPATH); |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * Page のプロセス. |
---|
57 | * |
---|
58 | * @return void |
---|
59 | */ |
---|
60 | function process() { |
---|
61 | parent::process(); |
---|
62 | $this->action(); |
---|
63 | $this->sendResponse(); |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * Page のAction. |
---|
68 | * |
---|
69 | * @return void |
---|
70 | */ |
---|
71 | function action() { |
---|
72 | |
---|
73 | $objCustomer = new SC_Customer_Ex(); |
---|
74 | $objAddress = new SC_Helper_Address_Ex(); |
---|
75 | $ParentPage = MYPAGE_DELIVADDR_URLPATH; |
---|
76 | |
---|
77 | // GETでページを指定されている場合には指定ページに戻す |
---|
78 | if (isset($_GET['page'])) { |
---|
79 | $ParentPage = htmlspecialchars($_GET['page'], ENT_QUOTES); |
---|
80 | } else if (isset($_POST['ParentPage'])) { |
---|
81 | $ParentPage = htmlspecialchars($_POST['ParentPage'], ENT_QUOTES); |
---|
82 | } |
---|
83 | $this->ParentPage = $ParentPage; |
---|
84 | |
---|
85 | /* |
---|
86 | * ログイン判定 及び 退会判定 |
---|
87 | * 未ログインでも, 複数配送設定ページからのアクセスの場合は表示する |
---|
88 | * |
---|
89 | * TODO 購入遷移とMyPageで別クラスにすべき |
---|
90 | */ |
---|
91 | if (!$objCustomer->isLoginSuccess(true) && $ParentPage != MULTIPLE_URLPATH) { |
---|
92 | $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();"; |
---|
93 | } |
---|
94 | |
---|
95 | // other_deliv_id のあるなしで追加か編集か判定しているらしい |
---|
96 | $_SESSION['other_deliv_id'] = $_REQUEST['other_deliv_id']; |
---|
97 | |
---|
98 | // パラメーター管理クラス,パラメーター情報の初期化 |
---|
99 | $objFormParam = new SC_FormParam_Ex(); |
---|
100 | $objAddress->setFormParam($objFormParam); |
---|
101 | $objFormParam->setParam($_POST); |
---|
102 | $this->arrForm = $objFormParam->getHashArray(); |
---|
103 | |
---|
104 | switch ($this->getMode()) { |
---|
105 | // 入力は必ずedit |
---|
106 | case 'edit': |
---|
107 | $this->arrErr = $objAddress->errorCheck($objFormParam); |
---|
108 | // 入力エラーなし |
---|
109 | if (empty($this->arrErr)) { |
---|
110 | |
---|
111 | // TODO ここでやるべきではない |
---|
112 | if (in_array($_POST['ParentPage'], $this->validUrl)) { |
---|
113 | $this->tpl_onload = "fnUpdateParent('". $this->getLocation($_POST['ParentPage']) ."'); window.close();"; |
---|
114 | } else { |
---|
115 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
116 | } |
---|
117 | |
---|
118 | if ($objCustomer->isLoginSuccess(true)) { |
---|
119 | $this->lfRegistData($objAddress, $objFormParam, $objCustomer->getValue('customer_id')); |
---|
120 | } else { |
---|
121 | $this->lfRegistDataNonMember($objFormParam); |
---|
122 | } |
---|
123 | |
---|
124 | if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) { |
---|
125 | |
---|
126 | // モバイルの場合、元のページに遷移 |
---|
127 | SC_Response_Ex::sendRedirect($this->getLocation($_POST['ParentPage'])); |
---|
128 | SC_Response_Ex::actionExit(); |
---|
129 | } |
---|
130 | } |
---|
131 | break; |
---|
132 | case 'multiple': |
---|
133 | // 複数配送先用 |
---|
134 | break; |
---|
135 | default : |
---|
136 | |
---|
137 | if ($_GET['other_deliv_id'] != '') { |
---|
138 | $arrOtherDeliv = $objAddress->getAddress($objCustomer->getValue('customer_id'), $_SESSION['other_deliv_id']); |
---|
139 | |
---|
140 | //不正アクセス判定 |
---|
141 | if (!$objCustomer->isLoginSuccess(true) || !$arrOtherDeliv) { |
---|
142 | SC_Utils_Ex::sfDispSiteError(CUSTOMER_ERROR); |
---|
143 | } |
---|
144 | |
---|
145 | //別のお届け先情報取得 |
---|
146 | $this->arrForm = $arrOtherDeliv; |
---|
147 | } |
---|
148 | break; |
---|
149 | } |
---|
150 | |
---|
151 | if (SC_Display_Ex::detectDevice() === DEVICE_TYPE_MOBILE) { |
---|
152 | $this->tpl_mainpage = 'mypage/delivery_addr.tpl'; |
---|
153 | } else { |
---|
154 | $this->setTemplate('mypage/delivery_addr.tpl'); |
---|
155 | } |
---|
156 | |
---|
157 | } |
---|
158 | |
---|
159 | /** |
---|
160 | * デストラクタ. |
---|
161 | * |
---|
162 | * @return void |
---|
163 | */ |
---|
164 | function destroy() { |
---|
165 | parent::destroy(); |
---|
166 | } |
---|
167 | |
---|
168 | /* 登録実行 */ |
---|
169 | function lfRegistData($objAddress, $objFormParam, $customer_id) { |
---|
170 | $arrRet = $objFormParam->getHashArray(); |
---|
171 | $sqlval = $objFormParam->getDbArray(); |
---|
172 | |
---|
173 | $sqlval['customer_id'] = $customer_id; |
---|
174 | |
---|
175 | $objAddress->registAddress($customer_id, $sqlval, $arrRet['other_deliv_id']); |
---|
176 | } |
---|
177 | |
---|
178 | function lfRegistDataNonMember($objFormParam) { |
---|
179 | $arrRegistColumn = $objFormParam->getDbArray(); |
---|
180 | foreach ($arrRegistColumn as $key => $val) { |
---|
181 | $arrRegist['shipping_' . $key ] = $val; |
---|
182 | } |
---|
183 | if (count($_SESSION['shipping']) >= DELIV_ADDR_MAX) { |
---|
184 | SC_Utils_Ex::sfDispSiteError(FREE_ERROR_MSG, '', false, '別のお届け先最大登録数に達しています。'); |
---|
185 | } else { |
---|
186 | $_SESSION['shipping'][] = $arrRegist; |
---|
187 | } |
---|
188 | } |
---|
189 | } |
---|