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