Changeset 22493
- Timestamp:
- 2013/02/02 19:25:52 (11 years ago)
- Location:
- branches/version-2_12-dev/data
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/Smarty/templates/admin/order/edit.tpl
r22490 r22493 39 39 var shipping_data = $('input[name^=shipping_name01]').attr('name'); 40 40 var shipping_slt = shipping_data.split("shipping_name01"); 41 41 42 42 var shipping_key = "[0]"; 43 43 if(shipping_slt.length > 1) { … … 82 82 } 83 83 84 $(document).ready(function() { 85 if(<!--{$arrForm.shipping_quantity.value}--> > 1){ 86 $("input[name^='quantity[']").attr("disabled","disabled"); 87 } 88 }); 89 84 90 //--> 85 91 </script> … … 92 98 <input type="hidden" id="add_product_id" name="add_product_id" value="" /> 93 99 <input type="hidden" id="add_product_class_id" name="add_product_class_id" value="" /> 100 <input type="hidden" id="select_shipping_id" name="select_shipping_id" value="" /> 94 101 <input type="hidden" id="edit_product_id" name="edit_product_id" value="" /> 95 102 <input type="hidden" id="edit_product_class_id" name="edit_product_class_id" value="" /> … … 274 281 受注商品情報 275 282 <a class="btn-normal" href="javascript:;" name="recalculate" onclick="fnModeSubmit('recalculate','anchor_key','order_products');">計算結果の確認</a> 276 <a class="btn-normal" href="javascript:;" name="add_product" onclick="win03('<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->order/product_select.php?order_id=<!--{$arrForm.order_id.value|h}-->', 'search', '615', '500'); return false;">商品の追加</a> 283 <!--{if $arrForm.shipping_quantity.value <= 1}--> 284 <a class="btn-normal" href="javascript:;" name="add_product" onclick="win03('<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->order/product_select.php?order_id=<!--{$arrForm.order_id.value|h}-->&shipping_id=<!--{$top_shipping_id}-->', 'search', '615', '500'); return false;">商品の追加</a> 285 <!--{/if}--> 277 286 </h2> 278 287 … … 303 312 <input type="hidden" name="classcategory_name2[<!--{$product_index}-->]" value="<!--{$arrForm.classcategory_name2.value[$product_index]|h}-->" id="classcategory_name2_<!--{$product_index}-->" /> 304 313 <br /> 305 <a class="btn-normal" href="javascript:;" name="change" onclick="win03('<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->order/product_select.php?no=<!--{$product_index}-->&order_id=<!--{$arrForm.order_id.value|h}-->', 'search', '615', '500'); return false;">変更</a> 306 <!--{if count($arrForm.quantity.value) > 1}--> 307 <a class="btn-normal" href="javascript:;" name="delete" onclick="fnSetFormVal('form1', 'delete_no', <!--{$product_index}-->); fnModeSubmit('delete_product','anchor_key','order_products'); return false;">削除</a> 314 <!--{if $arrForm.shipping_quantity.value <= 1}--> 315 <a class="btn-normal" href="javascript:;" name="change" onclick="win03('<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->order/product_select.php?no=<!--{$product_index}-->&order_id=<!--{$arrForm.order_id.value|h}-->&shipping_id=<!--{$top_shipping_id}-->', 'search', '615', '500'); return false;">変更</a> 316 <!--{if count($arrForm.quantity.value) > 1}--> 317 <a class="btn-normal" href="javascript:;" name="delete" onclick="fnSetFormVal('form1', 'delete_no', <!--{$product_index}-->); fnSetFormVal('form1', 'select_shipping_id', '<!--{$top_shipping_id}-->'); fnModeSubmit('delete_product','anchor_key','order_products'); return false;">削除</a> 318 <!--{/if}--> 308 319 <!--{/if}--> 309 320 <input type="hidden" name="product_type_id[<!--{$product_index}-->]" value="<!--{$arrForm.product_type_id.value[$product_index]|h}-->" id="product_type_id_<!--{$product_index}-->" /> … … 429 440 <input type="hidden" name="<!--{$key}-->[<!--{$shipping_index}-->]" value="<!--{$arrShipping[$key]|default:"0"|h}-->" id="<!--{$key}-->_<!--{$shipping_index}-->" /> 430 441 <!--{if $arrForm.shipping_quantity.value > 1}--> 442 <h2>届け先商品情報 <a class="btn-normal" href="javascript:;" name="add_product" onclick="win03('<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->order/product_select.php?order_id=<!--{$arrForm.order_id.value|h}-->&shipping_id=<!--{$shipping_index}-->', 'search', '615', '500'); return false;">商品の追加</a> 443 </h2> 431 444 <!--{assign var=product_quantity value="shipping_product_quantity"}--> 432 445 <input type="hidden" name="<!--{$product_quantity}-->[<!--{$shipping_index}-->]" value="<!--{$arrShipping[$product_quantity]|h}-->" /> … … 459 472 <input type="hidden" name="<!--{$key3}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key3][$item_index]|h}-->" /> 460 473 <!--{$arrShipping[$key1][$item_index]|h}-->/<!--{$arrShipping[$key2][$item_index]|default:"(なし)"|h}-->/<!--{$arrShipping[$key3][$item_index]|default:"(なし)"|h}--> 474 <br /> 475 <a class="btn-normal" href="javascript:;" name="change" onclick="win03('<!--{$smarty.const.ROOT_URLPATH}--><!--{$smarty.const.ADMIN_DIR}-->order/product_select.php?no=<!--{$item_index}-->&order_id=<!--{$arrForm.order_id.value|h}-->&shipping_id=<!--{$shipping_index}-->', 'search', '615', '500'); return false;">変更</a> 476 <!--{if count($arrForm.quantity.value) > 1}--> 477 <a class="btn-normal" href="javascript:;" name="delete" onclick="fnSetFormVal('form1', 'delete_no', <!--{$item_index}-->);fnSetFormVal('form1', 'select_shipping_id', <!--{$shipping_index}-->); fnModeSubmit('delete_product','anchor_key','order_products'); return false;">削除</a> 478 <!--{/if}--> 461 479 </td> 462 480 <td class="right"> … … 467 485 <td class="right"> 468 486 <!--{assign var=key value="shipment_quantity"}--> 469 < !--{$arrShipping[$key][$item_index]|h}-->470 <input type=" hidden" name="<!--{$key}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key][$item_index]|h}-->" />487 <span class="attention"><!--{$arrErr[$key][$shipping_index][$item_index]}--></span> 488 <input type="text" name="<!--{$key}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key][$item_index]|h}-->" size="3" class="box3" maxlength="<!--{$arrForm[$key].length}-->" /> 471 489 </td> 472 490 </tr> … … 474 492 </table> 475 493 <!--{/if}--> 494 <!--{else}--> 495 <!-- 配送先が1つでも、shipment_itemを更新するために必要 --> 496 <!--{assign var=product_quantity value="shipping_product_quantity"}--> 497 <input type="hidden" name="<!--{$product_quantity}-->[<!--{$shipping_index}-->]" value="<!--{$arrShipping[$product_quantity]|h}-->" /> 498 <!--{section name=item loop=$arrShipping.shipment_product_class_id|@count}--> 499 <!--{assign var=item_index value="`$smarty.section.item.index`"}--> 500 <!--{assign var=key value="shipment_product_class_id"}--> 501 <input type="hidden" name="<!--{$key}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key][$item_index]|h}-->" /> 502 <!--{assign var=key value="shipment_product_code"}--> 503 <input type="hidden" name="<!--{$key}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key][$item_index]|h}-->" /> 504 <!--{assign var=key1 value="shipment_product_name"}--> 505 <!--{assign var=key2 value="shipment_classcategory_name1"}--> 506 <!--{assign var=key3 value="shipment_classcategory_name2"}--> 507 <input type="hidden" name="<!--{$key1}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key1][$item_index]|h}-->" /> 508 <input type="hidden" name="<!--{$key2}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key2][$item_index]|h}-->" /> 509 <input type="hidden" name="<!--{$key3}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key3][$item_index]|h}-->" /> 510 <!--{assign var=key value="shipment_price"}--> 511 <input type="hidden" name="<!--{$key}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key][$item_index]|h}-->" /> 512 <!--{assign var=key value="shipment_quantity"}--> 513 <input type="hidden" name="<!--{$key}-->[<!--{$shipping_index}-->][<!--{$item_index}-->]" value="<!--{$arrShipping[$key][$item_index]|h}-->" /> 514 <!--{/section}--> 476 515 <!--{/if}--> 477 516 -
branches/version-2_12-dev/data/Smarty/templates/admin/order/product_select.tpl
r22491 r22493 42 42 var opner_product_class_id = 'add_product_class_id'; 43 43 var tpl_no = '<!--{$tpl_no}-->'; 44 var shipping_id = '<!--{$shipping_id}-->'; 44 45 45 46 if (tpl_no != '') { … … 47 48 opner_product_class_id = 'edit_product_class_id'; 48 49 fm1.getElementById("no").value = escape('<!--{$tpl_no}-->'); 50 } 51 if (shipping_id != '') { 52 fm1.getElementById("select_shipping_id").value = escape('<!--{$shipping_id}-->'); 49 53 } 50 54 if (document.getElementById(class1).type == 'select-one' && class1_id == '__unselected') { … … 136 140 <input name="anchor_key" type="hidden" value="" /> 137 141 <input name="search_pageno" type="hidden" value="" /> 142 <input name="shipping_id" type="hidden" value="<!--{$shipping_id}-->" /> 138 143 <input name="no" type="hidden" value="<!--{$tpl_no|h}-->" /> 139 144 <table class="form"> -
branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
r22490 r22493 67 67 ); 68 68 69 var $arrProductKeys = array( 70 'product_id', 71 'product_class_id', 72 'product_type_id', 73 'point_rate', 74 'product_code', 75 'product_name', 76 'classcategory_name1', 77 'classcategory_name2', 78 'quantity', 79 'price', 80 'tax_rate', 81 'tax_rule' 82 ); 83 69 84 // }}} 70 85 // {{{ functions … … 166 181 $objFormParam->setParam($_POST); 167 182 $objFormParam->convParam(); 183 //複数配送時に各商品の総量を設定 184 $this->setProductsQuantity($objFormParam); 168 185 $this->arrErr = $this->lfCheckError($objFormParam); 169 186 if (SC_Utils_Ex::isBlank($this->arrErr)) { … … 181 198 $objFormParam->setParam($_POST); 182 199 $objFormParam->convParam(); 200 //複数配送時に各商品の総量を設定 201 $this->setProductsQuantity($objFormParam); 183 202 $this->arrErr = $this->lfCheckError($objFormParam); 184 203 if (SC_Utils_Ex::isBlank($this->arrErr)) { … … 204 223 $objFormParam->setParam($_POST); 205 224 $objFormParam->convParam(); 225 //複数配送時に各商品の総量を設定 226 $this->setProductsQuantity($objFormParam); 206 227 $this->arrErr = $this->lfCheckError($objFormParam); 207 228 break; … … 213 234 $delete_no = $objFormParam->getValue('delete_no'); 214 235 $this->doDeleteProduct($delete_no, $objFormParam); 236 //複数配送時に各商品の総量を設定 237 $this->setProductsQuantity($objFormParam); 215 238 $this->arrErr = $this->lfCheckError($objFormParam); 216 239 break; … … 221 244 $objFormParam->convParam(); 222 245 $this->doRegisterProduct($objFormParam); 246 //複数配送時に各商品の総量を設定 247 $this->setProductsQuantity($objFormParam); 223 248 $this->arrErr = $this->lfCheckError($objFormParam); 224 249 break; … … 273 298 } 274 299 275 $this->arrForm = $objFormParam->getFormParamList();300 $this->arrForm = $objFormParam->getFormParamList(); 276 301 $this->arrAllShipping = $objFormParam->getSwapArray(array_merge($this->arrShippingKeys, $this->arrShipmentItemKeys)); 277 $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id')); 302 $this->top_shipping_id = array_shift((array_keys($this->arrAllShipping))); 303 $this->arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id')); 278 304 $this->tpl_onload .= $this->getAnchorKey($objFormParam); 279 305 if ($arrValuesBefore['payment_id']) 280 306 $this->arrPayment[$arrValuesBefore['payment_id']] = $arrValuesBefore['payment_method']; 281 282 307 } 283 308 … … 333 358 $objFormParam->addParam('対応状況', 'status', INT_LEN, 'n', array('EXIST_CHECK', 'MAX_LENGTH_CHECK', 'NUM_CHECK')); 334 359 $objFormParam->addParam('お支払方法名称', 'payment_method'); 360 335 361 336 362 // 受注詳細情報 … … 407 433 $objFormParam->addParam('追加商品規格ID', 'add_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 408 434 $objFormParam->addParam('修正商品規格ID', 'edit_product_class_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 435 $objFormParam->addParam('対象届け先ID', 'select_shipping_id', INT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 409 436 $objFormParam->addParam('アンカーキー', 'anchor_key', STEXT_LEN, 'KVa', array('SPTAB_CHECK', 'MAX_LENGTH_CHECK')); 410 437 } … … 744 771 745 772 $arrDelivTime = $objPurchase->getDelivTime($objFormParam->getValue('deliv_id')); 746 773 //商品単価を複数配送にも適応 747 774 $arrShippingValues = array(); 775 $arrIsNotQuantityUp = array(); 748 776 foreach ($arrAllShipping as $shipping_index => $arrShipping) { 749 777 $shipping_id = $arrShipping['shipping_id']; … … 755 783 $arrShipping['shipping_date_day']); 756 784 757 //商品単価 、数量を複数配送にも反映する785 //商品単価を複数配送にも反映する 758 786 foreach ($arrDetail as $product_detail) { 759 787 foreach ($arrAllShipmentItem[$shipping_index]['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { 760 788 if($product_detail['product_class_id'] == $shipment_product_class_id){ 761 789 $arrAllShipmentItem[$shipping_index]['shipment_price'][$relation_index] = $product_detail['price']; 762 foreach ($arrStockData as $arrStock) {763 //数量は先頭の届け先のみ増加764 if($arrStock['product_class_id'] == $shipment_product_class_id && $arrIsNotQuantityUp[$shipment_product_class_id] != true){765 $arrIsNotQuantityUp[$shipment_product_class_id] = true;766 $arrAllShipmentItem[$shipping_index]['shipment_quantity'][$relation_index] -= $arrStock['quantity'];767 break;768 }769 }770 790 } 771 791 } 772 792 } 773 774 793 // 配送業者IDを取得 775 794 $arrShippingValues[$shipping_index]['deliv_id'] = $objFormParam->getValue('deliv_id'); … … 793 812 } 794 813 } 814 795 815 $objPurchase->registerShipping($order_id, $arrShippingValues, false); 796 816 $objQuery->commit(); … … 811 831 $product_class_id = $objFormParam->getValue('edit_product_class_id'); 812 832 $changed_no = $objFormParam->getValue('no'); 813 } 814 // FXIME バリデーションを通さず $objFormParam の値で DB 問い合わせしている。(管理機能ため、さほど問題は無いと思うものの…) 815 816 // 商品規格IDが指定されていない場合、例外エラーを発生 817 if (strlen($product_class_id) === 0) { 818 trigger_error('商品規格指定なし', E_USER_ERROR); 819 } 820 821 // 選択済みの商品であれば数量を1増やす 822 $exists = false; 823 $arrExistsProductClassIds = $objFormParam->getValue('product_class_id'); 824 foreach ($arrExistsProductClassIds as $key => $value) { 825 $exists_product_class_id = $arrExistsProductClassIds[$key]; 826 if ($exists_product_class_id == $product_class_id) { 827 $exists = true; 828 $exists_no = $key; 829 $arrExistsQuantity = $objFormParam->getValue('quantity'); 830 $arrExistsQuantity[$key]++; 831 $objFormParam->setValue('quantity', $arrExistsQuantity); 832 } 833 } 834 835 // 新しく商品を追加した場合はフォームに登録 836 // 商品を変更した場合は、該当行を変更 837 if (!$exists) { 838 $objProduct = new SC_Product_Ex(); 839 $arrProduct = $objProduct->getDetailAndProductsClass($product_class_id); 840 841 // 一致する商品規格がない場合、例外エラーを発生 842 if (empty($arrProduct)) { 843 trigger_error('商品規格一致なし', E_USER_ERROR); 844 } 845 846 $arrProduct['quantity'] = 1; 847 $arrProduct['price'] = $arrProduct['price02']; 848 $arrProduct['tax_rate'] = $objFormParam->getValue('order_tax_rate') == '' ? $this->arrInfo['tax'] : $objFormParam->getValue('order_tax_rate'); 849 $arrProduct['tax_rule'] = $objFormParam->getValue('order_tax_rule') == '' ? $this->arrInfo['tax_rule'] : $objFormParam->getValue('order_tax_rule'); 850 $arrProduct['product_name'] = $arrProduct['name']; 851 852 $arrUpdateKeys = array( 853 'product_id', 'product_class_id', 'product_type_id', 'point_rate', 854 'product_code', 'product_name', 'classcategory_name1', 'classcategory_name2', 855 'quantity', 'price', 'tax_rate', 'tax_rule' 856 ); 857 foreach ($arrUpdateKeys as $key) { 858 $arrValues = $objFormParam->getValue($key); 859 // FIXME getValueで文字列が返る場合があるので配列であるかをチェック 860 if (!is_array($arrValues)) { 861 $arrValues = array(); 833 $this->shipmentEditProduct($objFormParam, $product_class_id, $changed_no); 834 }else{ 835 $this->shipmentAddProduct($objFormParam, $product_class_id); 836 } 837 } 838 839 /** 840 * 受注商品を削除する. 841 * 842 * @param integer $delete_no 削除する受注商品の項番 843 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 844 * @return void 845 */ 846 function doDeleteProduct($delete_no, &$objFormParam) { 847 848 $select_shipping_id = $objFormParam->getValue('select_shipping_id'); 849 850 //変更前のproduct_class_idが他の届け先にも存在するか 851 $arrPreShipmentProductClassIds = $objFormParam->getValue('shipment_product_class_id'); 852 $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); 853 $delete_product_class_id = $arrPreShipmentProductClassIds[$select_shipping_id][$delete_no]; 854 855 //配送先データ削除 856 $arrNewShipments = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $delete_no); 857 $objFormParam->setParam($arrNewShipments); 858 859 $is_product_delete = true; 860 foreach ($arrNewShipments['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { 861 foreach ($arrShipmentProductClassIds as $relation_index => $shipment_product_class_id) { 862 if(in_array($delete_product_class_id, $arrShipmentProductClassIds)){ 863 $is_product_delete = false; 864 break; 862 865 } 863 864 if (isset($changed_no)) { 865 $arrValues[$changed_no] = $arrProduct[$key]; 866 } else { 867 $added_no = 0; 868 if (is_array($arrExistsProductClassIds)) { 869 $added_no = count($arrExistsProductClassIds); 870 } 871 $arrValues[$added_no] = $arrProduct[$key]; 872 } 873 $objFormParam->setValue($key, $arrValues); 874 } 875 } elseif (isset($changed_no) && $exists_no != $changed_no) { 876 // 変更したが、選択済みの商品だった場合は、変更対象行を削除。 877 $this->doDeleteProduct($changed_no, $objFormParam); 878 } 879 } 880 881 /** 882 * 受注商品を削除する. 883 * 884 * @param integer $delete_no 削除する受注商品の項番 885 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 886 * @return void 887 */ 888 function doDeleteProduct($delete_no, &$objFormParam) { 889 $arrDeleteKeys = array( 890 'product_id', 'product_class_id', 'product_type_id', 'point_rate', 891 'product_code', 'product_name', 'classcategory_name1', 'classcategory_name2', 892 'quantity', 'price', 'tax_rate', 'tax_rule' 893 ); 894 foreach ($arrDeleteKeys as $key) { 895 $arrNewValues = array(); 896 $arrValues = $objFormParam->getValue($key); 897 foreach ($arrValues as $index => $val) { 898 if ($index != $delete_no) { 899 $arrNewValues[] = $val; 900 } 901 } 902 $objFormParam->setValue($key, $arrNewValues); 866 } 867 } 868 869 //商品情報から削除 870 if($is_product_delete){ 871 $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $delete_product_class_id, $this->arrProductKeys); 903 872 } 904 873 } … … 949 918 return ''; 950 919 } 920 921 /** 922 * 商品を追加 923 * 924 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 925 * @param integer $add_product_class_id 追加商品規格ID 926 * @return void 927 */ 928 function shipmentAddProduct(&$objFormParam, $add_product_class_id){ 929 930 //複数配送に商品情報追加 931 $select_shipping_id = $objFormParam->getValue('select_shipping_id'); 932 933 //届け先に選択済みの商品がある場合 934 $arrShipmentProducts = $this->getShipmentProducts($objFormParam); 935 936 if(in_array($add_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])){ 937 foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { 938 if($shipment_product_class_id == $add_product_class_id){ 939 $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index]++; 940 break; 941 } 942 } 943 }else{ 944 945 //届け先に選択商品がない場合 946 $objProduct = new SC_Product_Ex(); 947 $arrAddProductInfo = $objProduct->getDetailAndProductsClass($add_product_class_id); 948 949 $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][] = $add_product_class_id; 950 $arrShipmentProducts['shipment_product_code'][$select_shipping_id][] = $arrAddProductInfo['product_code']; 951 $arrShipmentProducts['shipment_product_name'][$select_shipping_id][] = $arrAddProductInfo['name']; 952 $arrShipmentProducts['shipment_price'][$select_shipping_id][] = $arrAddProductInfo['price02']; 953 $arrShipmentProducts['shipment_quantity'][$select_shipping_id][] = 1; 954 955 //受注商品情報に追加 956 $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); 957 $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $add_product_class_id, $arrAddProductInfo); 958 $objFormParam->setParam($arrProducts); 959 } 960 $objFormParam->setParam($arrShipmentProducts); 961 } 962 963 /** 964 * 商品を変更 965 * 966 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 967 * @param integer $add_product_class_id 変更商品規格ID 968 * @param integer $change_no 変更対象 969 * @return void 970 */ 971 function shipmentEditProduct(&$objFormParam, $edit_product_class_id, $change_no){ 972 $arrPreProductClassIds = $objFormParam->getValue('product_class_id'); 973 $select_shipping_id = $objFormParam->getValue('select_shipping_id'); 974 975 $arrShipmentProducts = $this->getShipmentProducts($objFormParam); 976 977 //既にあるデータは1つだけ数量を1増やす 978 $pre_shipment_product_class_id = $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id][$change_no]; 979 if($pre_shipment_product_class_id == $edit_product_class_id) { 980 $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$change_no] ++; 981 }elseif(in_array($edit_product_class_id, $arrShipmentProducts['shipment_product_class_id'][$select_shipping_id])){ 982 //配送先データ削除 983 $arrShipmentProducts = $this->deleteShipment($objFormParam, $this->arrShipmentItemKeys , $select_shipping_id, $change_no); 984 foreach ($arrShipmentProducts['shipment_product_class_id'][$select_shipping_id] as $relation_index => $shipment_product_class_id) { 985 if($shipment_product_class_id == $edit_product_class_id){ 986 $arrShipmentProducts['shipment_quantity'][$select_shipping_id][$relation_index] ++; 987 break; 988 } 989 } 990 }else{ 991 $objProduct = new SC_Product_Ex(); 992 $arrAddProductInfo = $objProduct->getDetailAndProductsClass($edit_product_class_id); 993 994 //上書き 995 $this->changeShipmentProducts($arrShipmentProducts, $arrAddProductInfo, $select_shipping_id, $change_no); 996 //受注商品情報に追加 997 $arrProducts = $this->checkInsertOrderProducts($objFormParam, $arrPreProductClassIds, $edit_product_class_id, $arrAddProductInfo); 998 $objFormParam->setParam($arrProducts); 999 } 1000 $objFormParam->setParam($arrShipmentProducts); 1001 1002 //更新のみの場合、全配列を持っていないので、新しい配列を取得 1003 $arrNewShipmentProducts = $this->getShipmentProducts($objFormParam); 1004 $is_product_delete = true; 1005 //変更前のproduct_class_idが他の届け先にも存在するか 1006 foreach ($arrNewShipmentProducts['shipment_product_class_id'] as $shipping_id => $arrShipmentProductClassIds) { 1007 if(in_array($pre_shipment_product_class_id, $arrShipmentProductClassIds)){ 1008 $is_product_delete = false; 1009 break; 1010 } 1011 } 1012 1013 //商品情報から削除 1014 if($is_product_delete){ 1015 $this->checkDeleteProducts($objFormParam, $arrPreProductClassIds, $pre_shipment_product_class_id, $this->arrProductKeys); 1016 } 1017 } 1018 1019 /** 1020 * 複数配送のパラメータを取り出す 1021 * 1022 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 1023 * @return array 配送データ 1024 */ 1025 function getShipmentProducts(&$objFormParam){ 1026 $arrShipmentProducts['shipment_product_class_id'] = $objFormParam->getValue('shipment_product_class_id'); 1027 $arrShipmentProducts['shipment_product_code'] = $objFormParam->getValue('shipment_product_code'); 1028 $arrShipmentProducts['shipment_product_name'] = $objFormParam->getValue('shipment_product_name'); 1029 $arrShipmentProducts['shipment_classcategory_name1'] = $objFormParam->getValue('shipment_classcategory_name1'); 1030 $arrShipmentProducts['shipment_classcategory_name2'] = $objFormParam->getValue('shipment_classcategory_name2'); 1031 $arrShipmentProducts['shipment_price'] = $objFormParam->getValue('shipment_price'); 1032 $arrShipmentProducts['shipment_quantity'] = $objFormParam->getValue('shipment_quantity'); 1033 1034 return $arrShipmentProducts; 1035 } 1036 1037 /** 1038 * 変更対象のデータを上書きする 1039 * 1040 * @param array $arrShipmentProducts 変更対象配列 1041 * @param array $arrProductInfo 上書きデータ 1042 * @param integer $shipping_id 配送先ID 1043 * @param array $no 変更対象 1044 * @return void 1045 */ 1046 function changeShipmentProducts(&$arrShipmentProducts, $arrProductInfo, $shipping_id, $no){ 1047 $arrShipmentProducts['shipment_product_class_id'][$shipping_id][$no] = $arrProductInfo['product_class_id']; 1048 $arrShipmentProducts['shipment_product_code'][$shipping_id][$no] = $arrProductInfo['product_code']; 1049 $arrShipmentProducts['shipment_product_name'][$shipping_id][$no] = $arrProductInfo['name']; 1050 $arrShipmentProducts['shipment_classcategory_name1'][$shipping_id][$no] = $arrProductInfo['classcategory_name1']; 1051 $arrShipmentProducts['shipment_classcategory_name2'][$shipping_id][$no] = $arrProductInfo['classcategory_name2']; 1052 $arrShipmentProducts['shipment_price'][$shipping_id][$no] = $arrProductInfo['price02']; 1053 $arrShipmentProducts['shipment_quantity'][$shipping_id][$no] = 1; 1054 } 1055 1056 /** 1057 * 商品側の総量計算&セット 1058 * 1059 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 1060 * @return void 1061 */ 1062 function setProductsQuantity(&$objFormParam){ 1063 $arrShipmentsItems = $objFormParam->getSwapArray(array('shipment_product_class_id','shipment_quantity')); 1064 foreach ($arrShipmentsItems as $arritems) { 1065 foreach ($arritems['shipment_product_class_id'] as $relation_index => $shipment_product_class_id) { 1066 $arrUpdateQuantity[$shipment_product_class_id] += $arritems['shipment_quantity'][$relation_index]; 1067 } 1068 } 1069 1070 $arrProductsClass = $objFormParam->getValue('product_class_id'); 1071 $arrProductsQuantity = $objFormParam->getValue('quantity'); 1072 foreach ($arrProductsClass as $relation_key => $product_class_id) { 1073 $arrQuantity['quantity'][$relation_key] = $arrUpdateQuantity[$product_class_id]; 1074 } 1075 $objFormParam->setParam($arrQuantity); 1076 } 1077 1078 /** 1079 * 削除対象の確認、削除をする 1080 * 1081 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 1082 * @param array $arrProductClassIds 削除対象配列の商品規格ID 1083 * @param integer $delete_product_class_id 削除商品規格ID 1084 * @param array $arrDeleteKeys 削除項目 1085 * @return void 1086 */ 1087 function checkDeleteProducts(&$objFormParam, $arrProductClassIds, $delete_product_class_id, $arrDeleteKeys){ 1088 foreach ($arrProductClassIds as $relation_index => $product_class_id) { 1089 //product_class_idの重複はないので、1つ削除したら完了 1090 if($product_class_id == $delete_product_class_id){ 1091 foreach ($arrDeleteKeys as $delete_key) { 1092 $arrProducts = $objFormParam->getValue($delete_key); 1093 foreach ($arrProducts as $index => $product_info) { 1094 if($index != $relation_index){ 1095 $arrUpdateParams[$delete_key][] = $product_info; 1096 } 1097 } 1098 $objFormParam->setParam($arrUpdateParams); 1099 } 1100 break; 1101 } 1102 } 1103 } 1104 1105 /** 1106 * 配送先商品の削除の削除 1107 * 1108 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 1109 * @param array $arrShipmentDeleteKeys 削除項目 1110 * @param integer $delete_shipping_id 削除配送ID 1111 * @param array $delete_no 削除対象 1112 * @return void 1113 */ 1114 function deleteShipment(&$objFormParam, $arrShipmentDeletKeys, $delete_shipping_id, $delete_no){ 1115 foreach ($arrShipmentDeletKeys as $delete_key) { 1116 $arrShipments = $objFormParam->getValue($delete_key); 1117 foreach ($arrShipments as $shipp_id => $arrKeyData){ 1118 foreach ($arrKeyData as $relation_index => $shipment_info) { 1119 if($relation_index != $delete_no || $shipp_id != $delete_shipping_id){ 1120 $arrUpdateParams[$delete_key][$shipp_id][] = $shipment_info; 1121 } 1122 } 1123 } 1124 } 1125 //$objFormParam->setParam($arrUpdateParams); 1126 return $arrUpdateParams; 1127 } 1128 1129 1130 /** 1131 * 受注商品一覧側に商品を追加 1132 * 1133 * @param SC_FormParam $objFormParam SC_FormParam インスタンス 1134 * @param array $arrProductClassIds 対象配列の商品規格ID 1135 * @param integer $indert_product_class_id 追加商品規格ID 1136 * @param array $arrAddProductInfo 追加データ 1137 * @return array $arrAddProducts 更新データ 1138 */ 1139 function checkInsertOrderProducts(&$objFormParam, $arrProductClassIds, $insert_product_class_id, $arrAddProductInfo){ 1140 if(!in_array($insert_product_class_id, $arrProductClassIds)){ 1141 $arrAddProductInfo['product_name'] = ($arrAddProductInfo['product_name'])? $arrAddProductInfo['product_name']:$arrAddProductInfo['name']; 1142 $arrAddProductInfo['price'] = ($arrAddProductInfo['price'])? $arrAddProductInfo['price']:$arrAddProductInfo['price02']; 1143 $arrAddProductInfo['quantity'] = 1; 1144 $arrAddProductInfo['tax_rate'] = ($objFormParam->getValue('order_tax_rate') == '')? $this->arrInfo['tax'] :$objFormParam->getValue('order_tax_rate'); 1145 $arrAddProductInfo['tax_rule'] = ($objFormParam->getValue('order_tax_rule') == '')? $this->arrInfo['tax_rule']:$objFormParam->getValue('order_tax_rule'); 1146 foreach ($this->arrProductKeys as $insert_key) { 1147 $arrAddProducts[$insert_key] = $objFormParam->getValue($insert_key); 1148 $arrAddProducts[$insert_key][] = $arrAddProductInfo[$insert_key]; 1149 } 1150 return $arrAddProducts; 1151 }else{ 1152 //受注商品の数量は、複数配送側の集計で出しているので、重複しても数量を増やさない。 1153 return null; 1154 } 1155 } 951 1156 } -
branches/version-2_12-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php
r22206 r22493 78 78 79 79 $this->tpl_no = $this->getNo(array($_GET,$_POST)); 80 $this->shipping_id = $this->getShippingId(array($_GET,$_POST)); 80 81 81 82 switch ($this->getMode()) { … … 252 253 253 254 /** 255 * リクエストパラメーター shipping_id を取ってくる。 256 * @param unknown_type $globalParams 257 */ 258 function getShippingId($globalParams) { 259 foreach ($globalParams as $params) { 260 if (isset($params['shipping_id']) && $params['shipping_id']!= '') { 261 return intval($params['shipping_id']); 262 } 263 } 264 return null; 265 } 266 267 268 /** 254 269 * 取得している並び順で並び替え 255 270 * @param $arrProduct_id … … 286 301 $objFormParam->addParam('商品コード', 'search_product_code', LTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK', 'SPTAB_CHECK')); 287 302 $objFormParam->addParam('フッター', 'footer', LTEXT_LEN, 'KVa', array('MAX_LENGTH_CHECK', 'SPTAB_CHECK')); 303 $objFormParam->addParam('届け先ID', 'shipping_id', LTEXT_LEN, 'n', array('MAX_LENGTH_CHECK', 'NUM_CHECK')); 288 304 } 289 305 }
Note: See TracChangeset
for help on using the changeset viewer.