[15594] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[21867] | 5 | * Copyright(c) 2000-2012 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 | |
---|
| 24 | // {{{ requires |
---|
[20534] | 25 | require_once CLASS_EX_REALDIR . 'page_extends/admin/order/LC_Page_Admin_Order_Ex.php'; |
---|
[15594] | 26 | |
---|
| 27 | /** |
---|
| 28 | * 受注修正 のページクラス. |
---|
| 29 | * |
---|
| 30 | * @package Page |
---|
| 31 | * @author LOCKON CO.,LTD. |
---|
| 32 | * @version $Id$ |
---|
| 33 | */ |
---|
[20180] | 34 | class LC_Page_Admin_Order_Edit extends LC_Page_Admin_Order_Ex { |
---|
[15594] | 35 | |
---|
[20943] | 36 | var $arrShippingKeys = array( |
---|
| 37 | 'shipping_id', |
---|
| 38 | 'shipping_name01', |
---|
| 39 | 'shipping_name02', |
---|
| 40 | 'shipping_kana01', |
---|
| 41 | 'shipping_kana02', |
---|
| 42 | 'shipping_tel01', |
---|
| 43 | 'shipping_tel02', |
---|
| 44 | 'shipping_tel03', |
---|
| 45 | 'shipping_fax01', |
---|
| 46 | 'shipping_fax02', |
---|
| 47 | 'shipping_fax03', |
---|
| 48 | 'shipping_pref', |
---|
[22205] | 49 | // 'shipping_zip01', |
---|
| 50 | // 'shipping_zip02', |
---|
| 51 | 'shipping_zipcode', |
---|
[20943] | 52 | 'shipping_addr01', |
---|
| 53 | 'shipping_addr02', |
---|
| 54 | 'shipping_date_year', |
---|
| 55 | 'shipping_date_month', |
---|
| 56 | 'shipping_date_day', |
---|
| 57 | 'time_id', |
---|
| 58 | ); |
---|
| 59 | |
---|
| 60 | var $arrShipmentItemKeys = array( |
---|
| 61 | 'shipment_product_class_id', |
---|
| 62 | 'shipment_product_code', |
---|
| 63 | 'shipment_product_name', |
---|
| 64 | 'shipment_classcategory_name1', |
---|
| 65 | 'shipment_classcategory_name2', |
---|
| 66 | 'shipment_price', |
---|
| 67 | 'shipment_quantity', |
---|
| 68 | ); |
---|
| 69 | |
---|
[15594] | 70 | // }}} |
---|
| 71 | // {{{ functions |
---|
| 72 | |
---|
| 73 | /** |
---|
| 74 | * Page を初期化する. |
---|
| 75 | * |
---|
| 76 | * @return void |
---|
| 77 | */ |
---|
| 78 | function init() { |
---|
| 79 | parent::init(); |
---|
| 80 | $this->tpl_mainpage = 'order/edit.tpl'; |
---|
[17293] | 81 | $this->tpl_mainno = 'order'; |
---|
[22100] | 82 | $this->tpl_maintitle = t('TPL_MAINTITLE_001'); |
---|
| 83 | $this->tpl_subtitle = t('LC_Page_Admin_Order_Edit_001'); |
---|
[15594] | 84 | |
---|
| 85 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[19773] | 86 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[21481] | 87 | $this->arrORDERSTATUS = $masterData->getMasterData('mtb_order_status'); |
---|
[19975] | 88 | $this->arrDeviceType = $masterData->getMasterData('mtb_device_type'); |
---|
[17886] | 89 | |
---|
[20499] | 90 | $objDate = new SC_Date_Ex(RELEASE_YEAR); |
---|
[20180] | 91 | $this->arrYearShippingDate = $objDate->getYear('', date('Y'), ''); |
---|
| 92 | $this->arrMonthShippingDate = $objDate->getMonth(true); |
---|
| 93 | $this->arrDayShippingDate = $objDate->getDay(true); |
---|
| 94 | |
---|
| 95 | // 支払い方法の取得 |
---|
[21481] | 96 | $this->arrPayment = SC_Helper_DB_Ex::sfGetIDValueList('dtb_payment', 'payment_id', 'payment_method'); |
---|
[20180] | 97 | |
---|
| 98 | // 配送業者の取得 |
---|
[21481] | 99 | $this->arrDeliv = SC_Helper_DB_Ex::sfGetIDValueList('dtb_deliv', 'deliv_id', 'name'); |
---|
[20180] | 100 | |
---|
[18187] | 101 | $this->httpCacheControl('nocache'); |
---|
[15594] | 102 | } |
---|
| 103 | |
---|
| 104 | /** |
---|
| 105 | * Page のプロセス. |
---|
| 106 | * |
---|
| 107 | * @return void |
---|
| 108 | */ |
---|
| 109 | function process() { |
---|
[19661] | 110 | $this->action(); |
---|
| 111 | $this->sendResponse(); |
---|
| 112 | } |
---|
| 113 | |
---|
| 114 | /** |
---|
| 115 | * Page のアクション. |
---|
| 116 | * |
---|
| 117 | * @return void |
---|
| 118 | */ |
---|
| 119 | function action() { |
---|
[21591] | 120 | |
---|
[19923] | 121 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[20501] | 122 | $objFormParam = new SC_FormParam_Ex(); |
---|
[15594] | 123 | |
---|
[20970] | 124 | // パラメーター情報の初期化 |
---|
[20180] | 125 | $this->lfInitParam($objFormParam); |
---|
| 126 | $objFormParam->setParam($_REQUEST); |
---|
| 127 | $objFormParam->convParam(); |
---|
| 128 | $order_id = $objFormParam->getValue('order_id'); |
---|
[21036] | 129 | $arrValuesBefore = array(); |
---|
[15594] | 130 | |
---|
| 131 | // DBから受注情報を読み込む |
---|
[19963] | 132 | if (!SC_Utils_Ex::isBlank($order_id)) { |
---|
[20180] | 133 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 134 | $this->tpl_subno = 'index'; |
---|
[21036] | 135 | $arrValuesBefore['payment_id'] = $objFormParam->getValue('payment_id'); |
---|
| 136 | $arrValuesBefore['payment_method'] = $objFormParam->getValue('payment_method'); |
---|
[20180] | 137 | } else { |
---|
| 138 | $this->tpl_subno = 'add'; |
---|
| 139 | $this->tpl_mode = 'add'; |
---|
[21036] | 140 | $arrValuesBefore['payment_id'] = NULL; |
---|
| 141 | $arrValuesBefore['payment_method'] = NULL; |
---|
[21222] | 142 | // お届け先情報を空情報で表示 |
---|
| 143 | $arrShippingIds[] = null; |
---|
| 144 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[21420] | 145 | |
---|
[21419] | 146 | // 新規受注登録で入力エラーがあった場合の画面表示用に、会員の現在ポイントを取得 |
---|
[21069] | 147 | if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { |
---|
| 148 | $customer_id = $objFormParam->getValue('customer_id'); |
---|
| 149 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
| 150 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
[21774] | 151 | |
---|
| 152 | // 新規受注登録で、ポイント利用できるように現在ポイントを設定 |
---|
| 153 | $objFormParam->setValue('point', $arrCustomer['point']); |
---|
[21069] | 154 | } |
---|
[19963] | 155 | } |
---|
[15594] | 156 | |
---|
[20180] | 157 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
| 158 | |
---|
[21441] | 159 | switch ($this->getMode()) { |
---|
[21526] | 160 | case 'pre_edit': |
---|
| 161 | case 'order_id': |
---|
| 162 | break; |
---|
[20180] | 163 | |
---|
[21526] | 164 | case 'edit': |
---|
[20180] | 165 | $objFormParam->setParam($_POST); |
---|
| 166 | $objFormParam->convParam(); |
---|
| 167 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 168 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
[22100] | 169 | $message = t('LC_Page_Admin_Order_Edit_003'); |
---|
[21526] | 170 | $order_id = $this->doRegister($order_id, $objPurchase, $objFormParam, $message, $arrValuesBefore); |
---|
[20577] | 171 | if ($order_id >= 0) { |
---|
| 172 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 173 | } |
---|
| 174 | $this->tpl_onload = "window.alert('" . $message . "');"; |
---|
[18068] | 175 | } |
---|
[21526] | 176 | break; |
---|
[20180] | 177 | |
---|
[21526] | 178 | case 'add': |
---|
| 179 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
---|
| 180 | $objFormParam->setParam($_POST); |
---|
| 181 | $objFormParam->convParam(); |
---|
| 182 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 183 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
[22100] | 184 | $message = t('LC_Page_Admin_Order_Edit_002'); |
---|
[21526] | 185 | $order_id = $this->doRegister(null, $objPurchase, $objFormParam, $message, $arrValuesBefore); |
---|
| 186 | if ($order_id >= 0) { |
---|
| 187 | $this->tpl_mode = 'edit'; |
---|
| 188 | $objFormParam->setValue('order_id', $order_id); |
---|
| 189 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 190 | } |
---|
| 191 | $this->tpl_onload = "window.alert('" . $message . "');"; |
---|
| 192 | } |
---|
| 193 | } |
---|
[20180] | 194 | |
---|
[21526] | 195 | break; |
---|
[19912] | 196 | |
---|
[21526] | 197 | // 再計算 |
---|
| 198 | case 'recalculate': |
---|
| 199 | //支払い方法の選択 |
---|
| 200 | case 'payment': |
---|
| 201 | // 配送業者の選択 |
---|
| 202 | case 'deliv': |
---|
| 203 | $objFormParam->setParam($_POST); |
---|
| 204 | $objFormParam->convParam(); |
---|
| 205 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 206 | break; |
---|
[20180] | 207 | |
---|
[21526] | 208 | // 商品削除 |
---|
| 209 | case 'delete_product': |
---|
| 210 | $objFormParam->setParam($_POST); |
---|
| 211 | $objFormParam->convParam(); |
---|
| 212 | $delete_no = $objFormParam->getValue('delete_no'); |
---|
| 213 | $this->doDeleteProduct($delete_no, $objFormParam); |
---|
| 214 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 215 | break; |
---|
[19963] | 216 | |
---|
[21526] | 217 | // 商品追加ポップアップより商品選択 |
---|
| 218 | case 'select_product_detail': |
---|
| 219 | $objFormParam->setParam($_POST); |
---|
| 220 | $objFormParam->convParam(); |
---|
| 221 | $this->doRegisterProduct($objFormParam); |
---|
| 222 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 223 | break; |
---|
[17887] | 224 | |
---|
[21526] | 225 | // 会員検索ポップアップより会員指定 |
---|
| 226 | case 'search_customer': |
---|
| 227 | $objFormParam->setParam($_POST); |
---|
| 228 | $objFormParam->convParam(); |
---|
| 229 | $this->setCustomerTo($objFormParam->getValue('edit_customer_id'), |
---|
| 230 | $objFormParam); |
---|
| 231 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 232 | break; |
---|
[19934] | 233 | |
---|
[21526] | 234 | // 複数配送設定表示 |
---|
| 235 | case 'multiple': |
---|
| 236 | $objFormParam->setParam($_POST); |
---|
| 237 | $objFormParam->convParam(); |
---|
| 238 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 239 | break; |
---|
[19963] | 240 | |
---|
[21526] | 241 | // 複数配送設定を反映 |
---|
| 242 | case 'multiple_set_to': |
---|
| 243 | $this->lfInitMultipleParam($objFormParam); |
---|
| 244 | $objFormParam->setParam($_POST); |
---|
| 245 | $objFormParam->convParam(); |
---|
| 246 | $this->setMultipleItemTo($objFormParam); |
---|
| 247 | break; |
---|
[19963] | 248 | |
---|
[21526] | 249 | // お届け先の追加 |
---|
| 250 | case 'append_shipping': |
---|
| 251 | $objFormParam->setParam($_POST); |
---|
| 252 | $objFormParam->convParam(); |
---|
| 253 | $this->addShipping($objFormParam); |
---|
| 254 | break; |
---|
| 255 | |
---|
| 256 | default: |
---|
| 257 | break; |
---|
[15594] | 258 | } |
---|
| 259 | |
---|
[20180] | 260 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
[20943] | 261 | $this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys)); |
---|
[20180] | 262 | $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id')); |
---|
| 263 | $this->tpl_onload .= $this->getAnchorKey($objFormParam); |
---|
[20484] | 264 | $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
[21036] | 265 | if ($arrValuesBefore['payment_id']) |
---|
| 266 | $this->arrPayment[$arrValuesBefore['payment_id']] = $arrValuesBefore['payment_method']; |
---|
[21592] | 267 | |
---|
[15594] | 268 | } |
---|
| 269 | |
---|
| 270 | /** |
---|
| 271 | * デストラクタ. |
---|
| 272 | * |
---|
| 273 | * @return void |
---|
| 274 | */ |
---|
| 275 | function destroy() { |
---|
| 276 | parent::destroy(); |
---|
| 277 | } |
---|
| 278 | |
---|
[20180] | 279 | /** |
---|
[20970] | 280 | * パラメーター情報の初期化を行う. |
---|
[20180] | 281 | * |
---|
| 282 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 283 | * @return void |
---|
| 284 | */ |
---|
| 285 | function lfInitParam(&$objFormParam) { |
---|
[20970] | 286 | // 検索条件のパラメーターを初期化 |
---|
[20180] | 287 | parent::lfInitParam($objFormParam); |
---|
[18037] | 288 | |
---|
[17508] | 289 | // お客様情報 |
---|
[22100] | 290 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_LASTNAME'), 'order_name01', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 291 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_FIRSTNAME'), 'order_name02', STEXT_LEN, 'KVa', array('EXIST_CHECK', 'SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[22177] | 292 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_LASTKANA'), 'order_kana01', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 293 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_FIRSTKANA'), 'order_kana02', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[22100] | 294 | $objFormParam->addParam(t('PARAM_LABEL_EMAIL'), 'order_email', null, 'KVCa', array('NO_SPTAB', 'EMAIL_CHECK', 'EMAIL_CHAR_CHECK')); |
---|
[22205] | 295 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'order_zip01', ZIP01_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 296 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'order_zip02', ZIP02_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 297 | $objFormParam->addParam(t('PARAM_LABEL_ZIP'), 'order_zipcode', ZIPCODE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[22100] | 298 | $objFormParam->addParam(t('PARAM_LABEL_PREF'), 'order_pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 299 | $objFormParam->addParam(t('PARAM_LABEL_ADDR1'), 'order_addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 300 | $objFormParam->addParam(t('PARAM_LABEL_ADDR2'), 'order_addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 301 | $objFormParam->addParam(t('PARAM_LABEL_TEL1'), 'order_tel01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 302 | $objFormParam->addParam(t('PARAM_LABEL_TEL2'), 'order_tel02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 303 | $objFormParam->addParam(t('PARAM_LABEL_TEL3'), 'order_tel03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 304 | $objFormParam->addParam(t('PARAM_LABEL_FAX1'), 'order_fax01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 305 | $objFormParam->addParam(t('PARAM_LABEL_FAX2'), 'order_fax02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 306 | $objFormParam->addParam(t('PARAM_LABEL_FAX3'), 'order_fax03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
[17293] | 307 | |
---|
[15594] | 308 | // 受注商品情報 |
---|
[22100] | 309 | $objFormParam->addParam(t('PARAM_LABEL_DISCOUNT'), 'discount', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 310 | $objFormParam->addParam(t('PARAM_LABEL_DELIV_FEE'), 'deliv_fee', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 311 | $objFormParam->addParam(t('PARAM_LABEL_CHARGE'), 'charge', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
[18054] | 312 | |
---|
| 313 | // ポイント機能ON時のみ |
---|
| 314 | if (USE_POINT !== false) { |
---|
[22100] | 315 | $objFormParam->addParam(t('PARAM_LABEL_USE_POINT'), 'use_point', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
[18054] | 316 | } |
---|
| 317 | |
---|
[22100] | 318 | $objFormParam->addParam(t('PARAM_LABEL_DELIV'), 'deliv_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 319 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_PAYMENT_METHOD'), 'payment_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 320 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_STATUS'), 'status', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 321 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_PAYMENT_METHOD_NAME'), 'payment_method'); |
---|
[15594] | 322 | |
---|
| 323 | // 受注詳細情報 |
---|
[22100] | 324 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_TYPE_ID'), 'product_type_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 325 | $objFormParam->addParam(t('PARAM_LABEL_PRICE'), 'price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 326 | $objFormParam->addParam(t('PARAM_LABEL_QUANTITY'), 'quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 327 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_ID'), 'product_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 328 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_CLASS_ID'), 'product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 329 | $objFormParam->addParam(t('PARAM_LABEL_POINT_RATE'), 'point_rate'); |
---|
| 330 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_CODE'), 'product_code'); |
---|
| 331 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_NAME'), 'product_name'); |
---|
| 332 | $objFormParam->addParam(t('PARAM_LABEL_CLASS_NAME1'), 'classcategory_name1'); |
---|
| 333 | $objFormParam->addParam(t('PARAM_LABEL_CLASS_NAME2'), 'classcategory_name2'); |
---|
| 334 | $objFormParam->addParam(t('PARAM_LABEL_NOTE'), 'note', MTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK')); |
---|
| 335 | $objFormParam->addParam(t('PARAM_LABEL_DELETE_NO'), 'delete_no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
[20180] | 336 | |
---|
[15594] | 337 | // DB読込用 |
---|
[22100] | 338 | $objFormParam->addParam(t('PARAM_LABEL_SUBTOTAL'), 'subtotal'); |
---|
| 339 | $objFormParam->addParam(t('PARAM_LABEL_TOTAL'), 'total'); |
---|
| 340 | $objFormParam->addParam(t('PARAM_LABEL_PAYMENT_TOTAL'), 'payment_total'); |
---|
| 341 | $objFormParam->addParam(t('PARAM_LABEL_ADD_POINT'), 'add_point'); |
---|
| 342 | $objFormParam->addParam(t('PARAM_LABEL_BIRTH_POINT'), 'birth_point', null, 'n', array(), 0); |
---|
| 343 | $objFormParam->addParam(t('PARAM_LABEL_TAX_TOTAL'), 'tax'); |
---|
| 344 | $objFormParam->addParam(t('PARAM_LABEL_TOTAL_POINT'), 'total_point'); |
---|
| 345 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_ID'), 'customer_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 346 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_ID'), 'edit_customer_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 347 | $objFormParam->addParam(t('PARAM_LABEL_NOW_POINT'), 'customer_point'); |
---|
| 348 | $objFormParam->addParam(t('PARAM_LABEL_BEFORE_POINT'), 'point'); |
---|
| 349 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_NUMBER'), 'order_id'); |
---|
| 350 | $objFormParam->addParam(t('PARAM_LABEL_ORDER_DATE'), 'create_date'); |
---|
| 351 | $objFormParam->addParam(t('PARAM_LABEL_SHIPPING_DATE'), 'commit_date'); |
---|
| 352 | $objFormParam->addParam(t('PARAM_LABEL_REMARKS'), 'message'); |
---|
| 353 | $objFormParam->addParam(t('PARAM_LABEL_PAYMENT_DATE'), 'payment_date'); |
---|
| 354 | $objFormParam->addParam(t('PARAM_LABEL_DEVICE_TYPE'), 'device_type_id'); |
---|
[15594] | 355 | |
---|
[20180] | 356 | // 複数情報 |
---|
[22100] | 357 | $objFormParam->addParam(t('PARAM_LABEL_SHIPPING_QUANTITY'), 'shipping_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 358 | $objFormParam->addParam(t('PARAM_LABEL_SHIPPING_ID'), 'shipping_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), 0); |
---|
| 359 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_LASTNAME'), 'shipping_name01', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 360 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_FIRSTNAME'), 'shipping_name02', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 361 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_LASTKANA'), 'shipping_kana01', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 362 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_FIRSTKANA'), 'shipping_kana02', STEXT_LEN, 'KVCa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[22205] | 363 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP01'), 'shipping_zip01', ZIP01_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 364 | // $objFormParam->addParam(t('PARAM_LABEL_ZIP02'), 'shipping_zip02', ZIP02_LEN, 'n', array('NUM_CHECK', 'NUM_COUNT_CHECK')); |
---|
| 365 | $objFormParam->addParam(t('PARAM_LABEL_ZIP'), 'shipping_zipcode', ZIPCODE_LEN, 'n', array('NUM_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[22100] | 366 | $objFormParam->addParam(t('PARAM_LABEL_PREF'), 'shipping_pref', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 367 | $objFormParam->addParam(t('PARAM_LABEL_ADDR1'), 'shipping_addr01', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 368 | $objFormParam->addParam(t('PARAM_LABEL_ADDR2'), 'shipping_addr02', MTEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 369 | $objFormParam->addParam(t('PARAM_LABEL_TEL1'), 'shipping_tel01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 370 | $objFormParam->addParam(t('PARAM_LABEL_TEL2'), 'shipping_tel02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 371 | $objFormParam->addParam(t('PARAM_LABEL_TEL3'), 'shipping_tel03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 372 | $objFormParam->addParam(t('PARAM_LABEL_FAX1'), 'shipping_fax01', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 373 | $objFormParam->addParam(t('PARAM_LABEL_FAX2'), 'shipping_fax02', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 374 | $objFormParam->addParam(t('PARAM_LABEL_FAX3'), 'shipping_fax03', TEL_ITEM_LEN, 'n', array('MAX_LENGTH_CHECK' ,'NUM_CHECK')); |
---|
| 375 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_DELIV_TIME_ID'), 'time_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 376 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_DELIV_DATE_YEAR'), 'shipping_date_year', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 377 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_DELIV_DATE_MONTH'), 'shipping_date_month', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 378 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_DELIV_DATE_DAY'), 'shipping_date_day', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 379 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_DELIV_DATE'), 'shipping_date', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
| 380 | $objFormParam->addParam(t('PARAM_LABEL_SHIPPING_PRODUCT_QUANTITY'), 'shipping_product_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
[19963] | 381 | |
---|
[22100] | 382 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_CLASS_ID'), 'shipment_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 383 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_CODE'), 'shipment_product_code'); |
---|
| 384 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_NAME'), 'shipment_product_name'); |
---|
| 385 | $objFormParam->addParam(t('PARAM_LABEL_CLASS_NAME1'), 'shipment_classcategory_name1'); |
---|
| 386 | $objFormParam->addParam(t('PARAM_LABEL_CLASS_NAME2'), 'shipment_classcategory_name2'); |
---|
| 387 | $objFormParam->addParam(t('PARAM_LABEL_PRICE'), 'shipment_price', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
| 388 | $objFormParam->addParam(t('PARAM_LABEL_QUANTITY'), 'shipment_quantity', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK'), '0'); |
---|
[19963] | 389 | |
---|
[22100] | 390 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_NO'), 'no', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 391 | $objFormParam->addParam(t('PARAM_LABEL_ADD_PRODUCT_CLASS_ID'), 'add_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 392 | $objFormParam->addParam(t('PARAM_LABEL_EDIT_PRODUCT_CLASS_ID'), 'edit_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 393 | $objFormParam->addParam(t('PARAM_LABEL_ANCHOR_KEY'), 'anchor_key', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); |
---|
[19919] | 394 | } |
---|
| 395 | |
---|
[19934] | 396 | /** |
---|
[20180] | 397 | * 複数配送用フォームの初期化を行う. |
---|
| 398 | * |
---|
| 399 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 400 | * @return void |
---|
[19934] | 401 | */ |
---|
[20180] | 402 | function lfInitMultipleParam(&$objFormParam) { |
---|
[22100] | 403 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_CLASS_ID'), 'multiple_product_class_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
| 404 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_CODE'), 'multiple_product_code', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 405 | $objFormParam->addParam(t('PARAM_LABEL_PRODUCT_NAME'), 'multiple_product_name', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 406 | $objFormParam->addParam(t('PARAM_LABEL_CLASS1'), 'multiple_classcategory_name1', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 407 | $objFormParam->addParam(t('PARAM_LABEL_CLASS2'), 'multiple_classcategory_name2', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 408 | $objFormParam->addParam(t('PARAM_LABEL_PRICE'), 'multiple_price', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 409 | $objFormParam->addParam(t('PARAM_LABEL_QUANTITY'), 'multiple_quantity', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK'), 1); |
---|
| 410 | $objFormParam->addParam(t('PARAM_LABEL_CUSTOMER_DELIV_ADDRESSEE'), 'multiple_shipping_id', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); |
---|
[19934] | 411 | } |
---|
[19919] | 412 | |
---|
[20180] | 413 | /** |
---|
| 414 | * 複数配送入力フォームで入力された値を SC_FormParam へ設定する. |
---|
| 415 | * |
---|
| 416 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 417 | * @return void |
---|
| 418 | */ |
---|
| 419 | function setMultipleItemTo(&$objFormParam) { |
---|
| 420 | $arrMultipleKey = array('multiple_shipping_id', |
---|
| 421 | 'multiple_product_class_id', |
---|
| 422 | 'multiple_product_name', |
---|
| 423 | 'multiple_product_code', |
---|
| 424 | 'multiple_classcategory_name1', |
---|
| 425 | 'multiple_classcategory_name2', |
---|
| 426 | 'multiple_price', |
---|
| 427 | 'multiple_quantity'); |
---|
| 428 | $arrMultipleParams = $objFormParam->getSwapArray($arrMultipleKey); |
---|
[19934] | 429 | |
---|
[20180] | 430 | /* |
---|
| 431 | * 複数配送フォームの入力値を shipping_id ごとにマージ |
---|
| 432 | * |
---|
[21549] | 433 | * $arrShipmentItem[お届け先ID][商品規格ID]['shipment_(key)'] = 値 |
---|
[20180] | 434 | */ |
---|
[19934] | 435 | $arrShipmentItem = array(); |
---|
[20180] | 436 | foreach ($arrMultipleParams as $arrMultiple) { |
---|
| 437 | $shipping_id = $arrMultiple['multiple_shipping_id']; |
---|
| 438 | $product_class_id = $arrMultiple['multiple_product_class_id']; |
---|
| 439 | foreach ($arrMultiple as $key => $val) { |
---|
| 440 | if ($key == 'multiple_quantity') { |
---|
| 441 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] += $val; |
---|
| 442 | } else { |
---|
| 443 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] = $val; |
---|
| 444 | } |
---|
| 445 | } |
---|
[19934] | 446 | } |
---|
| 447 | |
---|
[20180] | 448 | /* |
---|
[21549] | 449 | * フォームのお届け先ごとの配列を生成 |
---|
[20180] | 450 | * |
---|
[20943] | 451 | * $arrShipmentForm['(key)'][$shipping_id][$item_index] = 値 |
---|
[21549] | 452 | * $arrProductQuantity[$shipping_id] = お届け先ごとの配送商品数量 |
---|
[20180] | 453 | */ |
---|
| 454 | $arrShipmentForm = array(); |
---|
| 455 | $arrProductQuantity = array(); |
---|
| 456 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
[20943] | 457 | foreach ($arrShippingIds as $shipping_id) { |
---|
[20180] | 458 | $item_index = 0; |
---|
| 459 | foreach ($arrShipmentItem[$shipping_id] as $product_class_id => $shipment_item) { |
---|
| 460 | foreach ($shipment_item as $key => $val) { |
---|
[20943] | 461 | $arrShipmentForm[$key][$shipping_id][$item_index] = $val; |
---|
[19934] | 462 | } |
---|
[20180] | 463 | // 受注商品の数量を設定 |
---|
| 464 | $arrQuantity[$product_class_id] += $shipment_item['shipment_quantity']; |
---|
| 465 | $item_index++; |
---|
[19934] | 466 | } |
---|
[21549] | 467 | // お届け先ごとの配送商品数量を設定 |
---|
[20943] | 468 | $arrProductQuantity[$shipping_id] = count($arrShipmentItem[$shipping_id]); |
---|
[19934] | 469 | } |
---|
[19949] | 470 | |
---|
[20180] | 471 | $objFormParam->setParam($arrShipmentForm); |
---|
| 472 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 473 | |
---|
[19949] | 474 | // 受注商品の数量を変更 |
---|
[20180] | 475 | $arrDest = array(); |
---|
[21224] | 476 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
| 477 | $arrDest['quantity'][$n] = 0; |
---|
| 478 | } |
---|
[20180] | 479 | foreach ($arrQuantity as $product_class_id => $quantity) { |
---|
| 480 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
| 481 | if ($product_class_id == $order_product_class_id) { |
---|
| 482 | $arrDest['quantity'][$n] = $quantity; |
---|
[19949] | 483 | } |
---|
| 484 | } |
---|
| 485 | } |
---|
[20180] | 486 | $objFormParam->setParam($arrDest); |
---|
[19934] | 487 | } |
---|
| 488 | |
---|
[20180] | 489 | /** |
---|
| 490 | * 受注データを取得して, SC_FormParam へ設定する. |
---|
| 491 | * |
---|
| 492 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 493 | * @param integer $order_id 取得元の受注ID |
---|
| 494 | * @return void |
---|
| 495 | */ |
---|
| 496 | function setOrderToFormParam(&$objFormParam, $order_id) { |
---|
| 497 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[18235] | 498 | |
---|
[20180] | 499 | // 受注詳細を設定 |
---|
| 500 | $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); |
---|
| 501 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); |
---|
[15594] | 502 | |
---|
[20943] | 503 | $arrShippingsTmp = $objPurchase->getShippings($order_id); |
---|
| 504 | $arrShippings = array(); |
---|
| 505 | foreach ($arrShippingsTmp as $row) { |
---|
| 506 | // お届け日の処理 |
---|
[21481] | 507 | if (!SC_Utils_Ex::isBlank($row['shipping_date'])) { |
---|
| 508 | $ts = strtotime($row['shipping_date']); |
---|
[20943] | 509 | $row['shipping_date_year'] = date('Y', $ts); |
---|
| 510 | $row['shipping_date_month'] = date('n', $ts); |
---|
| 511 | $row['shipping_date_day'] = date('j', $ts); |
---|
[20180] | 512 | } |
---|
[20943] | 513 | $arrShippings[$row['shipping_id']] = $row; |
---|
[20180] | 514 | } |
---|
| 515 | $objFormParam->setValue('shipping_quantity', count($arrShippings)); |
---|
| 516 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings)); |
---|
[19919] | 517 | |
---|
[20180] | 518 | /* |
---|
| 519 | * 配送商品を設定 |
---|
| 520 | * |
---|
[20943] | 521 | * $arrShipmentItem['shipment_(key)'][$shipping_id][$item_index] = 値 |
---|
[21549] | 522 | * $arrProductQuantity[$shipping_id] = お届け先ごとの配送商品数量 |
---|
[20180] | 523 | */ |
---|
| 524 | $arrProductQuantity = array(); |
---|
| 525 | $arrShipmentItem = array(); |
---|
[20943] | 526 | foreach ($arrShippings as $shipping_id => $arrShipping) { |
---|
| 527 | $arrProductQuantity[$shipping_id] = count($arrShipping['shipment_item']); |
---|
[20180] | 528 | foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) { |
---|
| 529 | foreach ($arrItem as $item_key => $item_val) { |
---|
[20943] | 530 | $arrShipmentItem['shipment_' . $item_key][$shipping_id][$item_index] = $item_val; |
---|
[19928] | 531 | } |
---|
[19912] | 532 | } |
---|
[15594] | 533 | } |
---|
[20180] | 534 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 535 | $objFormParam->setParam($arrShipmentItem); |
---|
[15594] | 536 | |
---|
[20180] | 537 | /* |
---|
| 538 | * 受注情報を設定 |
---|
| 539 | * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 |
---|
| 540 | * が渡ってくるため, $arrOrder で上書きする. |
---|
| 541 | */ |
---|
| 542 | $arrOrder = $objPurchase->getOrder($order_id); |
---|
| 543 | $objFormParam->setParam($arrOrder); |
---|
| 544 | |
---|
[21165] | 545 | // ポイントを設定 |
---|
| 546 | list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint( |
---|
| 547 | $order_id, $arrOrder['use_point'], $arrOrder['add_point'], $arrOrder['status'] |
---|
| 548 | ); |
---|
[20180] | 549 | $objFormParam->setValue('total_point', $db_point); |
---|
| 550 | $objFormParam->setValue('point', $rollback_point); |
---|
[20442] | 551 | |
---|
[21003] | 552 | if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { |
---|
[21004] | 553 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($objFormParam->getValue('customer_id')); |
---|
| 554 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
[20442] | 555 | } |
---|
[15594] | 556 | } |
---|
| 557 | |
---|
[19912] | 558 | /** |
---|
[20180] | 559 | * 入力内容のチェックを行う. |
---|
| 560 | * |
---|
| 561 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 562 | * @return array エラーメッセージの配列 |
---|
[19912] | 563 | */ |
---|
[20180] | 564 | function lfCheckError(&$objFormParam) { |
---|
[21311] | 565 | $objProduct = new SC_Product_Ex(); |
---|
| 566 | |
---|
[20226] | 567 | $arrErr = $objFormParam->checkError(); |
---|
[19912] | 568 | |
---|
[20180] | 569 | if (!SC_Utils_Ex::isBlank($objErr->arrErr)) { |
---|
[20226] | 570 | return $arrErr; |
---|
[18087] | 571 | } |
---|
[18819] | 572 | |
---|
[20180] | 573 | $arrValues = $objFormParam->getHashArray(); |
---|
[15594] | 574 | |
---|
| 575 | // 商品の種類数 |
---|
[20180] | 576 | $max = count($arrValues['quantity']); |
---|
[15594] | 577 | $subtotal = 0; |
---|
| 578 | $totalpoint = 0; |
---|
| 579 | $totaltax = 0; |
---|
[21441] | 580 | for ($i = 0; $i < $max; $i++) { |
---|
[15594] | 581 | // 小計の計算 |
---|
[20180] | 582 | $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 583 | // 小計の計算 |
---|
[20180] | 584 | $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 585 | // 加算ポイントの計算 |
---|
[20180] | 586 | $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; |
---|
[20719] | 587 | |
---|
| 588 | // 在庫数のチェック |
---|
| 589 | $arrProduct = $objProduct->getDetailAndProductsClass($arrValues['product_class_id'][$i]); |
---|
| 590 | |
---|
| 591 | // 編集前の値と比較するため受注詳細を取得 |
---|
| 592 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
| 593 | $arrOrderDetail = SC_Utils_Ex::sfSwapArray($objPurchase->getOrderDetail($objFormParam->getValue('order_id'), false)); |
---|
| 594 | |
---|
| 595 | if ($arrProduct['stock_unlimited'] != '1' |
---|
| 596 | && $arrProduct['stock'] < $arrValues['quantity'][$i] - $arrOrderDetail['quantity'][$i]) { |
---|
| 597 | $class_name1 = $arrValues['classcategory_name1'][$i]; |
---|
[22100] | 598 | $class_name1 = SC_Utils_Ex::isBlank($class_name1) ? t('LC_Page_Admin_Order_Edit_004') : $class_name1; |
---|
[20719] | 599 | $class_name2 = $arrValues['classcategory_name2'][$i]; |
---|
[22100] | 600 | $class_name2 = SC_Utils_Ex::isBlank($class_name2) ? t('LC_Page_Admin_Order_Edit_004') : $class_name2; |
---|
| 601 | $arrErr['quantity'][$i] .= t('LC_Page_Admin_Order_Edit_005', array('T_FIELD1' => $arrValues['product_name'][$i], 'T_FIELD2' => $class_name1,'T_FIELD3' => $class_name1, 'T_FIELD4' => ($arrOrderDetail['quantity'][$i] + $arrProduct['stock']))); |
---|
[20719] | 602 | } |
---|
[15594] | 603 | } |
---|
| 604 | |
---|
| 605 | // 消費税 |
---|
[20180] | 606 | $arrValues['tax'] = $totaltax; |
---|
[15594] | 607 | // 小計 |
---|
[20180] | 608 | $arrValues['subtotal'] = $subtotal; |
---|
[15594] | 609 | // 合計 |
---|
[20180] | 610 | $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge']; |
---|
[15594] | 611 | // お支払い合計 |
---|
[20180] | 612 | $arrValues['payment_total'] = $arrValues['total'] - ($arrValues['use_point'] * POINT_VALUE); |
---|
[15594] | 613 | |
---|
| 614 | // 加算ポイント |
---|
[20180] | 615 | $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']); |
---|
[20041] | 616 | |
---|
[19674] | 617 | // 最終保持ポイント |
---|
[21101] | 618 | $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point']; |
---|
[20041] | 619 | |
---|
[20180] | 620 | if ($arrValues['total'] < 0) { |
---|
[22100] | 621 | $arrErr['total'] = t('LC_Page_Admin_Order_Edit_006'); |
---|
[15594] | 622 | } |
---|
| 623 | |
---|
[20180] | 624 | if ($arrValues['payment_total'] < 0) { |
---|
[22100] | 625 | $arrErr['payment_total'] = t('LC_Page_Admin_Order_Edit_007'); |
---|
[15594] | 626 | } |
---|
[20180] | 627 | |
---|
| 628 | if ($arrValues['total_point'] < 0) { |
---|
[22100] | 629 | $arrErr['use_point'] = t('LC_Page_Admin_Order_Edit_008'); |
---|
[15594] | 630 | } |
---|
| 631 | |
---|
[20180] | 632 | $objFormParam->setParam($arrValues); |
---|
[20226] | 633 | return $arrErr; |
---|
[15594] | 634 | } |
---|
| 635 | |
---|
[18100] | 636 | /** |
---|
| 637 | * DB更新処理 |
---|
| 638 | * |
---|
[20180] | 639 | * @param integer $order_id 受注ID |
---|
| 640 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 641 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
[20577] | 642 | * @param string $message 通知メッセージ |
---|
[21036] | 643 | * @param array $arrValuesBefore 更新前の受注情報 |
---|
[20180] | 644 | * @return integer $order_id 受注ID |
---|
[20577] | 645 | * |
---|
| 646 | * エラー発生時は負数を返す。 |
---|
[18100] | 647 | */ |
---|
[21036] | 648 | function doRegister($order_id, &$objPurchase, &$objFormParam, &$message, &$arrValuesBefore) { |
---|
[15594] | 649 | |
---|
[20507] | 650 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20180] | 651 | $arrValues = $objFormParam->getDbArray(); |
---|
[15594] | 652 | |
---|
[21514] | 653 | $where = 'order_id = ?'; |
---|
[15594] | 654 | |
---|
[18329] | 655 | $objQuery->begin(); |
---|
[21118] | 656 | |
---|
[21036] | 657 | // 支払い方法が変更されたら、支払い方法名称も更新 |
---|
| 658 | if ($arrValues['payment_id'] != $arrValuesBefore['payment_id']) { |
---|
| 659 | $arrValues['payment_method'] = $this->arrPayment[$arrValues['payment_id']]; |
---|
| 660 | $arrValuesBefore['payment_id'] = NULL; |
---|
| 661 | } |
---|
[18329] | 662 | |
---|
[15594] | 663 | // 受注テーブルの更新 |
---|
[20180] | 664 | $order_id = $objPurchase->registerOrder($order_id, $arrValues); |
---|
[18819] | 665 | |
---|
[21527] | 666 | $arrDetail = $objFormParam->getSwapArray(array( |
---|
| 667 | 'product_id', |
---|
| 668 | 'product_class_id', |
---|
| 669 | 'product_code', |
---|
| 670 | 'product_name', |
---|
| 671 | 'price', 'quantity', |
---|
| 672 | 'point_rate', |
---|
| 673 | 'classcategory_name1', |
---|
| 674 | 'classcategory_name2', |
---|
| 675 | )); |
---|
[18819] | 676 | |
---|
[18646] | 677 | // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 |
---|
| 678 | $max = count($arrDetail); |
---|
| 679 | $k = 0; |
---|
| 680 | $arrStockData = array(); |
---|
[21441] | 681 | for ($i = 0; $i < $max; $i++) { |
---|
[18646] | 682 | if (!empty($arrDetail[$i]['product_id'])) { |
---|
[21515] | 683 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 684 | if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { |
---|
| 685 | // 数量が変更された商品 |
---|
[18872] | 686 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 687 | $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; |
---|
| 688 | ++$k; |
---|
| 689 | } elseif (empty($arrPreDetail)) { |
---|
| 690 | // 新しく追加された商品 もしくは 違う商品に変更された商品 |
---|
[18872] | 691 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 692 | $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; |
---|
| 693 | ++$k; |
---|
| 694 | } |
---|
[21514] | 695 | $objQuery->delete('dtb_order_detail', 'order_id = ? AND product_class_id = ?', array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 696 | } |
---|
| 697 | } |
---|
| 698 | |
---|
| 699 | // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 |
---|
[21515] | 700 | $arrPreDetail = $objQuery->select('*', 'dtb_order_detail', 'order_id = ?', array($order_id)); |
---|
[18646] | 701 | foreach ($arrPreDetail AS $key=>$val) { |
---|
[18872] | 702 | $arrStockData[$k]['product_class_id'] = $val['product_class_id']; |
---|
[18646] | 703 | $arrStockData[$k]['quantity'] = $val['quantity']; |
---|
| 704 | ++$k; |
---|
| 705 | } |
---|
| 706 | |
---|
| 707 | // 受注詳細データの更新 |
---|
[20180] | 708 | $objPurchase->registerOrderDetail($order_id, $arrDetail); |
---|
[18074] | 709 | |
---|
[18646] | 710 | // 在庫数調整 |
---|
[20180] | 711 | if (ORDER_DELIV != $arrValues['status'] |
---|
| 712 | && ORDER_CANCEL != $arrValues['status']) { |
---|
| 713 | foreach ($arrStockData AS $stock) { |
---|
| 714 | $objQuery->update('dtb_products_class', array(), |
---|
| 715 | 'product_class_id = ?', |
---|
| 716 | array($stock['product_class_id']), |
---|
| 717 | array('stock' => 'stock + ?'), |
---|
| 718 | array($stock['quantity'])); |
---|
[18646] | 719 | } |
---|
| 720 | } |
---|
| 721 | |
---|
[20943] | 722 | $arrAllShipping = $objFormParam->getSwapArray($this->arrShippingKeys); |
---|
| 723 | $arrAllShipmentItem = $objFormParam->getSwapArray($this->arrShipmentItemKeys); |
---|
[19949] | 724 | |
---|
[20804] | 725 | $arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id')); |
---|
| 726 | |
---|
[20180] | 727 | $arrShippingValues = array(); |
---|
| 728 | foreach ($arrAllShipping as $shipping_index => $arrShipping) { |
---|
| 729 | $shipping_id = $arrShipping['shipping_id']; |
---|
| 730 | $arrShippingValues[$shipping_index] = $arrShipping; |
---|
[19949] | 731 | |
---|
[20180] | 732 | $arrShippingValues[$shipping_index]['shipping_date'] |
---|
| 733 | = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], |
---|
| 734 | $arrShipping['shipping_date_month'], |
---|
| 735 | $arrShipping['shipping_date_day']); |
---|
[19963] | 736 | |
---|
[20180] | 737 | // 配送業者IDを取得 |
---|
| 738 | $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); |
---|
[19949] | 739 | |
---|
[20804] | 740 | // お届け時間名称を取得 |
---|
| 741 | $arrShippingValues[$shipping_index]['shipping_time'] = $arrDelivTime[$arrShipping['time_id']]; |
---|
| 742 | |
---|
[20180] | 743 | // 複数配送の場合は配送商品を登録 |
---|
| 744 | if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) { |
---|
| 745 | $arrShipmentValues = array(); |
---|
[19963] | 746 | |
---|
[20180] | 747 | foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) { |
---|
| 748 | $i = 0; |
---|
| 749 | foreach ($arrItem as $item) { |
---|
| 750 | $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item; |
---|
| 751 | $i++; |
---|
| 752 | } |
---|
[19949] | 753 | } |
---|
[20180] | 754 | $objPurchase->registerShipmentItem($order_id, $shipping_id, |
---|
| 755 | $arrShipmentValues[$shipping_index]); |
---|
[19949] | 756 | } |
---|
| 757 | } |
---|
[20180] | 758 | $objPurchase->registerShipping($order_id, $arrShippingValues, false); |
---|
[15594] | 759 | $objQuery->commit(); |
---|
[20180] | 760 | return $order_id; |
---|
[15594] | 761 | } |
---|
[17293] | 762 | |
---|
[18100] | 763 | /** |
---|
[20180] | 764 | * 受注商品の追加/更新を行う. |
---|
[18100] | 765 | * |
---|
[20180] | 766 | * 小画面で選択した受注商品をフォームに反映させる. |
---|
| 767 | * |
---|
| 768 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 769 | * @return void |
---|
[18100] | 770 | */ |
---|
[20180] | 771 | function doRegisterProduct(&$objFormParam) { |
---|
| 772 | $product_class_id = $objFormParam->getValue('add_product_class_id'); |
---|
| 773 | if (SC_Utils_Ex::isBlank($product_class_id)) { |
---|
| 774 | $product_class_id = $objFormParam->getValue('edit_product_class_id'); |
---|
[20415] | 775 | $changed_no = $objFormParam->getValue('no'); |
---|
[17293] | 776 | } |
---|
[21331] | 777 | // FXIME バリデーションを通さず $objFormParam の値で DB 問い合わせしている。(管理機能ため、さほど問題は無いと思うものの…) |
---|
[18037] | 778 | |
---|
[21331] | 779 | // 商品規格IDが指定されていない場合、例外エラーを発生 |
---|
| 780 | if (strlen($product_class_id) === 0) { |
---|
[21582] | 781 | trigger_error('商品規格指定なし', E_USER_ERROR); |
---|
[21331] | 782 | } |
---|
| 783 | |
---|
[20415] | 784 | // 選択済みの商品であれば数量を1増やす |
---|
[20180] | 785 | $exists = false; |
---|
| 786 | $arrExistsProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
[21935] | 787 | foreach ($arrExistsProductClassIds as $key => $value) { |
---|
[20180] | 788 | $exists_product_class_id = $arrExistsProductClassIds[$key]; |
---|
| 789 | if ($exists_product_class_id == $product_class_id) { |
---|
| 790 | $exists = true; |
---|
[20982] | 791 | $exists_no = $key; |
---|
[20180] | 792 | $arrExistsQuantity = $objFormParam->getValue('quantity'); |
---|
| 793 | $arrExistsQuantity[$key]++; |
---|
| 794 | $objFormParam->setValue('quantity', $arrExistsQuantity); |
---|
[19963] | 795 | } |
---|
[18646] | 796 | } |
---|
[19963] | 797 | |
---|
[20180] | 798 | // 新しく商品を追加した場合はフォームに登録 |
---|
[20415] | 799 | // 商品を変更した場合は、該当行を変更 |
---|
[20180] | 800 | if (!$exists) { |
---|
[20487] | 801 | $objProduct = new SC_Product_Ex(); |
---|
[20180] | 802 | $arrProduct = $objProduct->getDetailAndProductsClass($product_class_id); |
---|
[21331] | 803 | |
---|
| 804 | // 一致する商品規格がない場合、例外エラーを発生 |
---|
| 805 | if (empty($arrProduct)) { |
---|
[21582] | 806 | trigger_error('商品規格一致なし', E_USER_ERROR); |
---|
[21331] | 807 | } |
---|
| 808 | |
---|
[20180] | 809 | $arrProduct['quantity'] = 1; |
---|
| 810 | $arrProduct['price'] = $arrProduct['price02']; |
---|
| 811 | $arrProduct['product_name'] = $arrProduct['name']; |
---|
[21981] | 812 | |
---|
[21527] | 813 | $arrUpdateKeys = array( |
---|
| 814 | 'product_id', 'product_class_id', 'product_type_id', 'point_rate', |
---|
| 815 | 'product_code', 'product_name', 'classcategory_name1', 'classcategory_name2', |
---|
| 816 | 'quantity', 'price', |
---|
| 817 | ); |
---|
[20180] | 818 | foreach ($arrUpdateKeys as $key) { |
---|
| 819 | $arrValues = $objFormParam->getValue($key); |
---|
[21870] | 820 | // FIXME getValueで文字列が返る場合があるので配列であるかをチェック |
---|
[21981] | 821 | if (!is_array($arrValues)) { |
---|
[21870] | 822 | $arrValues = array(); |
---|
| 823 | } |
---|
[21981] | 824 | |
---|
[20415] | 825 | if (isset($changed_no)) { |
---|
| 826 | $arrValues[$changed_no] = $arrProduct[$key]; |
---|
| 827 | } else { |
---|
[21117] | 828 | $added_no = 0; |
---|
| 829 | if (is_array($arrExistsProductClassIds)) { |
---|
| 830 | $added_no = count($arrExistsProductClassIds); |
---|
| 831 | } |
---|
| 832 | $arrValues[$added_no] = $arrProduct[$key]; |
---|
[20415] | 833 | } |
---|
[20180] | 834 | $objFormParam->setValue($key, $arrValues); |
---|
[19963] | 835 | } |
---|
[20982] | 836 | } elseif (isset($changed_no) && $exists_no != $changed_no) { |
---|
[20416] | 837 | // 変更したが、選択済みの商品だった場合は、変更対象行を削除。 |
---|
[20415] | 838 | $this->doDeleteProduct($changed_no, $objFormParam); |
---|
[19963] | 839 | } |
---|
[17293] | 840 | } |
---|
| 841 | |
---|
[19919] | 842 | /** |
---|
[20180] | 843 | * 受注商品を削除する. |
---|
| 844 | * |
---|
| 845 | * @param integer $delete_no 削除する受注商品の項番 |
---|
| 846 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 847 | * @return void |
---|
[19919] | 848 | */ |
---|
[20180] | 849 | function doDeleteProduct($delete_no, &$objFormParam) { |
---|
[21527] | 850 | $arrDeleteKeys = array( |
---|
| 851 | 'product_id', 'product_class_id', 'product_type_id', 'point_rate', |
---|
| 852 | 'product_code', 'product_name', 'classcategory_name1', 'classcategory_name2', |
---|
| 853 | 'quantity', 'price', |
---|
| 854 | ); |
---|
[20180] | 855 | foreach ($arrDeleteKeys as $key) { |
---|
| 856 | $arrNewValues = array(); |
---|
| 857 | $arrValues = $objFormParam->getValue($key); |
---|
| 858 | foreach ($arrValues as $index => $val) { |
---|
| 859 | if ($index != $delete_no) { |
---|
| 860 | $arrNewValues[] = $val; |
---|
[18014] | 861 | } |
---|
| 862 | } |
---|
[20180] | 863 | $objFormParam->setValue($key, $arrNewValues); |
---|
[18014] | 864 | } |
---|
[17293] | 865 | } |
---|
| 866 | |
---|
[20180] | 867 | /** |
---|
| 868 | * お届け先を追加する. |
---|
| 869 | * |
---|
| 870 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 871 | * @return void |
---|
| 872 | */ |
---|
| 873 | function addShipping(&$objFormParam) { |
---|
| 874 | $objFormParam->setValue('shipping_quantity', |
---|
| 875 | $objFormParam->getValue('shipping_quantity') + 1); |
---|
| 876 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 877 | $arrShippingIds[] = max($arrShippingIds) + 1; |
---|
| 878 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[17293] | 879 | } |
---|
| 880 | |
---|
[18068] | 881 | /** |
---|
[21419] | 882 | * 会員情報をフォームに設定する. |
---|
[20180] | 883 | * |
---|
[21419] | 884 | * @param integer $customer_id 会員ID |
---|
[20180] | 885 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 886 | * @return void |
---|
[18068] | 887 | */ |
---|
[20180] | 888 | function setCustomerTo($customer_id, &$objFormParam) { |
---|
| 889 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
| 890 | foreach ($arrCustomer as $key => $val) { |
---|
| 891 | $objFormParam->setValue('order_' . $key, $val); |
---|
[18068] | 892 | } |
---|
[20180] | 893 | $objFormParam->setValue('customer_id', $customer_id); |
---|
[20442] | 894 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
[18068] | 895 | } |
---|
[18329] | 896 | |
---|
| 897 | /** |
---|
[20180] | 898 | * アンカーキーを取得する. |
---|
[18329] | 899 | * |
---|
[20180] | 900 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 901 | * @return アンカーキーの文字列 |
---|
[18329] | 902 | */ |
---|
[20180] | 903 | function getAnchorKey(&$objFormParam) { |
---|
| 904 | $ancor_key = $objFormParam->getValue('anchor_key'); |
---|
| 905 | if (!SC_Utils_Ex::isBlank($ancor_key)) { |
---|
| 906 | return "location.hash='#" . htmlentities(urlencode($ancor_key), ENT_QUOTES) . "'"; |
---|
[18329] | 907 | } |
---|
[20180] | 908 | return ''; |
---|
[19963] | 909 | } |
---|
[15594] | 910 | } |
---|