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