Ignore:
Timestamp:
2011/03/10 23:23:15 (13 years ago)
Author:
nanasess
bzr:base-revision:
svn-v4:1e3b908f-19a9-db11-a64c-001125224ba8:branches/version-2_5-dev:20594
bzr:committer:
Kentaro Ohkouchi <ohkouchi@loop-az.jp>
bzr:file-ids:

data/Smarty/templates/admin/products/product_class.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fproducts%2Fproduct_class.tpl
data/Smarty/templates/admin/products/product_class_confirm.tpl 15732@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2FSmarty%2Ftemplates%2Fdefault%2Fadmin%2Fproducts%2Fproduct_class_confirm.tpl
data/class/SC_Product.php 18277@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fcomu-ver2%2Fdata%2Fclass%2FSC_Product.php
data/class/helper/SC_Helper_DB.php 15176@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fhelper%2FSC_Helper_DB.php
data/class/pages/admin/products/LC_Page_Admin_Products.php 15342@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fproducts%2FLC_Page_Admin_Products.php
data/class/pages/admin/products/LC_Page_Admin_Products_ClassCategory.php 15486@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fproducts%2FLC_Page_Admin_Products_ClassCategory.php
data/class/pages/admin/products/LC_Page_Admin_Products_ProductClass.php 15559@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fadmin%2Fproducts%2FLC_Page_Admin_Products_ProductClass.php
data/class/pages/products/LC_Page_Products_List.php 15154@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fdata%2Fclass%2Fpages%2Fproducts%2FLC_Page_Products_List.php
html/install/sql/insert_data.sql 15078@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Ffeature-module-update%2Fhtml%2Finstall%2Fsql%2Finsert_data.sql
html/user_data/packages/admin/js/admin.js 18900@1e3b908f-19a9-db11-a64c-001125224ba8:branches%2Fversion-2_5-dev%2Fhtml%2Fuser_data%2Fpackages%2Fadmin%2Fjs%2Fadmin.js
bzr:mapping-version:
v4
bzr:merge:

ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
bzr:repository-uuid:
1e3b908f-19a9-db11-a64c-001125224ba8
bzr:revision-id:
ohkouchi@loop-az.jp-20110310142305-qjs7yo89ouuc2kyb
bzr:revno:
3322
bzr:revprop:branch-nick:
branches/version-2_5-dev
bzr:root:
branches/version-2_5-dev
bzr:text-revisions:

