[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 | { |
---|
[23124] | 35 | public $arrShippingKeys = array( |
---|
[20943] | 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 | |
---|
[23124] | 61 | public $arrShipmentItemKeys = array( |
---|
[20943] | 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 | |
---|
[23124] | 71 | public $arrProductKeys = array( |
---|
[22493] | 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 | */ |
---|
[23124] | 91 | public function init() |
---|
[22567] | 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 | */ |
---|
[23124] | 126 | public function process() |
---|
[22567] | 127 | { |
---|
[19661] | 128 | $this->action(); |
---|
| 129 | $this->sendResponse(); |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | /** |
---|
| 133 | * Page のアクション. |
---|
| 134 | * |
---|
| 135 | * @return void |
---|
| 136 | */ |
---|
[23124] | 137 | public function action() |
---|
[22567] | 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 | // 加算ポイントの計算 |
---|
[23124] | 260 | if (USE_POINT === true && $this->tpl_mode == 'add') { |
---|
[22490] | 261 | $birth_point = 0; |
---|
[23124] | 262 | if ($customer_birth) { |
---|
[22490] | 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 | * |
---|
[23124] | 314 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[22792] | 315 | * @return void |
---|
| 316 | */ |
---|
[23124] | 317 | public function lfInitParam(&$objFormParam) |
---|
[22792] | 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')); |
---|
[23230] | 327 | $objFormParam->addParam('注文者 会社名', 'order_company_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[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'); |
---|
[23170] | 369 | $objFormParam->addParam('税率', 'tax_rate', INT_LEN, 'n', array('NUM_CHECK')); |
---|
| 370 | $objFormParam->addParam('課税規則', 'tax_rule', INT_LEN, 'n', array('NUM_CHECK')); |
---|
[22792] | 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')); |
---|
[23230] | 402 | $objFormParam->addParam('会社名', 'shipping_company_name', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[23024] | 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 | * |
---|
[23124] | 441 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[22792] | 442 | * @return void |
---|
[19934] | 443 | */ |
---|
[23124] | 444 | public function lfInitMultipleParam(&$objFormParam) |
---|
[22792] | 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 | * |
---|
[23124] | 459 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[22792] | 460 | * @return void |
---|
[20180] | 461 | */ |
---|
[23124] | 462 | public function setMultipleItemTo(&$objFormParam) |
---|
[22792] | 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 | * |
---|
[23124] | 536 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 537 | * @param integer $order_id 取得元の受注ID |
---|
[22792] | 538 | * @return void |
---|
| 539 | */ |
---|
[23124] | 540 | public function setOrderToFormParam(&$objFormParam, $order_id) |
---|
[22792] | 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 | * |
---|
[23124] | 606 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 607 | * @return array エラーメッセージの配列 |
---|
[22792] | 608 | */ |
---|
[23124] | 609 | public function lfCheckError(&$objFormParam) |
---|
[22792] | 610 | { |
---|
| 611 | $objProduct = new SC_Product_Ex(); |
---|
[23053] | 612 | $arrValues = $objFormParam->getHashArray(); |
---|
[21311] | 613 | |
---|
[22858] | 614 | $arrErr = array(); |
---|
| 615 | $arrErrTemp = $objFormParam->checkError(); |
---|
[23053] | 616 | $arrErrDate = array(); |
---|
| 617 | foreach ($arrValues['shipping_date_year'] as $key_index => $year) { |
---|
| 618 | $month = $arrValues['shipping_date_month'][$key_index]; |
---|
| 619 | $day = $arrValues['shipping_date_day'][$key_index]; |
---|
| 620 | $objError = new SC_CheckError_Ex(array('shipping_date_year' => $year, |
---|
| 621 | 'shipping_date_month' => $month, |
---|
| 622 | 'shipping_date_day' => $day)); |
---|
| 623 | $objError->doFunc(array('お届け日', 'shipping_date_year', 'shipping_date_month', 'shipping_date_day'), array('CHECK_DATE')); |
---|
| 624 | $arrErrDate['shipping_date_year'][$key_index] = $objError->arrErr['shipping_date_year']; |
---|
| 625 | } |
---|
| 626 | $arrErrTemp = array_merge($arrErrTemp, $arrErrDate); |
---|
[19912] | 627 | |
---|
[22792] | 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]; |
---|
[20719] | 640 | |
---|
[22792] | 641 | // 在庫数のチェック |
---|
| 642 | $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); |
---|
[20719] | 643 | |
---|
[22792] | 644 | // 編集前の値と比較するため受注詳細を取得 |
---|
| 645 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 646 | $arrOrderDetail = SC_Utils_Ex::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false)); |
---|
[20719] | 647 | |
---|
[22792] | 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 | } |
---|
[15594] | 658 | } |
---|
| 659 | |
---|
[22792] | 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); |
---|
[15594] | 668 | |
---|
[22792] | 669 | // 加算ポイント |
---|
| 670 | $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']) + $arrValues['birth_point']; |
---|
[20041] | 671 | |
---|
[22792] | 672 | // 最終保持ポイント |
---|
| 673 | $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point']; |
---|
[20041] | 674 | |
---|
[22792] | 675 | if ($arrValues['total'] < 0) { |
---|
| 676 | $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
| 677 | } |
---|
[15594] | 678 | |
---|
[22792] | 679 | if ($arrValues['payment_total'] < 0) { |
---|
| 680 | $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
| 681 | } |
---|
[20180] | 682 | |
---|
[22792] | 683 | if ($arrValues['total_point'] < 0) { |
---|
| 684 | $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; |
---|
| 685 | } |
---|
| 686 | |
---|
| 687 | $objFormParam->setParam($arrValues); |
---|
[22858] | 688 | $arrErr = array_merge($arrErr, $arrErrTemp); |
---|
[22856] | 689 | |
---|
[22792] | 690 | return $arrErr; |
---|
[15594] | 691 | } |
---|
| 692 | |
---|
[18100] | 693 | /** |
---|
| 694 | * DB更新処理 |
---|
| 695 | * |
---|
[23124] | 696 | * @param integer $order_id 受注ID |
---|
| 697 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 698 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 699 | * @param string $message 通知メッセージ |
---|
| 700 | * @param array $arrValuesBefore 更新前の受注情報 |
---|
| 701 | * @return integer $order_id 受注ID |
---|
[20577] | 702 | * |
---|
| 703 | * エラー発生時は負数を返す。 |
---|
[18100] | 704 | */ |
---|
[23124] | 705 | public function doRegister($order_id, &$objPurchase, &$objFormParam, &$message, &$arrValuesBefore) |
---|
[22567] | 706 | { |
---|
[20507] | 707 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20180] | 708 | $arrValues = $objFormParam->getDbArray(); |
---|
[15594] | 709 | |
---|
[21514] | 710 | $where = 'order_id = ?'; |
---|
[15594] | 711 | |
---|
[18329] | 712 | $objQuery->begin(); |
---|
[21118] | 713 | |
---|
[21036] | 714 | // 支払い方法が変更されたら、支払い方法名称も更新 |
---|
| 715 | if ($arrValues['payment_id'] != $arrValuesBefore['payment_id']) { |
---|
| 716 | $arrValues['payment_method'] = $this->arrPayment[$arrValues['payment_id']]; |
---|
| 717 | $arrValuesBefore['payment_id'] = NULL; |
---|
| 718 | } |
---|
[18329] | 719 | |
---|
[15594] | 720 | // 受注テーブルの更新 |
---|
[20180] | 721 | $order_id = $objPurchase->registerOrder($order_id, $arrValues); |
---|
[18819] | 722 | |
---|
[21527] | 723 | $arrDetail = $objFormParam->getSwapArray(array( |
---|
| 724 | 'product_id', |
---|
| 725 | 'product_class_id', |
---|
| 726 | 'product_code', |
---|
| 727 | 'product_name', |
---|
| 728 | 'price', 'quantity', |
---|
| 729 | 'point_rate', |
---|
| 730 | 'classcategory_name1', |
---|
| 731 | 'classcategory_name2', |
---|
[22218] | 732 | 'tax_rate', |
---|
| 733 | 'tax_rule' |
---|
[21527] | 734 | )); |
---|
[18819] | 735 | |
---|
[18646] | 736 | // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 |
---|
| 737 | $max = count($arrDetail); |
---|
| 738 | $k = 0; |
---|
| 739 | $arrStockData = array(); |
---|
[21441] | 740 | for ($i = 0; $i < $max; $i++) { |
---|
[18646] | 741 | if (!empty($arrDetail[$i]['product_id'])) { |
---|
[21515] | 742 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 743 | if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { |
---|
| 744 | // 数量が変更された商品 |
---|
[18872] | 745 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 746 | $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; |
---|
| 747 | ++$k; |
---|
| 748 | } elseif (empty($arrPreDetail)) { |
---|
| 749 | // 新しく追加された商品 もしくは 違う商品に変更された商品 |
---|
[18872] | 750 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 751 | $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; |
---|
| 752 | ++$k; |
---|
| 753 | } |
---|
[21514] | 754 | $objQuery->delete('dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 755 | } |
---|
| 756 | } |
---|
| 757 | |
---|
| 758 | // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 |
---|
[21515] | 759 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ?', array($order_id)); |
---|
[18646] | 760 | foreach ($arrPreDetail AS $key=>$val) { |
---|
[18872] | 761 | $arrStockData[$k]['product_class_id'] = $val['product_class_id']; |
---|
[18646] | 762 | $arrStockData[$k]['quantity'] = $val['quantity']; |
---|
| 763 | ++$k; |
---|
| 764 | } |
---|
| 765 | |
---|
| 766 | // 受注詳細データの更新 |
---|
[20180] | 767 | $objPurchase->registerOrderDetail($order_id, $arrDetail); |
---|
[18074] | 768 | |
---|
[18646] | 769 | // 在庫数調整 |
---|
[20180] | 770 | if (ORDER_DELIV != $arrValues['status'] |
---|
| 771 | && ORDER_CANCEL != $arrValues['status']) { |
---|
| 772 | foreach ($arrStockData AS $stock) { |
---|
| 773 | $objQuery->update('dtb_products_class', array(), |
---|
| 774 | 'product_class_id = ?', |
---|
| 775 | array($stock['product_class_id']), |
---|
| 776 | array('stock' => 'stock + ?'), |
---|
| 777 | array($stock['quantity'])); |
---|
[18646] | 778 | } |
---|
| 779 | } |
---|
| 780 | |
---|
[20943] | 781 | $arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys); |
---|
| 782 | $arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys); |
---|
[19949] | 783 | |
---|
[22554] | 784 | $arrDelivTime = SC_Helper_Delivery_Ex::getDelivTime($objFormParam->getValue('deliv_id')); |
---|
[22493] | 785 | //商品単価を複数配送にも適応 |
---|
[20180] | 786 | $arrShippingValues = array(); |
---|
[22493] | 787 | $arrIsNotQuantityUp = array(); |
---|
[20180] | 788 | foreach ($arrAllShipping as $shipping_index => $arrShipping) { |
---|
| 789 | $shipping_id = $arrShipping['shipping_id']; |
---|
| 790 | $arrShippingValues[$shipping_index] = $arrShipping; |
---|
[19949] | 791 | |
---|
[20180] | 792 | $arrShippingValues[$shipping_index]['shipping_date'] |
---|
| 793 | = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], |
---|
| 794 | $arrShipping['shipping_date_month'], |
---|
| 795 | $arrShipping['shipping_date_day']); |
---|
[19963] | 796 | |
---|
[22493] | 797 | //商品単価を複数配送にも反映する |
---|
[22283] | 798 | foreach ($arrDetail as $product_detail) { |
---|
| 799 | foreach ($arrAllShipmentItem[$shipping_index]['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { |
---|
[23124] | 800 | if ($product_detail['product_class_id'] == $shipment_product_class_id) { |
---|
[22283] | 801 | $arrAllShipmentItem[$shipping_index]['shipment_price'][$relation_index] = $product_detail['price']; |
---|
| 802 | } |
---|
| 803 | } |
---|
| 804 | } |
---|
[20180] | 805 | // 配送業者IDを取得 |
---|
| 806 | $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); |
---|
[19949] | 807 | |
---|
[20804] | 808 | // お届け時間名称を取得 |
---|
| 809 | $arrShippingValues[$shipping_index]['shipping_time'] = $arrDelivTime[$arrShipping['time_id']]; |
---|
| 810 | |
---|
[20180] | 811 | // 複数配送の場合は配送商品を登録 |
---|
| 812 | if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) { |
---|
| 813 | $arrShipmentValues = array(); |
---|
[19963] | 814 | |
---|
[20180] | 815 | foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) { |
---|
| 816 | $i = 0; |
---|
| 817 | foreach ($arrItem as $item) { |
---|
| 818 | $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item; |
---|
| 819 | $i++; |
---|
| 820 | } |
---|
[19949] | 821 | } |
---|
[20180] | 822 | $objPurchase->registerShipmentItem($order_id, $shipping_id, |
---|
| 823 | $arrShipmentValues[$shipping_index]); |
---|
[19949] | 824 | } |
---|
| 825 | } |
---|
[22493] | 826 | |
---|
[20180] | 827 | $objPurchase->registerShipping($order_id, $arrShippingValues, false); |
---|
[15594] | 828 | $objQuery->commit(); |
---|
[22856] | 829 | |
---|
[20180] | 830 | return $order_id; |
---|
[15594] | 831 | } |
---|
[17293] | 832 | |
---|
[18100] | 833 | /** |
---|
[20180] | 834 | * 受注商品の追加/更新を行う. |
---|
[18100] | 835 | * |
---|
[20180] | 836 | * 小画面で選択した受注商品をフォームに反映させる. |
---|
| 837 | * |
---|
[23124] | 838 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20180] | 839 | * @return void |
---|
[18100] | 840 | */ |
---|
[23124] | 841 | public function doRegisterProduct(&$objFormParam) |
---|
[22567] | 842 | { |
---|
[20180] | 843 | $product_class_id = $objFormParam->getValue('add_product_class_id'); |
---|
| 844 | if (SC_Utils_Ex::isBlank($product_class_id)) { |
---|
| 845 | $product_class_id = $objFormParam->getValue('edit_product_class_id'); |
---|
[20415] | 846 | $changed_no = $objFormParam->getValue('no'); |
---|
[22493] | 847 | $this->shipmentEditProduct($objFormParam, $product_class_id, $changed_no); |
---|
[23124] | 848 | } else { |
---|
[22493] | 849 | $this->shipmentAddProduct($objFormParam, $product_class_id); |
---|
[17293] | 850 | } |
---|
| 851 | } |
---|
| 852 | |
---|
[19919] | 853 | /** |
---|
[20180] | 854 | * 受注商品を削除する. |
---|
| 855 | * |
---|
[23124] | 856 | * @param integer $delete_no 削除する受注商品の項番 |
---|
| 857 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20180] | 858 | * @return void |
---|
[19919] | 859 | */ |
---|
[23124] | 860 | public function doDeleteProduct($delete_no, &$objFormParam) |
---|
[22567] | 861 | { |
---|
[22493] | 862 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
| 863 | |
---|
| 864 | //変更前のproduct_class_idが他の届け先にも存在するか |
---|
| 865 | $arrPreShipmentProductClassIds = $objFormParam->getValue('shipment_product_class_id'); |
---|
| 866 | $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
| 867 | $delete_product_class_id = $arrPreShipmentProductClassIds[$select_shipping_id][$delete_no]; |
---|
| 868 | |
---|
| 869 | //配送先データ削除 |
---|
| 870 | $arrNewShipments = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $delete_no); |
---|
| 871 | $objFormParam->setParam($arrNewShipments); |
---|
| 872 | |
---|
| 873 | $is_product_delete = true; |
---|
| 874 | foreach ($arrNewShipments['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { |
---|
| 875 | foreach ($arrShipmentProductClassIds as $relation_index => $shipment_product_class_id) { |
---|
[23124] | 876 | if (in_array($delete_product_class_id, $arrShipmentProductClassIds)) { |
---|
[22493] | 877 | $is_product_delete = false; |
---|
| 878 | break; |
---|
[18014] | 879 | } |
---|
| 880 | } |
---|
| 881 | } |
---|
[22493] | 882 | |
---|
| 883 | //商品情報から削除 |
---|
[23124] | 884 | if ($is_product_delete) { |
---|
[22493] | 885 | $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $delete_product_class_id, $this->arrProductKeys); |
---|
| 886 | } |
---|
[17293] | 887 | } |
---|
| 888 | |
---|
[20180] | 889 | /** |
---|
| 890 | * お届け先を追加する. |
---|
| 891 | * |
---|
[23124] | 892 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20180] | 893 | * @return void |
---|
| 894 | */ |
---|
[23124] | 895 | public function addShipping(&$objFormParam) |
---|
[22567] | 896 | { |
---|
[20180] | 897 | $objFormParam->setValue('shipping_quantity', |
---|
| 898 | $objFormParam->getValue('shipping_quantity') + 1); |
---|
| 899 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 900 | $arrShippingIds[] = max($arrShippingIds) + 1; |
---|
| 901 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[17293] | 902 | } |
---|
| 903 | |
---|
[18068] | 904 | /** |
---|
[21419] | 905 | * 会員情報をフォームに設定する. |
---|
[20180] | 906 | * |
---|
[23124] | 907 | * @param integer $customer_id 会員ID |
---|
| 908 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20180] | 909 | * @return void |
---|
[18068] | 910 | */ |
---|
[23124] | 911 | public function setCustomerTo($customer_id, &$objFormParam) |
---|
[22567] | 912 | { |
---|
[20180] | 913 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
| 914 | foreach ($arrCustomer as $key => $val) { |
---|
| 915 | $objFormParam->setValue('order_' . $key, $val); |
---|
[18068] | 916 | } |
---|
[20180] | 917 | $objFormParam->setValue('customer_id', $customer_id); |
---|
[20442] | 918 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
[22490] | 919 | |
---|
| 920 | return $arrCustomer['birth']; |
---|
[18068] | 921 | } |
---|
[18329] | 922 | |
---|
| 923 | /** |
---|
[20180] | 924 | * アンカーキーを取得する. |
---|
[18329] | 925 | * |
---|
[23124] | 926 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20180] | 927 | * @return アンカーキーの文字列 |
---|
[18329] | 928 | */ |
---|
[23124] | 929 | public function getAnchorKey(&$objFormParam) |
---|
[22567] | 930 | { |
---|
[20180] | 931 | $ancor_key = $objFormParam->getValue('anchor_key'); |
---|
| 932 | if (!SC_Utils_Ex::isBlank($ancor_key)) { |
---|
| 933 | return "location.hash='#" . htmlentities(urlencode($ancor_key), ENT_QUOTES) . "'"; |
---|
[18329] | 934 | } |
---|
[22856] | 935 | |
---|
[20180] | 936 | return ''; |
---|
[19963] | 937 | } |
---|
[22493] | 938 | |
---|
| 939 | /** |
---|
| 940 | * 商品を追加 |
---|
| 941 | * |
---|
[23124] | 942 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 943 | * @param integer $add_product_class_id 追加商品規格ID |
---|
[22493] | 944 | * @return void |
---|
| 945 | */ |
---|
[23124] | 946 | public function shipmentAddProduct(&$objFormParam, $add_product_class_id) |
---|
[22567] | 947 | { |
---|
[22493] | 948 | //複数配送に商品情報追加 |
---|
| 949 | $select_shipping_id = $objFormParam->getValue('select_shipping_id'); |
---|
| 950 | |
---|
| 951 | //届け先に選択済みの商品がある場合 |
---|
| 952 | $arrShipmentProducts = $this->getShipmentProducts($objFormParam); |
---|
| 953 | |
---|
[23123] | 954 | if($arrShipmentProducts['shipment_product_class_id'] && in_array($add_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])){ |
---|
[22493] | 955 | foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { |
---|
[23124] | 956 | if ($shipment_product_class_id == $add_product_class_id) { |
---|
[22493] | 957 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++; |
---|
| 958 | break; |
---|
| 959 | } |
---|
| 960 | } |
---|
[23124] | 961 | } else { |
---|
[22493] | 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 | * |
---|
[23124] | 983 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 984 | * @param integer $add_product_class_id 変更商品規格ID |
---|
| 985 | * @param integer $change_no 変更対象 |
---|
[22493] | 986 | * @return void |
---|
| 987 | */ |
---|
[23124] | 988 | public function shipmentEditProduct(&$objFormParam, $edit_product_class_id, $change_no) |
---|
[22567] | 989 | { |
---|
[22493] | 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]; |
---|
[23124] | 997 | if ($pre_shipment_product_class_id == $edit_product_class_id) { |
---|
[22493] | 998 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$change_no] ++; |
---|
[23124] | 999 | } elseif (in_array($edit_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])) { |
---|
[22493] | 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) { |
---|
[23124] | 1003 | if ($shipment_product_class_id == $edit_product_class_id) { |
---|
[22493] | 1004 | $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index] ++; |
---|
| 1005 | break; |
---|
| 1006 | } |
---|
| 1007 | } |
---|
[23124] | 1008 | } else { |
---|
[22493] | 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) { |
---|
[23124] | 1025 | if (in_array($pre_shipment_product_class_id, $arrShipmentProductClassIds)) { |
---|
[22493] | 1026 | $is_product_delete = false; |
---|
| 1027 | break; |
---|
| 1028 | } |
---|
| 1029 | } |
---|
| 1030 | |
---|
| 1031 | //商品情報から削除 |
---|
[23124] | 1032 | if ($is_product_delete) { |
---|
[22493] | 1033 | $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $pre_shipment_product_class_id, $this->arrProductKeys); |
---|
| 1034 | } |
---|
| 1035 | } |
---|
| 1036 | |
---|
| 1037 | /** |
---|
[22792] | 1038 | * 複数配送のパラメータを取り出す |
---|
[22493] | 1039 | * |
---|
[23124] | 1040 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1041 | * @return array 配送データ |
---|
[22493] | 1042 | */ |
---|
[23124] | 1043 | public function getShipmentProducts(&$objFormParam) |
---|
[22567] | 1044 | { |
---|
[22493] | 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 | |
---|
[23039] | 1053 | foreach ($arrShipmentProducts as $key => $value) { |
---|
[23124] | 1054 | if (!is_array($value)) { |
---|
[23039] | 1055 | $arrShipmentProducts[$key] = array(); |
---|
| 1056 | } |
---|
| 1057 | } |
---|
| 1058 | |
---|
[22493] | 1059 | return $arrShipmentProducts; |
---|
| 1060 | } |
---|
| 1061 | |
---|
| 1062 | /** |
---|
| 1063 | * 変更対象のデータを上書きする |
---|
| 1064 | * |
---|
[23124] | 1065 | * @param array $arrShipmentProducts 変更対象配列 |
---|
| 1066 | * @param array $arrProductInfo 上書きデータ |
---|
| 1067 | * @param integer $shipping_id 配送先ID |
---|
| 1068 | * @param array $no 変更対象 |
---|
[22493] | 1069 | * @return void |
---|
| 1070 | */ |
---|
[23124] | 1071 | public function changeShipmentProducts(&$arrShipmentProducts, $arrProductInfo, $shipping_id, $no) |
---|
[22567] | 1072 | { |
---|
[22493] | 1073 | $arrShipmentProducts['shipment_product_class_id'][$shipping_id][$no] = $arrProductInfo['product_class_id']; |
---|
| 1074 | $arrShipmentProducts['shipment_product_code'][$shipping_id][$no] = $arrProductInfo['product_code']; |
---|
| 1075 | $arrShipmentProducts['shipment_product_name'][$shipping_id][$no] = $arrProductInfo['name']; |
---|
| 1076 | $arrShipmentProducts['shipment_classcategory_name1'][$shipping_id][$no] = $arrProductInfo['classcategory_name1']; |
---|
| 1077 | $arrShipmentProducts['shipment_classcategory_name2'][$shipping_id][$no] = $arrProductInfo['classcategory_name2']; |
---|
| 1078 | $arrShipmentProducts['shipment_price'][$shipping_id][$no] = $arrProductInfo['price02']; |
---|
| 1079 | $arrShipmentProducts['shipment_quantity'][$shipping_id][$no] = 1; |
---|
| 1080 | } |
---|
| 1081 | |
---|
| 1082 | /** |
---|
| 1083 | * 商品側の総量計算&セット |
---|
| 1084 | * |
---|
[23124] | 1085 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[22493] | 1086 | * @return void |
---|
| 1087 | */ |
---|
[23124] | 1088 | public function setProductsQuantity(&$objFormParam) |
---|
[22567] | 1089 | { |
---|
[22493] | 1090 | $arrShipmentsItems = $objFormParam->getSwapArray(array('shipment_product_class_id','shipment_quantity')); |
---|
[23230] | 1091 | |
---|
| 1092 | // 配送先が存在する時のみ、商品個数の再設定を行います |
---|
| 1093 | if(!SC_Utils_Ex::isBlank($arrShipmentsItems)) { |
---|
| 1094 | foreach ($arrShipmentsItems as $arritems) { |
---|
| 1095 | foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { |
---|
| 1096 | $arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index]; |
---|
| 1097 | } |
---|
[22493] | 1098 | } |
---|
| 1099 | |
---|
[23230] | 1100 | $arrProductsClass = $objFormParam->getValue('product_class_id'); |
---|
| 1101 | $arrProductsQuantity = $objFormParam->getValue('quantity'); |
---|
| 1102 | foreach ($arrProductsClass as $relation_key => $product_class_id) { |
---|
| 1103 | $arrQuantity['quantity'][$relation_key] = $arrUpdateQuantity[$product_class_id]; |
---|
| 1104 | } |
---|
| 1105 | $objFormParam->setParam($arrQuantity); |
---|
[22493] | 1106 | } |
---|
| 1107 | } |
---|
| 1108 | |
---|
| 1109 | /** |
---|
| 1110 | * 削除対象の確認、削除をする |
---|
| 1111 | * |
---|
[23124] | 1112 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1113 | * @param array $arrProductClassIds 削除対象配列の商品規格ID |
---|
| 1114 | * @param integer $delete_product_class_id 削除商品規? ?ID |
---|
| 1115 | * @param array $arrDeleteKeys 削除項目 |
---|
[22493] | 1116 | * @return void |
---|
| 1117 | */ |
---|
[23124] | 1118 | public function checkDeleteProducts(&$objFormParam, $arrProductClassIds, $delete_product_class_id, $arrDeleteKeys) |
---|
[22567] | 1119 | { |
---|
[22493] | 1120 | foreach ($arrProductClassIds as $relation_index => $product_class_id) { |
---|
| 1121 | //product_class_idの重複はないので、1つ削除したら完了 |
---|
[23124] | 1122 | if ($product_class_id == $delete_product_class_id) { |
---|
[22493] | 1123 | foreach ($arrDeleteKeys as $delete_key) { |
---|
| 1124 | $arrProducts = $objFormParam->getValue($delete_key); |
---|
| 1125 | foreach ($arrProducts as $index => $product_info) { |
---|
[23124] | 1126 | if ($index != $relation_index) { |
---|
[22493] | 1127 | $arrUpdateParams[$delete_key][] = $product_info; |
---|
| 1128 | } |
---|
| 1129 | } |
---|
| 1130 | $objFormParam->setParam($arrUpdateParams); |
---|
| 1131 | } |
---|
| 1132 | break; |
---|
| 1133 | } |
---|
| 1134 | } |
---|
| 1135 | } |
---|
| 1136 | |
---|
| 1137 | /** |
---|
| 1138 | * 配送先商品の削除の削除 |
---|
| 1139 | * |
---|
[23124] | 1140 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1141 | * @param array $arrShipmentDeleteKeys 削除項目 |
---|
| 1142 | * @param integer $delete_shipping_id 削除配送ID |
---|
| 1143 | * @param array $delete_no 削除対象 |
---|
[22493] | 1144 | * @return void |
---|
| 1145 | */ |
---|
[23124] | 1146 | public function deleteShipment(&$objFormParam, $arrShipmentDeletKeys, $delete_shipping_id, $delete_no) |
---|
[22567] | 1147 | { |
---|
[22493] | 1148 | foreach ($arrShipmentDeletKeys as $delete_key) { |
---|
| 1149 | $arrShipments = $objFormParam->getValue($delete_key); |
---|
[23124] | 1150 | foreach ($arrShipments as $shipp_id => $arrKeyData) { |
---|
[22493] | 1151 | foreach ($arrKeyData as $relation_index => $shipment_info) { |
---|
[23124] | 1152 | if ($relation_index != $delete_no || $shipp_id != $delete_shipping_id) { |
---|
[22493] | 1153 | $arrUpdateParams[$delete_key][$shipp_id][] = $shipment_info; |
---|
| 1154 | } |
---|
| 1155 | } |
---|
| 1156 | } |
---|
| 1157 | } |
---|
| 1158 | //$objFormParam->setParam($arrUpdateParams); |
---|
| 1159 | return $arrUpdateParams; |
---|
| 1160 | } |
---|
| 1161 | |
---|
| 1162 | /** |
---|
| 1163 | * 受注商品一覧側に商品を追加 |
---|
| 1164 | * |
---|
[23124] | 1165 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 1166 | * @param array $arrProductClassIds 対象配列の商品規格ID |
---|
| 1167 | * @param integer $indert_product_class_id 追?? 商品規格ID |
---|
| 1168 | * @param array $arrAddProductInfo 追加データ |
---|
| 1169 | * @return array $arrAddProducts 更新データ |
---|
[22493] | 1170 | */ |
---|
[23124] | 1171 | public function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $insert_product_class_id, $arrAddProductInfo) |
---|
[22567] | 1172 | { |
---|
[23123] | 1173 | if(!$arrProductClassIds || !in_array($insert_product_class_id, $arrProductClassIds)){ |
---|
[23039] | 1174 | $arrAddProducts = array(); |
---|
| 1175 | |
---|
| 1176 | $arrAddProductInfo['product_name'] = ($arrAddProductInfo['product_name'])? |
---|
| 1177 | $arrAddProductInfo['product_name']:$arrAddProductInfo['name']; |
---|
| 1178 | $arrAddProductInfo['price'] = ($arrAddProductInfo['price'])? |
---|
| 1179 | $arrAddProductInfo['price']:$arrAddProductInfo['price02']; |
---|
[22493] | 1180 | $arrAddProductInfo['quantity'] = 1; |
---|
[23039] | 1181 | $arrAddProductInfo['tax_rate'] = ($objFormParam->getValue('order_tax_rate') == '')? |
---|
| 1182 | $this->arrInfo['tax'] :$objFormParam->getValue('order_tax_rate'); |
---|
| 1183 | $arrAddProductInfo['tax_rule'] = ($objFormParam->getValue('order_tax_rule') == '')? |
---|
| 1184 | $this->arrInfo['tax_rule']:$objFormParam->getValue('order_tax_rule'); |
---|
[22493] | 1185 | foreach ($this->arrProductKeys as $insert_key) { |
---|
[23039] | 1186 | $value = $objFormParam->getValue($insert_key); |
---|
| 1187 | $arrAddProducts[$insert_key] = (is_array($value))? $value: array(); |
---|
[22493] | 1188 | $arrAddProducts[$insert_key][] = $arrAddProductInfo[$insert_key]; |
---|
| 1189 | } |
---|
[23124] | 1190 | |
---|
[22493] | 1191 | return $arrAddProducts; |
---|
[23124] | 1192 | } else { |
---|
[22493] | 1193 | //受注商品の数量は、複数配送側の集計で出しているので、重複しても数量を増やさない。 |
---|
| 1194 | return null; |
---|
| 1195 | } |
---|
| 1196 | } |
---|
[22882] | 1197 | } |
---|