1 | <?php |
---|
2 | /* |
---|
3 | * This file is part of EC-CUBE |
---|
4 | * |
---|
5 | * Copyright(c) 2000-2013 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 | require_once CLASS_EX_REALDIR . 'page_extends/admin/order/LC_Page_Admin_Order_Ex.php'; |
---|
25 | |
---|
26 | /** |
---|
27 | * 受注修正 のページクラス. |
---|
28 | * |
---|
29 | * @package Page |
---|
30 | * @author LOCKON CO.,LTD. |
---|
31 | * @version $Id$ |
---|
32 | */ |
---|
33 | class LC_Page_Admin_Order_Edit extends LC_Page_Admin_Order_Ex |
---|
34 | { |
---|
35 | public $arrShippingKeys = array( |
---|
36 | 'shipping_id', |
---|
37 | 'shipping_name01', |
---|
38 | 'shipping_name02', |
---|
39 | 'shipping_kana01', |
---|
40 | 'shipping_kana02', |
---|
41 | 'shipping_company_name', |
---|
42 | 'shipping_tel01', |
---|
43 | 'shipping_tel02', |
---|
44 | 'shipping_tel03', |
---|
45 | 'shipping_fax01', |
---|
46 | 'shipping_fax02', |
---|
47 | 'shipping_fax03', |
---|
48 | 'shipping_pref', |
---|
49 | 'shipping_country_id', |
---|
50 | 'shipping_zipcode', |
---|
51 | 'shipping_zip01', |
---|
52 | 'shipping_zip02', |
---|
53 | 'shipping_addr01', |
---|
54 | 'shipping_addr02', |
---|
55 | 'shipping_date_year', |
---|
56 | 'shipping_date_month', |
---|
57 | 'shipping_date_day', |
---|
58 | 'time_id', |
---|
59 | ); |
---|
60 | |
---|
61 | public $arrShipmentItemKeys = array( |
---|
62 | 'shipment_product_class_id', |
---|
63 | 'shipment_product_code', |
---|
64 | 'shipment_product_name', |
---|
65 | 'shipment_classcategory_name1', |
---|
66 | 'shipment_classcategory_name2', |
---|
67 | 'shipment_price', |
---|
68 | 'shipment_quantity', |
---|
69 | ); |
---|
70 | |
---|
71 | public $arrProductKeys = array( |
---|
72 | 'product_id', |
---|
73 | 'product_class_id', |
---|
74 | 'product_type_id', |
---|
75 | 'point_rate', |
---|
76 | 'product_code', |
---|
77 | 'product_name', |
---|
78 | 'classcategory_name1', |
---|
79 | 'classcategory_name2', |
---|
80 | 'quantity', |
---|
81 | 'price', |
---|
82 | 'tax_rate', |
---|
83 | 'tax_rule' |
---|
84 | ); |
---|
85 | |
---|
86 | /** |
---|
87 | * Page を初期化する. |
---|
88 | * |
---|
89 | * @return void |
---|
90 | */ |
---|
91 | public function init() |
---|
92 | { |
---|
93 | parent::init(); |
---|
94 | $this->tpl_mainpage = 'order/edit.tpl'; |
---|
95 | $this->tpl_mainno = 'order'; |
---|
96 | $this->tpl_maintitle = '受注管理'; |
---|
97 | $this->tpl_subtitle = '受注登録'; |
---|
98 | |
---|
99 | $masterData = new SC_DB_MasterData_Ex(); |
---|
100 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
101 | $this->arrCountry = $masterData->getMasterData('mtb_country'); |
---|
102 | $this->arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); |
---|
103 | $this->arrDeviceType = $masterData->getMasterData('mtb_device_type'); |
---|
104 | |
---|
105 | $objDate = new SC_Date_Ex(RELEASE_YEAR); |
---|
106 | $this->arrYearShippingDate = $objDate->getYear('', date('Y'), ''); |
---|
107 | $this->arrMonthShippingDate = $objDate->getMonth(true); |
---|
108 | $this->arrDayShippingDate = $objDate->getDay(true); |
---|
109 | |
---|
110 | // 支払い方法の取得 |
---|
111 | $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList(); |
---|
112 | |
---|
113 | // 配送業者の取得 |
---|
114 | $this->arrDeliv = SC_Helper_Delivery_Ex::getIDValueList(); |
---|
115 | |
---|
116 | $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
117 | |
---|
118 | $this->httpCacheControl('nocache'); |
---|
119 | } |
---|
120 | |
---|
121 | /** |
---|
122 | * Page のプロセス. |
---|
123 | * |
---|
124 | * @return void |
---|
125 | */ |
---|
126 | public function process() |
---|
127 | { |
---|
128 | $this->action(); |
---|
129 | $this->sendResponse(); |
---|
130 | } |
---|
131 | |
---|
132 | /** |
---|
133 | * Page のアクション. |
---|
134 | * |
---|
135 | * @return void |
---|
136 | */ |
---|
137 | public function action() |
---|
138 | { |
---|
139 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
140 | $objFormParam = new SC_FormParam_Ex(); |
---|
141 | |
---|
142 | // パラメーター情報の初期化 |
---|
143 | $this->lfInitParam($objFormParam); |
---|
144 | $objFormParam->setParam($_REQUEST); |
---|
145 | $objFormParam->convParam(); |
---|
146 | $order_id = $objFormParam->getValue('order_id'); |
---|
147 | $arrValuesBefore = array(); |
---|
148 | |
---|
149 | // DBから受注情報を読み込む |
---|
150 | if (!SC_Utils_Ex::isBlank($order_id)) { |
---|
151 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
152 | $this->tpl_subno = 'index'; |
---|
153 | $arrValuesBefore['payment_id'] = $objFormParam->getValue('payment_id'); |
---|
154 | $arrValuesBefore['payment_method'] = $objFormParam->getValue('payment_method'); |
---|
155 | } else { |
---|
156 | $this->tpl_subno = 'add'; |
---|
157 | $this->tpl_mode = 'add'; |
---|
158 | $arrValuesBefore['payment_id'] = NULL; |
---|
159 | $arrValuesBefore['payment_method'] = NULL; |
---|
160 | // お届け先情報を空情報で表示 |
---|
161 | $arrShippingIds[] = null; |
---|
162 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
163 | |
---|
164 | // 新規受注登録で入力エラーがあった場合の画面表示用に、会員の現在ポイントを取得 |
---|
165 | if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { |
---|
166 | $customer_id = $objFormParam->getValue('customer_id'); |
---|
167 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
168 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
169 | |
---|
170 | // 新規受注登録で、ポイント利用できるように現在ポイントを設定 |
---|
171 | $objFormParam->setValue('point', $arrCustomer['point']); |
---|
172 | } |
---|
173 | } |
---|
174 | |
---|
175 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
176 | |
---|
177 | switch ($this->getMode()) { |
---|
178 | case 'pre_edit': |
---|
179 | case 'order_id': |
---|
180 | break; |
---|
181 | |
---|
182 | case 'edit': |
---|
183 | $objFormParam->setParam($_POST); |
---|
184 | $objFormParam->convParam(); |
---|
185 | //複数配送時に各商品の総量を設定 |
---|
186 | $this->setProductsQuantity($objFormParam); |
---|
187 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
188 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
189 | $message = '受注を編集しました。'; |
---|
190 | $order_id = $this->doRegister($order_id, $objPurchase, $objFormParam, $message, $arrValuesBefore); |
---|
191 | if ($order_id >= 0) { |
---|
192 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
193 | } |
---|
194 | $this->tpl_onload = "window.alert('" . $message . "');"; |
---|
195 | } |
---|
196 | break; |
---|
197 | |
---|
198 | case 'add': |
---|
199 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
---|
200 | $objFormParam->setParam($_POST); |
---|
201 | $objFormParam->convParam(); |
---|
202 | //複数配送時に各商品の総量を設定 |
---|
203 | $this->setProductsQuantity($objFormParam); |
---|
204 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
205 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
206 | $message = '受注を登録しました。'; |
---|
207 | $order_id = $this->doRegister(null, $objPurchase, $objFormParam, $message, $arrValuesBefore); |
---|
208 | if ($order_id >= 0) { |
---|
209 | $this->tpl_mode = 'edit'; |
---|
210 | $objFormParam->setValue('order_id', $order_id); |
---|
211 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
212 | } |
---|
213 | $this->tpl_onload = "window.alert('" . $message . "');"; |
---|
214 | } |
---|
215 | } |
---|
216 | |
---|
217 | break; |
---|
218 | |
---|
219 | // 再計算 |
---|
220 | case 'recalculate': |
---|
221 | //支払い方法の選択 |
---|
222 | case 'payment': |
---|
223 | // 配送業者の選択 |
---|
224 | case 'deliv': |
---|
225 | $objFormParam->setParam($_POST); |
---|
226 | $objFormParam->convParam(); |
---|
227 | //複数配送時に各商品の総量を設定 |
---|
228 | $this->setProductsQuantity($objFormParam); |
---|
229 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
230 | break; |
---|
231 | |
---|
232 | // 商品削除 |
---|
233 | case 'delete_product': |
---|
234 | $objFormParam->setParam($_POST); |
---|
235 | $objFormParam->convParam(); |
---|
236 | $delete_no = $objFormParam->getValue('delete_no'); |
---|
237 | $this->doDeleteProduct($delete_no, $objFormParam); |
---|
238 | //複数配送時に各商品の総量を設定 |
---|
239 | $this->setProductsQuantity($objFormParam); |
---|
240 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
241 | break; |
---|
242 | |
---|
243 | // 商品追加ポップアップより商品選択 |
---|
244 | case 'select_product_detail': |
---|
245 | $objFormParam->setParam($_POST); |
---|
246 | $objFormParam->convParam(); |
---|
247 | $this->doRegisterProduct($objFormParam); |
---|
248 | //複数配送時に各商品の総量を設定 |
---|
249 | $this->setProductsQuantity($objFormParam); |
---|
250 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
251 | break; |
---|
252 | |
---|
253 | // 会員検索ポップアップより会員指定 |
---|
254 | case 'search_customer': |
---|
255 | $objFormParam->setParam($_POST); |
---|
256 | $objFormParam->convParam(); |
---|
257 | $customer_birth = $this->setCustomerTo($objFormParam->getValue('edit_customer_id'), |
---|
258 | $objFormParam); |
---|
259 | // 加算ポイントの計算 |
---|
260 | if (USE_POINT === true && $this->tpl_mode == 'add') { |
---|
261 | $birth_point = 0; |
---|
262 | if ($customer_birth) { |
---|
263 | $arrRet = preg_split('|[- :/]|', $customer_birth); |
---|
264 | $birth_date = intval($arrRet[1]); |
---|
265 | $now_date = intval(date('m')); |
---|
266 | // 誕生日月であった場合 |
---|
267 | if ($birth_date == $now_date) { |
---|
268 | $birth_point = BIRTH_MONTH_POINT; |
---|
269 | } |
---|
270 | } |
---|
271 | $objFormParam->setValue("birth_point",$birth_point); |
---|
272 | } |
---|
273 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
274 | break; |
---|
275 | |
---|
276 | // 複数配送設定表示 |
---|
277 | case 'multiple': |
---|
278 | $objFormParam->setParam($_POST); |
---|
279 | $objFormParam->convParam(); |
---|
280 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
281 | break; |
---|
282 | |
---|
283 | // 複数配送設定を反映 |
---|
284 | case 'multiple_set_to': |
---|
285 | $this->lfInitMultipleParam($objFormParam); |
---|
286 | $objFormParam->setParam($_POST); |
---|
287 | $objFormParam->convParam(); |
---|
288 | $this->setMultipleItemTo($objFormParam); |
---|
289 | break; |
---|
290 | |
---|
291 | // お届け先の追加 |
---|
292 | case 'append_shipping': |
---|
293 | $objFormParam->setParam($_POST); |
---|
294 | $objFormParam->convParam(); |
---|
295 | $this->addShipping($objFormParam); |
---|
296 | break; |
---|
297 | |
---|
298 | default: |
---|
299 | break; |
---|
300 | } |
---|
301 | |
---|
302 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
303 | $this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys)); |
---|
304 | $this->top_shipping_id = array_shift((array_keys($this->arrAllShipping))); |
---|
305 | $this->arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id')); |
---|
306 | $this->tpl_onload .= $this->getAnchorKey($objFormParam); |
---|
307 | if ($arrValuesBefore['payment_id']) |
---|
308 | $this->arrPayment[$arrValuesBefore['payment_id']] = $arrValuesBefore['payment_method']; |
---|
309 | } |
---|
310 | |
---|
311 | /** |
---|
312 | * パラメーター情報の初期化を行う. |
---|
313 | * |
---|
314 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
315 | * @return void |
---|
316 | */ |
---|
317 | public function lfInitParam(&$objFormParam) |
---|
318 | { |
---|
319 | // 検索条件のパラメーターを初期化 |
---|
320 | parent::lfInitParam($objFormParam); |
---|
321 | |
---|
322 | // お客様情報 |
---|
323 | $objFormParam->addParam('注文者 お名前(姓)', 'order_name01', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
324 | $objFormParam->addParam('注文者 お名前(名)', 'order_name02', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
325 | $objFormParam->addParam('注文者 お名前(フリガナ・姓)', 'order_kana01', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
326 | $objFormParam->addParam('注文者 お名前(フリガナ・名)', 'order_kana02', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
327 | $objFormParam->addParam('注文者 会社名', 'order_company_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
328 | $objFormParam->addParam('メールアドレス', 'order_email', null, 'KVCa', array('NO_SPTAB', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
329 | $objFormParam->addParam('国', 'order_country_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
330 | $objFormParam->addParam('ZIPCODE', 'order_zipcode', STEXT_LEN, 'n', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
---|
331 | $objFormParam->addParam('郵便番号1', 'order_zip01', ZIP01_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
332 | $objFormParam->addParam('郵便番号2', 'order_zip02', ZIP02_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
333 | $objFormParam->addParam('都道府県', 'order_pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
334 | $objFormParam->addParam('住所1', 'order_addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
335 | $objFormParam->addParam('住所2', 'order_addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
336 | $objFormParam->addParam('電話番号1', 'order_tel01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
337 | $objFormParam->addParam('電話番号2', 'order_tel02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
338 | $objFormParam->addParam('電話番号3', 'order_tel03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
339 | $objFormParam->addParam('FAX番号1', 'order_fax01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
340 | $objFormParam->addParam('FAX番号2', 'order_fax02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
341 | $objFormParam->addParam('FAX番号3', 'order_fax03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
342 | |
---|
343 | // 受注商品情報 |
---|
344 | $objFormParam->addParam('値引き', 'discount', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
345 | $objFormParam->addParam('送料', 'deliv_fee', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
346 | $objFormParam->addParam('手数料', 'charge', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
347 | |
---|
348 | // ポイント機能ON時のみ |
---|
349 | if (USE_POINT !== false) { |
---|
350 | $objFormParam->addParam('利用ポイント', 'use_point', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
351 | } |
---|
352 | |
---|
353 | $objFormParam->addParam('配送業者', 'deliv_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
354 | $objFormParam->addParam('お支払い方法', 'payment_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
355 | $objFormParam->addParam('対応状況', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
356 | $objFormParam->addParam('お支払方法名称', 'payment_method'); |
---|
357 | |
---|
358 | // 受注詳細情報 |
---|
359 | $objFormParam->addParam('商品種別ID', 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
360 | $objFormParam->addParam('単価', 'price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
361 | $objFormParam->addParam('数量', 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
362 | $objFormParam->addParam('商品ID', 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
363 | $objFormParam->addParam('商品規格ID', 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
364 | $objFormParam->addParam('ポイント付与率', 'point_rate'); |
---|
365 | $objFormParam->addParam('商品コード', 'product_code'); |
---|
366 | $objFormParam->addParam('商品名', 'product_name'); |
---|
367 | $objFormParam->addParam('規格名1', 'classcategory_name1'); |
---|
368 | $objFormParam->addParam('規格名2', 'classcategory_name2'); |
---|
369 | $objFormParam->addParam('税率', 'tax_rate', INT_LEN, 'n', array('NUM_CHECK')); |
---|
370 | $objFormParam->addParam('課税規則', 'tax_rule', INT_LEN, 'n', array('NUM_CHECK')); |
---|
371 | $objFormParam->addParam('メモ', 'note', MTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
372 | $objFormParam->addParam('削除用項番', 'delete_no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
373 | |
---|
374 | // DB読込用 |
---|
375 | $objFormParam->addParam('小計', 'subtotal'); |
---|
376 | $objFormParam->addParam('合計', 'total'); |
---|
377 | $objFormParam->addParam('支払い合計', 'payment_total'); |
---|
378 | $objFormParam->addParam('加算ポイント', 'add_point'); |
---|
379 | $objFormParam->addParam('お誕生日ポイント', 'birth_point', null, 'n', array(), 0); |
---|
380 | $objFormParam->addParam('消費税合計', 'tax'); |
---|
381 | $objFormParam->addParam('最終保持ポイント', 'total_point'); |
---|
382 | $objFormParam->addParam('会員ID', 'customer_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
383 | $objFormParam->addParam('会員ID', 'edit_customer_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
384 | $objFormParam->addParam('現在のポイント', 'customer_point'); |
---|
385 | $objFormParam->addParam('受注前ポイント', 'point'); |
---|
386 | $objFormParam->addParam('注文番号', 'order_id'); |
---|
387 | $objFormParam->addParam('受注日', 'create_date'); |
---|
388 | $objFormParam->addParam('発送日', 'commit_date'); |
---|
389 | $objFormParam->addParam('備考', 'message'); |
---|
390 | $objFormParam->addParam('入金日', 'payment_date'); |
---|
391 | $objFormParam->addParam('端末種別', 'device_type_id'); |
---|
392 | $objFormParam->addParam('税率', 'order_tax_rate'); |
---|
393 | $objFormParam->addParam('課税規則', 'order_tax_rule'); |
---|
394 | |
---|
395 | // 複数情報 |
---|
396 | $objFormParam->addParam('配送数', 'shipping_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
397 | $objFormParam->addParam('配送ID', 'shipping_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), 0); |
---|
398 | $objFormParam->addParam('お名前(姓)', 'shipping_name01', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
399 | $objFormParam->addParam('お名前(名)', 'shipping_name02', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
400 | $objFormParam->addParam('お名前(フリガナ・姓)', 'shipping_kana01', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
401 | $objFormParam->addParam('お名前(フリガナ・名)', 'shipping_kana02', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
402 | $objFormParam->addParam('会社名', 'shipping_company_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
403 | $objFormParam->addParam('国', 'shipping_country_id', INT_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
404 | $objFormParam->addParam('ZIPCODE', 'shipping_zipcode', STEXT_LEN, 'n', array('GRAPH_CHECK', 'MAX_LENGTH_CHECK')); |
---|
405 | $objFormParam->addParam('郵便番号1', 'shipping_zip01', ZIP01_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
406 | $objFormParam->addParam('郵便番号2', 'shipping_zip02', ZIP02_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
407 | $objFormParam->addParam('都道府県', 'shipping_pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
408 | $objFormParam->addParam('住所1', 'shipping_addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
409 | $objFormParam->addParam('住所2', 'shipping_addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
410 | $objFormParam->addParam('電話番号1', 'shipping_tel01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
411 | $objFormParam->addParam('電話番号2', 'shipping_tel02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
412 | $objFormParam->addParam('電話番号3', 'shipping_tel03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
413 | $objFormParam->addParam('FAX番号1', 'shipping_fax01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
414 | $objFormParam->addParam('FAX番号2', 'shipping_fax02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
415 | $objFormParam->addParam('FAX番号3', 'shipping_fax03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
416 | $objFormParam->addParam('お届け時間ID', 'time_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
417 | $objFormParam->addParam('お届け日(年)', 'shipping_date_year', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
418 | $objFormParam->addParam('お届け日(月)', 'shipping_date_month', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
419 | $objFormParam->addParam('お届け日(日)', 'shipping_date_day', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
420 | $objFormParam->addParam('お届け日', 'shipping_date', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
421 | $objFormParam->addParam('配送商品数量', 'shipping_product_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
422 | |
---|
423 | $objFormParam->addParam('商品規格ID', 'shipment_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
424 | $objFormParam->addParam('商品コード', 'shipment_product_code'); |
---|
425 | $objFormParam->addParam('商品名', 'shipment_product_name'); |
---|
426 | $objFormParam->addParam('規格名1', 'shipment_classcategory_name1'); |
---|
427 | $objFormParam->addParam('規格名2', 'shipment_classcategory_name2'); |
---|
428 | $objFormParam->addParam('単価', 'shipment_price', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
429 | $objFormParam->addParam('数量', 'shipment_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
430 | |
---|
431 | $objFormParam->addParam('商品項番', 'no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
432 | $objFormParam->addParam('追加商品規格ID', 'add_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
433 | $objFormParam->addParam('修正商品規格ID', 'edit_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
434 | $objFormParam->addParam('対象届け先ID', 'select_shipping_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
435 | $objFormParam->addParam('アンカーキー', 'anchor_key', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
436 | } |
---|
437 | |
---|
438 | /** |
---|
439 | * 複数配送用フォームの初期化を行う. |
---|
440 | * |
---|
441 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
442 | * @return void |
---|
443 | */ |
---|
444 | public function lfInitMultipleParam(&$objFormParam) |
---|
445 | { |
---|
446 | $objFormParam->addParam('商品規格ID', 'multiple_product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
447 | $objFormParam->addParam('商品コード', 'multiple_product_code', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
448 | $objFormParam->addParam('商品名', 'multiple_product_name', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
449 | $objFormParam->addParam('規格1', 'multiple_classcategory_name1', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
450 | $objFormParam->addParam('規格2', 'multiple_classcategory_name2', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
451 | $objFormParam->addParam('単価', 'multiple_price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
452 | $objFormParam->addParam('数量', 'multiple_quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
453 | $objFormParam->addParam('お届け先', 'multiple_shipping_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
454 | } |
---|
455 | |
---|
456 | /** |
---|
457 | * 複数配送入力フォームで入力された値を SC_FormParam へ設定する. |
---|
458 | * |
---|
459 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
460 | * @return void |
---|
461 | */ |
---|
462 | public function setMultipleItemTo(&$objFormParam) |
---|
463 | { |
---|
464 | $arrMultipleKey = array('multiple_shipping_id', |
---|
465 | 'multiple_product_class_id', |
---|
466 | 'multiple_product_name', |
---|
467 | 'multiple_product_code', |
---|
468 | 'multiple_classcategory_name1', |
---|
469 | 'multiple_classcategory_name2', |
---|
470 | 'multiple_price', |
---|
471 | 'multiple_quantity'); |
---|
472 | $arrMultipleParams = $objFormParam->getSwapArray($arrMultipleKey); |
---|
473 | |
---|
474 | /* |
---|
475 | * 複数配送フォームの入力値を shipping_id ごとにマージ |
---|
476 | * |
---|
477 | * $arrShipmentItem[お届け先ID][商品規格ID]['shipment_(key)'] = 値 |
---|
478 | */ |
---|
479 | $arrShipmentItem = array(); |
---|
480 | foreach ($arrMultipleParams as $arrMultiple) { |
---|
481 | $shipping_id = $arrMultiple['multiple_shipping_id']; |
---|
482 | $product_class_id = $arrMultiple['multiple_product_class_id']; |
---|
483 | foreach ($arrMultiple as $key => $val) { |
---|
484 | if ($key == 'multiple_quantity') { |
---|
485 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] += $val; |
---|
486 | } else { |
---|
487 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] = $val; |
---|
488 | } |
---|
489 | } |
---|
490 | } |
---|
491 | |
---|
492 | /* |
---|
493 | * フォームのお届け先ごとの配列を生成 |
---|
494 | * |
---|
495 | * $arrShipmentForm['(key)'][$shipping_id][$item_index] = 値 |
---|
496 | * $arrProductQuantity[$shipping_id] = お届け先ごとの配送商品数量 |
---|
497 | */ |
---|
498 | $arrShipmentForm = array(); |
---|
499 | $arrProductQuantity = array(); |
---|
500 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
501 | foreach ($arrShippingIds as $shipping_id) { |
---|
502 | $item_index = 0; |
---|
503 | foreach ($arrShipmentItem[$shipping_id] as $product_class_id => $shipment_item) { |
---|
504 | foreach ($shipment_item as $key => $val) { |
---|
505 | $arrShipmentForm[$key][$shipping_id][$item_index] = $val; |
---|
506 | } |
---|
507 | // 受注商品の数量を設定 |
---|
508 | $arrQuantity[$product_class_id] += $shipment_item['shipment_quantity']; |
---|
509 | $item_index++; |
---|
510 | } |
---|
511 | // お届け先ごとの配送商品数量を設定 |
---|
512 | $arrProductQuantity[$shipping_id] = count($arrShipmentItem[$shipping_id]); |
---|
513 | } |
---|
514 | |
---|
515 | $objFormParam->setParam($arrShipmentForm); |
---|
516 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
517 | |
---|
518 | // 受注商品の数量を変更 |
---|
519 | $arrDest = array(); |
---|
520 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
521 | $arrDest['quantity'][$n] = 0; |
---|
522 | } |
---|
523 | foreach ($arrQuantity as $product_class_id => $quantity) { |
---|
524 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
525 | if ($product_class_id == $order_product_class_id) { |
---|
526 | $arrDest['quantity'][$n] = $quantity; |
---|
527 | } |
---|
528 | } |
---|
529 | } |
---|
530 | $objFormParam->setParam($arrDest); |
---|
531 | } |
---|
532 | |
---|
533 | /** |
---|
534 | * 受注データを取得して, SC_FormParam へ設定する. |
---|
535 | * |
---|
536 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
537 | * @param integer $order_id 取得元の受注ID |
---|
538 | * @return void |
---|
539 | */ |
---|
540 | public function setOrderToFormParam(&$objFormParam, $order_id) |
---|
541 | { |
---|
542 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
543 | |
---|
544 | // 受注詳細を設定 |
---|
545 | $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); |
---|
546 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); |
---|
547 | |
---|
548 | $arrShippingsTmp = $objPurchase->getShippings($order_id); |
---|
549 | $arrShippings = array(); |
---|
550 | foreach ($arrShippingsTmp as $row) { |
---|
551 | // お届け日の処理 |
---|
552 | if (!SC_Utils_Ex::isBlank($row['shipping_date'])) { |
---|
553 | $ts = strtotime($row['shipping_date']); |
---|
554 | $row['shipping_date_year'] = date('Y', $ts); |
---|
555 | $row['shipping_date_month'] = date('n', $ts); |
---|
556 | $row['shipping_date_day'] = date('j', $ts); |
---|
557 | } |
---|
558 | $arrShippings[$row['shipping_id']] = $row; |
---|
559 | } |
---|
560 | $objFormParam->setValue('shipping_quantity', count($arrShippings)); |
---|
561 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings)); |
---|
562 | |
---|
563 | /* |
---|
564 | * 配送商品を設定 |
---|
565 | * |
---|
566 | * $arrShipmentItem['shipment_(key)'][$shipping_id][$item_index] = 値 |
---|
567 | * $arrProductQuantity[$shipping_id] = お届け先ごとの配送商品数量 |
---|
568 | */ |
---|
569 | $arrProductQuantity = array(); |
---|
570 | $arrShipmentItem = array(); |
---|
571 | foreach ($arrShippings as $shipping_id => $arrShipping) { |
---|
572 | $arrProductQuantity[$shipping_id] = count($arrShipping['shipment_item']); |
---|
573 | foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) { |
---|
574 | foreach ($arrItem as $item_key => $item_val) { |
---|
575 | $arrShipmentItem['shipment_' . $item_key][$shipping_id][$item_index] = $item_val; |
---|
576 | } |
---|
577 | } |
---|
578 | } |
---|
579 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
580 | $objFormParam->setParam($arrShipmentItem); |
---|
581 | |
---|
582 | /* |
---|
583 | * 受注情報を設定 |
---|
584 | * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 |
---|
585 | * が渡ってくるため, $arrOrder で上書きする. |
---|
586 | */ |
---|
587 | $arrOrder = $objPurchase->getOrder($order_id); |
---|
588 | $objFormParam->setParam($arrOrder); |
---|
589 | |
---|
590 | // ポイントを設定 |
---|
591 | list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint( |
---|
592 | $order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status'] |
---|
593 | ); |
---|
594 | $objFormParam->setValue('total_point', $db_point); |
---|
595 | $objFormParam->setValue('point', $rollback_point); |
---|
596 | |
---|
597 | if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { |
---|
598 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($objFormParam->getValue('customer_id')); |
---|
599 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
600 | } |
---|
601 | } |
---|
602 | |
---|
603 | /** |
---|
604 | * 入力内容のチェックを行う. |
---|
605 | * |
---|
606 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
607 | * @return array エラーメッセージの配列 |
---|
608 | */ |
---|
609 | public function lfCheckError(&$objFormParam) |
---|
610 | { |
---|
611 | $objProduct = new SC_Product_Ex(); |
---|
612 | $arrValues = $objFormParam->getHashArray(); |
---|
613 | |
---|
614 | $arrErr = array(); |
---|
615 | $arrErrTemp = $objFormParam->checkError(); |
---|
616 | $arrErrDate = array(); |
---|
617 | foreach ($arrValues['shipping_date_year'] as $key_index => $year) { |
---|
618 | $month = $arrValues['shipping_date_month'][$key_index]; |
---|
619 | $day = $arrValues['shipping_date_day'][$key_index]; |
---|
620 | $objError = new SC_CheckError_Ex(array('shipping_date_year' => $year, |
---|
621 | 'shipping_date_month' => $month, |
---|
622 | 'shipping_date_day' => $day)); |
---|
623 | $objError->doFunc(array('お届け日', 'shipping_date_year', 'shipping_date_month', 'shipping_date_day'), array('CHECK_DATE')); |
---|
624 | $arrErrDate['shipping_date_year'][$key_index] = $objError->arrErr['shipping_date_year']; |
---|
625 | } |
---|
626 | $arrErrTemp = array_merge($arrErrTemp, $arrErrDate); |
---|
627 | |
---|
628 | // 商品の種類数 |
---|
629 | $max = count($arrValues['quantity']); |
---|
630 | $subtotal = 0; |
---|
631 | $totalpoint = 0; |
---|
632 | $totaltax = 0; |
---|
633 | for ($i = 0; $i < $max; $i++) { |
---|
634 | // 小計の計算 |
---|
635 | $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; |
---|
636 | // 小計の計算 |
---|
637 | $totaltax += SC_Utils_Ex::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; |
---|
638 | // 加算ポイントの計算 |
---|
639 | $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; |
---|
640 | |
---|
641 | // 在庫数のチェック |
---|
642 | $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); |
---|
643 | |
---|
644 | // 編集前の値と比較するため受注詳細を取得 |
---|
645 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
646 | $arrOrderDetail = SC_Utils_Ex::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false)); |
---|
647 | |
---|
648 | if ($arrProduct['stock_unlimited'] != '1' |
---|
649 | && $arrProduct['stock'] < $arrValues['quantity'][$i] - $arrOrderDetail['quantity'][$i]) { |
---|
650 | $class_name1 = $arrValues['classcategory_name1'][$i]; |
---|
651 | $class_name1 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1; |
---|
652 | $class_name2 = $arrValues['classcategory_name2'][$i]; |
---|
653 | $class_name2 = SC_Utils_Ex::isBlank($class_name2) ? 'なし' : $class_name2; |
---|
654 | $arrErr['quantity'][$i] .= $arrValues['product_name'][$i] |
---|
655 | . '/(' . $class_name1 . ')/(' . $class_name2 . ') の在庫が不足しています。 設定できる数量は「' |
---|
656 | . ($arrOrderDetail['quantity'][$i] + $arrProduct['stock']) . '」までです。<br />'; |
---|
657 | } |
---|
658 | } |
---|
659 | |
---|
660 | // 消費税 |
---|
661 | $arrValues['tax'] = $totaltax; |
---|
662 | // 小計 |
---|
663 | $arrValues['subtotal'] = $subtotal; |
---|
664 | // 合計 |
---|
665 | $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge']; |
---|
666 | // お支払い合計 |
---|
667 | $arrValues['payment_total'] = $arrValues['total'] - ($arrValues['use_point'] * POINT_VALUE); |
---|
668 | |
---|
669 | // 加算ポイント |
---|
670 | $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']) + $arrValues['birth_point']; |
---|
671 | |
---|
672 | // 最終保持ポイント |
---|
673 | $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point']; |
---|
674 | |
---|
675 | if ($arrValues['total'] < 0) { |
---|
676 | $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
677 | } |
---|
678 | |
---|
679 | if ($arrValues['payment_total'] < 0) { |
---|
680 | $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
681 | } |
---|
682 | |
---|
683 | if ($arrValues['total_point'] < 0) { |
---|
684 | $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; |
---|
685 | } |
---|
686 | |
---|
687 | $objFormParam->setParam($arrValues); |
---|
688 | $arrErr = array_merge($arrErr, $arrErrTemp); |
---|
689 | |
---|
690 | return $arrErr; |
---|
691 | } |
---|
692 | |
---|
693 | /** |
---|
694 | * DB更新処理 |
---|
695 | * |
---|
696 | * @param integer $order_id 受注ID |
---|
697 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
698 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
699 | * @param string $message 通知メッセージ |
---|
700 | * @param array $arrValuesBefore 更新前の受注情報 |
---|
701 | * @return integer $order_id 受注ID |
---|
702 | * |
---|
703 | * エラー発生時は負数を返す。 |
---|
704 | */ |
---|
705 | public function doRegister($order_id, &$objPurchase, &$objFormParam, &$message, &$arrValuesBefore) |
---|
706 | { |
---|
707 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
708 | $arrValues = $objFormParam->getDbArray(); |
---|
709 | |
---|
710 | $where = 'order_id = ?'; |
---|
711 | |
---|
712 | $objQuery->begin(); |
---|
713 | |
---|
714 | // 支払い方法が変更されたら、支払い方法名称も更新 |
---|
715 | if ($arrValues['payment_id'] != $arrValuesBefore['payment_id']) { |
---|
716 | $arrValues['payment_method'] = $this->arrPayment[$arrValues['payment_id']]; |
---|
717 | $arrValuesBefore['payment_id'] = NULL; |
---|
718 | } |
---|
719 | |
---|
720 | // 受注テーブルの更新 |
---|
721 | $order_id = $objPurchase->registerOrder($order_id, $arrValues); |
---|
722 | |
---|
723 | $arrDetail = $objFormParam->getSwapArray(array( |
---|
724 | 'product_id', |
---|
725 | 'product_class_id', |
---|
726 | 'product_code', |
---|
727 | 'product_name', |
---|
728 | 'price', 'quantity', |
---|
729 | 'point_rate', |
---|
730 | 'classcategory_name1', |
---|
731 | 'classcategory_name2', |
---|
732 | 'tax_rate', |
---|
733 | 'tax_rule' |
---|
734 | )); |
---|
735 | |
---|
736 | // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 |
---|
737 | $max = count($arrDetail); |
---|
738 | $k = 0; |
---|
739 | $arrStockData = array(); |
---|
740 | for ($i = 0; $i < $max; $i++) { |
---|
741 | if (!empty($arrDetail[$i]['product_id'])) { |
---|
742 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
743 | if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { |
---|
744 | // 数量が変更された商品 |
---|
745 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
746 | $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; |
---|
747 | ++$k; |
---|
748 | } elseif (empty($arrPreDetail)) { |
---|
749 | // 新しく追加された商品 もしくは 違う商品に変更された商品 |
---|
750 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
751 | $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; |
---|
752 | ++$k; |
---|
753 | } |
---|
754 | $objQuery->delete('dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
755 | } |
---|
756 | } |
---|
757 | |
---|
758 | // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 |
---|
759 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ?', array($order_id)); |
---|
760 | foreach ($arrPreDetail AS $key=>$val) { |
---|
761 | $arrStockData[$k]['product_class_id'] = $val['product_class_id']; |
---|
762 | $arrStockData[$k]['quantity'] = $val['quantity']; |
---|
763 | ++$k; |
---|
764 | } |
---|
765 | |
---|
766 | // 受注詳細データの更新 |
---|
767 | $objPurchase->registerOrderDetail($order_id, $arrDetail); |
---|
768 | |
---|
769 | // 在庫数調整 |
---|
770 | if (ORDER_DELIV != $arrValues['status'] |
---|
771 | && ORDER_CANCEL != $arrValues['status']) { |
---|
772 | foreach ($arrStockData AS $stock) { |
---|
773 | $objQuery->update('dtb_products_class', array(), |
---|
774 | 'product_class_id = ?', |
---|
775 | array($stock['product_class_id']), |
---|
776 | array('stock' => 'stock + ?'), |
---|
777 | array($stock['quantity'])); |
---|
778 | } |
---|
779 | } |
---|
780 | |
---|
781 | $arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys); |
---|
782 | $arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys); |
---|
783 | |
---|
784 | $arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id')); |
---|
785 | //商品単価を複数配送にも適応 |
---|
786 | $arrShippingValues = array(); |
---|
787 | $arrIsNotQuantityUp = array(); |
---|
788 | foreach ($arrAllShipping as $shipping_index => $arrShipping) { |
---|
789 | $shipping_id = $arrShipping['shipping_id']; |
---|
790 | $arrShippingValues[$shipping_index] = $arrShipping; |
---|
791 | |
---|
792 | $arrShippingValues[$shipping_index]['shipping_date'] |
---|
793 | = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], |
---|
794 | $arrShipping['shipping_date_month'], |
---|
795 | $arrShipping['shipping_date_day']); |
---|
796 | |
---|
797 | //商品単価を複数配送にも反映する |
---|
798 | foreach ($arrDetail as $product_detail) { |
---|
799 | foreach ($arrAllShipmentItem[$shipping_index]['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { |
---|
800 | if ($product_detail['product_class_id'] == $shipment_product_class_id) { |
---|
801 | $arrAllShipmentItem[$shipping_index]['shipment_price'][$relation_index] = $product_detail['price']; |
---|
802 | } |
---|
803 | } |
---|
804 | } |
---|
805 | // 配送業者IDを取得 |
---|
806 | $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); |
---|
807 | |
---|
808 | // お届け時間名称を取得 |
---|
809 | $arrShippingValues[$shipping_index]['shipping_time'] = $arrDelivTime[$arrShipping['time_id']]; |
---|
810 | |
---|
811 | // 複数配送の場合は配送商品を登録 |
---|
812 | if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) { |
---|
813 | $arrShipmentValues = array(); |
---|
814 | |
---|
815 | foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) { |
---|
816 | $i = 0; |
---|
817 | foreach ($arrItem as $item) { |
---|
818 | $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item; |
---|
819 | $i++; |
---|
820 | } |
---|
821 | } |
---|
822 | $objPurchase->registerShipmentItem($order_id, $shipping_id, |
---|
823 | $arrShipmentValues[$shipping_index]); |
---|
824 | } |
---|
825 | } |
---|
826 | |
---|
827 | $objPurchase->registerShipping($order_id, $arrShippingValues, false); |
---|
828 | $objQuery->commit(); |
---|
829 | |
---|
830 | return $order_id; |
---|
831 | } |
---|
832 | |
---|
833 | /** |
---|
834 | * 受注商品の追加/更新を行う. |
---|
835 | * |
---|
836 | * 小画面で選択した受注商品をフォームに反映させる. |
---|
837 | * |
---|
838 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
839 | * @return void |
---|
840 | */ |
---|
841 | public function doRegisterProduct(&$objFormParam) |
---|
842 | { |
---|
843 | $product_class_id = $objFormParam->getValue('add_product_class_id'); |
---|
844 | if (SC_Utils_Ex::isBlank($product_class_id)) { |
---|
845 | $product_class_id = $objFormParam->getValue('edit_product_class_id'); |
---|
846 | $changed_no = $objFormParam->getValue('no'); |
---|
847 | $this->shipmentEditProduct($objFormParam, $product_class_id, $changed_no); |
---|
848 | } else { |
---|
849 | $this->shipmentAddProduct($objFormParam, $product_class_id); |
---|
850 | } |
---|
851 | } |
---|
852 | |
---|
853 | /** |
---|
854 | * 受注商品を削除する. |
---|
855 | * |
---|
856 | * @param integer $delete_no 削除する受注商品の項番 |
---|
857 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
858 | * @return void |
---|
859 | */ |
---|
860 | public function doDeleteProduct($delete_no, &$objFormParam) |
---|
861 | { |
---|
862 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
863 | |
---|
864 | //変更前のproduct_class_idが他の届け先にも存在するか |
---|
865 | $arrPreShipmentProductClassIds = $objFormParam->getValue('shipment_product_class_id'); |
---|
866 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
867 | $delete_product_class_id = $arrPreShipmentProductClassIds[$select_shipping_id][$delete_no]; |
---|
868 | |
---|
869 | //配送先データ削除 |
---|
870 | $arrNewShipments = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $delete_no); |
---|
871 | $objFormParam->setParam($arrNewShipments); |
---|
872 | |
---|
873 | $is_product_delete = true; |
---|
874 | foreach ($arrNewShipments['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { |
---|
875 | foreach ($arrShipmentProductClassIds as $relation_index => $shipment_product_class_id) { |
---|
876 | if (in_array($delete_product_class_id, $arrShipmentProductClassIds)) { |
---|
877 | $is_product_delete = false; |
---|
878 | break; |
---|
879 | } |
---|
880 | } |
---|
881 | } |
---|
882 | |
---|
883 | //商品情報から削除 |
---|
884 | if ($is_product_delete) { |
---|
885 | $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $delete_product_class_id, $this->arrProductKeys); |
---|
886 | } |
---|
887 | } |
---|
888 | |
---|
889 | /** |
---|
890 | * お届け先を追加する. |
---|
891 | * |
---|
892 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
893 | * @return void |
---|
894 | */ |
---|
895 | public function addShipping(&$objFormParam) |
---|
896 | { |
---|
897 | $objFormParam->setValue('shipping_quantity', |
---|
898 | $objFormParam->getValue('shipping_quantity') + 1); |
---|
899 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
900 | $arrShippingIds[] = max($arrShippingIds) + 1; |
---|
901 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
902 | } |
---|
903 | |
---|
904 | /** |
---|
905 | * 会員情報をフォームに設定する. |
---|
906 | * |
---|
907 | * @param integer $customer_id 会員ID |
---|
908 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
909 | * @return void |
---|
910 | */ |
---|
911 | public function setCustomerTo($customer_id, &$objFormParam) |
---|
912 | { |
---|
913 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
914 | foreach ($arrCustomer as $key => $val) { |
---|
915 | $objFormParam->setValue('order_' . $key, $val); |
---|
916 | } |
---|
917 | $objFormParam->setValue('customer_id', $customer_id); |
---|
918 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
919 | |
---|
920 | return $arrCustomer['birth']; |
---|
921 | } |
---|
922 | |
---|
923 | /** |
---|
924 | * アンカーキーを取得する. |
---|
925 | * |
---|
926 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
927 | * @return アンカーキーの文字列 |
---|
928 | */ |
---|
929 | public function getAnchorKey(&$objFormParam) |
---|
930 | { |
---|
931 | $ancor_key = $objFormParam->getValue('anchor_key'); |
---|
932 | if (!SC_Utils_Ex::isBlank($ancor_key)) { |
---|
933 | return "location.hash='#" . htmlentities(urlencode($ancor_key), ENT_QUOTES) . "'"; |
---|
934 | } |
---|
935 | |
---|
936 | return ''; |
---|
937 | } |
---|
938 | |
---|
939 | /** |
---|
940 | * 商品を追加 |
---|
941 | * |
---|
942 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
943 | * @param integer $add_product_class_id 追加商品規格ID |
---|
944 | * @return void |
---|
945 | */ |
---|
946 | public function shipmentAddProduct(&$objFormParam, $add_product_class_id) |
---|
947 | { |
---|
948 | //複数配送に商品情報追加 |
---|
949 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
950 | |
---|
951 | //届け先に選択済みの商品がある場合 |
---|
952 | $arrShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
953 | |
---|
954 | if($arrShipmentProducts['shipment_product_class_id'] && in_array($add_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])){ |
---|
955 | foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { |
---|
956 | if ($shipment_product_class_id == $add_product_class_id) { |
---|
957 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++; |
---|
958 | break; |
---|
959 | } |
---|
960 | } |
---|
961 | } else { |
---|
962 | //届け先に選択商品がない場合 |
---|
963 | $objProduct = new SC_Product_Ex(); |
---|
964 | $arrAddProductInfo = $objProduct->getDetailAndProductsClass($add_product_class_id); |
---|
965 | |
---|
966 | $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][] = $add_product_class_id; |
---|
967 | $arrShipmentProducts['shipment_product_code'][$select_shipping_id][] = $arrAddProductInfo['product_code']; |
---|
968 | $arrShipmentProducts['shipment_product_name'][$select_shipping_id][] = $arrAddProductInfo['name']; |
---|
969 | $arrShipmentProducts['shipment_price'][$select_shipping_id][] = $arrAddProductInfo['price02']; |
---|
970 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][] = 1; |
---|
971 | |
---|
972 | //受注商品情報に追加 |
---|
973 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
974 | $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $add_product_class_id, $arrAddProductInfo); |
---|
975 | $objFormParam->setParam($arrProducts); |
---|
976 | } |
---|
977 | $objFormParam->setParam($arrShipmentProducts); |
---|
978 | } |
---|
979 | |
---|
980 | /** |
---|
981 | * 商品を変更 |
---|
982 | * |
---|
983 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
984 | * @param integer $add_product_class_id 変更商品規格ID |
---|
985 | * @param integer $change_no 変更対象 |
---|
986 | * @return void |
---|
987 | */ |
---|
988 | public function shipmentEditProduct(&$objFormParam, $edit_product_class_id, $change_no) |
---|
989 | { |
---|
990 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
991 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
992 | |
---|
993 | $arrShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
994 | |
---|
995 | //既にあるデータは1つだけ数量を1増やす |
---|
996 | $pre_shipment_product_class_id = $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][$change_no]; |
---|
997 | if ($pre_shipment_product_class_id == $edit_product_class_id) { |
---|
998 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$change_no] ++; |
---|
999 | } elseif (in_array($edit_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])) { |
---|
1000 | //配送先データ削除 |
---|
1001 | $arrShipmentProducts = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $change_no); |
---|
1002 | foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { |
---|
1003 | if ($shipment_product_class_id == $edit_product_class_id) { |
---|
1004 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index] ++; |
---|
1005 | break; |
---|
1006 | } |
---|
1007 | } |
---|
1008 | } else { |
---|
1009 | $objProduct = new SC_Product_Ex(); |
---|
1010 | $arrAddProductInfo = $objProduct->getDetailAndProductsClass($edit_product_class_id); |
---|
1011 | |
---|
1012 | //上書き |
---|
1013 | $this->changeShipmentProducts($arrShipmentProducts, $arrAddProductInfo, $select_shipping_id, $change_no); |
---|
1014 | //受注商品情報に追加 |
---|
1015 | $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $edit_product_class_id, $arrAddProductInfo); |
---|
1016 | $objFormParam->setParam($arrProducts); |
---|
1017 | } |
---|
1018 | $objFormParam->setParam($arrShipmentProducts); |
---|
1019 | |
---|
1020 | //更新のみの場合、全配列を持っていないので、新しい配列を取得 |
---|
1021 | $arrNewShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
1022 | $is_product_delete = true; |
---|
1023 | //変更前のproduct_class_idが他の届け先にも存在するか |
---|
1024 | foreach ($arrNewShipmentProducts['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { |
---|
1025 | if (in_array($pre_shipment_product_class_id, $arrShipmentProductClassIds)) { |
---|
1026 | $is_product_delete = false; |
---|
1027 | break; |
---|
1028 | } |
---|
1029 | } |
---|
1030 | |
---|
1031 | //商品情報から削除 |
---|
1032 | if ($is_product_delete) { |
---|
1033 | $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $pre_shipment_product_class_id, $this->arrProductKeys); |
---|
1034 | } |
---|
1035 | } |
---|
1036 | |
---|
1037 | /** |
---|
1038 | * 複数配送のパラメータを取り出す |
---|
1039 | * |
---|
1040 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
1041 | * @return array 配送データ |
---|
1042 | */ |
---|
1043 | public function getShipmentProducts(&$objFormParam) |
---|
1044 | { |
---|
1045 | $arrShipmentProducts['shipment_product_class_id'] = $objFormParam->getValue('shipment_product_class_id'); |
---|
1046 | $arrShipmentProducts['shipment_product_code'] = $objFormParam->getValue('shipment_product_code'); |
---|
1047 | $arrShipmentProducts['shipment_product_name'] = $objFormParam->getValue('shipment_product_name'); |
---|
1048 | $arrShipmentProducts['shipment_classcategory_name1'] = $objFormParam->getValue('shipment_classcategory_name1'); |
---|
1049 | $arrShipmentProducts['shipment_classcategory_name2'] = $objFormParam->getValue('shipment_classcategory_name2'); |
---|
1050 | $arrShipmentProducts['shipment_price'] = $objFormParam->getValue('shipment_price'); |
---|
1051 | $arrShipmentProducts['shipment_quantity'] = $objFormParam->getValue('shipment_quantity'); |
---|
1052 | |
---|
1053 | foreach ($arrShipmentProducts as $key => $value) { |
---|
1054 | if (!is_array($value)) { |
---|
1055 | $arrShipmentProducts[$key] = array(); |
---|
1056 | } |
---|
1057 | } |
---|
1058 | |
---|
1059 | return $arrShipmentProducts; |
---|
1060 | } |
---|
1061 | |
---|
1062 | /** |
---|
1063 | * 変更対象のデータを上書きする |
---|
1064 | * |
---|
1065 | * @param array $arrShipmentProducts 変更対象配列 |
---|
1066 | * @param array $arrProductInfo 上書きデータ |
---|
1067 | * @param integer $shipping_id 配送先ID |
---|
1068 | * @param array $no 変更対象 |
---|
1069 | * @return void |
---|
1070 | */ |
---|
1071 | public function changeShipmentProducts(&$arrShipmentProducts, $arrProductInfo, $shipping_id, $no) |
---|
1072 | { |
---|
1073 | $arrShipmentProducts['shipment_product_class_id'][$shipping_id][$no] = $arrProductInfo['product_class_id']; |
---|
1074 | $arrShipmentProducts['shipment_product_code'][$shipping_id][$no] = $arrProductInfo['product_code']; |
---|
1075 | $arrShipmentProducts['shipment_product_name'][$shipping_id][$no] = $arrProductInfo['name']; |
---|
1076 | $arrShipmentProducts['shipment_classcategory_name1'][$shipping_id][$no] = $arrProductInfo['classcategory_name1']; |
---|
1077 | $arrShipmentProducts['shipment_classcategory_name2'][$shipping_id][$no] = $arrProductInfo['classcategory_name2']; |
---|
1078 | $arrShipmentProducts['shipment_price'][$shipping_id][$no] = $arrProductInfo['price02']; |
---|
1079 | $arrShipmentProducts['shipment_quantity'][$shipping_id][$no] = 1; |
---|
1080 | } |
---|
1081 | |
---|
1082 | /** |
---|
1083 | * 商品側の総量計算&セット |
---|
1084 | * |
---|
1085 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
1086 | * @return void |
---|
1087 | */ |
---|
1088 | public function setProductsQuantity(&$objFormParam) |
---|
1089 | { |
---|
1090 | $arrShipmentsItems = $objFormParam->getSwapArray(array('shipment_product_class_id','shipment_quantity')); |
---|
1091 | |
---|
1092 | // 配送先が存在する時のみ、商品個数の再設定を行います |
---|
1093 | if(!SC_Utils_Ex::isBlank($arrShipmentsItems)) { |
---|
1094 | foreach ($arrShipmentsItems as $arritems) { |
---|
1095 | foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { |
---|
1096 | $arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index]; |
---|
1097 | } |
---|
1098 | } |
---|
1099 | |
---|
1100 | $arrProductsClass = $objFormParam->getValue('product_class_id'); |
---|
1101 | $arrProductsQuantity = $objFormParam->getValue('quantity'); |
---|
1102 | foreach ($arrProductsClass as $relation_key => $product_class_id) { |
---|
1103 | $arrQuantity['quantity'][$relation_key] = $arrUpdateQuantity[$product_class_id]; |
---|
1104 | } |
---|
1105 | $objFormParam->setParam($arrQuantity); |
---|
1106 | } |
---|
1107 | } |
---|
1108 | |
---|
1109 | /** |
---|
1110 | * 削除対象の確認、削除をする |
---|
1111 | * |
---|
1112 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
1113 | * @param array $arrProductClassIds 削除対象配列の商品規格ID |
---|
1114 | * @param integer $delete_product_class_id 削除商品規? ?ID |
---|
1115 | * @param array $arrDeleteKeys 削除項目 |
---|
1116 | * @return void |
---|
1117 | */ |
---|
1118 | public function checkDeleteProducts(&$objFormParam, $arrProductClassIds, $delete_product_class_id, $arrDeleteKeys) |
---|
1119 | { |
---|
1120 | foreach ($arrProductClassIds as $relation_index => $product_class_id) { |
---|
1121 | //product_class_idの重複はないので、1つ削除したら完了 |
---|
1122 | if ($product_class_id == $delete_product_class_id) { |
---|
1123 | foreach ($arrDeleteKeys as $delete_key) { |
---|
1124 | $arrProducts = $objFormParam->getValue($delete_key); |
---|
1125 | foreach ($arrProducts as $index => $product_info) { |
---|
1126 | if ($index != $relation_index) { |
---|
1127 | $arrUpdateParams[$delete_key][] = $product_info; |
---|
1128 | } |
---|
1129 | } |
---|
1130 | $objFormParam->setParam($arrUpdateParams); |
---|
1131 | } |
---|
1132 | break; |
---|
1133 | } |
---|
1134 | } |
---|
1135 | } |
---|
1136 | |
---|
1137 | /** |
---|
1138 | * 配送先商品の削除の削除 |
---|
1139 | * |
---|
1140 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
1141 | * @param array $arrShipmentDeleteKeys 削除項目 |
---|
1142 | * @param integer $delete_shipping_id 削除配送ID |
---|
1143 | * @param array $delete_no 削除対象 |
---|
1144 | * @return void |
---|
1145 | */ |
---|
1146 | public function deleteShipment(&$objFormParam, $arrShipmentDeletKeys, $delete_shipping_id, $delete_no) |
---|
1147 | { |
---|
1148 | foreach ($arrShipmentDeletKeys as $delete_key) { |
---|
1149 | $arrShipments = $objFormParam->getValue($delete_key); |
---|
1150 | foreach ($arrShipments as $shipp_id => $arrKeyData) { |
---|
1151 | foreach ($arrKeyData as $relation_index => $shipment_info) { |
---|
1152 | if ($relation_index != $delete_no || $shipp_id != $delete_shipping_id) { |
---|
1153 | $arrUpdateParams[$delete_key][$shipp_id][] = $shipment_info; |
---|
1154 | } |
---|
1155 | } |
---|
1156 | } |
---|
1157 | } |
---|
1158 | //$objFormParam->setParam($arrUpdateParams); |
---|
1159 | return $arrUpdateParams; |
---|
1160 | } |
---|
1161 | |
---|
1162 | /** |
---|
1163 | * 受注商品一覧側に商品を追加 |
---|
1164 | * |
---|
1165 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
1166 | * @param array $arrProductClassIds 対象配列の商品規格ID |
---|
1167 | * @param integer $indert_product_class_id 追?? 商品規格ID |
---|
1168 | * @param array $arrAddProductInfo 追加データ |
---|
1169 | * @return array $arrAddProducts 更新データ |
---|
1170 | */ |
---|
1171 | public function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $insert_product_class_id, $arrAddProductInfo) |
---|
1172 | { |
---|
1173 | if(!$arrProductClassIds || !in_array($insert_product_class_id, $arrProductClassIds)){ |
---|
1174 | $arrAddProducts = array(); |
---|
1175 | |
---|
1176 | $arrAddProductInfo['product_name'] = ($arrAddProductInfo['product_name'])? |
---|
1177 | $arrAddProductInfo['product_name']:$arrAddProductInfo['name']; |
---|
1178 | $arrAddProductInfo['price'] = ($arrAddProductInfo['price'])? |
---|
1179 | $arrAddProductInfo['price']:$arrAddProductInfo['price02']; |
---|
1180 | $arrAddProductInfo['quantity'] = 1; |
---|
1181 | $arrAddProductInfo['tax_rate'] = ($objFormParam->getValue('order_tax_rate') == '')? |
---|
1182 | $this->arrInfo['tax'] :$objFormParam->getValue('order_tax_rate'); |
---|
1183 | $arrAddProductInfo['tax_rule'] = ($objFormParam->getValue('order_tax_rule') == '')? |
---|
1184 | $this->arrInfo['tax_rule']:$objFormParam->getValue('order_tax_rule'); |
---|
1185 | foreach ($this->arrProductKeys as $insert_key) { |
---|
1186 | $value = $objFormParam->getValue($insert_key); |
---|
1187 | $arrAddProducts[$insert_key] = (is_array($value))? $value: array(); |
---|
1188 | $arrAddProducts[$insert_key][] = $arrAddProductInfo[$insert_key]; |
---|
1189 | } |
---|
1190 | |
---|
1191 | return $arrAddProducts; |
---|
1192 | } else { |
---|
1193 | //受注商品の数量は、複数配送側の集計で出しているので、重複しても数量を増やさない。 |
---|
1194 | return null; |
---|
1195 | } |
---|
1196 | } |
---|
1197 | } |
---|