data/Smarty/templates/admin/products/product_class.tpl ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
data/Smarty/templates/admin/products/product_class_confirm.tpl ohkouchi@loop-az.jp-20110310120612-5yubhkd34q0kh1wv
data/class/SC_Product.php ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
data/class/helper/SC_Helper_DB.php ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
data/class/pages/admin/products/LC_Page_Admin_Products.php ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
data/class/pages/admin/products/LC_Page_Admin_Products_ClassCategory.php ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
data/class/pages/products/LC_Page_Products_List.php ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
html/install/sql/insert_data.sql ohkouchi@loop-az.jp-20110310141144-qucx7d0zkt4jgao9
html/user_data/packages/admin/js/admin.js ohkouchi@loop-az.jp-20110310121605-jifwd9debb5hzvwo
bzr:timestamp:
2011-03-10 23:23:05.288000107 +0900
bzr:user-agent:
bzr2.2.1+bzr-svn1.0.4
svn:original-date:
2011-03-10T14:23:05.288000Z
Message:
  • #1097([管理画面]商品管理(商品規格登録):規格編集で、登録されていない行にもチェックが入っている)
  • #1064([管理画面]商品管理(商品規格登録):規格編集で、登録されている規格を外して登録しても削除されない)
  • #991(商品規格登録での不具合)
  • #1101([フロント]商品(一覧、詳細):規格削除しても価格表記に削除した価格も出ている)
  • 商品規格管理画面を全面的にリファクタリング
  • TODO 入力チェック, ダウンロード販売用ファイルには後続のコミットで対応します
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/admin/products/LC_Page_Admin_Products_ProductClass.php

    r20538 r20595  
    5656        $masterData = new SC_DB_MasterData_Ex(); 
    5757        $this->arrProductType = $masterData->getMasterData("mtb_product_type"); 
     58        // 規格プルダウンのリスト 
     59        $this->arrClass = $this->getAllClass(); 
    5860    } 
    5961 
     
    7880        $this->initParam($objFormParam); 
    7981 
    80         // 規格行のPOSTパラメータを初期化 
    81         $count = $this->getRowMax($_POST); 
    82         $this->initRowParam($count, $objFormParam); 
    8382        $objFormParam->setParam($_POST); 
    8483        $objFormParam->convParam(); 
    8584 
    8685        $this->arrSearchHidden = $objFormParam->getSearchArray(); 
    87  
    88         $this->tpl_product_id = $objFormParam->getValue('product_id'); 
    89         $this->tpl_pageno = $objFormParam->getValue('pageno'); 
    9086 
    9187        // Downファイル管理クラスを初期化 
     
    9389        $this->initDownFile($count, $this->objDownFile); 
    9490 
    95         $this->arrForm = $objFormParam->getHashArray(); 
    96  
    9791        switch ($this->getMode()) { 
    9892 
     
    10094        case 'edit': 
    10195            // エラーチェック 
    102             $this->arrErr = $this->lfProductClassError($this->arrForm); 
     96            $this->arrErr = $this->lfProductClassError($objFormParam->getHashArray()); 
    10397            if (empty($this->arrErr)){ 
    10498                $this->tpl_mainpage = 'products/product_class_confirm.tpl'; 
    105                 $this->lfProductConfirmPage($this->arrForm); // 確認ページ表示 
     99                $this->doDisp($objFormParam); 
     100                $objFormParam->setParam($_POST); 
     101                $objFormParam->convParam(); 
     102 
    106103            } else { 
    107104                $this->doPreEdit($objFormParam->getValue('product_id'), false ,true); 
     105                /* TODO 
    108106                // Hiddenからのデータを引き継ぐ 
    109107                $this->objDownFile->setHiddenFileList($_POST); 
     
    112110                // Form用に配列を渡す。 
    113111                $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); 
    114                 $this->doDisp($objFormParam->getValue('product_id'), 
    115                               $objFormParam->getValue('select_class_id1'), 
    116                               $objFormParam->getValue('select_class_id2')); 
     112                */ 
     113                $this->doDisp($objFormParam); 
     114                $objFormParam->setParam($_POST); 
     115                $objFormParam->convParam(); 
     116 
    117117            } 
    118118            break; 
     
    125125        // 初期表示 
    126126        case 'pre_edit': 
    127             $this->doPreEdit($objFormParam->getValue('product_id')); 
     127            $this->doPreEdit($objFormParam); 
     128            /* TODO 
    128129            // HIDDEN用に配列を渡す。 
    129130            $this->arrHidden = array_merge((array)$this->arrHidden, (array)$this->objDownFile->getHiddenFileList()); 
     131            */ 
    130132            break; 
    131133 
    132134        // 「表示する」ボタン押下時 
    133135        case 'disp': 
    134             $this->doDisp($objFormParam->getValue('product_id'), 
    135                           $objFormParam->getValue('select_class_id1'), 
    136                           $objFormParam->getValue('select_class_id2')); 
     136            $this->arrErr = $this->lfClassError(); 
     137            if (SC_Utils_Ex::isBlank($this->arrErr)) { 
     138                $this->doDisp($objFormParam); 
     139            } 
    137140            break; 
    138141 
    139142        // ダウンロード商品ファイルアップロード 
    140143        case 'upload_down': 
     144            /* TODO 
    141145            $product_id = $objFormParam->getValue('product_id'); 
    142146            $down_key   = $objFormParam->getValue('down_key'); 
     
    156160            $this->doDisp($product_id, 
    157161                          $objFormParam->getValue('select_class_id1'), 
    158                           $objFormParam->getValue('select_class_id2')); 
     162                          $objFormParam->getValue('select_class_id2'), $objFormParam); 
     163            */ 
    159164            break; 
    160165 
    161166        // ダウンロードファイルの削除 
    162167        case 'delete_down': 
     168            /* TODO 
    163169            $product_id = $objFormParam->getValue('product_id'); 
    164170            $down_key   = $objFormParam->getValue('down_key'); 
     
    176182            $this->doDisp($product_id, 
    177183                          $objFormParam->getValue('select_class_id1'), 
    178                           $objFormParam->getValue('select_class_id2')); 
     184                          $objFormParam->getValue('select_class_id2'), $objFormParam); 
     185            */ 
    179186            break; 
    180187 
    181188        // 確認画面からの戻り 
    182189        case 'confirm_return': 
    183             // 規格の選択情報は引き継がない。 
    184             $this->arrForm['select_class_id1'] = ""; 
    185             $this->arrForm['select_class_id2'] = ""; 
    186             $this->doPreEdit($objFormParam->getValue('product_id'), false, true); 
     190            $this->doPreEdit($objFormParam); 
     191            $objFormParam->setParam($_POST); 
     192            $objFormParam->convParam(); 
     193 
     194            /* TODO 
    187195            // Hiddenからのデータを引き継ぐ 
    188196            $this->objDownFile->setHiddenFileList($_POST); 
     
    191199            // Form用に配列を渡す。 
    192200            $this->arrForm = array_merge((array)$this->arrForm, (array)$this->objDownFile->getFormKikakuDownFile()); 
    193             $this->doDisp($objFormParam->getValue('product_id'), 
    194                           $objFormParam->getValue('select_class_id1'), 
    195                           $objFormParam->getValue('select_class_id2')); 
     201            */ 
     202 
    196203            break; 
    197204        case 'complete': 
     
    203210            // 商品規格の登録 
    204211            $arrList = $objFormParam->getHashArray(); 
    205             $this->registerProductClass($arrList, $objFormParam->getValue('product_id')); 
     212            $this->registerProductClass($arrList, $objFormParam->getValue('product_id'), 
     213                                        $objFormParam->getValue('total')); 
    206214            // 一時ファイルを本番ディレクトリに移動する 
    207215            $this->objDownFile->moveTempDownFile(); 
     
    211219        } 
    212220 
    213         // 規格プルダウンのリストを取得 
    214         $this->arrClass = $this->getAllClass(); 
    215221        // 登録対象の商品名を取得 
    216         $this->arrForm['product_name'] = $this->getProductName($objFormParam->getValue('product_id')); 
     222        $objFormParam->setValue('product_name', 
     223                $this->getProductName($objFormParam->getValue('product_id'))); 
     224        $this->arrForm = $objFormParam->getFormParamList(); 
    217225    } 
    218226 
     
    228236     * パラメータ初期化 
    229237     * 
    230      * @param <type> $objFormParam 
     238     * @param SC_FormParam $objFormParam SC_FormParam インスタンス 
     239     * @return void 
    231240     */ 
    232241    function initParam(&$objFormParam) { 
    233         $objFormParam->addParam(); 
    234242        // 商品マスタ検索パラメータ引き継ぎ 
    235243        $objFormParam->addParam("商品ID", "product_id", INT_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); 
     
    251259 
    252260        // 規格プルダウン 
    253         $objFormParam->addParam("規格1", "select_class_id1", null, null, array()); 
    254         $objFormParam->addParam("規格2", "select_class_id2", null, null, array()); 
    255         $objFormParam->addParam("規格1", "class_id1", null, null, array()); 
    256         $objFormParam->addParam("規格2", "class_id2", null, null, array()); 
    257  
    258         // ファイルアップロード用 
    259         $objFormParam->addParam("ファイルアップロード用キー", "down_key", null, null, array()); 
    260     } 
    261  
    262     /** 
    263      * 規格行ごとのパラメータを初期化する 
    264      * 
    265      * @param 行数 $count 
    266      * @param SC_FormParam $objFormParam 
    267      */ 
    268     function initRowParam($count, &$objFormParam) { 
    269         for ($i = 1; $i < $count; $i++) { 
    270             $objFormParam->addParam("規格ID1", "classcategory_id1:$i", null, null, array()); 
    271             $objFormParam->addParam("規格ID2", "classcategory_id2:$i", null, null, array()); 
    272             $objFormParam->addParam("規格名", "name1:$i", null, null, array()); 
    273             $objFormParam->addParam("企画名", "name2:$i", null, null, array()); 
    274             $objFormParam->addParam("product_class_id", "product_class_id:$i", null, null, array()); 
    275             $objFormParam->addParam("商品コード", "product_code:$i", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
    276             $objFormParam->addParam("在庫数", "stock:$i", AMOUNT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    277             $objFormParam->addParam("在庫数", "stock_unlimited:$i", null, null, array()); 
    278             $objFormParam->addParam(NORMAL_PRICE_TITLE, "price01:$i", PRICE_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); 
    279             $objFormParam->addParam(SALE_PRICE_TITLE, "price02:$i", PRICE_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
    280             $objFormParam->addParam("商品種別", "product_type_id:$i", null, null, array()); 
    281             $objFormParam->addParam("DLファイル名", "down_filename:$i", null, null, array()); 
    282             $objFormParam->addParam("DLファイル名", "down_realfilename:$i", null, null, array()); 
    283             $objFormParam->addParam("チェックボックス", "check:$i", null, null, array()); 
    284         } 
     261        $objFormParam->addParam("規格1", "select_class_id1", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     262        $objFormParam->addParam("規格2", "select_class_id2", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     263        $objFormParam->addParam("規格1", "class_id1", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     264        $objFormParam->addParam("規格2", "class_id2", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     265 
     266        // 商品規格 
     267        $objFormParam->addParam("商品規格数", "total", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     268        $objFormParam->addParam("商品名", "product_name", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
     269        $objFormParam->addParam("商品コード", "product_code", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
     270        $objFormParam->addParam("規格ID1", "classcategory_id1", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     271        $objFormParam->addParam("規格ID2", "classcategory_id2", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     272        $objFormParam->addParam("規格名1", "classcategory_name1", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
     273        $objFormParam->addParam("規格名2", "classcategory_name2", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
     274        $objFormParam->addParam("商品規格ID", "product_class_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     275        $objFormParam->addParam("在庫数", "stock", AMOUNT_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     276        $objFormParam->addParam("在庫数", "stock_unlimited", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     277        $objFormParam->addParam(NORMAL_PRICE_TITLE, "price01", PRICE_LEN, 'n', array("NUM_CHECK", "MAX_LENGTH_CHECK")); 
     278        $objFormParam->addParam(SALE_PRICE_TITLE, "price02", PRICE_LEN, 'n', array("EXIST_CHECK", "NUM_CHECK", "MAX_LENGTH_CHECK")); 
     279        $objFormParam->addParam("商品種別", "product_type_id", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     280        $objFormParam->addParam("削除フラグ", "del_flg", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     281        $objFormParam->addParam("DLファイル名", "down_filename", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
     282        $objFormParam->addParam("DLファイル名", "down_realfilename", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
     283        $objFormParam->addParam("チェックボックス", "check", INT_LEN, 'n', array("MAX_LENGTH_CHECK", "NUM_CHECK")); 
     284        $objFormParam->addParam("ファイルアップロード用キー", "down_key", STEXT_LEN, 'KVa', array("MAX_LENGTH_CHECK")); 
    285285    } 
    286286 
     
    299299 
    300300    /** 
    301      * 規格行の最大値を返す 
    302      * 
    303      * @param array $arrPost POSTパラメータ 
    304      * @return int 規格行の最大値 
    305      */ 
    306     function getRowMax($arrPost) { 
    307         $i = 1; 
    308         foreach ($arrPost as $key => $value) { 
    309             if ($key == "classcategory_id1:$i") { 
    310                 $i++; 
    311             } 
    312         } 
    313         return $i; 
    314     } 
    315  
    316     /** 
    317301     * 規格の登録または更新を行う. 
    318302     * 
     
    323307     * @param integer $product_id 登録を行う商品ID 
    324308     */ 
    325     function registerProductClass($arrList, $product_id) { 
     309    function registerProductClass($arrList, $product_id, $total) { 
    326310        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    327311        $objDb = new SC_Helper_DB_Ex(); 
     
    329313        $objQuery->begin(); 
    330314 
    331         $productsClass = $objQuery->select("*", "dtb_products_class", "product_id = ?", array($product_id)); 
    332  
    333         $exists = array(); 
    334         foreach ($productsClass as $val) { 
    335             $exists[$val['product_class_id']] = $val; 
    336         } 
    337         $i = 1; 
    338         while (!SC_Utils_Ex::isBlank($arrList['check:' . $i])) { 
    339             $pVal = array(); 
    340             $pVal['product_id'] = $product_id;; 
    341             $pVal['product_code'] = $arrList["product_code:".$i]; 
    342             $pVal['stock'] = $arrList["stock:".$i]; 
    343             $pVal['stock_unlimited'] = ($arrList["stock_unlimited:".$i]) ? '1' : '0'; 
    344             $pVal['price01'] = $arrList['price01:'.$i]; 
    345             $pVal['price02'] = $arrList['price02:'.$i]; 
    346             $pVal['product_type_id'] = $arrList['product_type_id:'.$i]; 
    347             $pVal['down_filename'] = $arrList['down_filename:'.$i]; 
    348             $pVal['down_realfilename'] = $arrList['down_realfilename:'.$i]; 
    349             $pVal['creator_id'] = $_SESSION['member_id']; 
    350             $pVal['update_date'] = "now()"; 
    351  
    352             if($arrList["check:".$i] == 1) { 
    353                 $pVal['del_flg'] = 0; 
    354             } else { 
    355                 $pVal['del_flg'] = 1; 
    356             } 
    357  
    358             // 更新 or 登録 
    359             $isUpdate = false; 
    360             if (!SC_Utils_Ex::isBlank($arrList["product_class_id:".$i])) { 
    361                 $isUpdate = true; 
     315        $arrProductsClass = $objQuery->select("*", "dtb_products_class", "product_id = ?", array($product_id)); 
     316        $arrExists = array(); 
     317        foreach ($arrProductsClass as $val) { 
     318            $arrExists[$val['product_class_id']] = $val; 
     319        } 
     320 
     321        // デフォルト値として設定する値を取得しておく 
     322        $arrDefault = $this->getProductsClass($product_id); 
     323 
     324        for ($i = 0; $i < $total; $i++) { 
     325            $del_flg = SC_Utils_Ex::isBlank($arrList['check'][$i]) ? 1 : 0; 
     326            $stock_unlimited = SC_Utils_Ex::isBlank($arrList['stock_unlimited'][$i]) ? 0 : 1; 
     327 
     328            // dtb_products_class 登録/更新用 
     329            $registerKeys = array('product_code', 'stock', 
     330                                  'price01', 'price02', 'product_type_id', 
     331                                  'down_filename', 'down_realfilename'); 
     332 
     333            $arrPC = array(); 
     334            foreach ($registerKeys as $key) { 
     335                $arrPC[$key] = $arrList[$key][$i]; 
     336            } 
     337            $arrPC['product_id'] = $product_id; 
     338            $arrPC['sale_limit'] = $arrDefault['sale_limit']; 
     339            $arrPC['deliv_fee'] = $arrDefault['deliv_fee']; 
     340            $arrPC['point_rate'] = $arrDefault['point_rate']; 
     341            $arrPC['stock_unlimited'] = $stock_unlimited; 
     342 
     343            // 該当関数が無いため, セッションの値を直接代入 
     344            $arrPC['creator_id'] = $_SESSION['member_id']; 
     345            $arrPC['update_date'] = 'now()'; 
     346            $arrPC['del_flg'] = $del_flg; 
     347 
     348            // 登録 or 更新 
     349            $is_update = false; 
     350            if (!SC_Utils_Ex::isBlank($arrList['product_class_id'][$i])) { 
     351                $is_update = true; 
     352 
    362353                // 更新の場合は規格組み合わせを検索し, 削除しておく 
    363                 $class_combination_id = $exists[$arrList["product_class_id:".$i]]['class_combination_id']; 
     354                $class_combination_id = $arrExists[$arrList['product_class_id'][$i]]['class_combination_id']; 
    364355                $existsCombi = $objQuery->getRow( 
    365                     "*", 
    366                     "dtb_class_combination", 
    367                     "class_combination_id = ?", 
    368                     array($class_combination_id) 
    369                 ); 
    370  
    371                 $objQuery->delete("dtb_class_combination", 
    372                                   "class_combination_id IN (?, ?)", 
     356                    '*', 
     357                    'dtb_class_combination', 
     358                    'class_combination_id = ?', 
     359                    array($class_combination_id)); 
     360 
     361                $objQuery->delete('dtb_class_combination', 
     362                                  'class_combination_id IN (?, ?)', 
    373363                                  array($existsCombi['class_combination_id'], 
    374364                                        $existsCombi['parent_class_combination_id'])); 
     
    376366 
    377367            // 規格組み合わせを登録 
    378             $cVal1['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); 
    379  
    380             $cVal1['classcategory_id'] = $arrList["classcategory_id1:".$i]; 
    381             $cVal1['level'] = 1; 
    382             $objQuery->insert("dtb_class_combination", $cVal1); 
    383  
    384             $pVal['class_combination_id'] = $cVal1['class_combination_id']; 
     368            $arrComb1['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); 
     369            $arrComb1['classcategory_id'] = $arrList['classcategory_id1'][$i]; 
     370            $arrComb1['level'] = 1; 
     371            $objQuery->insert('dtb_class_combination', $arrComb1); 
    385372 
    386373            // 規格2も登録する場合 
    387             if (!SC_Utils_Ex::isBlank($arrList["classcategory_id2:".$i])) { 
    388                 $cVal2['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); 
    389                 $cVal2['classcategory_id'] = $arrList["classcategory_id2:".$i]; 
    390                 $cVal2['parent_class_combination_id'] = $cVal1['class_combination_id']; 
    391                 $cVal2['level'] = 2; 
    392                 $objQuery->insert("dtb_class_combination", $cVal2); 
    393  
    394                 $pVal['class_combination_id'] = $cVal2['class_combination_id']; 
     374            if (!SC_Utils_Ex::isBlank($arrList['classcategory_id2'][$i])) { 
     375                $arrComb2['class_combination_id'] = $objQuery->nextVal('dtb_class_combination_class_combination_id'); 
     376                $arrComb2['classcategory_id'] = $arrList['classcategory_id2'][$i]; 
     377                $arrComb2['parent_class_combination_id'] = $arrComb1['class_combination_id']; 
     378                $arrComb2['level'] = 2; 
     379                $objQuery->insert('dtb_class_combination', $arrComb2); 
     380 
     381                $arrPC['class_combination_id'] = $arrComb2['class_combination_id']; 
     382            } else { 
     383                $arrPC['class_combination_id'] = $arrComb1['class_combination_id']; 
    395384            } 
    396385 
    397386            // 更新 
    398             if ($isUpdate) { 
    399                 $pVal['product_class_id'] = $arrList["product_class_id:".$i]; 
    400                 $objQuery->update("dtb_products_class", $pVal, 
     387            if ($is_update) { 
     388                $arrPC['product_class_id'] = $arrList['product_class_id'][$i]; 
     389                $objQuery->update("dtb_products_class", $arrPC, 
    401390                                  "product_class_id = ?", 
    402                                   array($pVal['product_class_id'])); 
     391                                  array($arrPC['product_class_id'])); 
    403392            } 
    404393            // 新規登録 
    405394            else { 
    406                 $pVal['create_date'] = "now()"; 
    407                 $pVal['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); 
    408                 $objQuery->insert("dtb_products_class", $pVal); 
    409             } 
    410  
    411             $i++; 
     395                $arrPC['create_date'] = "now()"; 
     396                $arrPC['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); 
     397                $objQuery->insert("dtb_products_class", $arrPC); 
     398            } 
    412399        } 
    413400 
    414401        // 規格無し用の商品規格を非表示に 
    415         $bVal['del_flg'] = 1; 
    416         $bVal['update_date'] = 'now()'; 
    417         $objQuery->update("dtb_products_class", $bVal, 
    418                           "product_class_id = ? AND class_combination_id IS NULL", 
    419                           array($pVal['product_class_id'])); 
     402        $arrBlank['del_flg'] = 1; 
     403        $arrBlank['update_date'] = 'now()'; 
     404        $objQuery->update("dtb_products_class", $arrBlank, 
     405                          "product_id = ? AND class_combination_id IS NULL", 
     406                          array($product_id)); 
    420407 
    421408        // 件数カウントバッチ実行 
     
    491478 
    492479    /** 
    493      * 確認ページを表示する 
    494      * 
    495      */ 
    496     function lfProductConfirmPage($arrPost) { 
    497         $objDb = new SC_Helper_DB_Ex(); 
    498         $this->arrForm['mode'] = 'complete'; 
    499         $this->arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name'); 
    500         $cnt = 0; 
    501         $check = 0; 
    502         $no = 1; 
    503         while ($arrPost["classcategory_id1:".$no] != "") { 
    504             if ($arrPost["check:".$no] != "") { 
    505                 $check++; 
    506             } 
    507             $no++; 
    508             $cnt++; 
    509         } 
    510         $this->tpl_check = $check; 
    511         $this->tpl_count = $cnt; 
    512     } 
    513  
    514     /** 
    515480     * 規格の組み合わせ一覧を表示する. 
    516481     * 
    517      * 1. 規格1, 規格2を組み合わせた場合の妥当性を検証する. 
    518      * 2. 規格1, 規格2における規格分類のすべての組み合わせを取得し, 
    519      *    該当商品の商品規格の内容を取得し, フォームに設定する. 
    520      */ 
    521     function doDisp($product_id, $select_class_id1, $select_class_id2) { 
    522         $this->arrForm['select_class_id1'] = $select_class_id1; 
    523         $this->arrForm['select_class_id2'] = $select_class_id2; 
    524         $dispError = $this->lfClassError(); 
    525         if (SC_Utils_Ex::isBlank($dispError)) { 
    526             $this->arrClassCat = $this->getAllClassCategory($select_class_id1, $select_class_id2); 
    527             $productsClass = $this->getProductsClass($product_id); 
    528  
    529             $total = count($this->arrClassCat); 
    530             for ($i = 1; $i <= $total; $i++) { 
    531                 foreach ($productsClass as $key => $val) { 
    532                     $this->arrForm[$key . ":" . $i] = $val; 
    533                 } 
    534             } 
    535         } 
    536         $this->arrErr = array_merge((array) $this->arrErr, $dispError); 
    537         $this->tpl_onload.= "fnCheckAllStockLimit('$total', '" . DISABLED_RGB . "');"; 
     482     * 規格1, 規格2における規格分類のすべての組み合わせを取得し, 
     483     * 該当商品の商品規格の内容を取得後, フォームに設定する. 
     484     * 
     485     * @param SC_FormParam $objFormParam SC_FormParam インスタンス 
     486     * @return void 
     487     */ 
     488    function doDisp(&$objFormParam) { 
     489        $product_id = $objFormParam->getValue('product_id'); 
     490        $select_class_id1 = $objFormParam->getValue('select_class_id1'); 
     491        $select_class_id2 = $objFormParam->getValue('select_class_id2'); 
     492 
     493        // すべての組み合わせを取得し, フォームに設定 
     494        $arrClassCat = $this->getAllClassCategory($select_class_id1, $select_class_id2); 
     495        $total = count($arrClassCat); 
     496        $objFormParam->setValue('total', $total); 
     497        $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($arrClassCat)); 
     498 
     499        // class_id1, class_id2 は select_class_id1 で上書き 
     500        $objFormParam->setValue('class_id1', $select_class_id1); 
     501        $objFormParam->setValue('class_id2', $select_class_id2); 
     502 
     503        // 商品情報を取得し, フォームに設定 
     504        $arrProductsClass = $this->getProductsClass($product_id); 
     505 
     506        foreach ($arrProductsClass as $key => $val) { 
     507            // 組み合わせ数分の値の配列を生成する 
     508            $arrValues = array(); 
     509            for ($i = 0; $i < $total; $i++) { 
     510                $arrValues[] = $val; 
     511            } 
     512            $objFormParam->setValue($key, $arrValues); 
     513        } 
    538514    } 
    539515 
     
    545521     * @param bool $usepostValue 
    546522     */ 
    547     function doPreEdit($product_id, $existsValue = true, $usepostValue = false) { 
     523    function doPreEdit(&$objFormParam) { 
     524        $product_id = $objFormParam->getValue('product_id'); 
    548525        $existsProductsClass = $this->getProductsClassAndClasscategory($product_id); 
    549         $productsClass = $this->getProductsClass($product_id); 
    550         $this->arrForm["class_id1"] = $existsProductsClass[0]['class_id1']; 
    551         $this->arrForm["class_id2"] = $existsProductsClass[0]['class_id2']; 
    552         $this->arrForm['select_class_id1'] = $this->arrForm["class_id1"]; 
    553         $this->arrForm['select_class_id2'] = $this->arrForm["class_id2"]; 
    554         $this->arrClassCat = $this->getAllClassCategory($this->arrForm["class_id1"], $this->arrForm["class_id2"]); 
    555  
    556         $total = count($this->arrClassCat); 
    557         $line  = ''; 
    558  
    559         for ($i = 0; $i < $total; $i++) { 
    560             $no = $i + 1; 
    561             if ($existsValue) { 
    562                 foreach ($productsClass as $key => $val) { 
    563                     if(!$usepostValue){ 
    564                         $this->arrForm[$key . ":" . $no] = $val; 
    565                     } 
    566                 } 
    567             } 
    568             foreach ($existsProductsClass[$i] as $key => $val) { 
    569                 if (!$usepostValue) { 
    570                     $this->arrForm[$key . ":" . $no] = $val; 
    571                 } 
    572                 switch ($key) { 
    573                 case 'down': 
    574                     $this->objDownFile->addFile("ダウンロード販売用ファイル". ":" . $no, 'down_realfilename'. ":" . $no, explode(",", DOWNLOAD_EXTENSION),DOWN_SIZE, true, 0, 0); 
    575                     break; 
    576                 default: 
    577                 } 
    578             } 
    579             if (!SC_Utils_Ex::isBlank($this->arrForm['product_id:' . $no]) 
    580                 && $this->arrForm["del_flg:" . $no] == 0) { 
    581                 $line .= "'check:" . $no . "',"; 
    582             } 
    583         } 
    584  
    585         $line = preg_replace("/,$/", "", $line); 
    586         $this->tpl_javascript = "list = new Array($line);"; 
    587         $color = DISABLED_RGB; 
    588         $this->tpl_onload.= "fnListCheck(list); fnCheckAllStockLimit('$total', '$color');"; 
     526 
     527        $class_id1 = $existsProductsClass[0]['class_id1']; 
     528        $class_id2 = $existsProductsClass[0]['class_id2']; 
     529        $objFormParam->setValue('class_id1', $class_id1); 
     530        $objFormParam->setValue('class_id2', $class_id2); 
     531        $objFormParam->setValue('select_class_id1', $class_id1); 
     532        $objFormParam->setValue('select_class_id2', $class_id2); 
     533        $this->doDisp($objFormParam); 
     534 
     535        // 登録済みのデータで上書き 
     536        $objFormParam->setParam(SC_Utils_Ex::sfSwapArray($existsProductsClass)); 
     537 
     538        // $existsProductsClass で product_id が配列になってしまうため数値で上書き 
     539        $objFormParam->setValue('product_id', $product_id); 
     540 
     541        // check を設定 
     542        $arrChecks = array(); 
     543        $index = 0; 
     544        foreach ($objFormParam->getValue('del_flg') as $key => $val) { 
     545            if ($val == 0) { 
     546                $arrChecks[$index] = 1; 
     547            } 
     548            $index++; 
     549        } 
     550        $objFormParam->setValue('check', $arrChecks); 
    589551 
    590552        // DBデータからダウンロードファイル名の読込 
     
    604566 
    605567        $objQuery->begin(); 
    606  
    607         $arrProductsClass = array(); 
    608         $arrProductsClass['del_flg'] = 0; 
    609         $objQuery->update("dtb_products_class", $arrProductsClass, "product_id = ? AND class_combination_id IS NULL", array($product_id)); 
    610  
    611         $arrProductsClass['del_flg'] = 1; 
    612         $objQuery->update("dtb_products_class", $arrProductsClass, "product_id = ? AND class_combination_id IS NOT NULL", array($product_id)); 
    613  
     568        $objQuery->update("dtb_products_class", array('del_flg' => 0), 
     569                          "product_id = ? AND class_combination_id IS NULL", array($product_id)); 
     570        $objQuery->update("dtb_products_class", array('del_flg' => 1), 
     571                          "product_id = ? AND class_combination_id IS NOT NULL", array($product_id)); 
    614572        $objQuery->commit(); 
    615573 
     
    634592        $col = "T1.class_id AS class_id1, " 
    635593            . " T1.classcategory_id AS classcategory_id1, " 
    636             . " T1.name AS name1, " 
     594            . " T1.name AS classcategory_name1, " 
    637595            . " T1.rank AS rank1 "; 
    638596 
     
    648606                . "T2.class_id AS class_id2," 
    649607                . "T2.classcategory_id AS classcategory_id2," 
    650                 . "T2.name AS name2," 
     608                . "T2.name AS classcategory_name2," 
    651609                . "T2.rank AS rank2"; 
    652610            $table = "dtb_classcategory AS T1, dtb_classcategory AS T2"; 
     
    667625    function getProductName($product_id) { 
    668626        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    669         return $objQuery->getOne("SELECT name FROM dtb_products WHERE product_id = ?", array($product_id)); 
     627        return $objQuery->get('name', 'dtb_products', 'product_id = ?', array($product_id)); 
    670628    } 
    671629 
     
    698656     */ 
    699657    function getAllClass() { 
    700         $objDb = new SC_Helper_DB_Ex(); 
    701         $arrClass = $objDb->sfGetIDValueList("dtb_class", 'class_id', 'name'); 
     658        $arrClass = SC_Helper_DB_Ex::sfGetIDValueList("dtb_class", 'class_id', 'name'); 
    702659 
    703660        // 規格分類が登録されていない規格は表示しないようにする。 
     
    716673 
    717674    /** 
    718      * 商品IDをキーにして, 商品規格を取得する. 
     675     * 商品IDをキーにして, 商品規格の初期値を取得する. 
     676     * 
     677     * 商品IDをキーにし, デフォルトに設定されている商品規格を取得する. 
    719678     * 
    720679     * @param integer $product_id 商品ID 
     
    723682    function getProductsClass($product_id) { 
    724683        $objQuery =& SC_Query_Ex::getSingletonInstance(); 
    725         $col = "product_id, product_code, price01, price02, stock,  stock_unlimited, point_rate"; 
    726         return $objQuery->getRow($col, "dtb_products_class", "product_id = ?", array($product_id)); 
     684        $col = "product_code, price01, price02, stock, stock_unlimited, sale_limit, deliv_fee, point_rate"; 
     685        return $objQuery->getRow($col, "dtb_products_class", "product_id = ? AND class_combination_id IS NULL", array($product_id)); 
    727686    } 
    728687 
     
    735694    function getProductsClassAndClasscategory($productId) { 
    736695        $objProduct = new SC_Product_Ex(); 
    737         return $objProduct->getProductsClassFullByProductId($productId); 
     696        return $objProduct->getProductsClassFullByProductId($productId, true); 
    738697    } 
    739698} 
Note: See TracChangeset for help on using the changeset viewer.