Changeset 18527


Ignore:
Timestamp:
2010/02/02 11:10:57 (12 years ago)
Author:
nanasess
bzr:base-revision:
ohkouchi@loop-az.jp-20100201111114-927czga31dyj225a
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/Smarty/templates/default/admin/order/edit.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Forder%2Fedit.tpl
data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php 15594@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Forder%2FLC_Page_Admin_Order_Edit.php
bzr:mapping-version:
v4
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20100202021053-53f6wpklom2hsuoe
bzr:revno:
1897
bzr:revprop:branch-nick:
branches/version-2_4
bzr:root:
branches/version-2_4
bzr:text-parents:

data/Smarty/templates/default/admin/order/edit.tpl svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_4:18521
data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_4:18523
bzr:timestamp:
2010-02-02 11:10:53.976000071 +0900
bzr:user-agent:
bzr2.0.4+bzr-svn1.0.1
svn:original-date:
2010-02-02T02:10:53.976000Z
Message:

merged r18478:18479

  • 受注管理での編集が在庫に反映されない(#507)
Location:
branches/version-2_4/data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_4/data/Smarty/templates/default/admin/order/edit.tpl

    r18521 r18527  
    407407                                <input type="button" name="add_product" value="商品の追加" onclick="win03('<!--{$smarty.const.SITE_URL}-->admin/order/product_select.php<!--{if $tpl_order_id}-->?order_id=<!--{$tpl_order_id}--><!--{/if}-->', 'search', '500', '500'); " /> 
    408408                                <br /> 
     409<!--{** 
    409410                                <span class="red">(商品の追加、及び数量の変更に伴う在庫数の変更は手動にてお願いします。)</span> 
     411**}--> 
    410412                                <br /> 
    411413                                <span class="red12"><!--{$arrErr.product_id}--></span> 
  • branches/version-2_4/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php

    r18523 r18527  
    112112        $objDb = new SC_Helper_DB_Ex(); 
    113113        $objDate = new SC_Date(1901);  
    114           $this->arrYearDelivDate = $objDate->getYear('', date('Y'), '');  
    115             $this->arrMonthDelivDate = $objDate->getMonth(true);  
    116             $this->arrDayDelivDate = $objDate->getDay(true); 
     114        $this->arrYearDelivDate = $objDate->getYear('', date('Y'), ''); 
     115        $this->arrMonthDelivDate = $objDate->getMonth(true); 
     116        $this->arrDayDelivDate = $objDate->getDay(true); 
    117117        $arrInfo = $objSiteInfo->data; 
    118118 
     
    381381        $this->objFormParam->addParam("お届け時間ID", "deliv_time_id", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
    382382        $this->objFormParam->addParam("対応状況", "status", INT_LEN, "n", array("EXIST_CHECK", "MAX_LENGTH_CHECK", "NUM_CHECK")); 
    383         $this->objFormParam->addParam("配達日", "deliv_date", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    384           $this->objFormParam->addParam("お届け日(年)", "deliv_date_year", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));  
    385             $this->objFormParam->addParam("お届け日(月)", "deliv_date_month", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));  
    386             $this->objFormParam->addParam("お届け日(日)", "deliv_date_day", INT_LEN, "n", array("MAX_LENGTH_CHECK", "NUM_CHECK"));  
     383        $this->objFormParam->addParam("お届け日", "deliv_date", STEXT_LEN, "KVa", array("SPTAB_CHECK", "MAX_LENGTH_CHECK")); 
    387384        $this->objFormParam->addParam("お支払方法名称", "payment_method"); 
    388385        $this->objFormParam->addParam("お届け時間", "deliv_time"); 
     
    427424            $this->objFormParam->setValue('total_point', $total_point); 
    428425            $this->objFormParam->setValue('point', $point); 
    429             $delivDate = split(" ", $arrRet[0]["deliv_date"]);  
    430               $delivDate = split("-", $delivDate[0]);  
    431               $this->objFormParam->setValue('deliv_date_year', $delivDate[0]);  
    432               $this->objFormParam->setValue('deliv_date_month', isset($delivDate[1]) ? $delivDate[1] : "");  
    433               $this->objFormParam->setValue('deliv_date_day', isset($delivDate[2]) ? $delivDate[2] : ""); 
     426            $delivDate = split(" ", $arrRet[0]["deliv_date"]); 
     427            $delivDate = split("-", $delivDate[0]); 
     428            $this->objFormParam->setValue('deliv_date_year', $delivDate[0]); 
     429            $this->objFormParam->setValue('deliv_date_month', isset($delivDate[1]) ? $delivDate[1] : ""); 
     430            $this->objFormParam->setValue('deliv_date_day', isset($delivDate[2]) ? $delivDate[2] : ""); 
    434431            $this->arrForm = $arrRet[0]; 
    435432 
     
    603600        $objQuery->query($sql, $arrUpdData); 
    604601 
     602        $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2")); 
     603 
     604 
     605        // 変更しようとしている商品情報とDBに登録してある商品情報を比較することで、更新すべき数量を計算 
     606        $max = count($arrDetail); 
     607        $k = 0; 
     608        $arrStockData = array(); 
     609        for($i = 0; $i < $max; $i++) { 
     610            if (!empty($arrDetail[$i]['product_id'])) { 
     611                $arrPreDetail = $objQuery->select('*', "dtb_order_detail", "order_id = ? AND product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?", array($order_id, $arrDetail[$i]['product_id'], $arrDetail[$i]['classcategory_id1'], $arrDetail[$i]['classcategory_id2'])); 
     612                if (!empty($arrPreDetail) && $arrPreDetail[0]['quantity'] != $arrDetail[$i]['quantity']) { 
     613                    // 数量が変更された商品 
     614                    $arrStockData[$k]['product_id'] = $arrDetail[$i]['product_id']; 
     615                    $arrStockData[$k]['classcategory_id1'] = $arrDetail[$i]['classcategory_id1']; 
     616                    $arrStockData[$k]['classcategory_id2'] = $arrDetail[$i]['classcategory_id2']; 
     617                    $arrStockData[$k]['quantity'] = $arrPreDetail[0]['quantity'] - $arrDetail[$i]['quantity']; 
     618                    ++$k; 
     619                } elseif (empty($arrPreDetail)) { 
     620                    // 新しく追加された商品 もしくは 違う商品に変更された商品 
     621                    $arrStockData[$k]['product_id'] = $arrDetail[$i]['product_id']; 
     622                    $arrStockData[$k]['classcategory_id1'] = $arrDetail[$i]['classcategory_id1']; 
     623                    $arrStockData[$k]['classcategory_id2'] = $arrDetail[$i]['classcategory_id2']; 
     624                    $arrStockData[$k]['quantity'] = -$arrDetail[$i]['quantity']; 
     625                    ++$k; 
     626                } 
     627                $objQuery->delete("dtb_order_detail", "order_id = ? AND product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?", array($order_id, $arrDetail[$i]['product_id'], $arrDetail[$i]['classcategory_id1'], $arrDetail[$i]['classcategory_id2'])); 
     628            } 
     629        } 
     630 
     631        // 上記の新しい商品のループでDELETEされなかった商品は、注文より削除された商品 
     632        $arrPreDetail = $objQuery->select('*', "dtb_order_detail", "order_id = ?", array($order_id)); 
     633        foreach ($arrPreDetail AS $key=>$val) { 
     634            $arrStockData[$k]['product_id'] = $val['product_id']; 
     635            $arrStockData[$k]['classcategory_id1'] = $val['classcategory_id1']; 
     636            $arrStockData[$k]['classcategory_id2'] = $val['classcategory_id2']; 
     637            $arrStockData[$k]['quantity'] = $val['quantity']; 
     638            ++$k; 
     639        } 
     640 
     641        // 受注詳細データの初期化 
     642        $objQuery->delete("dtb_order_detail", $where, array($order_id)); 
     643 
     644 
    605645        // 受注詳細データの更新 
    606         $arrDetail = $this->objFormParam->getSwapArray(array("product_id", "product_code", "product_name", "price", "quantity", "point_rate", "classcategory_id1", "classcategory_id2", "classcategory_name1", "classcategory_name2")); 
    607         $objQuery->delete("dtb_order_detail", $where, array($order_id)); 
    608  
    609  
    610646        $max = count($arrDetail); 
    611647        for($i = 0; $i < $max; $i++) { 
     
    625661        } 
    626662 
     663        // 在庫数調整 
     664        $status = $sqlval['status']; 
     665        if (ORDER_DELIV != $status && ORDER_CANCEL != $status) { 
     666            $stock_sql = "UPDATE dtb_products_class SET stock = stock + ? WHERE product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?;"; 
     667            foreach ($arrStockData AS $key=>$val) { 
     668                $stock_sqlval = array(); 
     669                $stock_sqlval[] = $val['quantity']; 
     670                $stock_sqlval[] = $val['product_id']; 
     671                $stock_sqlval[] = $val['classcategory_id1']; 
     672                $stock_sqlval[] = $val['classcategory_id2']; 
     673 
     674                $objQuery->query($stock_sql, $stock_sqlval); 
     675            } 
     676        } 
    627677 
    628678        $objQuery->commit(); 
     
    712762            $sqlval['classcategory_name1'] = $arrDetail[$i]['classcategory_name1']; 
    713763            $sqlval['classcategory_name2'] = $arrDetail[$i]['classcategory_name2']; 
     764 
    714765            $objQuery->insert("dtb_order_detail", $sqlval); 
     766 
     767 
     768            // 在庫数減少処理 
     769            // 現在の実在庫数取得 
     770            $pre_stock = $objQuery->getone("SELECT stock FROM dtb_products_class WHERE product_id = ? AND classcategory_id1 = ?  AND classcategory_id2 = ?", array($arrDetail[$i]['product_id'], $arrDetail[$i]['classcategory_id1'], $arrDetail[$i]['classcategory_id2'])); 
     771 
     772            $stock_sqlval = array(); 
     773            $stock_sqlval['stock'] = intval($pre_stock - $arrDetail[$i]['quantity']); 
     774            if ($stock_sqlval['stock'] === 0) { 
     775                $stock_sqlval['stock'] = '0'; 
     776            } 
     777 
     778            $st_params = array(); 
     779            $st_params[] = $arrDetail[$i]['product_id']; 
     780            $st_params[] = $arrDetail[$i]['classcategory_id1']; 
     781            $st_params[] = $arrDetail[$i]['classcategory_id2']; 
     782 
     783            $objQuery->update("dtb_products_class", $stock_sqlval, 'product_id = ? AND classcategory_id1 = ? AND classcategory_id2 = ?', $st_params); 
    715784        } 
    716785        $objQuery->commit(); 
Note: See TracChangeset for help on using the changeset viewer.