[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 |
---|
[20180] | 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 | |
---|
[20180] | 55 | $objDate = new SC_Date(RELEASE_YEAR); |
---|
| 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(); |
---|
[20180] | 86 | $objFormParam = new SC_FormParam(); |
---|
[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); |
---|
| 204 | $this->arrInfo = SC_Helper_DB::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'); |
---|
| 281 | $objFormParam->addParam("現在のポイント", "point"); |
---|
| 282 | $objFormParam->addParam("注文番号", "order_id"); |
---|
| 283 | $objFormParam->addParam("受注日", "create_date"); |
---|
| 284 | $objFormParam->addParam("発送日", "commit_date"); |
---|
| 285 | $objFormParam->addParam("備考", "message"); |
---|
| 286 | $objFormParam->addParam("入金日", "payment_date"); |
---|
| 287 | $objFormParam->addParam("アクセス端末", "device_type_id"); |
---|
[15594] | 288 | |
---|
[20180] | 289 | // 複数情報 |
---|
| 290 | $objFormParam->addParam("配送数", "shipping_quantity", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 291 | $objFormParam->addParam("配送ID", "shipping_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), 0); |
---|
| 292 | $objFormParam->addParam("お名前1", "shipping_name01", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 293 | $objFormParam->addParam("お名前2", "shipping_name02", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 294 | $objFormParam->addParam("お名前(フリガナ・姓)", "shipping_kana01", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 295 | $objFormParam->addParam("お名前(フリガナ・名)", "shipping_kana02", STEXT_LEN, "KVCa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 296 | $objFormParam->addParam("郵便番号1", "shipping_zip01", ZIP01_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
| 297 | $objFormParam->addParam("郵便番号2", "shipping_zip02", ZIP02_LEN, "n", array("NUM_CHECK", "NUM_COUNT_CHECK")); |
---|
| 298 | $objFormParam->addParam("都道府県", "shipping_pref", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 299 | $objFormParam->addParam("住所1", "shipping_addr01", MTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 300 | $objFormParam->addParam("住所2", "shipping_addr02", MTEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 301 | $objFormParam->addParam("電話番号1", "shipping_tel01", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 302 | $objFormParam->addParam("電話番号2", "shipping_tel02", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 303 | $objFormParam->addParam("電話番号3", "shipping_tel03", TEL_ITEM_LEN, "n", array("MAX_LENGTH_CHECK" ,"NUM_CHECK")); |
---|
| 304 | $objFormParam->addParam("お届け時間ID", "time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 305 | $objFormParam->addParam("お届け時間", "shipping_time"); |
---|
[20430] | 306 | $objFormParam->addParam("お届け日(年)", "shipping_date_year", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[20180] | 307 | $objFormParam->addParam("お届け日(月)", "shipping_date_month", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 308 | $objFormParam->addParam("お届け日(日)", "shipping_date_day", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 309 | $objFormParam->addParam("お届け日", "shipping_date", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
| 310 | $objFormParam->addParam("配送商品数", "shipping_product_quantity", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[19963] | 311 | |
---|
[20180] | 312 | $objFormParam->addParam("商品規格ID", "shipment_product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 313 | $objFormParam->addParam("商品コード", "shipment_product_code"); |
---|
| 314 | $objFormParam->addParam("商品名", "shipment_product_name"); |
---|
| 315 | $objFormParam->addParam("規格名1", "shipment_classcategory_name1"); |
---|
| 316 | $objFormParam->addParam("規格名2", "shipment_classcategory_name2"); |
---|
| 317 | $objFormParam->addParam("単価", "shipment_price", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
| 318 | $objFormParam->addParam("数量", "shipment_quantity", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"), '0'); |
---|
[19963] | 319 | |
---|
[20180] | 320 | $objFormParam->addParam("商品項番", "no", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 321 | $objFormParam->addParam("追加商品規格ID", "add_product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 322 | $objFormParam->addParam("修正商品規格ID", "edit_product_class_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 323 | $objFormParam->addParam("アンカーキー", "anchor_key", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); |
---|
[19919] | 324 | } |
---|
| 325 | |
---|
[19934] | 326 | /** |
---|
[20180] | 327 | * 複数配送用フォームの初期化を行う. |
---|
| 328 | * |
---|
| 329 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 330 | * @return void |
---|
[19934] | 331 | */ |
---|
[20180] | 332 | function lfInitMultipleParam(&$objFormParam) { |
---|
| 333 | $objFormParam->addParam("商品規格ID", "multiple_product_class_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
| 334 | $objFormParam->addParam("商品コード", "multiple_product_code", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 335 | $objFormParam->addParam("商品名", "multiple_product_name", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 336 | $objFormParam->addParam("規格1", "multiple_classcategory_name1", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 337 | $objFormParam->addParam("規格2", "multiple_classcategory_name2", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 338 | $objFormParam->addParam("単価", "multiple_price", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 339 | $objFormParam->addParam("数量", "multiple_quantity", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK"), 1); |
---|
| 340 | $objFormParam->addParam("配送先住所", "multiple_shipping_id", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); |
---|
[19934] | 341 | } |
---|
[19919] | 342 | |
---|
[20180] | 343 | /** |
---|
| 344 | * 複数配送入力フォームで入力された値を SC_FormParam へ設定する. |
---|
| 345 | * |
---|
| 346 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 347 | * @return void |
---|
| 348 | */ |
---|
| 349 | function setMultipleItemTo(&$objFormParam) { |
---|
| 350 | $arrMultipleKey = array('multiple_shipping_id', |
---|
| 351 | 'multiple_product_class_id', |
---|
| 352 | 'multiple_product_name', |
---|
| 353 | 'multiple_product_code', |
---|
| 354 | 'multiple_classcategory_name1', |
---|
| 355 | 'multiple_classcategory_name2', |
---|
| 356 | 'multiple_price', |
---|
| 357 | 'multiple_quantity'); |
---|
| 358 | $arrMultipleParams = $objFormParam->getSwapArray($arrMultipleKey); |
---|
[19934] | 359 | |
---|
[20180] | 360 | /* |
---|
| 361 | * 複数配送フォームの入力値を shipping_id ごとにマージ |
---|
| 362 | * |
---|
| 363 | * $arrShipmentItem[配送先ID][商品規格ID]['shipment_(key)'] = 値 |
---|
| 364 | */ |
---|
[19934] | 365 | $arrShipmentItem = array(); |
---|
[20180] | 366 | foreach ($arrMultipleParams as $arrMultiple) { |
---|
| 367 | $shipping_id = $arrMultiple['multiple_shipping_id']; |
---|
| 368 | $product_class_id = $arrMultiple['multiple_product_class_id']; |
---|
| 369 | foreach ($arrMultiple as $key => $val) { |
---|
| 370 | if ($key == 'multiple_quantity') { |
---|
| 371 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] += $val; |
---|
| 372 | } else { |
---|
| 373 | $arrShipmentItem[$shipping_id][$product_class_id][str_replace('multiple', 'shipment', $key)] = $val; |
---|
| 374 | } |
---|
| 375 | } |
---|
[19934] | 376 | } |
---|
| 377 | |
---|
[20180] | 378 | /* |
---|
| 379 | * フォームの配送先ごとの配列を生成 |
---|
| 380 | * |
---|
| 381 | * $arrShipmentForm['(key)'][$shipping_index][$item_index] = 値 |
---|
| 382 | * $arrProductQuantity[$shipping_index] = 配送先ごとの配送商品数 |
---|
| 383 | */ |
---|
| 384 | $arrShipmentForm = array(); |
---|
| 385 | $arrProductQuantity = array(); |
---|
| 386 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 387 | foreach ($arrShippingIds as $shipping_index => $shipping_id) { |
---|
| 388 | $item_index = 0; |
---|
| 389 | foreach ($arrShipmentItem[$shipping_id] as $product_class_id => $shipment_item) { |
---|
| 390 | foreach ($shipment_item as $key => $val) { |
---|
| 391 | $arrShipmentForm[$key][$shipping_index][$item_index] = $val; |
---|
[19934] | 392 | } |
---|
[20180] | 393 | // 受注商品の数量を設定 |
---|
| 394 | $arrQuantity[$product_class_id] += $shipment_item['shipment_quantity']; |
---|
| 395 | $item_index++; |
---|
[19934] | 396 | } |
---|
[20180] | 397 | // 配送先ごとの配送商品数を設定 |
---|
| 398 | $arrProductQuantity[$shipping_index] = count($arrShipmentItem[$shipping_id]); |
---|
[19934] | 399 | } |
---|
[19949] | 400 | |
---|
[20180] | 401 | $objFormParam->setParam($arrShipmentForm); |
---|
| 402 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 403 | |
---|
[19949] | 404 | // 受注商品の数量を変更 |
---|
[20180] | 405 | $arrDest = array(); |
---|
| 406 | foreach ($arrQuantity as $product_class_id => $quantity) { |
---|
| 407 | foreach ($objFormParam->getValue('product_class_id') as $n => $order_product_class_id) { |
---|
| 408 | if ($product_class_id == $order_product_class_id) { |
---|
| 409 | $arrDest['quantity'][$n] = $quantity; |
---|
[19949] | 410 | } |
---|
| 411 | } |
---|
| 412 | } |
---|
[20180] | 413 | $objFormParam->setParam($arrDest); |
---|
[19934] | 414 | } |
---|
| 415 | |
---|
[20180] | 416 | /** |
---|
| 417 | * 受注データを取得して, SC_FormParam へ設定する. |
---|
| 418 | * |
---|
| 419 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 420 | * @param integer $order_id 取得元の受注ID |
---|
| 421 | * @return void |
---|
| 422 | */ |
---|
| 423 | function setOrderToFormParam(&$objFormParam, $order_id) { |
---|
| 424 | $objPurchase = new SC_Helper_Purchase_Ex(); |
---|
[18235] | 425 | |
---|
[20180] | 426 | // 受注詳細を設定 |
---|
| 427 | $arrOrderDetail = $objPurchase->getOrderDetail($order_id, false); |
---|
| 428 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrOrderDetail)); |
---|
[15594] | 429 | |
---|
[20180] | 430 | $arrShippings = $objPurchase->getShippings($order_id); |
---|
| 431 | // お届け日の処理 |
---|
| 432 | foreach (array_keys($arrShippings) as $key) { |
---|
| 433 | $shipping =& $arrShippings[$key]; |
---|
| 434 | if (!SC_Utils_Ex::isBlank($shipping["shipping_date"])) { |
---|
| 435 | $ts = strtotime($shipping["shipping_date"]); |
---|
| 436 | $arrShippings[$key]['shipping_date_year'] = date("Y", $ts); |
---|
| 437 | $arrShippings[$key]['shipping_date_month'] = date("n", $ts); |
---|
| 438 | $arrShippings[$key]['shipping_date_day'] = date("j", $ts); |
---|
| 439 | } |
---|
| 440 | } |
---|
| 441 | $objFormParam->setValue('shipping_quantity', count($arrShippings)); |
---|
| 442 | $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrShippings)); |
---|
[19919] | 443 | |
---|
[20180] | 444 | /* |
---|
| 445 | * 配送商品を設定 |
---|
| 446 | * |
---|
| 447 | * $arrShipmentItem['shipment_(key)'][$shipping_index][$item_index] = 値 |
---|
| 448 | * $arrProductQuantity[$shipping_index] = 配送先ごとの配送商品数 |
---|
| 449 | */ |
---|
| 450 | $arrProductQuantity = array(); |
---|
| 451 | $arrShipmentItem = array(); |
---|
| 452 | foreach ($arrShippings as $shipping_index => $arrShipping) { |
---|
| 453 | $arrProductQuantity[$shipping_index] = count($arrShipping['shipment_item']); |
---|
| 454 | foreach ($arrShipping['shipment_item'] as $item_index => $arrItem) { |
---|
| 455 | foreach ($arrItem as $item_key => $item_val) { |
---|
| 456 | $arrShipmentItem['shipment_' . $item_key][$shipping_index][$item_index] = $item_val; |
---|
[19928] | 457 | } |
---|
[19912] | 458 | } |
---|
[15594] | 459 | } |
---|
[20180] | 460 | $objFormParam->setValue('shipping_product_quantity', $arrProductQuantity); |
---|
| 461 | $objFormParam->setParam($arrShipmentItem); |
---|
[15594] | 462 | |
---|
[20180] | 463 | /* |
---|
| 464 | * 受注情報を設定 |
---|
| 465 | * $arrOrderDetail と項目が重複しており, $arrOrderDetail は連想配列の値 |
---|
| 466 | * が渡ってくるため, $arrOrder で上書きする. |
---|
| 467 | */ |
---|
| 468 | $arrOrder = $objPurchase->getOrder($order_id); |
---|
| 469 | $objFormParam->setParam($arrOrder); |
---|
| 470 | |
---|
| 471 | // XXX ポイントを設定 |
---|
| 472 | list($db_point, $rollback_point) = SC_Helper_DB_Ex::sfGetRollbackPoint($order_id, $arrOrder['use_point'], $arrOrder['add_point']); |
---|
| 473 | $objFormParam->setValue('total_point', $db_point); |
---|
| 474 | $objFormParam->setValue('point', $rollback_point); |
---|
[15594] | 475 | } |
---|
| 476 | |
---|
[19912] | 477 | /** |
---|
[20180] | 478 | * 入力内容のチェックを行う. |
---|
| 479 | * |
---|
| 480 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 481 | * @return array エラーメッセージの配列 |
---|
[19912] | 482 | */ |
---|
[20180] | 483 | function lfCheckError(&$objFormParam) { |
---|
[20226] | 484 | $arrErr = $objFormParam->checkError(); |
---|
[19912] | 485 | |
---|
[20180] | 486 | if (!SC_Utils_Ex::isBlank($objErr->arrErr)) { |
---|
[20226] | 487 | return $arrErr; |
---|
[18087] | 488 | } |
---|
[18819] | 489 | |
---|
[20180] | 490 | $arrValues = $objFormParam->getHashArray(); |
---|
[15594] | 491 | |
---|
| 492 | // 商品の種類数 |
---|
[20180] | 493 | $max = count($arrValues['quantity']); |
---|
[15594] | 494 | $subtotal = 0; |
---|
| 495 | $totalpoint = 0; |
---|
| 496 | $totaltax = 0; |
---|
| 497 | for($i = 0; $i < $max; $i++) { |
---|
| 498 | // 小計の計算 |
---|
[20180] | 499 | $subtotal += SC_Helper_DB_Ex::sfCalcIncTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 500 | // 小計の計算 |
---|
[20180] | 501 | $totaltax += SC_Helper_DB_Ex::sfTax($arrValues['price'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 502 | // 加算ポイントの計算 |
---|
[20180] | 503 | $totalpoint += SC_Utils_Ex::sfPrePoint($arrValues['price'][$i], $arrValues['point_rate'][$i]) * $arrValues['quantity'][$i]; |
---|
[15594] | 504 | } |
---|
| 505 | |
---|
| 506 | // 消費税 |
---|
[20180] | 507 | $arrValues['tax'] = $totaltax; |
---|
[15594] | 508 | // 小計 |
---|
[20180] | 509 | $arrValues['subtotal'] = $subtotal; |
---|
[15594] | 510 | // 合計 |
---|
[20180] | 511 | $arrValues['total'] = $subtotal - $arrValues['discount'] + $arrValues['deliv_fee'] + $arrValues['charge']; |
---|
[15594] | 512 | // お支払い合計 |
---|
[20180] | 513 | $arrValues['payment_total'] = $arrValues['total'] - ($arrValues['use_point'] * POINT_VALUE); |
---|
[15594] | 514 | |
---|
| 515 | // 加算ポイント |
---|
[20180] | 516 | $arrValues['add_point'] = SC_Helper_DB_Ex::sfGetAddPoint($totalpoint, $arrValues['use_point']); |
---|
[20041] | 517 | |
---|
[19674] | 518 | // 最終保持ポイント |
---|
[20180] | 519 | $arrValues['total_point'] = $objFormParam->getValue('point') - $arrValues['use_point'] + $arrValues['add_point']; |
---|
[20041] | 520 | |
---|
[20180] | 521 | if ($arrValues['total'] < 0) { |
---|
[20226] | 522 | $arrErr['total'] = '合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
[15594] | 523 | } |
---|
| 524 | |
---|
[20180] | 525 | if ($arrValues['payment_total'] < 0) { |
---|
[20226] | 526 | $arrErr['payment_total'] = 'お支払い合計額がマイナス表示にならないように調整して下さい。<br />'; |
---|
[15594] | 527 | } |
---|
[20180] | 528 | |
---|
| 529 | if ($arrValues['total_point'] < 0) { |
---|
[20226] | 530 | $arrErr['use_point'] = '最終保持ポイントがマイナス表示にならないように調整して下さい。<br />'; |
---|
[15594] | 531 | } |
---|
| 532 | |
---|
[20180] | 533 | $objFormParam->setParam($arrValues); |
---|
[20226] | 534 | return $arrErr; |
---|
[15594] | 535 | } |
---|
| 536 | |
---|
[18100] | 537 | /** |
---|
| 538 | * DB更新処理 |
---|
| 539 | * |
---|
[20180] | 540 | * @param integer $order_id 受注ID |
---|
| 541 | * @param SC_Helper_Purchase $objPurchase SC_Helper_Purchase インスタンス |
---|
| 542 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 543 | * @return integer $order_id 受注ID |
---|
[18100] | 544 | */ |
---|
[20180] | 545 | function doRegister($order_id, &$objPurchase, &$objFormParam) { |
---|
[15594] | 546 | |
---|
[20180] | 547 | $objQuery =& SC_Query::getSingletonInstance(); |
---|
| 548 | $arrValues = $objFormParam->getDbArray(); |
---|
[15594] | 549 | |
---|
| 550 | $where = "order_id = ?"; |
---|
| 551 | |
---|
[18329] | 552 | $objQuery->begin(); |
---|
| 553 | |
---|
[15594] | 554 | // 受注テーブルの更新 |
---|
[20180] | 555 | $order_id = $objPurchase->registerOrder($order_id, $arrValues); |
---|
[18819] | 556 | |
---|
[20180] | 557 | $arrDetail = $objFormParam->getSwapArray(array("product_id", |
---|
| 558 | "product_class_id", |
---|
| 559 | "product_code", |
---|
| 560 | "product_name", |
---|
| 561 | "price", "quantity", |
---|
| 562 | "point_rate", |
---|
| 563 | "classcategory_name1", |
---|
| 564 | "classcategory_name2")); |
---|
[18819] | 565 | |
---|
[18646] | 566 | // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 |
---|
| 567 | $max = count($arrDetail); |
---|
| 568 | $k = 0; |
---|
| 569 | $arrStockData = array(); |
---|
| 570 | for($i = 0; $i < $max; $i++) { |
---|
| 571 | if (!empty($arrDetail[$i]['product_id'])) { |
---|
[18872] | 572 | $arrPreDetail = $objQuery->select('*', "dtb_order_detail", "order_id = ? AND product_class_id = ?", array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 573 | if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { |
---|
| 574 | // 数量が変更された商品 |
---|
[18872] | 575 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 576 | $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; |
---|
| 577 | ++$k; |
---|
| 578 | } elseif (empty($arrPreDetail)) { |
---|
| 579 | // 新しく追加された商品 もしくは 違う商品に変更された商品 |
---|
[18872] | 580 | $arrStockData[$k]['product_class_id'] = $arrDetail[$i]['product_class_id']; |
---|
[18646] | 581 | $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; |
---|
| 582 | ++$k; |
---|
| 583 | } |
---|
[18872] | 584 | $objQuery->delete("dtb_order_detail", "order_id = ? AND product_class_id = ?", array($order_id, $arrDetail[$i]['product_class_id'])); |
---|
[18646] | 585 | } |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 |
---|
| 589 | $arrPreDetail = $objQuery->select('*', "dtb_order_detail", "order_id = ?", array($order_id)); |
---|
| 590 | foreach ($arrPreDetail AS $key=>$val) { |
---|
[18872] | 591 | $arrStockData[$k]['product_class_id'] = $val['product_class_id']; |
---|
[18646] | 592 | $arrStockData[$k]['quantity'] = $val['quantity']; |
---|
| 593 | ++$k; |
---|
| 594 | } |
---|
| 595 | |
---|
| 596 | // 受注詳細データの更新 |
---|
[20180] | 597 | $objPurchase->registerOrderDetail($order_id, $arrDetail); |
---|
[18074] | 598 | |
---|
[18646] | 599 | // 在庫数調整 |
---|
[20180] | 600 | if (ORDER_DELIV != $arrValues['status'] |
---|
| 601 | && ORDER_CANCEL != $arrValues['status']) { |
---|
| 602 | foreach ($arrStockData AS $stock) { |
---|
| 603 | $objQuery->update('dtb_products_class', array(), |
---|
| 604 | 'product_class_id = ?', |
---|
| 605 | array($stock['product_class_id']), |
---|
| 606 | array('stock' => 'stock + ?'), |
---|
| 607 | array($stock['quantity'])); |
---|
[18646] | 608 | } |
---|
| 609 | } |
---|
| 610 | |
---|
[20180] | 611 | $arrAllShipping = $objFormParam->getSwapArray(array('shipping_id', |
---|
| 612 | 'shipping_name01', |
---|
| 613 | 'shipping_name02', |
---|
| 614 | 'shipping_kana01', |
---|
| 615 | 'shipping_kana02', |
---|
| 616 | 'shipping_tel01', |
---|
| 617 | 'shipping_tel02', |
---|
| 618 | 'shipping_tel03', |
---|
| 619 | 'shipping_fax01', |
---|
| 620 | 'shipping_fax02', |
---|
| 621 | 'shipping_fax03', |
---|
| 622 | 'shipping_pref', |
---|
| 623 | 'shipping_zip01', |
---|
| 624 | 'shipping_zip02', |
---|
| 625 | 'shipping_addr01', |
---|
| 626 | 'shipping_addr02', |
---|
| 627 | 'shipping_date_year', |
---|
| 628 | 'shipping_date_month', |
---|
| 629 | 'shipping_date_day', |
---|
| 630 | 'time_id')); |
---|
[19949] | 631 | |
---|
[20180] | 632 | $arrAllShipmentItem = |
---|
| 633 | $objFormParam->getSwapArray(array('shipment_product_class_id', |
---|
| 634 | 'shipment_product_code', |
---|
| 635 | 'shipment_product_name', |
---|
| 636 | 'shipment_classcategory_name1', |
---|
| 637 | 'shipment_classcategory_name2', |
---|
| 638 | 'shipment_price', |
---|
| 639 | 'shipment_quantity')); |
---|
| 640 | $arrShippingValues = array(); |
---|
| 641 | foreach ($arrAllShipping as $shipping_index => $arrShipping) { |
---|
| 642 | $shipping_id = $arrShipping['shipping_id']; |
---|
| 643 | $arrShippingValues[$shipping_index] = $arrShipping; |
---|
[19949] | 644 | |
---|
[20180] | 645 | $arrShippingValues[$shipping_index]['shipping_date'] |
---|
| 646 | = SC_Utils_Ex::sfGetTimestamp($arrShipping['shipping_date_year'], |
---|
| 647 | $arrShipping['shipping_date_month'], |
---|
| 648 | $arrShipping['shipping_date_day']); |
---|
[19963] | 649 | |
---|
[20180] | 650 | // 配送業者IDを取得 |
---|
| 651 | $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); |
---|
[19949] | 652 | |
---|
[20180] | 653 | // 複数配送の場合は配送商品を登録 |
---|
| 654 | if (!SC_Utils_Ex::isBlank($arrAllShipmentItem)) { |
---|
| 655 | $arrShipmentValues = array(); |
---|
[19963] | 656 | |
---|
[20180] | 657 | foreach ($arrAllShipmentItem[$shipping_index] as $key => $arrItem) { |
---|
| 658 | $i = 0; |
---|
| 659 | foreach ($arrItem as $item) { |
---|
| 660 | $arrShipmentValues[$shipping_index][$i][str_replace('shipment_', '', $key)] = $item; |
---|
| 661 | $i++; |
---|
| 662 | } |
---|
[19949] | 663 | } |
---|
[20180] | 664 | $objPurchase->registerShipmentItem($order_id, $shipping_id, |
---|
| 665 | $arrShipmentValues[$shipping_index]); |
---|
[19949] | 666 | } |
---|
| 667 | } |
---|
[20180] | 668 | $objPurchase->registerShipping($order_id, $arrShippingValues, false); |
---|
[15594] | 669 | $objQuery->commit(); |
---|
[20180] | 670 | return $order_id; |
---|
[15594] | 671 | } |
---|
[17293] | 672 | |
---|
[18100] | 673 | /** |
---|
[20180] | 674 | * 受注商品の追加/更新を行う. |
---|
[18100] | 675 | * |
---|
[20180] | 676 | * 小画面で選択した受注商品をフォームに反映させる. |
---|
| 677 | * |
---|
| 678 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 679 | * @return void |
---|
[18100] | 680 | */ |
---|
[20180] | 681 | function doRegisterProduct(&$objFormParam) { |
---|
| 682 | $product_class_id = $objFormParam->getValue('add_product_class_id'); |
---|
| 683 | if (SC_Utils_Ex::isBlank($product_class_id)) { |
---|
| 684 | $product_class_id = $objFormParam->getValue('edit_product_class_id'); |
---|
[20415] | 685 | $changed_no = $objFormParam->getValue('no'); |
---|
[17293] | 686 | } |
---|
[18037] | 687 | |
---|
[20415] | 688 | // 選択済みの商品であれば数量を1増やす |
---|
[20180] | 689 | $exists = false; |
---|
| 690 | $arrExistsProductClassIds = $objFormParam->getValue('product_class_id'); |
---|
| 691 | foreach (array_keys($arrExistsProductClassIds) as $key) { |
---|
| 692 | $exists_product_class_id = $arrExistsProductClassIds[$key]; |
---|
| 693 | if ($exists_product_class_id == $product_class_id) { |
---|
| 694 | $exists = true; |
---|
| 695 | $arrExistsQuantity = $objFormParam->getValue('quantity'); |
---|
| 696 | $arrExistsQuantity[$key]++; |
---|
| 697 | $objFormParam->setValue('quantity', $arrExistsQuantity); |
---|
[19963] | 698 | } |
---|
[18646] | 699 | } |
---|
[19963] | 700 | |
---|
[20180] | 701 | // 新しく商品を追加した場合はフォームに登録 |
---|
[20415] | 702 | // 商品を変更した場合は、該当行を変更 |
---|
[20180] | 703 | if (!$exists) { |
---|
| 704 | $objProduct = new SC_Product(); |
---|
| 705 | $arrProduct = $objProduct->getDetailAndProductsClass($product_class_id); |
---|
| 706 | $arrProduct['quantity'] = 1; |
---|
| 707 | $arrProduct['price'] = $arrProduct['price02']; |
---|
| 708 | $arrProduct['product_name'] = $arrProduct['name']; |
---|
[19963] | 709 | |
---|
[20180] | 710 | $arrUpdateKeys = array('product_id', 'product_class_id', |
---|
| 711 | 'product_type_id', 'point_rate', |
---|
| 712 | 'product_code', 'product_name', |
---|
| 713 | 'classcategory_name1', 'classcategory_name2', |
---|
| 714 | 'quantity', 'price'); |
---|
| 715 | foreach ($arrUpdateKeys as $key) { |
---|
| 716 | $arrValues = $objFormParam->getValue($key); |
---|
[20415] | 717 | if (isset($changed_no)) { |
---|
| 718 | $arrValues[$changed_no] = $arrProduct[$key]; |
---|
| 719 | } else { |
---|
| 720 | $arrValues[] = $arrProduct[$key]; |
---|
| 721 | } |
---|
[20180] | 722 | $objFormParam->setValue($key, $arrValues); |
---|
[19963] | 723 | } |
---|
[20415] | 724 | } elseif (isset($changed_no)) { |
---|
[20416] | 725 | // 変更したが、選択済みの商品だった場合は、変更対象行を削除。 |
---|
[20415] | 726 | $this->doDeleteProduct($changed_no, $objFormParam); |
---|
[19963] | 727 | } |
---|
[17293] | 728 | } |
---|
| 729 | |
---|
[19919] | 730 | /** |
---|
[20180] | 731 | * 受注商品を削除する. |
---|
| 732 | * |
---|
| 733 | * @param integer $delete_no 削除する受注商品の項番 |
---|
| 734 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 735 | * @return void |
---|
[19919] | 736 | */ |
---|
[20180] | 737 | function doDeleteProduct($delete_no, &$objFormParam) { |
---|
| 738 | $arrDeleteKeys = array('product_id', 'product_class_id', |
---|
| 739 | 'product_type_id', 'point_rate', |
---|
| 740 | 'product_code', 'product_name', |
---|
| 741 | 'classcategory_name1', 'classcategory_name2', |
---|
| 742 | 'quantity', 'price'); |
---|
| 743 | foreach ($arrDeleteKeys as $key) { |
---|
| 744 | $arrNewValues = array(); |
---|
| 745 | $arrValues = $objFormParam->getValue($key); |
---|
| 746 | foreach ($arrValues as $index => $val) { |
---|
| 747 | if ($index != $delete_no) { |
---|
| 748 | $arrNewValues[] = $val; |
---|
[18014] | 749 | } |
---|
| 750 | } |
---|
[20180] | 751 | $objFormParam->setValue($key, $arrNewValues); |
---|
[18014] | 752 | } |
---|
[17293] | 753 | } |
---|
| 754 | |
---|
[20180] | 755 | /** |
---|
| 756 | * お届け先を追加する. |
---|
| 757 | * |
---|
| 758 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 759 | * @return void |
---|
| 760 | */ |
---|
| 761 | function addShipping(&$objFormParam) { |
---|
| 762 | $objFormParam->setValue('shipping_quantity', |
---|
| 763 | $objFormParam->getValue('shipping_quantity') + 1); |
---|
| 764 | $arrShippingIds = $objFormParam->getValue('shipping_id'); |
---|
| 765 | $arrShippingIds[] = max($arrShippingIds) + 1; |
---|
| 766 | $objFormParam->setValue('shipping_id', $arrShippingIds); |
---|
[17293] | 767 | } |
---|
| 768 | |
---|
[18068] | 769 | /** |
---|
[20180] | 770 | * 顧客情報をフォームに設定する. |
---|
| 771 | * |
---|
| 772 | * @param integer $customer_id 顧客ID |
---|
| 773 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 774 | * @return void |
---|
[18068] | 775 | */ |
---|
[20180] | 776 | function setCustomerTo($customer_id, &$objFormParam) { |
---|
| 777 | $arrCustomer = SC_Helper_Customer_Ex::sfGetCustomerDataFromId($customer_id); |
---|
| 778 | foreach ($arrCustomer as $key => $val) { |
---|
| 779 | $objFormParam->setValue('order_' . $key, $val); |
---|
[18068] | 780 | } |
---|
[20180] | 781 | $objFormParam->setValue('customer_id', $customer_id); |
---|
[18068] | 782 | } |
---|
[18329] | 783 | |
---|
| 784 | /** |
---|
[20180] | 785 | * アンカーキーを取得する. |
---|
[18329] | 786 | * |
---|
[20180] | 787 | * @param SC_FormParam $objFormParam SC_FormParam インスタンス |
---|
| 788 | * @return アンカーキーの文字列 |
---|
[18329] | 789 | */ |
---|
[20180] | 790 | function getAnchorKey(&$objFormParam) { |
---|
| 791 | $ancor_key = $objFormParam->getValue('anchor_key'); |
---|
| 792 | if (!SC_Utils_Ex::isBlank($ancor_key)) { |
---|
| 793 | return "location.hash='#" . htmlentities(urlencode($ancor_key), ENT_QUOTES) . "'"; |
---|
[18329] | 794 | } |
---|
[20180] | 795 | return ''; |
---|
[19963] | 796 | } |
---|
[15594] | 797 | } |
---|
| 798 | ?> |
---|