[15594] | 1 | <?php |
---|
| 2 | /* |
---|
[16582] | 3 | * This file is part of EC-CUBE |
---|
| 4 | * |
---|
[18701] | 5 | * Copyright(c) 2000-2010 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 | |
---|
| 36 | // }}} |
---|
| 37 | // {{{ functions |
---|
| 38 | |
---|
| 39 | /** |
---|
| 40 | * Page を初期化する. |
---|
| 41 | * |
---|
| 42 | * @return void |
---|
| 43 | */ |
---|
| 44 | function init() { |
---|
| 45 | parent::init(); |
---|
| 46 | $this->tpl_mainpage = 'order/edit.tpl'; |
---|
[17293] | 47 | $this->tpl_subnavi = 'order/subnavi.tpl'; |
---|
| 48 | $this->tpl_mainno = 'order'; |
---|
[15594] | 49 | |
---|
| 50 | $masterData = new SC_DB_MasterData_Ex(); |
---|
[19773] | 51 | $this->arrPref = $masterData->getMasterData('mtb_pref'); |
---|
[17293] | 52 | $this->arrORDERSTATUS = $masterData->getMasterData("mtb_order_status"); |
---|
[19975] | 53 | $this->arrDeviceType = $masterData->getMasterData('mtb_device_type'); |
---|
[17886] | 54 | |
---|
[20499] | 55 | $objDate = new SC_Date_Ex(RELEASE_YEAR); |
---|
[20180] | 56 | $this->arrYearShippingDate = $objDate->getYear('', date('Y'), ''); |
---|
| 57 | $this->arrMonthShippingDate = $objDate->getMonth(true); |
---|
| 58 | $this->arrDayShippingDate = $objDate->getDay(true); |
---|
| 59 | |
---|
| 60 | // 支払い方法の取得 |
---|
| 61 | $this->arrPayment = SC_Helper_DB_Ex::sfGetIDValueList("dtb_payment", "payment_id", "payment_method"); |
---|
| 62 | |
---|
| 63 | // 配送業者の取得 |
---|
| 64 | $this->arrDeliv = SC_Helper_DB_Ex::sfGetIDValueList("dtb_deliv", "deliv_id", "name"); |
---|
| 65 | |
---|
[18187] | 66 | $this->httpCacheControl('nocache'); |
---|
[15594] | 67 | } |
---|
| 68 | |
---|
| 69 | /** |
---|
| 70 | * Page のプロセス. |
---|
| 71 | * |
---|
| 72 | * @return void |
---|
| 73 | */ |
---|
| 74 | function process() { |
---|
[19661] | 75 | $this->action(); |
---|
| 76 | $this->sendResponse(); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /** |
---|
| 80 | * Page のアクション. |
---|
| 81 | * |
---|
| 82 | * @return void |
---|
| 83 | */ |
---|
| 84 | function action() { |
---|
[19923] | 85 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[20501] | 86 | $objFormParam = new SC_FormParam_Ex(); |
---|
[15594] | 87 | |
---|
| 88 | // パラメータ情報の初期化 |
---|
[20180] | 89 | $this->lfInitParam($objFormParam); |
---|
| 90 | $objFormParam->setParam($_REQUEST); |
---|
| 91 | $objFormParam->convParam(); |
---|
| 92 | $order_id = $objFormParam->getValue('order_id'); |
---|
[15594] | 93 | |
---|
| 94 | // DBから受注情報を読み込む |
---|
[19963] | 95 | if (!SC_Utils_Ex::isBlank($order_id)) { |
---|
[20180] | 96 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 97 | $this->tpl_subno = 'index'; |
---|
| 98 | $this->tpl_subtitle = '受注管理'; |
---|
| 99 | } else { |
---|
| 100 | $this->tpl_subno = 'add'; |
---|
| 101 | $this->tpl_mode = 'add'; |
---|
| 102 | $this->tpl_subtitle = '新規受注入力'; |
---|
[19963] | 103 | } |
---|
[15594] | 104 | |
---|
[20180] | 105 | $this->arrSearchHidden = $objFormParam->getSearchArray(); |
---|
| 106 | |
---|
[20041] | 107 | switch($this->getMode()) { |
---|
[15594] | 108 | case 'pre_edit': |
---|
| 109 | case 'order_id': |
---|
| 110 | break; |
---|
[20180] | 111 | |
---|
[15594] | 112 | case 'edit': |
---|
[20180] | 113 | $objFormParam->setParam($_POST); |
---|
| 114 | $objFormParam->convParam(); |
---|
| 115 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 116 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 117 | $order_id = $this->doRegister($order_id, $objPurchase, $objFormParam); |
---|
| 118 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 119 | $this->tpl_onload = "window.alert('受注を編集しました。');"; |
---|
| 120 | } |
---|
| 121 | break; |
---|
| 122 | |
---|
[17293] | 123 | case 'add': |
---|
[20180] | 124 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { |
---|
| 125 | $objFormParam->setParam($_POST); |
---|
| 126 | $objFormParam->convParam(); |
---|
| 127 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 128 | if (SC_Utils_Ex::isBlank($this->arrErr)) { |
---|
| 129 | $order_id = $this->doRegister(null, $objPurchase, $objFormParam); |
---|
[18100] | 130 | $this->tpl_mode = 'edit'; |
---|
[20180] | 131 | $objFormParam->setValue('order_id', $order_id); |
---|
| 132 | $this->setOrderToFormParam($objFormParam, $order_id); |
---|
| 133 | $this->tpl_onload = "window.alert('新規受注を登録しました。');"; |
---|
[18068] | 134 | } |
---|
[15594] | 135 | } |
---|
[20180] | 136 | |
---|
[15594] | 137 | break; |
---|
[20180] | 138 | |
---|
[19963] | 139 | // 再計算 |
---|
[20180] | 140 | case 'recalculate': |
---|
[18464] | 141 | //支払い方法の選択 |
---|
| 142 | case 'payment': |
---|
[20180] | 143 | // 配送業者の選択 |
---|
| 144 | case 'deliv': |
---|
| 145 | $objFormParam->setParam($_POST); |
---|
| 146 | $objFormParam->convParam(); |
---|
| 147 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
[15594] | 148 | break; |
---|
[19912] | 149 | |
---|
[20180] | 150 | // 商品削除 |
---|
[18037] | 151 | case 'delete_product': |
---|
[20180] | 152 | $objFormParam->setParam($_POST); |
---|
| 153 | $objFormParam->convParam(); |
---|
| 154 | $delete_no = $objFormParam->getValue('delete_no'); |
---|
| 155 | $this->doDeleteProduct($delete_no, $objFormParam); |
---|
| 156 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
[18037] | 157 | break; |
---|
[20180] | 158 | |
---|
| 159 | // 商品追加ポップアップより商品選択 |
---|
[18037] | 160 | case 'select_product_detail': |
---|
[20180] | 161 | $objFormParam->setParam($_POST); |
---|
| 162 | $objFormParam->convParam(); |
---|
| 163 | $this->doRegisterProduct($objFormParam); |
---|
| 164 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
| 165 | break; |
---|
[19963] | 166 | |
---|
[20180] | 167 | // 顧客検索ポップアップより顧客指定 |
---|
[18068] | 168 | case 'search_customer': |
---|
[20180] | 169 | $objFormParam->setParam($_POST); |
---|
| 170 | $objFormParam->convParam(); |
---|
| 171 | $this->setCustomerTo($objFormParam->getValue('edit_customer_id'), |
---|
| 172 | $objFormParam); |
---|
| 173 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
[18068] | 174 | break; |
---|
[17887] | 175 | |
---|
[19934] | 176 | // 複数配送設定表示 |
---|
| 177 | case 'multiple': |
---|
[20180] | 178 | $objFormParam->setParam($_POST); |
---|
| 179 | $objFormParam->convParam(); |
---|
| 180 | $this->arrErr = $this->lfCheckError($objFormParam); |
---|
[19934] | 181 | break; |
---|
| 182 | |
---|
| 183 | // 複数配送設定を反映 |
---|
| 184 | case 'multiple_set_to': |
---|
[20180] | 185 | $this->lfInitMultipleParam($objFormParam); |
---|
| 186 | $objFormParam->setParam($_POST); |
---|
| 187 | $objFormParam->convParam(); |
---|
| 188 | $this->setMultipleItemTo($objFormParam); |
---|
[19934] | 189 | break; |
---|
[19963] | 190 | |
---|
| 191 | // お届け先の追加 |
---|
| 192 | case 'append_shipping': |
---|
[20180] | 193 | $objFormParam->setParam($_POST); |
---|
| 194 | $objFormParam->convParam(); |
---|
| 195 | $this->addShipping($objFormParam); |
---|
[19963] | 196 | break; |
---|
| 197 | |
---|
[15594] | 198 | default: |
---|
| 199 | } |
---|
| 200 | |
---|
[20180] | 201 | $this->arrForm = $objFormParam->getFormParamList(); |
---|
| 202 | $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id')); |
---|
| 203 | $this->tpl_onload .= $this->getAnchorKey($objFormParam); |
---|
[20484] | 204 | $this->arrInfo = SC_Helper_DB_Ex::sfGetBasisData(); |
---|
[15594] | 205 | } |
---|
| 206 | |
---|
| 207 | /** |
---|
| 208 | * デストラクタ. |
---|
| 209 | * |
---|
| 210 | * @return void |
---|
| 211 | */ |
---|
| 212 | function destroy() { |
---|
| 213 | parent::destroy(); |
---|
| 214 | } |
---|
| 215 | |
---|
[20180] | 216 | /** |
---|
| 217 | * パラメータ情報の初期化を行う. |
---|
| 218 | * |
---|
| 219 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 220 | * @return void |
---|
| 221 | */ |
---|
| 222 | function lfInitParam(&$objFormParam) { |
---|
| 223 | // 検索条件のパラメータを初期化 |
---|
| 224 | parent::lfInitParam($objFormParam); |
---|
[18037] | 225 | |
---|
[17508] | 226 | // お客様情報 |
---|
[20180] | 227 | $objFormParam->addParam("顧客名1", "order_name01", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 228 | $objFormParam->addParam("顧客名2", "order_name02", STEXT_LEN, "KVa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 229 | $objFormParam->addParam("顧客名カナ1", "order_kana01", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 230 | $objFormParam->addParam("顧客名カナ2", "order_kana02", STEXT_LEN, "KVCa", array("EXIST_CHECK", "SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 231 | $objFormParam->addParam("メールアドレス", "order_email", MTEXT_LEN, "KVCa", array("NO_SPTAB", "EMAIL_CHECK", "EMAIL_CHAR_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 232 | $objFormParam->addParam("郵便番号1", "order_zip01", ZIP01_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
| 233 | $objFormParam->addParam("郵便番号2", "order_zip02", ZIP02_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
| 234 | $objFormParam->addParam("都道府県", "order_pref", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 235 | $objFormParam->addParam("住所1", "order_addr01", MTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 236 | $objFormParam->addParam("住所2", "order_addr02", MTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 237 | $objFormParam->addParam("電話番号1", "order_tel01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 238 | $objFormParam->addParam("電話番号2", "order_tel02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 239 | $objFormParam->addParam("電話番号3", "order_tel03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
[17293] | 240 | |
---|
[15594] | 241 | // 受注商品情報 |
---|
[20180] | 242 | $objFormParam->addParam("値引き", "discount", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 243 | $objFormParam->addParam("送料", "deliv_fee", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 244 | $objFormParam->addParam("手数料", "charge", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
[18054] | 245 | |
---|
| 246 | // ポイント機能ON時のみ |
---|
| 247 | if (USE_POINT !== false) { |
---|
[20180] | 248 | $objFormParam->addParam("利用ポイント", "use_point", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[18054] | 249 | } |
---|
| 250 | |
---|
[20180] | 251 | $objFormParam->addParam("配送業者", "deliv_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 252 | $objFormParam->addParam("お支払い方法", "payment_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 253 | $objFormParam->addParam("対応状況", "status", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 254 | $objFormParam->addParam("お支払方法名称", "payment_method"); |
---|
[15594] | 255 | |
---|
| 256 | // 受注詳細情報 |
---|
[20180] | 257 | $objFormParam->addParam("商品項番", "product_class_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 258 | $objFormParam->addParam("商品種別ID", "product_type_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 259 | $objFormParam->addParam("単価", "price", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 260 | $objFormParam->addParam("数量", "quantity", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 261 | $objFormParam->addParam("商品ID", "product_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 262 | $objFormParam->addParam("商品規格ID", "product_class_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 263 | $objFormParam->addParam("ポイント付与率", "point_rate"); |
---|
| 264 | $objFormParam->addParam("商品コード", "product_code"); |
---|
| 265 | $objFormParam->addParam("商品名", "product_name"); |
---|
| 266 | $objFormParam->addParam("規格名1", "classcategory_name1"); |
---|
| 267 | $objFormParam->addParam("規格名2", "classcategory_name2"); |
---|
| 268 | $objFormParam->addParam("メモ", "note", MTEXT_LEN, "KVa", array("MAX_LENGTH_CHECK")); |
---|
| 269 | $objFormParam->addParam("削除用項番", "delete_no", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 270 | |
---|
[15594] | 271 | // DB読込用 |
---|
[20180] | 272 | $objFormParam->addParam("小計", "subtotal"); |
---|
| 273 | $objFormParam->addParam("合計", "total"); |
---|
| 274 | $objFormParam->addParam("支払い合計", "payment_total"); |
---|
| 275 | $objFormParam->addParam("加算ポイント", "add_point"); |
---|
| 276 | $objFormParam->addParam("お誕生日ポイント", "birth_point"); |
---|
| 277 | $objFormParam->addParam("消費税合計", "tax"); |
---|
| 278 | $objFormParam->addParam("最終保持ポイント", "total_point"); |
---|
| 279 | $objFormParam->addParam("顧客ID", "customer_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 280 | $objFormParam->addParam("顧客ID", "edit_customer_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
[20442] | 281 | $objFormParam->addParam("現在のポイント", "customer_point"); |
---|
| 282 | $objFormParam->addParam("受注前ポイント", "point"); |
---|
[20180] | 283 | $objFormParam->addParam("注文番号", "order_id"); |
---|
| 284 | $objFormParam->addParam("受注日", "create_date"); |
---|
| 285 | $objFormParam->addParam("発送日", "commit_date"); |
---|
| 286 | $objFormParam->addParam("備考", "message"); |
---|
| 287 | $objFormParam->addParam("入金日", "payment_date"); |
---|
| 288 | $objFormParam->addParam("アクセス端末", "device_type_id"); |
---|
[15594] | 289 | |
---|
[20180] | 290 | // 複数情報 |
---|
| 291 | $objFormParam->addParam("配送数", "shipping_quantity", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 292 | $objFormParam->addParam("配送ID", "shipping_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), 0); |
---|
| 293 | $objFormParam->addParam("お名前1", "shipping_name01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 294 | $objFormParam->addParam("お名前2", "shipping_name02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 295 | $objFormParam->addParam("お名前(フリガナ・姓)", "shipping_kana01", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 296 | $objFormParam->addParam("お名前(フリガナ・名)", "shipping_kana02", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 297 | $objFormParam->addParam("郵便番号1", "shipping_zip01", ZIP01_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
| 298 | $objFormParam->addParam("郵便番号2", "shipping_zip02", ZIP02_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
| 299 | $objFormParam->addParam("都道府県", "shipping_pref", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 300 | $objFormParam->addParam("住所1", "shipping_addr01", MTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 301 | $objFormParam->addParam("住所2", "shipping_addr02", MTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 302 | $objFormParam->addParam("電話番号1", "shipping_tel01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 303 | $objFormParam->addParam("電話番号2", "shipping_tel02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 304 | $objFormParam->addParam("電話番号3", "shipping_tel03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 305 | $objFormParam->addParam("お届け時間ID", "time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 306 | $objFormParam->addParam("お届け時間", "shipping_time"); |
---|
[20430] | 307 | $objFormParam->addParam("お届け日(年)", "shipping_date_year", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[20180] | 308 | $objFormParam->addParam("お届け日(月)", "shipping_date_month", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 309 | $objFormParam->addParam("お届け日(日)", "shipping_date_day", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 310 | $objFormParam->addParam("お届け日", "shipping_date", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 311 | $objFormParam->addParam("配送商品数", "shipping_product_quantity", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[19963] | 312 | |
---|
[20180] | 313 | $objFormParam->addParam("商品規格ID", "shipment_product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 314 | $objFormParam->addParam("商品コード", "shipment_product_code"); |
---|
| 315 | $objFormParam->addParam("商品名", "shipment_product_name"); |
---|
| 316 | $objFormParam->addParam("規格名1", "shipment_classcategory_name1"); |
---|
| 317 | $objFormParam->addParam("規格名2", "shipment_classcategory_name2"); |
---|
| 318 | $objFormParam->addParam("単価", "shipment_price", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 319 | $objFormParam->addParam("数量", "shipment_quantity", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
[19963] | 320 | |
---|
[20180] | 321 | $objFormParam->addParam("商品項番", "no", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 322 | $objFormParam->addParam("追加商品規格ID", "add_product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 323 | $objFormParam->addParam("修正商品規格ID", "edit_product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 324 | $objFormParam->addParam("アンカーキー", "anchor_key", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
[19919] | 325 | } |
---|
| 326 | |
---|
[19934] | 327 | /** |
---|
[20180] | 328 | * 複数配送用フォームの初期化を行う. |
---|
| 329 | * |
---|
| 330 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 331 | * @return void |
---|
[19934] | 332 | */ |
---|
[20180] | 333 | function lfInitMultipleParam(&$objFormParam) { |
---|
| 334 | $objFormParam->addParam("商品規格ID", "multiple_product_class_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 335 | $objFormParam->addParam("商品コード", "multiple_product_code", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 336 | $objFormParam->addParam("商品名", "multiple_product_name", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 337 | $objFormParam->addParam("規格1", "multiple_classcategory_name1", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 338 | $objFormParam->addParam("規格2", "multiple_classcategory_name2", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 339 | $objFormParam->addParam("単価", "multiple_price", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 340 | $objFormParam->addParam("数量", "multiple_quantity", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 341 | $objFormParam->addParam("配送先住所", "multiple_shipping_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[19934] | 342 | } |
---|
[19919] | 343 | |
---|
[20180] | 344 | /** |
---|
| 345 | * 複数配送入力フォームで入力された値を SC_FormParam へ設定する. |
---|
| 346 | * |
---|
| 347 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 348 | * @return void |
---|
| 349 | */ |
---|
| 350 | function setMultipleItemTo(&$objFormParam) { |
---|
| 351 | $arrMultipleKey = array('multiple_shipping_id', |
---|
| 352 | 'multiple_product_class_id', |
---|
| 353 | 'multiple_product_name', |
---|
| 354 | 'multiple_product_code', |
---|
| 355 | 'multiple_classcategory_name1', |
---|
| 356 | 'multiple_classcategory_name2', |
---|
| 357 | 'multiple_price', |
---|
| 358 | 'multiple_quantity'); |
---|
| 359 | $arrMultipleParams = $objFormParam->getSwapArray($arrMultipleKey); |
---|
[19934] | 360 | |
---|
[20180] | 361 | /* |
---|
| 362 | * 複数配送フォームの入力値を shipping_id ごとにマージ |
---|
| 363 | * |
---|
| 364 | * $arrShipmentItem[配送先ID][商品規格ID]['shipment_(key)'] = 値 |
---|
| 365 | */ |
---|
[19934] | 366 | $arrShipmentItem = array(); |
---|
[20180] | 367 | foreach ($arrMultipleParams as $arrMultiple) { |
---|
| 368 | $shipping_id = $arrMultiple['multiple_shipping_id']; |
---|
| 369 | $product_class_id = $arrMultiple['multiple_product_class_id']; |
---|
| 370 | foreach ($arrMultiple as $key => $val) { |
---|
| 371 | if ($key == 'multiple_quantity') { |
---|
| 372 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] += $val; |
---|
| 373 | } else { |
---|
| 374 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] = $val; |
---|
| 375 | } |
---|
| 376 | } |
---|
[19934] | 377 | } |
---|
| 378 | |
---|
[20180] | 379 | /* |
---|
| 380 | * フォームの配送先ごとの配列を生成 |
---|
| 381 | * |
---|
| 382 | * $arrShipmentForm['(key)'][$shipping_index][$item_index] = 値 |
---|
| 383 | * $arrProductQuantity[$shipping_index] = 配送先ごとの配送商品数 |
---|
| 384 | */ |
---|
| 385 | $arrShipmentForm = array(); |
---|
| 386 | $arrProductQuantity = array(); |
---|
| 387 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 388 | foreach ($arrShippingIds as $shipping_index => $shipping_id) { |
---|
| 389 | $item_index = 0; |
---|
| 390 | foreach ($arrShipmentItem[$shipping_id] as $product_class_id => $shipment_item) { |
---|
| 391 | foreach ($shipment_item as $key => $val) { |
---|
| 392 | $arrShipmentForm[$key][$shipping_index][$item_index] = $val; |
---|
[19934] | 393 | } |
---|
[20180] | 394 | // 受注商品の数量を設定 |
---|
| 395 | $arrQuantity[$product_class_id] += $shipment_item['shipment_quantity']; |
---|
| 396 | $item_index++; |
---|
[19934] | 397 | } |
---|
[20180] | 398 | // 配送先ごとの配送商品数を設定 |
---|
| 399 | $arrProductQuantity[$shipping_index] = count($arrShipmentItem[$shipping_id]); |
---|
[19934] | 400 | } |
---|
[19949] | 401 | |
---|
[20180] | 402 | $objFormParam->setParam($arrShipmentForm); |
---|
| 403 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 404 | |
---|
[19949] | 405 | // 受注商品の数量を変更 |
---|
[20180] | 406 | $arrDest = array(); |
---|
| 407 | foreach ($arrQuantity as $product_class_id => $quantity) { |
---|
| 408 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
| 409 | if ($product_class_id == $order_product_class_id) { |
---|
| 410 | $arrDest['quantity'][$n] = $quantity; |
---|
[19949] | 411 | } |
---|
| 412 | } |
---|
| 413 | } |
---|
[20180] | 414 | $objFormParam->setParam($arrDest); |
---|
[19934] | 415 | } |
---|
| 416 | |
---|
[20180] | 417 | /** |
---|
| 418 | * 受注データを取得して, SC_FormParam へ設定する. |
---|
| 419 | * |
---|
| 420 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 421 | * @param integer $order_id 取得元の受注ID |
---|
| 422 | * @return void |
---|
| 423 | */ |
---|
| 424 | function setOrderToFormParam(&$objFormParam, $order_id) { |
---|
| 425 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[18235] | 426 | |
---|
[20180] | 427 | // 受注詳細を設定 |
---|
| 428 | $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); |
---|
| 429 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); |
---|
[15594] | 430 | |
---|
[20180] | 431 | $arrShippings = $objPurchase->getShippings($order_id); |
---|
| 432 | // お届け日の処理 |
---|
| 433 | foreach (array_keys($arrShippings) as $key) { |
---|
| 434 | $shipping =& $arrShippings[$key]; |
---|
| 435 | if (!SC_Utils_Ex::isBlank($shipping["shipping_date"])) { |
---|
| 436 | $ts = strtotime($shipping["shipping_date"]); |
---|
| 437 | $arrShippings[$key]['shipping_date_year'] = date("Y", $ts); |
---|
| 438 | $arrShippings[$key]['shipping_date_month'] = date("n", $ts); |
---|
| 439 | $arrShippings[$key]['shipping_date_day'] = date("j", $ts); |
---|
| 440 | } |
---|
| 441 | } |
---|
| 442 | $objFormParam->setValue('shipping_quantity', count($arrShippings)); |
---|
| 443 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings)); |
---|
[19919] | 444 | |
---|
[20180] | 445 | /* |
---|
| 446 | * 配送商品を設定 |
---|
| 447 | * |
---|
| 448 | * $arrShipmentItem['shipment_(key)'][$shipping_index][$item_index] = 値 |
---|
| 449 | * $arrProductQuantity[$shipping_index] = 配送先ごとの配送商品数 |
---|
| 450 | */ |
---|
| 451 | $arrProductQuantity = array(); |
---|
| 452 | $arrShipmentItem = array(); |
---|
| 453 | foreach ($arrShippings as $shipping_index => $arrShipping) { |
---|
| 454 | $arrProductQuantity[$shipping_index] = count($arrShipping['shipment_item']); |
---|
| 455 | foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) { |
---|
| 456 | foreach ($arrItem as $item_key => $item_val) { |
---|
| 457 | $arrShipmentItem['shipment_' . $item_key][$shipping_index][$item_index] = $item_val; |
---|
[19928] | 458 | } |
---|
[19912] | 459 | } |
---|
[15594] | 460 | } |
---|
[20180] | 461 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 462 | $objFormParam->setParam($arrShipmentItem); |
---|
[15594] | 463 | |
---|
[20180] | 464 | /* |
---|
| 465 | * 受注情報を設定 |
---|
| 466 | * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 |
---|
| 467 | * が渡ってくるため, $arrOrder で上書きする. |
---|
| 468 | */ |
---|
| 469 | $arrOrder = $objPurchase->getOrder($order_id); |
---|
| 470 | $objFormParam->setParam($arrOrder); |
---|
| 471 | |
---|
| 472 | // XXX ポイントを設定 |
---|
| 473 | list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint($order_id, $arrOrder['use_point'], $arrOrder['add_point']); |
---|
| 474 | $objFormParam->setValue('total_point', $db_point); |
---|
| 475 | $objFormParam->setValue('point', $rollback_point); |
---|
[20442] | 476 | |
---|
| 477 | if (!SC_Utils_Ex::isBlank($objFormParam->getValue('customer_id'))) { |
---|
| 478 | $this->setCustomerTo($objFormParam->getValue('customer_id'), |
---|
| 479 | $objFormParam); |
---|
| 480 | } |
---|
[15594] | 481 | } |
---|
| 482 | |
---|
[19912] | 483 | /** |
---|
[20180] | 484 | * 入力内容のチェックを行う. |
---|
| 485 | * |
---|
| 486 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 487 | * @return array エラーメッセージの配列 |
---|
[19912] | 488 | */ |
---|
[20180] | 489 | function lfCheckError(&$objFormParam) { |
---|
[20226] | 490 | $arrErr = $objFormParam->checkError(); |
---|
[19912] | 491 | |
---|
[20180] | 492 | if (!SC_Utils_Ex::isBlank($objErr->arrErr)) { |
---|
[20226] | 493 | return $arrErr; |
---|
[18087] | 494 | } |
---|
[18819] | 495 | |
---|
[20180] | 496 | $arrValues = $objFormParam->getHashArray(); |
---|
[15594] | 497 | |
---|
| 498 | // 商品の種類数 |
---|
[20180] | 499 | $max = count($arrValues['quantity']); |
---|
[15594] | 500 | $subtotal = 0; |
---|
| 501 | $totalpoint = 0; |
---|
| 502 | $totaltax = 0; |
---|
| 503 | for($i = 0; $i < $max; $i++) { |
---|
| 504 | // 小計の計算 |
---|
[20180] | 505 | $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 506 | // 小計の計算 |
---|
[20180] | 507 | $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 508 | // 加算ポイントの計算 |
---|
[20180] | 509 | $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 510 | } |
---|
| 511 | |
---|
| 512 | // 消費税 |
---|
[20180] | 513 | $arrValues['tax'] = $totaltax; |
---|
[15594] | 514 | // 小計 |
---|
[20180] | 515 | $arrValues['subtotal'] = $subtotal; |
---|
[15594] | 516 | // 合計 |
---|
[20180] | 517 | $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge']; |
---|
[15594] | 518 | // お支払い合計 |
---|
[20180] | 519 | $arrValues['payment_total'] = $arrValues['total'] - ($arrValues['use_point'] * POINT_VALUE); |
---|
[15594] | 520 | |
---|
| 521 | // 加算ポイント |
---|
[20180] | 522 | $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']); |
---|
[20041] | 523 | |
---|
[19674] | 524 | // 最終保持ポイント |
---|
[20180] | 525 | $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point'] + $arrValues['add_point']; |
---|
[20041] | 526 | |
---|
[20180] | 527 | if ($arrValues['total'] < 0) { |
---|
[20226] | 528 | $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
[15594] | 529 | } |
---|
| 530 | |
---|
[20180] | 531 | if ($arrValues['payment_total'] < 0) { |
---|
[20226] | 532 | $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
[15594] | 533 | } |
---|
[20180] | 534 | |
---|
| 535 | if ($arrValues['total_point'] < 0) { |
---|
[20226] | 536 | $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; |
---|
[15594] | 537 | } |
---|
| 538 | |
---|
[20180] | 539 | $objFormParam->setParam($arrValues); |
---|
[20226] | 540 | return $arrErr; |
---|
[15594] | 541 | } |
---|
| 542 | |
---|
[18100] | 543 | /** |
---|
| 544 | * DB更新処理 |
---|
| 545 | * |
---|
[20180] | 546 | * @param integer $order_id 受注ID |
---|
| 547 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 548 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 549 | * @return integer $order_id 受注ID |
---|
[18100] | 550 | */ |
---|
[20180] | 551 | function doRegister($order_id, &$objPurchase, &$objFormParam) { |
---|
[15594] | 552 | |
---|
[20507] | 553 | $objQuery =& SC_Query_Ex::getSingletonInstance(); |
---|
[20180] | 554 | $arrValues = $objFormParam->getDbArray(); |
---|
[15594] | 555 | |
---|
| 556 | $where = "order_id = ?"; |
---|
| 557 | |
---|
[18329] | 558 | $objQuery->begin(); |
---|
| 559 | |
---|
[15594] | 560 | // 受注テーブルの更新 |
---|
[20180] | 561 | $order_id = $objPurchase->registerOrder($order_id, $arrValues); |
---|
[18819] | 562 | |
---|
[20180] | 563 | $arrDetail = $objFormParam->getSwapArray(array("product_id", |
---|
| 564 | "product_class_id", |
---|
| 565 | "product_code", |
---|
| 566 | "product_name", |
---|
| 567 | "price", "quantity", |
---|
| 568 | "point_rate", |
---|
| 569 | "classcategory_name1", |
---|
| 570 | "classcategory_name2")); |
---|
[18819] | 571 | |
---|
[18646] | 572 | // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 |
---|
| 573 | $max = count($arrDetail); |
---|
| 574 | $k = 0; |
---|
| 575 | $arrStockData = array(); |
---|
| 576 | for($i = 0; $i < $max; $i++) { |
---|
| 577 | if (!empty($arrDetail[$i]['product_id'])) { |
---|
[18872] | 578 | $arrPreDetail = $objQuery->select('*', "dtb_order_detail", "order_id = ? AND product_class_id = ?", array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 579 | if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { |
---|
| 580 | // 数量が変更された商品 |
---|
[18872] | 581 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 582 | $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; |
---|
| 583 | ++$k; |
---|
| 584 | } elseif (empty($arrPreDetail)) { |
---|
| 585 | // 新しく追加された商品 もしくは 違う商品に変更された商品 |
---|
[18872] | 586 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 587 | $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; |
---|
| 588 | ++$k; |
---|
| 589 | } |
---|
[18872] | 590 | $objQuery->delete("dtb_order_detail", "order_id = ? AND product_class_id = ?", array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 591 | } |
---|
| 592 | } |
---|
| 593 | |
---|
| 594 | // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 |
---|
| 595 | $arrPreDetail = $objQuery->select('*', "dtb_order_detail", "order_id = ?", array($order_id)); |
---|
| 596 | foreach ($arrPreDetail AS $key=>$val) { |
---|
[18872] | 597 | $arrStockData[$k]['product_class_id'] = $val['product_class_id']; |
---|
[18646] | 598 | $arrStockData[$k]['quantity'] = $val['quantity']; |
---|
| 599 | ++$k; |
---|
| 600 | } |
---|
| 601 | |
---|
| 602 | // 受注詳細データの更新 |
---|
[20180] | 603 | $objPurchase->registerOrderDetail($order_id, $arrDetail); |
---|
[18074] | 604 | |
---|
[18646] | 605 | // 在庫数調整 |
---|
[20180] | 606 | if (ORDER_DELIV != $arrValues['status'] |
---|
| 607 | && ORDER_CANCEL != $arrValues['status']) { |
---|
| 608 | foreach ($arrStockData AS $stock) { |
---|
| 609 | $objQuery->update('dtb_products_class', array(), |
---|
| 610 | 'product_class_id = ?', |
---|
| 611 | array($stock['product_class_id']), |
---|
| 612 | array('stock' => 'stock + ?'), |
---|
| 613 | array($stock['quantity'])); |
---|
[18646] | 614 | } |
---|
| 615 | } |
---|
| 616 | |
---|
[20180] | 617 | $arrAllShipping = $objFormParam->getSwapArray(array('shipping_id', |
---|
| 618 | 'shipping_name01', |
---|
| 619 | 'shipping_name02', |
---|
| 620 | 'shipping_kana01', |
---|
| 621 | 'shipping_kana02', |
---|
| 622 | 'shipping_tel01', |
---|
| 623 | 'shipping_tel02', |
---|
| 624 | 'shipping_tel03', |
---|
| 625 | 'shipping_fax01', |
---|
| 626 | 'shipping_fax02', |
---|
| 627 | 'shipping_fax03', |
---|
| 628 | 'shipping_pref', |
---|
| 629 | 'shipping_zip01', |
---|
| 630 | 'shipping_zip02', |
---|
| 631 | 'shipping_addr01', |
---|
| 632 | 'shipping_addr02', |
---|
| 633 | 'shipping_date_year', |
---|
| 634 | 'shipping_date_month', |
---|
| 635 | 'shipping_date_day', |
---|
| 636 | 'time_id')); |
---|
[19949] | 637 | |
---|
[20180] | 638 | $arrAllShipmentItem = |
---|
| 639 | $objFormParam->getSwapArray(array('shipment_product_class_id', |
---|
| 640 | 'shipment_product_code', |
---|
| 641 | 'shipment_product_name', |
---|
| 642 | 'shipment_classcategory_name1', |
---|
| 643 | 'shipment_classcategory_name2', |
---|
| 644 | 'shipment_price', |
---|
| 645 | 'shipment_quantity')); |
---|
| 646 | $arrShippingValues = array(); |
---|
| 647 | foreach ($arrAllShipping as $shipping_index => $arrShipping) { |
---|
| 648 | $shipping_id = $arrShipping['shipping_id']; |
---|
| 649 | $arrShippingValues[$shipping_index] = $arrShipping; |
---|
[19949] | 650 | |
---|
[20180] | 651 | $arrShippingValues[$shipping_index]['shipping_date'] |
---|
| 652 | = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], |
---|
| 653 | $arrShipping['shipping_date_month'], |
---|
| 654 | $arrShipping['shipping_date_day']); |
---|
[19963] | 655 | |
---|
[20180] | 656 | // 配送業者IDを取得 |
---|
| 657 | $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); |
---|
[19949] | 658 | |
---|
[20180] | 659 | // 複数配送の場合は配送商品を登録 |
---|
| 660 | if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) { |
---|
| 661 | $arrShipmentValues = array(); |
---|
[19963] | 662 | |
---|
[20180] | 663 | foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) { |
---|
| 664 | $i = 0; |
---|
| 665 | foreach ($arrItem as $item) { |
---|
| 666 | $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item; |
---|
| 667 | $i++; |
---|
| 668 | } |
---|
[19949] | 669 | } |
---|
[20180] | 670 | $objPurchase->registerShipmentItem($order_id, $shipping_id, |
---|
| 671 | $arrShipmentValues[$shipping_index]); |
---|
[19949] | 672 | } |
---|
| 673 | } |
---|
[20180] | 674 | $objPurchase->registerShipping($order_id, $arrShippingValues, false); |
---|
[15594] | 675 | $objQuery->commit(); |
---|
[20180] | 676 | return $order_id; |
---|
[15594] | 677 | } |
---|
[17293] | 678 | |
---|
[18100] | 679 | /** |
---|
[20180] | 680 | * 受注商品の追加/更新を行う. |
---|
[18100] | 681 | * |
---|
[20180] | 682 | * 小画面で選択した受注商品をフォームに反映させる. |
---|
| 683 | * |
---|
| 684 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 685 | * @return void |
---|
[18100] | 686 | */ |
---|
[20180] | 687 | function doRegisterProduct(&$objFormParam) { |
---|
| 688 | $product_class_id = $objFormParam->getValue('add_product_class_id'); |
---|
| 689 | if (SC_Utils_Ex::isBlank($product_class_id)) { |
---|
| 690 | $product_class_id = $objFormParam->getValue('edit_product_class_id'); |
---|
[20415] | 691 | $changed_no = $objFormParam->getValue('no'); |
---|
[17293] | 692 | } |
---|
[18037] | 693 | |
---|
[20415] | 694 | // 選択済みの商品であれば数量を1増やす |
---|
[20180] | 695 | $exists = false; |
---|
| 696 | $arrExistsProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
| 697 | foreach (array_keys($arrExistsProductClassIds) as $key) { |
---|
| 698 | $exists_product_class_id = $arrExistsProductClassIds[$key]; |
---|
| 699 | if ($exists_product_class_id == $product_class_id) { |
---|
| 700 | $exists = true; |
---|
| 701 | $arrExistsQuantity = $objFormParam->getValue('quantity'); |
---|
| 702 | $arrExistsQuantity[$key]++; |
---|
| 703 | $objFormParam->setValue('quantity', $arrExistsQuantity); |
---|
[19963] | 704 | } |
---|
[18646] | 705 | } |
---|
[19963] | 706 | |
---|
[20180] | 707 | // 新しく商品を追加した場合はフォームに登録 |
---|
[20415] | 708 | // 商品を変更した場合は、該当行を変更 |
---|
[20180] | 709 | if (!$exists) { |
---|
[20487] | 710 | $objProduct = new SC_Product_Ex(); |
---|
[20180] | 711 | $arrProduct = $objProduct->getDetailAndProductsClass($product_class_id); |
---|
| 712 | $arrProduct['quantity'] = 1; |
---|
| 713 | $arrProduct['price'] = $arrProduct['price02']; |
---|
| 714 | $arrProduct['product_name'] = $arrProduct['name']; |
---|
[19963] | 715 | |
---|
[20180] | 716 | $arrUpdateKeys = array('product_id', 'product_class_id', |
---|
| 717 | 'product_type_id', 'point_rate', |
---|
| 718 | 'product_code', 'product_name', |
---|
| 719 | 'classcategory_name1', 'classcategory_name2', |
---|
| 720 | 'quantity', 'price'); |
---|
| 721 | foreach ($arrUpdateKeys as $key) { |
---|
| 722 | $arrValues = $objFormParam->getValue($key); |
---|
[20415] | 723 | if (isset($changed_no)) { |
---|
| 724 | $arrValues[$changed_no] = $arrProduct[$key]; |
---|
| 725 | } else { |
---|
| 726 | $arrValues[] = $arrProduct[$key]; |
---|
| 727 | } |
---|
[20180] | 728 | $objFormParam->setValue($key, $arrValues); |
---|
[19963] | 729 | } |
---|
[20415] | 730 | } elseif (isset($changed_no)) { |
---|
[20416] | 731 | // 変更したが、選択済みの商品だった場合は、変更対象行を削除。 |
---|
[20415] | 732 | $this->doDeleteProduct($changed_no, $objFormParam); |
---|
[19963] | 733 | } |
---|
[17293] | 734 | } |
---|
| 735 | |
---|
[19919] | 736 | /** |
---|
[20180] | 737 | * 受注商品を削除する. |
---|
| 738 | * |
---|
| 739 | * @param integer $delete_no 削除する受注商品の項番 |
---|
| 740 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 741 | * @return void |
---|
[19919] | 742 | */ |
---|
[20180] | 743 | function doDeleteProduct($delete_no, &$objFormParam) { |
---|
| 744 | $arrDeleteKeys = array('product_id', 'product_class_id', |
---|
| 745 | 'product_type_id', 'point_rate', |
---|
| 746 | 'product_code', 'product_name', |
---|
| 747 | 'classcategory_name1', 'classcategory_name2', |
---|
| 748 | 'quantity', 'price'); |
---|
| 749 | foreach ($arrDeleteKeys as $key) { |
---|
| 750 | $arrNewValues = array(); |
---|
| 751 | $arrValues = $objFormParam->getValue($key); |
---|
| 752 | foreach ($arrValues as $index => $val) { |
---|
| 753 | if ($index != $delete_no) { |
---|
| 754 | $arrNewValues[] = $val; |
---|
[18014] | 755 | } |
---|
| 756 | } |
---|
[20180] | 757 | $objFormParam->setValue($key, $arrNewValues); |
---|
[18014] | 758 | } |
---|
[17293] | 759 | } |
---|
| 760 | |
---|
[20180] | 761 | /** |
---|
| 762 | * お届け先を追加する. |
---|
| 763 | * |
---|
| 764 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 765 | * @return void |
---|
| 766 | */ |
---|
| 767 | function addShipping(&$objFormParam) { |
---|
| 768 | $objFormParam->setValue('shipping_quantity', |
---|
| 769 | $objFormParam->getValue('shipping_quantity') + 1); |
---|
| 770 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 771 | $arrShippingIds[] = max($arrShippingIds) + 1; |
---|
| 772 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[17293] | 773 | } |
---|
| 774 | |
---|
[18068] | 775 | /** |
---|
[20180] | 776 | * 顧客情報をフォームに設定する. |
---|
| 777 | * |
---|
| 778 | * @param integer $customer_id 顧客ID |
---|
| 779 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 780 | * @return void |
---|
[18068] | 781 | */ |
---|
[20180] | 782 | function setCustomerTo($customer_id, &$objFormParam) { |
---|
| 783 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
| 784 | foreach ($arrCustomer as $key => $val) { |
---|
| 785 | $objFormParam->setValue('order_' . $key, $val); |
---|
[18068] | 786 | } |
---|
[20180] | 787 | $objFormParam->setValue('customer_id', $customer_id); |
---|
[20442] | 788 | $objFormParam->setValue('customer_point', $arrCustomer['point']); |
---|
[18068] | 789 | } |
---|
[18329] | 790 | |
---|
| 791 | /** |
---|
[20180] | 792 | * アンカーキーを取得する. |
---|
[18329] | 793 | * |
---|
[20180] | 794 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 795 | * @return アンカーキーの文字列 |
---|
[18329] | 796 | */ |
---|
[20180] | 797 | function getAnchorKey(&$objFormParam) { |
---|
| 798 | $ancor_key = $objFormParam->getValue('anchor_key'); |
---|
| 799 | if (!SC_Utils_Ex::isBlank($ancor_key)) { |
---|
| 800 | return "location.hash='#" . htmlentities(urlencode($ancor_key), ENT_QUOTES) . "'"; |
---|
[18329] | 801 | } |
---|
[20180] | 802 | return ''; |
---|
[19963] | 803 | } |
---|
[15594] | 804 | } |
---|
| 805 | ?> |
---|