[15594] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[22206] | 5 | * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved. |
---|
[15594] | 6 | * |
---|
| 7 | * http://www.lockon.co.jp/ |
---|
[16582] | 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. |
---|
[15594] | 22 | */ |
---|
| 23 | |
---|
[20534] | 24 | require_once CLASS_EX_REALDIR . 'page_extends/admin/order/LC_Page_Admin_Order_Ex.php'; |
---|
[15594] | 25 | |
---|
| 26 | /** |
---|
| 27 | * 受注修正 のページクラス. |
---|
| 28 | * |
---|
| 29 | * @package Page |
---|
| 30 | * @author LOCKON CO.,LTD. |
---|
| 31 | * @version $Id$ |
---|
| 32 | */ |
---|
[22792] | 33 | class LC_Page_Admin_Order_Edit extends LC_Page_Admin_Order_Ex |
---|
[22567] | 34 | { |
---|
[20943] | 35 | var $arrShippingKeys = array( |
---|
| 36 | 'shipping_id', |
---|
| 37 | 'shipping_name01', |
---|
| 38 | 'shipping_name02', |
---|
| 39 | 'shipping_kana01', |
---|
| 40 | 'shipping_kana02', |
---|
[23024] | 41 | 'shipping_company_name', |
---|
[20943] | 42 | 'shipping_tel01', |
---|
| 43 | 'shipping_tel02', |
---|
| 44 | 'shipping_tel03', |
---|
| 45 | 'shipping_fax01', |
---|
| 46 | 'shipping_fax02', |
---|
| 47 | 'shipping_fax03', |
---|
| 48 | 'shipping_pref', |
---|
[23024] | 49 | 'shipping_country_id', |
---|
| 50 | 'shipping_zipcode', |
---|
[20943] | 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 | var $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 | |
---|
[22493] | 71 | var $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 | |
---|
[15594] | 86 | /** |
---|
| 87 | * Page を初期化する. |
---|
| 88 | * |
---|
| 89 | * @return void |
---|
| 90 | */ |
---|
[22567] | 91 | function init() |
---|
| 92 | { |
---|
[15594] | 93 | parent::init(); |
---|
| 94 | $this->tpl_mainpage = 'order/edit.tpl'; |
---|
[17293] | 95 | $this->tpl_mainno = 'order'; |
---|
[20911] | 96 | $this->tpl_maintitle = '受注管理'; |
---|
| 97 | $this->tpl_subtitle = '受注登録'; |
---|
[15594] | 98 | |
---|
| 99 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[19773] | 100 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[23024] | 101 | $this->arrCountry = $masterData->getMasterData('mtb_country'); |
---|
[21481] | 102 | $this->arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); |
---|
[19975] | 103 | $this->arrDeviceType = $masterData->getMasterData('mtb_device_type'); |
---|
[17886] | 104 | |
---|
[20499] | 105 | $objDate = new SC_Date_Ex(RELEASE_YEAR); |
---|
[20180] | 106 | $this->arrYearShippingDate = $objDate->getYear('', date('Y'), ''); |
---|
| 107 | $this->arrMonthShippingDate = $objDate->getMonth(true); |
---|
| 108 | $this->arrDayShippingDate = $objDate->getDay(true); |
---|
| 109 | |
---|
| 110 | // 支払い方法の取得 |
---|
[22537] | 111 | $this->arrPayment = SC_Helper_Payment_Ex::getIDValueList(); |
---|
[20180] | 112 | |
---|
| 113 | // 配送業者の取得 |
---|
[22543] | 114 | $this->arrDeliv = SC_Helper_Delivery_Ex::getIDValueList(); |
---|
[20180] | 115 | |
---|
[22218] | 116 | $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
| 117 | |
---|
[18187] | 118 | $this->httpCacheControl('nocache'); |
---|
[15594] | 119 | } |
---|
| 120 | |
---|
| 121 | /** |
---|
| 122 | * Page のプロセス. |
---|
| 123 | * |
---|
| 124 | * @return void |
---|
| 125 | */ |
---|
[22567] | 126 | function process() |
---|
| 127 | { |
---|
[19661] | 128 | $this->action(); |
---|
| 129 | $this->sendResponse(); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | /** |
---|
| 133 | * Page のアクション. |
---|
| 134 | * |
---|
| 135 | * @return void |
---|
| 136 | */ |
---|
[22567] | 137 | function action() |
---|
| 138 | { |
---|
[19923] | 139 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[20501] | 140 | $objFormParam = new SC_FormParam_Ex(); |
---|
[15594] | 141 | |
---|
[20970] | 142 | // パラメーター情報の初期化 |
---|
[20180] | 143 | $this->lfInitParam($objFormParam); |
---|
| 144 | $objFormParam->setParam($_REQUEST); |
---|
| 145 | $objFormParam->convParam(); |
---|
| 146 | $order_id = $objFormParam->getValue('order_id'); |
---|
[21036] | 147 | $arrValuesBefore = array(); |
---|
[15594] | 148 | |
---|
| 149 | // DBから受注情報を読み込む |
---|
[19963] | 150 | if (!SC_Utils_Ex::isBlank($order_id)) { |
---|
[20180] | 151 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 152 | $this->tpl_subno = 'index'; |
---|
[21036] | 153 | $arrValuesBefore['payment_id'] = $objFormParam->getValue('payment_id'); |
---|
| 154 | $arrValuesBefore['payment_method'] = $objFormParam->getValue('payment_method'); |
---|
[20180] | 155 | } else { |
---|
| 156 | $this->tpl_subno = 'add'; |
---|
| 157 | $this->tpl_mode = 'add'; |
---|
[21036] | 158 | $arrValuesBefore['payment_id'] = NULL; |
---|
| 159 | $arrValuesBefore['payment_method'] = NULL; |
---|
[21222] | 160 | // お届け先情報を空情報で表示 |
---|
| 161 | $arrShippingIds[] = null; |
---|
| 162 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[21420] | 163 | |
---|
[21419] | 164 | // 新規受注登録で入力エラーがあった場合の画面表示用に、会員の現在ポイントを取得 |
---|
[21069] | 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']); |
---|
[21774] | 169 | |
---|
| 170 | // 新規受注登録で、ポイント利用できるように現在ポイントを設定 |
---|
| 171 | $objFormParam->setValue('point', $arrCustomer['point']); |
---|
[21069] | 172 | } |
---|
[19963] | 173 | } |
---|
[15594] | 174 | |
---|
[20180] | 175 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
| 176 | |
---|
[21441] | 177 | switch ($this->getMode()) { |
---|
[21526] | 178 | case 'pre_edit': |
---|
| 179 | case 'order_id': |
---|
| 180 | break; |
---|
[20180] | 181 | |
---|
[21526] | 182 | case 'edit': |
---|
[20180] | 183 | $objFormParam->setParam($_POST); |
---|
| 184 | $objFormParam->convParam(); |
---|
[22493] | 185 | //複数配送時に各商品の総量を設定 |
---|
| 186 | $this->setProductsQuantity($objFormParam); |
---|
[20180] | 187 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 188 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
[21526] | 189 | $message = '受注を編集しました。'; |
---|
| 190 | $order_id = $this->doRegister($order_id, $objPurchase, $objFormParam, $message, $arrValuesBefore); |
---|
[20577] | 191 | if ($order_id >= 0) { |
---|
| 192 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 193 | } |
---|
| 194 | $this->tpl_onload = "window.alert('" . $message . "');"; |
---|
[18068] | 195 | } |
---|
[21526] | 196 | break; |
---|
[20180] | 197 | |
---|
[21526] | 198 | case 'add': |
---|
| 199 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
---|
| 200 | $objFormParam->setParam($_POST); |
---|
| 201 | $objFormParam->convParam(); |
---|
[22493] | 202 | //複数配送時に各商品の総量を設定 |
---|
| 203 | $this->setProductsQuantity($objFormParam); |
---|
[21526] | 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 | } |
---|
[20180] | 216 | |
---|
[21526] | 217 | break; |
---|
[19912] | 218 | |
---|
[21526] | 219 | // 再計算 |
---|
| 220 | case 'recalculate': |
---|
| 221 | //支払い方法の選択 |
---|
| 222 | case 'payment': |
---|
| 223 | // 配送業者の選択 |
---|
| 224 | case 'deliv': |
---|
| 225 | $objFormParam->setParam($_POST); |
---|
| 226 | $objFormParam->convParam(); |
---|
[22493] | 227 | //複数配送時に各商品の総量を設定 |
---|
| 228 | $this->setProductsQuantity($objFormParam); |
---|
[21526] | 229 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 230 | break; |
---|
[20180] | 231 | |
---|
[21526] | 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); |
---|
[22493] | 238 | //複数配送時に各商品の総量を設定 |
---|
| 239 | $this->setProductsQuantity($objFormParam); |
---|
[21526] | 240 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 241 | break; |
---|
[19963] | 242 | |
---|
[21526] | 243 | // 商品追加ポップアップより商品選択 |
---|
| 244 | case 'select_product_detail': |
---|
| 245 | $objFormParam->setParam($_POST); |
---|
| 246 | $objFormParam->convParam(); |
---|
| 247 | $this->doRegisterProduct($objFormParam); |
---|
[22493] | 248 | //複数配送時に各商品の総量を設定 |
---|
| 249 | $this->setProductsQuantity($objFormParam); |
---|
[21526] | 250 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 251 | break; |
---|
[17887] | 252 | |
---|
[21526] | 253 | // 会員検索ポップアップより会員指定 |
---|
| 254 | case 'search_customer': |
---|
| 255 | $objFormParam->setParam($_POST); |
---|
| 256 | $objFormParam->convParam(); |
---|
[22490] | 257 | $customer_birth = $this->setCustomerTo($objFormParam->getValue('edit_customer_id'), |
---|
[21526] | 258 | $objFormParam); |
---|
[22490] | 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 | } |
---|
[21526] | 273 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 274 | break; |
---|
[19934] | 275 | |
---|
[22490] | 276 | // 複数配送設定表示 |
---|
[21526] | 277 | case 'multiple': |
---|
| 278 | $objFormParam->setParam($_POST); |
---|
| 279 | $objFormParam->convParam(); |
---|
| 280 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 281 | break; |
---|
[19963] | 282 | |
---|
[22490] | 283 | // 複数配送設定を反映 |
---|
[21526] | 284 | case 'multiple_set_to': |
---|
| 285 | $this->lfInitMultipleParam($objFormParam); |
---|
| 286 | $objFormParam->setParam($_POST); |
---|
| 287 | $objFormParam->convParam(); |
---|
| 288 | $this->setMultipleItemTo($objFormParam); |
---|
| 289 | break; |
---|
[19963] | 290 | |
---|
[22490] | 291 | // お届け先の追加 |
---|
[21526] | 292 | case 'append_shipping': |
---|
| 293 | $objFormParam->setParam($_POST); |
---|
| 294 | $objFormParam->convParam(); |
---|
| 295 | $this->addShipping($objFormParam); |
---|
| 296 | break; |
---|
| 297 | |
---|
| 298 | default: |
---|
| 299 | break; |
---|
[15594] | 300 | } |
---|
| 301 | |
---|
[22493] | 302 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[20943] | 303 | $this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys)); |
---|
[22493] | 304 | $this->top_shipping_id = array_shift((array_keys($this->arrAllShipping))); |
---|
[22554] | 305 | $this->arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id')); |
---|
[20180] | 306 | $this->tpl_onload .= $this->getAnchorKey($objFormParam); |
---|
[21036] | 307 | if ($arrValuesBefore['payment_id']) |
---|
| 308 | $this->arrPayment[$arrValuesBefore['payment_id']] = $arrValuesBefore['payment_method']; |
---|
[15594] | 309 | } |
---|
| 310 | |
---|
[22792] | 311 | /** |
---|
| 312 | * パラメーター情報の初期化を行う. |
---|
| 313 | * |
---|
| 314 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 315 | * @return void |
---|
| 316 | */ |
---|
| 317 | function lfInitParam(&$objFormParam) |
---|
| 318 | { |
---|
| 319 | // 検索条件のパラメーターを初期化 |
---|
| 320 | parent::lfInitParam($objFormParam); |
---|
[18037] | 321 | |
---|
[22792] | 322 | // お客様情報 |
---|
[22882] | 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')); |
---|
[23024] | 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', 'NO_SPTAB')); |
---|
[22792] | 328 | $objFormParam->addParam('メールアドレス', 'order_email', null, 'KVCa', array('NO_SPTAB', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
[23024] | 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')); |
---|
[22792] | 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')); |
---|
[17293] | 342 | |
---|
[22792] | 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'); |
---|
[18054] | 347 | |
---|
[22792] | 348 | // ポイント機能ON時のみ |
---|
| 349 | if (USE_POINT !== false) { |
---|
| 350 | $objFormParam->addParam('利用ポイント', 'use_point', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 351 | } |
---|
[18054] | 352 | |
---|
[22792] | 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'); |
---|
[15594] | 357 | |
---|
[22792] | 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'); |
---|
| 370 | $objFormParam->addParam('課税規則', 'tax_rule'); |
---|
| 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')); |
---|
[20180] | 373 | |
---|
[22792] | 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'); |
---|
[15594] | 394 | |
---|
[22792] | 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); |
---|
[22882] | 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')); |
---|
[23024] | 402 | $objFormParam->addParam('会社名', 'shipping_company_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK', 'NO_SPTAB')); |
---|
| 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')); |
---|
[22792] | 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')); |
---|
[19963] | 422 | |
---|
[22792] | 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'); |
---|
[19963] | 430 | |
---|
[22792] | 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 | } |
---|
[19919] | 437 | |
---|
[22792] | 438 | /** |
---|
| 439 | * 複数配送用フォームの初期化を行う. |
---|
[20180] | 440 | * |
---|
[22792] | 441 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 442 | * @return void |
---|
[19934] | 443 | */ |
---|
[22792] | 444 | 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')); |
---|
[19934] | 454 | } |
---|
[19919] | 455 | |
---|
[22792] | 456 | /** |
---|
| 457 | * 複数配送入力フォームで入力された値を SC_FormParam へ設定する. |
---|
[20180] | 458 | * |
---|
[22792] | 459 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 460 | * @return void |
---|
[20180] | 461 | */ |
---|
[22792] | 462 | 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 | } |
---|
[20180] | 489 | } |
---|
[19934] | 490 | } |
---|
| 491 | |
---|
[22792] | 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 | } |
---|
[19949] | 514 | |
---|
[22792] | 515 | $objFormParam->setParam($arrShipmentForm); |
---|
| 516 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 517 | |
---|
| 518 | // 受注商品の数量を変更 |
---|
| 519 | $arrDest = array(); |
---|
[21224] | 520 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
[22792] | 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 | } |
---|
[19949] | 528 | } |
---|
| 529 | } |
---|
[22792] | 530 | $objFormParam->setParam($arrDest); |
---|
[19934] | 531 | } |
---|
| 532 | |
---|
[22792] | 533 | /** |
---|
| 534 | * 受注データを取得して, SC_FormParam へ設定する. |
---|
| 535 | * |
---|
| 536 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 537 | * @param integer $order_id 取得元の受注ID |
---|
| 538 | * @return void |
---|
| 539 | */ |
---|
| 540 | function setOrderToFormParam(&$objFormParam, $order_id) |
---|
| 541 | { |
---|
| 542 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[18235] | 543 | |
---|
[22792] | 544 | // 受注詳細を設定 |
---|
| 545 | $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); |
---|
| 546 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); |
---|
[15594] | 547 | |
---|
[22792] | 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; |
---|
[20180] | 559 | } |
---|
[22792] | 560 | $objFormParam->setValue('shipping_quantity', count($arrShippings)); |
---|
| 561 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings)); |
---|
[19919] | 562 | |
---|
[22792] | 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 | } |
---|
[19912] | 577 | } |
---|
[15594] | 578 | } |
---|
[22792] | 579 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 580 | $objFormParam->setParam($arrShipmentItem); |
---|
[15594] | 581 | |
---|
[22792] | 582 | /* |
---|
| 583 | * 受注情報を設定 |
---|
| 584 | * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 |
---|
| 585 | * が渡ってくるため, $arrOrder で上書きする. |
---|
| 586 | */ |
---|
| 587 | $arrOrder = $objPurchase->getOrder($order_id); |
---|
| 588 | $objFormParam->setParam($arrOrder); |
---|
[20180] | 589 | |
---|
[22792] | 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); |
---|
[20442] | 596 | |
---|
[22792] | 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 | } |
---|
[15594] | 601 | } |
---|
| 602 | |
---|
[22792] | 603 | /** |
---|
| 604 | * 入力内容のチェックを行う. |
---|
| 605 | * |
---|
| 606 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 607 | * @return array エラーメッセージの配列 |
---|
| 608 | */ |
---|
| 609 | function lfCheckError(&$objFormParam) |
---|
| 610 | { |
---|
| 611 | $objProduct = new SC_Product_Ex(); |
---|
[21311] | 612 | |
---|
[22858] | 613 | $arrErr = array(); |
---|
| 614 | $arrErrTemp = $objFormParam->checkError(); |
---|
[19912] | 615 | |
---|
[22792] | 616 | $arrValues = $objFormParam->getHashArray(); |
---|
[15594] | 617 | |
---|
[22792] | 618 | // 商品の種類数 |
---|
| 619 | $max = count($arrValues['quantity']); |
---|
| 620 | $subtotal = 0; |
---|
| 621 | $totalpoint = 0; |
---|
| 622 | $totaltax = 0; |
---|
| 623 | for ($i = 0; $i < $max; $i++) { |
---|
| 624 | // 小計の計算 |
---|
| 625 | $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; |
---|
| 626 | // 小計の計算 |
---|
| 627 | $totaltax += SC_Utils_Ex::sfTax($arrValues['price'][$i], $arrValues['tax_rate'][$i], $arrValues['tax_rule'][$i]) * $arrValues['quantity'][$i]; |
---|
| 628 | // 加算ポイントの計算 |
---|
| 629 | $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; |
---|
[20719] | 630 | |
---|
[22792] | 631 | // 在庫数のチェック |
---|
| 632 | $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); |
---|
[20719] | 633 | |
---|
[22792] | 634 | // 編集前の値と比較するため受注詳細を取得 |
---|
| 635 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 636 | $arrOrderDetail = SC_Utils_Ex::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false)); |
---|
[20719] | 637 | |
---|
[22792] | 638 | if ($arrProduct['stock_unlimited'] != '1' |
---|
| 639 | && $arrProduct['stock'] < $arrValues['quantity'][$i] - $arrOrderDetail['quantity'][$i]) { |
---|
| 640 | $class_name1 = $arrValues['classcategory_name1'][$i]; |
---|
| 641 | $class_name1 = SC_Utils_Ex::isBlank($class_name1) ? 'なし' : $class_name1; |
---|
| 642 | $class_name2 = $arrValues['classcategory_name2'][$i]; |
---|
| 643 | $class_name2 = SC_Utils_Ex::isBlank($class_name2) ? 'なし' : $class_name2; |
---|
| 644 | $arrErr['quantity'][$i] .= $arrValues['product_name'][$i] |
---|
| 645 | . '/(' . $class_name1 . ')/(' . $class_name2 . ') の在庫が不足しています。 設定できる数量は「' |
---|
| 646 | . ($arrOrderDetail['quantity'][$i] + $arrProduct['stock']) . '」までです。<br />'; |
---|
| 647 | } |
---|
[15594] | 648 | } |
---|
| 649 | |
---|
[22792] | 650 | // 消費税 |
---|
| 651 | $arrValues['tax'] = $totaltax; |
---|
| 652 | // 小計 |
---|
| 653 | $arrValues['subtotal'] = $subtotal; |
---|
| 654 | // 合計 |
---|
| 655 | $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge']; |
---|
| 656 | // お支払い合計 |
---|
| 657 | $arrValues['payment_total'] = $arrValues['total'] - ($arrValues['use_point'] * POINT_VALUE); |
---|
[15594] | 658 | |
---|
[22792] | 659 | // 加算ポイント |
---|
| 660 | $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']) + $arrValues['birth_point']; |
---|
[20041] | 661 | |
---|
[22792] | 662 | // 最終保持ポイント |
---|
| 663 | $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point']; |
---|
[20041] | 664 | |
---|
[22792] | 665 | if ($arrValues['total'] < 0) { |
---|
| 666 | $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
| 667 | } |
---|
[15594] | 668 | |
---|
[22792] | 669 | if ($arrValues['payment_total'] < 0) { |
---|
| 670 | $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
| 671 | } |
---|
[20180] | 672 | |
---|
[22792] | 673 | if ($arrValues['total_point'] < 0) { |
---|
| 674 | $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; |
---|
| 675 | } |
---|
| 676 | |
---|
| 677 | $objFormParam->setParam($arrValues); |
---|
[22858] | 678 | $arrErr = array_merge($arrErr, $arrErrTemp); |
---|
[22856] | 679 | |
---|
[22792] | 680 | return $arrErr; |
---|
[15594] | 681 | } |
---|
| 682 | |
---|
[18100] | 683 | /** |
---|
| 684 | * DB更新処理 |
---|
| 685 | * |
---|
[20180] | 686 | * @param integer $order_id 受注ID |
---|
| 687 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 688 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20577] | 689 | * @param string $message 通知メッセージ |
---|
[21036] | 690 | * @param array $arrValuesBefore 更新前の受注情報 |
---|
[20180] | 691 | * @return integer $order_id 受注ID |
---|
[20577] | 692 | * |
---|
| 693 | * エラー発生時は負数を返す。 |
---|
[18100] | 694 | */ |
---|
[22567] | 695 | function doRegister($order_id, &$objPurchase, &$objFormParam, &$message, &$arrValuesBefore) |
---|
| 696 | { |
---|
[20507] | 697 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20180] | 698 | $arrValues = $objFormParam->getDbArray(); |
---|
[15594] | 699 | |
---|
[21514] | 700 | $where = 'order_id = ?'; |
---|
[15594] | 701 | |
---|
[18329] | 702 | $objQuery->begin(); |
---|
[21118] | 703 | |
---|
[21036] | 704 | // 支払い方法が変更されたら、支払い方法名称も更新 |
---|
| 705 | if ($arrValues['payment_id'] != $arrValuesBefore['payment_id']) { |
---|
| 706 | $arrValues['payment_method'] = $this->arrPayment[$arrValues['payment_id']]; |
---|
| 707 | $arrValuesBefore['payment_id'] = NULL; |
---|
| 708 | } |
---|
[18329] | 709 | |
---|
[15594] | 710 | // 受注テーブルの更新 |
---|
[20180] | 711 | $order_id = $objPurchase->registerOrder($order_id, $arrValues); |
---|
[18819] | 712 | |
---|
[21527] | 713 | $arrDetail = $objFormParam->getSwapArray(array( |
---|
| 714 | 'product_id', |
---|
| 715 | 'product_class_id', |
---|
| 716 | 'product_code', |
---|
| 717 | 'product_name', |
---|
| 718 | 'price', 'quantity', |
---|
| 719 | 'point_rate', |
---|
| 720 | 'classcategory_name1', |
---|
| 721 | 'classcategory_name2', |
---|
[22218] | 722 | 'tax_rate', |
---|
| 723 | 'tax_rule' |
---|
[21527] | 724 | )); |
---|
[18819] | 725 | |
---|
[18646] | 726 | // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 |
---|
| 727 | $max = count($arrDetail); |
---|
| 728 | $k = 0; |
---|
| 729 | $arrStockData = array(); |
---|
[21441] | 730 | for ($i = 0; $i < $max; $i++) { |
---|
[18646] | 731 | if (!empty($arrDetail[$i]['product_id'])) { |
---|
[21515] | 732 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 733 | if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { |
---|
| 734 | // 数量が変更された商品 |
---|
[18872] | 735 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 736 | $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; |
---|
| 737 | ++$k; |
---|
| 738 | } elseif (empty($arrPreDetail)) { |
---|
| 739 | // 新しく追加された商品 もしくは 違う商品に変更された商品 |
---|
[18872] | 740 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 741 | $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; |
---|
| 742 | ++$k; |
---|
| 743 | } |
---|
[21514] | 744 | $objQuery->delete('dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 745 | } |
---|
| 746 | } |
---|
| 747 | |
---|
| 748 | // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 |
---|
[21515] | 749 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ?', array($order_id)); |
---|
[18646] | 750 | foreach ($arrPreDetail AS $key=>$val) { |
---|
[18872] | 751 | $arrStockData[$k]['product_class_id'] = $val['product_class_id']; |
---|
[18646] | 752 | $arrStockData[$k]['quantity'] = $val['quantity']; |
---|
| 753 | ++$k; |
---|
| 754 | } |
---|
| 755 | |
---|
| 756 | // 受注詳細データの更新 |
---|
[20180] | 757 | $objPurchase->registerOrderDetail($order_id, $arrDetail); |
---|
[18074] | 758 | |
---|
[18646] | 759 | // 在庫数調整 |
---|
[20180] | 760 | if (ORDER_DELIV != $arrValues['status'] |
---|
| 761 | && ORDER_CANCEL != $arrValues['status']) { |
---|
| 762 | foreach ($arrStockData AS $stock) { |
---|
| 763 | $objQuery->update('dtb_products_class', array(), |
---|
| 764 | 'product_class_id = ?', |
---|
| 765 | array($stock['product_class_id']), |
---|
| 766 | array('stock' => 'stock + ?'), |
---|
| 767 | array($stock['quantity'])); |
---|
[18646] | 768 | } |
---|
| 769 | } |
---|
| 770 | |
---|
[20943] | 771 | $arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys); |
---|
| 772 | $arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys); |
---|
[19949] | 773 | |
---|
[22554] | 774 | $arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id')); |
---|
[22493] | 775 | //商品単価を複数配送にも適応 |
---|
[20180] | 776 | $arrShippingValues = array(); |
---|
[22493] | 777 | $arrIsNotQuantityUp = array(); |
---|
[20180] | 778 | foreach ($arrAllShipping as $shipping_index => $arrShipping) { |
---|
| 779 | $shipping_id = $arrShipping['shipping_id']; |
---|
| 780 | $arrShippingValues[$shipping_index] = $arrShipping; |
---|
[19949] | 781 | |
---|
[20180] | 782 | $arrShippingValues[$shipping_index]['shipping_date'] |
---|
| 783 | = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], |
---|
| 784 | $arrShipping['shipping_date_month'], |
---|
| 785 | $arrShipping['shipping_date_day']); |
---|
[19963] | 786 | |
---|
[22493] | 787 | //商品単価を複数配送にも反映する |
---|
[22283] | 788 | foreach ($arrDetail as $product_detail) { |
---|
| 789 | foreach ($arrAllShipmentItem[$shipping_index]['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { |
---|
| 790 | if($product_detail['product_class_id'] == $shipment_product_class_id){ |
---|
| 791 | $arrAllShipmentItem[$shipping_index]['shipment_price'][$relation_index] = $product_detail['price']; |
---|
| 792 | } |
---|
| 793 | } |
---|
| 794 | } |
---|
[20180] | 795 | // 配送業者IDを取得 |
---|
| 796 | $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); |
---|
[19949] | 797 | |
---|
[20804] | 798 | // お届け時間名称を取得 |
---|
| 799 | $arrShippingValues[$shipping_index]['shipping_time'] = $arrDelivTime[$arrShipping['time_id']]; |
---|
| 800 | |
---|
[20180] | 801 | // 複数配送の場合は配送商品を登録 |
---|
| 802 | if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) { |
---|
| 803 | $arrShipmentValues = array(); |
---|
[19963] | 804 | |
---|
[20180] | 805 | foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) { |
---|
| 806 | $i = 0; |
---|
| 807 | foreach ($arrItem as $item) { |
---|
| 808 | $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item; |
---|
| 809 | $i++; |
---|
| 810 | } |
---|
[19949] | 811 | } |
---|
[20180] | 812 | $objPurchase->registerShipmentItem($order_id, $shipping_id, |
---|
| 813 | $arrShipmentValues[$shipping_index]); |
---|
[19949] | 814 | } |
---|
| 815 | } |
---|
[22493] | 816 | |
---|
[20180] | 817 | $objPurchase->registerShipping($order_id, $arrShippingValues, false); |
---|
[15594] | 818 | $objQuery->commit(); |
---|
[22856] | 819 | |
---|
[20180] | 820 | return $order_id; |
---|
[15594] | 821 | } |
---|
[17293] | 822 | |
---|
[18100] | 823 | /** |
---|
[20180] | 824 | * 受注商品の追加/更新を行う. |
---|
[18100] | 825 | * |
---|
[20180] | 826 | * 小画面で選択した受注商品をフォームに反映させる. |
---|
| 827 | * |
---|
| 828 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 829 | * @return void |
---|
[18100] | 830 | */ |
---|
[22567] | 831 | function doRegisterProduct(&$objFormParam) |
---|
| 832 | { |
---|
[20180] | 833 | $product_class_id = $objFormParam->getValue('add_product_class_id'); |
---|
| 834 | if (SC_Utils_Ex::isBlank($product_class_id)) { |
---|
| 835 | $product_class_id = $objFormParam->getValue('edit_product_class_id'); |
---|
[20415] | 836 | $changed_no = $objFormParam->getValue('no'); |
---|
[22493] | 837 | $this->shipmentEditProduct($objFormParam, $product_class_id, $changed_no); |
---|
| 838 | }else{ |
---|
| 839 | $this->shipmentAddProduct($objFormParam, $product_class_id); |
---|
[17293] | 840 | } |
---|
| 841 | } |
---|
| 842 | |
---|
[19919] | 843 | /** |
---|
[20180] | 844 | * 受注商品を削除する. |
---|
| 845 | * |
---|
| 846 | * @param integer $delete_no 削除する受注商品の項番 |
---|
| 847 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 848 | * @return void |
---|
[19919] | 849 | */ |
---|
[22567] | 850 | function doDeleteProduct($delete_no, &$objFormParam) |
---|
| 851 | { |
---|
[22493] | 852 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
| 853 | |
---|
| 854 | //変更前のproduct_class_idが他の届け先にも存在するか |
---|
| 855 | $arrPreShipmentProductClassIds = $objFormParam->getValue('shipment_product_class_id'); |
---|
| 856 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
| 857 | $delete_product_class_id = $arrPreShipmentProductClassIds[$select_shipping_id][$delete_no]; |
---|
| 858 | |
---|
| 859 | //配送先データ削除 |
---|
| 860 | $arrNewShipments = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $delete_no); |
---|
| 861 | $objFormParam->setParam($arrNewShipments); |
---|
| 862 | |
---|
| 863 | $is_product_delete = true; |
---|
| 864 | foreach ($arrNewShipments['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { |
---|
| 865 | foreach ($arrShipmentProductClassIds as $relation_index => $shipment_product_class_id) { |
---|
| 866 | if(in_array($delete_product_class_id, $arrShipmentProductClassIds)){ |
---|
| 867 | $is_product_delete = false; |
---|
| 868 | break; |
---|
[18014] | 869 | } |
---|
| 870 | } |
---|
| 871 | } |
---|
[22493] | 872 | |
---|
| 873 | //商品情報から削除 |
---|
| 874 | if($is_product_delete){ |
---|
| 875 | $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $delete_product_class_id, $this->arrProductKeys); |
---|
| 876 | } |
---|
[17293] | 877 | } |
---|
| 878 | |
---|
[20180] | 879 | /** |
---|
| 880 | * お届け先を追加する. |
---|
| 881 | * |
---|
| 882 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 883 | * @return void |
---|
| 884 | */ |
---|
[22567] | 885 | function addShipping(&$objFormParam) |
---|
| 886 | { |
---|
[20180] | 887 | $objFormParam->setValue('shipping_quantity', |
---|
| 888 | $objFormParam->getValue('shipping_quantity') + 1); |
---|
| 889 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 890 | $arrShippingIds[] = max($arrShippingIds) + 1; |
---|
| 891 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[17293] | 892 | } |
---|
| 893 | |
---|
[18068] | 894 | /** |
---|
[21419] | 895 | * 会員情報をフォームに設定する. |
---|
[20180] | 896 | * |
---|
[21419] | 897 | * @param integer $customer_id 会員ID |
---|
[20180] | 898 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 899 | * @return void |
---|
[18068] | 900 | */ |
---|
[22567] | 901 | function setCustomerTo($customer_id, &$objFormParam) |
---|
| 902 | { |
---|
[20180] | 903 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
| 904 | foreach ($arrCustomer as $key => $val) { |
---|
| 905 | $objFormParam->setValue('order_' . $key, $val); |
---|
[18068] | 906 | } |
---|
[20180] | 907 | $objFormParam->setValue('customer_id', $customer_id); |
---|
[20442] | 908 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
[22490] | 909 | |
---|
| 910 | return $arrCustomer['birth']; |
---|
[18068] | 911 | } |
---|
[18329] | 912 | |
---|
| 913 | /** |
---|
[20180] | 914 | * アンカーキーを取得する. |
---|
[18329] | 915 | * |
---|
[20180] | 916 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 917 | * @return アンカーキーの文字列 |
---|
[18329] | 918 | */ |
---|
[22567] | 919 | function getAnchorKey(&$objFormParam) |
---|
| 920 | { |
---|
[20180] | 921 | $ancor_key = $objFormParam->getValue('anchor_key'); |
---|
| 922 | if (!SC_Utils_Ex::isBlank($ancor_key)) { |
---|
| 923 | return "location.hash='#" . htmlentities(urlencode($ancor_key), ENT_QUOTES) . "'"; |
---|
[18329] | 924 | } |
---|
[22856] | 925 | |
---|
[20180] | 926 | return ''; |
---|
[19963] | 927 | } |
---|
[22493] | 928 | |
---|
| 929 | /** |
---|
| 930 | * 商品を追加 |
---|
| 931 | * |
---|
| 932 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 933 | * @param integer $add_product_class_id 追加商品規格ID |
---|
| 934 | * @return void |
---|
| 935 | */ |
---|
[22567] | 936 | function shipmentAddProduct(&$objFormParam, $add_product_class_id) |
---|
| 937 | { |
---|
[22493] | 938 | //複数配送に商品情報追加 |
---|
| 939 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
| 940 | |
---|
| 941 | //届け先に選択済みの商品がある場合 |
---|
| 942 | $arrShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
| 943 | |
---|
| 944 | if(in_array($add_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])){ |
---|
| 945 | foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { |
---|
| 946 | if($shipment_product_class_id == $add_product_class_id){ |
---|
| 947 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++; |
---|
| 948 | break; |
---|
| 949 | } |
---|
| 950 | } |
---|
| 951 | }else{ |
---|
| 952 | //届け先に選択商品がない場合 |
---|
| 953 | $objProduct = new SC_Product_Ex(); |
---|
| 954 | $arrAddProductInfo = $objProduct->getDetailAndProductsClass($add_product_class_id); |
---|
| 955 | |
---|
| 956 | $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][] = $add_product_class_id; |
---|
| 957 | $arrShipmentProducts['shipment_product_code'][$select_shipping_id][] = $arrAddProductInfo['product_code']; |
---|
| 958 | $arrShipmentProducts['shipment_product_name'][$select_shipping_id][] = $arrAddProductInfo['name']; |
---|
| 959 | $arrShipmentProducts['shipment_price'][$select_shipping_id][] = $arrAddProductInfo['price02']; |
---|
| 960 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][] = 1; |
---|
| 961 | |
---|
| 962 | //受注商品情報に追加 |
---|
| 963 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
| 964 | $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $add_product_class_id, $arrAddProductInfo); |
---|
| 965 | $objFormParam->setParam($arrProducts); |
---|
| 966 | } |
---|
| 967 | $objFormParam->setParam($arrShipmentProducts); |
---|
| 968 | } |
---|
| 969 | |
---|
| 970 | /** |
---|
| 971 | * 商品を変更 |
---|
| 972 | * |
---|
| 973 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 974 | * @param integer $add_product_class_id 変更商品規格ID |
---|
| 975 | * @param integer $change_no 変更対象 |
---|
| 976 | * @return void |
---|
| 977 | */ |
---|
[22567] | 978 | function shipmentEditProduct(&$objFormParam, $edit_product_class_id, $change_no) |
---|
| 979 | { |
---|
[22493] | 980 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
| 981 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
| 982 | |
---|
| 983 | $arrShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
| 984 | |
---|
| 985 | //既にあるデータは1つだけ数量を1増やす |
---|
| 986 | $pre_shipment_product_class_id = $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][$change_no]; |
---|
| 987 | if($pre_shipment_product_class_id == $edit_product_class_id) { |
---|
| 988 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$change_no] ++; |
---|
| 989 | }elseif(in_array($edit_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])){ |
---|
| 990 | //配送先データ削除 |
---|
| 991 | $arrShipmentProducts = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $change_no); |
---|
| 992 | foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { |
---|
| 993 | if($shipment_product_class_id == $edit_product_class_id){ |
---|
| 994 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index] ++; |
---|
| 995 | break; |
---|
| 996 | } |
---|
| 997 | } |
---|
| 998 | }else{ |
---|
| 999 | $objProduct = new SC_Product_Ex(); |
---|
| 1000 | $arrAddProductInfo = $objProduct->getDetailAndProductsClass($edit_product_class_id); |
---|
| 1001 | |
---|
| 1002 | //上書き |
---|
| 1003 | $this->changeShipmentProducts($arrShipmentProducts, $arrAddProductInfo, $select_shipping_id, $change_no); |
---|
| 1004 | //受注商品情報に追加 |
---|
| 1005 | $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $edit_product_class_id, $arrAddProductInfo); |
---|
| 1006 | $objFormParam->setParam($arrProducts); |
---|
| 1007 | } |
---|
| 1008 | $objFormParam->setParam($arrShipmentProducts); |
---|
| 1009 | |
---|
| 1010 | //更新のみの場合、全配列を持っていないので、新しい配列を取得 |
---|
| 1011 | $arrNewShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
| 1012 | $is_product_delete = true; |
---|
| 1013 | //変更前のproduct_class_idが他の届け先にも存在するか |
---|
| 1014 | foreach ($arrNewShipmentProducts['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { |
---|
| 1015 | if(in_array($pre_shipment_product_class_id, $arrShipmentProductClassIds)){ |
---|
| 1016 | $is_product_delete = false; |
---|
| 1017 | break; |
---|
| 1018 | } |
---|
| 1019 | } |
---|
| 1020 | |
---|
| 1021 | //商品情報から削除 |
---|
| 1022 | if($is_product_delete){ |
---|
| 1023 | $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $pre_shipment_product_class_id, $this->arrProductKeys); |
---|
| 1024 | } |
---|
| 1025 | } |
---|
| 1026 | |
---|
| 1027 | /** |
---|
[22792] | 1028 | * 複数配送のパラメータを取り出す |
---|
[22493] | 1029 | * |
---|
| 1030 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1031 | * @return array 配送データ |
---|
| 1032 | */ |
---|
[22567] | 1033 | function getShipmentProducts(&$objFormParam) |
---|
| 1034 | { |
---|
[22493] | 1035 | $arrShipmentProducts['shipment_product_class_id'] = $objFormParam->getValue('shipment_product_class_id'); |
---|
| 1036 | $arrShipmentProducts['shipment_product_code'] = $objFormParam->getValue('shipment_product_code'); |
---|
| 1037 | $arrShipmentProducts['shipment_product_name'] = $objFormParam->getValue('shipment_product_name'); |
---|
| 1038 | $arrShipmentProducts['shipment_classcategory_name1'] = $objFormParam->getValue('shipment_classcategory_name1'); |
---|
| 1039 | $arrShipmentProducts['shipment_classcategory_name2'] = $objFormParam->getValue('shipment_classcategory_name2'); |
---|
| 1040 | $arrShipmentProducts['shipment_price'] = $objFormParam->getValue('shipment_price'); |
---|
| 1041 | $arrShipmentProducts['shipment_quantity'] = $objFormParam->getValue('shipment_quantity'); |
---|
| 1042 | |
---|
| 1043 | return $arrShipmentProducts; |
---|
| 1044 | } |
---|
| 1045 | |
---|
| 1046 | /** |
---|
| 1047 | * 変更対象のデータを上書きする |
---|
| 1048 | * |
---|
| 1049 | * @param array $arrShipmentProducts 変更対象配列 |
---|
| 1050 | * @param array $arrProductInfo 上書きデータ |
---|
| 1051 | * @param integer $shipping_id 配送先ID |
---|
| 1052 | * @param array $no 変更対象 |
---|
| 1053 | * @return void |
---|
| 1054 | */ |
---|
[22567] | 1055 | function changeShipmentProducts(&$arrShipmentProducts, $arrProductInfo, $shipping_id, $no) |
---|
| 1056 | { |
---|
[22493] | 1057 | $arrShipmentProducts['shipment_product_class_id'][$shipping_id][$no] = $arrProductInfo['product_class_id']; |
---|
| 1058 | $arrShipmentProducts['shipment_product_code'][$shipping_id][$no] = $arrProductInfo['product_code']; |
---|
| 1059 | $arrShipmentProducts['shipment_product_name'][$shipping_id][$no] = $arrProductInfo['name']; |
---|
| 1060 | $arrShipmentProducts['shipment_classcategory_name1'][$shipping_id][$no] = $arrProductInfo['classcategory_name1']; |
---|
| 1061 | $arrShipmentProducts['shipment_classcategory_name2'][$shipping_id][$no] = $arrProductInfo['classcategory_name2']; |
---|
| 1062 | $arrShipmentProducts['shipment_price'][$shipping_id][$no] = $arrProductInfo['price02']; |
---|
| 1063 | $arrShipmentProducts['shipment_quantity'][$shipping_id][$no] = 1; |
---|
| 1064 | } |
---|
| 1065 | |
---|
| 1066 | /** |
---|
| 1067 | * 商品側の総量計算&セット |
---|
| 1068 | * |
---|
| 1069 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1070 | * @return void |
---|
| 1071 | */ |
---|
[22567] | 1072 | function setProductsQuantity(&$objFormParam) |
---|
| 1073 | { |
---|
[22493] | 1074 | $arrShipmentsItems = $objFormParam->getSwapArray(array('shipment_product_class_id','shipment_quantity')); |
---|
| 1075 | foreach ($arrShipmentsItems as $arritems) { |
---|
| 1076 | foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { |
---|
| 1077 | $arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index]; |
---|
| 1078 | } |
---|
| 1079 | } |
---|
| 1080 | |
---|
| 1081 | $arrProductsClass = $objFormParam->getValue('product_class_id'); |
---|
| 1082 | $arrProductsQuantity = $objFormParam->getValue('quantity'); |
---|
| 1083 | foreach ($arrProductsClass as $relation_key => $product_class_id) { |
---|
| 1084 | $arrQuantity['quantity'][$relation_key] = $arrUpdateQuantity[$product_class_id]; |
---|
| 1085 | } |
---|
| 1086 | $objFormParam->setParam($arrQuantity); |
---|
| 1087 | } |
---|
| 1088 | |
---|
| 1089 | /** |
---|
| 1090 | * 削除対象の確認、削除をする |
---|
| 1091 | * |
---|
| 1092 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1093 | * @param array $arrProductClassIds 削除対象配列の商品規格ID |
---|
| 1094 | * @param integer $delete_product_class_id 削除商品規格ID |
---|
| 1095 | * @param array $arrDeleteKeys 削除項目 |
---|
| 1096 | * @return void |
---|
| 1097 | */ |
---|
[22567] | 1098 | function checkDeleteProducts(&$objFormParam, $arrProductClassIds, $delete_product_class_id, $arrDeleteKeys) |
---|
| 1099 | { |
---|
[22493] | 1100 | foreach ($arrProductClassIds as $relation_index => $product_class_id) { |
---|
| 1101 | //product_class_idの重複はないので、1つ削除したら完了 |
---|
| 1102 | if($product_class_id == $delete_product_class_id){ |
---|
| 1103 | foreach ($arrDeleteKeys as $delete_key) { |
---|
| 1104 | $arrProducts = $objFormParam->getValue($delete_key); |
---|
| 1105 | foreach ($arrProducts as $index => $product_info) { |
---|
| 1106 | if($index != $relation_index){ |
---|
| 1107 | $arrUpdateParams[$delete_key][] = $product_info; |
---|
| 1108 | } |
---|
| 1109 | } |
---|
| 1110 | $objFormParam->setParam($arrUpdateParams); |
---|
| 1111 | } |
---|
| 1112 | break; |
---|
| 1113 | } |
---|
| 1114 | } |
---|
| 1115 | } |
---|
| 1116 | |
---|
| 1117 | /** |
---|
| 1118 | * 配送先商品の削除の削除 |
---|
| 1119 | * |
---|
| 1120 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1121 | * @param array $arrShipmentDeleteKeys 削除項目 |
---|
| 1122 | * @param integer $delete_shipping_id 削除配送ID |
---|
| 1123 | * @param array $delete_no 削除対象 |
---|
| 1124 | * @return void |
---|
| 1125 | */ |
---|
[22567] | 1126 | function deleteShipment(&$objFormParam, $arrShipmentDeletKeys, $delete_shipping_id, $delete_no) |
---|
| 1127 | { |
---|
[22493] | 1128 | foreach ($arrShipmentDeletKeys as $delete_key) { |
---|
| 1129 | $arrShipments = $objFormParam->getValue($delete_key); |
---|
| 1130 | foreach ($arrShipments as $shipp_id => $arrKeyData){ |
---|
| 1131 | foreach ($arrKeyData as $relation_index => $shipment_info) { |
---|
| 1132 | if($relation_index != $delete_no || $shipp_id != $delete_shipping_id){ |
---|
| 1133 | $arrUpdateParams[$delete_key][$shipp_id][] = $shipment_info; |
---|
| 1134 | } |
---|
| 1135 | } |
---|
| 1136 | } |
---|
| 1137 | } |
---|
| 1138 | //$objFormParam->setParam($arrUpdateParams); |
---|
| 1139 | return $arrUpdateParams; |
---|
| 1140 | } |
---|
| 1141 | |
---|
| 1142 | /** |
---|
| 1143 | * 受注商品一覧側に商品を追加 |
---|
| 1144 | * |
---|
| 1145 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1146 | * @param array $arrProductClassIds 対象配列の商品規格ID |
---|
| 1147 | * @param integer $indert_product_class_id 追加商品規格ID |
---|
| 1148 | * @param array $arrAddProductInfo 追加データ |
---|
| 1149 | * @return array $arrAddProducts 更新データ |
---|
| 1150 | */ |
---|
[22567] | 1151 | function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $insert_product_class_id, $arrAddProductInfo) |
---|
| 1152 | { |
---|
[22493] | 1153 | if(!in_array($insert_product_class_id, $arrProductClassIds)){ |
---|
| 1154 | $arrAddProductInfo['product_name'] = ($arrAddProductInfo['product_name'])? $arrAddProductInfo['product_name']:$arrAddProductInfo['name']; |
---|
| 1155 | $arrAddProductInfo['price'] = ($arrAddProductInfo['price'])? $arrAddProductInfo['price']:$arrAddProductInfo['price02']; |
---|
| 1156 | $arrAddProductInfo['quantity'] = 1; |
---|
| 1157 | $arrAddProductInfo['tax_rate'] = ($objFormParam->getValue('order_tax_rate') == '')? $this->arrInfo['tax'] :$objFormParam->getValue('order_tax_rate'); |
---|
| 1158 | $arrAddProductInfo['tax_rule'] = ($objFormParam->getValue('order_tax_rule') == '')? $this->arrInfo['tax_rule']:$objFormParam->getValue('order_tax_rule'); |
---|
| 1159 | foreach ($this->arrProductKeys as $insert_key) { |
---|
| 1160 | $arrAddProducts[$insert_key] = $objFormParam->getValue($insert_key); |
---|
| 1161 | $arrAddProducts[$insert_key][] = $arrAddProductInfo[$insert_key]; |
---|
| 1162 | } |
---|
| 1163 | return $arrAddProducts; |
---|
| 1164 | }else{ |
---|
| 1165 | //受注商品の数量は、複数配送側の集計で出しているので、重複しても数量を増やさない。 |
---|
| 1166 | return null; |
---|
| 1167 | } |
---|
| 1168 | } |
---|
[22882] | 1169 | } |
---|