Index: branches/version-2_5-dev/data/Smarty/templates/admin/order/product_select.tpl
===================================================================
--- branches/version-2_5-dev/data/Smarty/templates/admin/order/product_select.tpl	(revision 18873)
+++ branches/version-2_5-dev/data/Smarty/templates/admin/order/product_select.tpl	(revision 18875)
@@ -28,5 +28,5 @@
 self.moveTo(20,20);self.focus();
 
-function func_submit(product_id, class_name1, class_name2) {
+function func_submit(product_id, class_name1, class_name2, product_class_id) {
   var err_text = '';
   var fm = window.opener.document.form1;
@@ -40,11 +40,9 @@
   <!--{if $tpl_no != ''}-->
   var opner_product_id = 'edit_product_id';
-  var opner_classcategory_id1 = 'edit_classcategory_id1';
-  var opner_classcategory_id2 = 'edit_classcategory_id2';
+  var opner_product_class_id = 'edit_product_class_id';
   fm1.getElementById("no").value = <!--{$tpl_no}-->;
   <!--{else}-->
   var opner_product_id = 'add_product_id';
-  var opner_classcategory_id1 = 'add_classcategory_id1';
-  var opner_classcategory_id2 = 'add_classcategory_id2';
+  var opner_product_class_id = 'add_product_class_id';
   <!--{/if}-->
 
@@ -61,10 +59,5 @@
 
   fm1.getElementById(opner_product_id).value = product_id;
-  if (class1_id != '') {
-    fm1.getElementById(opner_classcategory_id1).value = class1_id;
-  }
-  if (class2_id != '') {
-    fm1.getElementById(opner_classcategory_id2).value = class2_id;
-  }
+  fm1.getElementById(opner_product_class_id).value = product_class_id;
 
   fm.mode.value = 'select_product_detail';
@@ -78,37 +71,52 @@
 </script>
 
+
 <script type="text/javascript">//<![CDATA[
-// セレクトボックスに項目を割り当てる。
-function lnSetSelect(name1, name2, id, val) {
-        sele1 = document.form1[name1];
-        sele2 = document.form1[name2];
-        lists = eval('lists' + id);
-        vals = eval('vals' + id);
-
-        if(sele1 && sele2) {
-                index = sele1.selectedIndex;
-
-                // セレクトボックスのクリア
-                count = sele2.options.length;
-                for(i = count; i >= 0; i--) {
-                        sele2.options[i] = null;
+// 規格2に選択肢を割り当てる。
+function fnSetClassCategories(form, classcat_id2_selected) {
+    sele1 = form.classcategory_id1;
+    sele2 = form.classcategory_id2;
+    product_id = form.product_id.value;
+
+    if (sele1) {
+        if (sele2) {
+            // 規格2の選択肢をクリア
+            count = sele2.options.length;
+            for(i = count; i >= 0; i--) {
+                sele2.options[i] = null;
+            }
+
+            // 規格2に選択肢を割り当てる
+            classcats = productsClassCategories[product_id][sele1.value];
+            i = 0;
+            for (var classcat_id2_key in classcats) {
+                sele2.options[i] = new Option(classcats[classcat_id2_key].name, classcat_id2_key);
+                if (classcat_id2_key == classcat_id2_selected) {
+                    sele2.options[i].selected = true;
                 }
-
-                // セレクトボックスに値を割り当てる
-                len = lists[index].length;
-                for(i = 0; i < len; i++) {
-                        sele2.options[i] = new Option(lists[index][i], vals[index][i]);
-                        if(val != "" && vals[index][i] == val) {
-                                sele2.options[i].selected = true;
-                        }
-                }
+                i++;
+            }
         }
+        fnCheckStock(form);
+    }
 }
-//]]>
-</script>
-
-
-<script type="text/javascript">//<![CDATA[
-    <!--{$tpl_javascript}-->
+
+function fnCheckStock(form) {
+    product_id = form.product_id.value;
+    classcat_id1 = form.classcategory_id1.value;
+    classcat_id2 = form.classcategory_id2 ? form.classcategory_id2.value : 0;
+    classcat2 = productsClassCategories[product_id][classcat_id1][classcat_id2];
+    // 商品規格
+    eleDynamic = document.getElementById('product_class_id' + product_id);
+    if (
+           classcat2
+        && typeof classcat2.product_class_id != 'undefined'
+        && String(classcat2.product_class_id).length >= 1
+    ) {
+        eleDynamic.value = classcat2.product_class_id;
+    } else {
+        eleDynamic.value = ''
+    }
+}
 //]]>
 </script>
@@ -142,5 +150,5 @@
   <button type="submit"><span>検索を開始</span></button>
 </div>
-
+</form>
 <!--▼検索結果表示-->
 <!--{if $tpl_linemax}-->
@@ -160,4 +168,5 @@
   <!--{section name=cnt loop=$arrProducts}-->
   <!--{assign var=id value=$arrProducts[cnt].product_id}-->
+  <form name="product_form<!--{$id|escape}-->" action="?" onsubmit="return false;">
   <!--▼商品<!--{$smarty.section.cnt.iteration}-->-->
   <tr>
@@ -183,6 +192,5 @@
       <dt><!--{$tpl_class_name1[$id]|escape}-->：</dt>
       <dd>
-        <select name="<!--{$class1}-->" id="<!--{$class1}-->" style="<!--{$arrErr[$class1]|sfGetErrorColor}-->"  <!--{if $tpl_classcat_find2[$id]}--> onchange="lnSetSelect('<!--{$class1}-->', '<!--{$class2}-->', '<!--{$id}-->','');"<!--{/if}-->>
-          <option value="">選択してください</option>
+        <select name="classcategory_id1" id="<!--{$class1}-->" style="<!--{$arrErr[$class1]|sfGetErrorColor}-->"  onchange="fnSetClassCategories(this.form);">
           <!--{html_options options=$arrClassCat1[$id] selected=$arrForm[$class1]}-->
         </select>
@@ -197,7 +205,5 @@
       <dt><!--{$tpl_class_name2[$id]|escape}-->：</dt>
       <dd>
-        <select name="<!--{$class2}-->" id="<!--{$class2}-->" style="<!--{$arrErr[$class2]|sfGetErrorColor}-->">
-          <option value="">選択してください</option>
-        </select>
+        <select name="classcategory_id2" id="<!--{$class2}-->" style="<!--{$arrErr[$class2]|sfGetErrorColor}-->" onchange="fnCheckStock(this.form);"></select>
         <!--{if $arrErr[$class2] != ""}-->
         <br /><span class="attention">※ <!--{$tpl_class_name2[$id]}-->を入力して下さい。</span>
@@ -207,8 +213,12 @@
       <input type="hidden" name="<!--{$class2}-->" id="<!--{$class2}-->" value="" />
       <!--{/if}-->
+      <input type="hidden" name="product_id" value="<!--{$id|escape}-->" />
+      <input type="hidden" name="product_class_id<!--{$id|escape}-->" id="product_class_id<!--{$id|escape}-->" value="<!--{$tpl_product_class_id[$id]}-->" />
+      <input type="hidden" name="product_type" id="product_type<!--{$id|escape}-->" value="<!--{$tpl_product_type[$id]}-->" />
     </td>
-    <td class="center"><a href="" onclick="return func_submit('<!--{$arrProducts[cnt].product_id}-->', '<!--{$tpl_class_name1[$id]}-->', '<!--{$tpl_class_name2[$id]}-->')">決定</a></td>
+    <td class="center"><a href="javascript:;" onclick="return func_submit('<!--{$arrProducts[cnt].product_id}-->', '<!--{$tpl_class_name1[$id]}-->', '<!--{$tpl_class_name2[$id]}-->', '<!--{$tpl_product_class_id[$id]}-->')">決定</a></td>
   </tr>
   <!--▲商品<!--{$smarty.section.cnt.iteration}-->-->
+</form>
   <!--{sectionelse}-->
   <tr>
@@ -220,5 +230,4 @@
 <!--▲検索結果表示-->
 
-</form>
 
 <!--{include file="`$smarty.const.TEMPLATE_ADMIN_DIR`admin_popup_footer.tpl"}-->
Index: branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php	(revision 18872)
+++ branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_ProductSelect.php	(revision 18875)
@@ -25,4 +25,5 @@
 // {{{ requires
 require_once(CLASS_PATH . "pages/LC_Page.php");
+require_once(DATA_PATH . 'module/Services/JSON.php');
 
 /**
@@ -111,7 +112,4 @@
             }
 
-            /*
-             * FIXME パフォーマンスに問題があるため SC_Product::lists() を使用する
-             */
             $objProduct = new SC_Product();
             $productIds = $objProduct->findProductIds($objQuery, $arrval);
@@ -142,4 +140,14 @@
             $this->arrProducts = $objProduct->lists($objQuery, $arrval);
             $objProduct->setProductsClassByProductIds($productIds);
+            $objJson = new Services_JSON();
+            $this->tpl_javascript .= 'productsClassCategories = ' . $objJson->encode($objProduct->classCategories) . '; ';
+
+            foreach ($this->arrProducts as $arrProduct) {
+                $js_fnOnLoad .= "fnSetClassCategories(document.product_form{$arrProduct['product_id']});\n";
+            }
+
+            $this->tpl_javascript .= 'function fnOnLoad(){' . $js_fnOnLoad . '}';
+            $this->tpl_onload .= 'fnOnLoad(); ';
+
             // 規格1クラス名
             $this->tpl_class_name1 = $objProduct->className1;
@@ -155,11 +163,6 @@
             // 規格2が設定されている
             $this->tpl_classcat_find2 = $objProduct->classCat2_find;
-
+            $this->tpl_product_class_id = $objProduct->product_class_id;
             $this->tpl_stock_find = $objProduct->stock_find;
-            $this->tpl_product_class_id = $objProduct->product_class_id;
-            $this->tpl_product_type = $objProduct->product_type;
-
-            // FIXME 規格のプルダウンを要修正
-            $this->tpl_javascript = "";
         }
 
@@ -201,152 +204,4 @@
         }
     }
-
-    // FIXME SC_Product クラスを使用する
-    /* 規格セレクトボックスの作成 */
-    function lfMakeSelect($product_id, $arrClassName, $arrClassCatName) {
-
-        $classcat_find1 = false;
-        $classcat_find2 = false;
-        // 在庫ありの商品の有無
-        $stock_find = false;
-
-        // 商品規格情報の取得
-        $arrProductsClass = $this->lfGetProductsClass($product_id);
-
-        // 規格1クラス名の取得
-        $this->tpl_class_name1[$product_id] =
-            isset($arrClassName[$arrProductsClass[0]['class_id1']])
-            ? $arrClassName[$arrProductsClass[0]['class_id1']]
-            : "";
-
-        // 規格2クラス名の取得
-        $this->tpl_class_name2[$product_id] =
-            isset($arrClassName[$arrProductsClass[0]['class_id2']])
-            ? $arrClassName[$arrProductsClass[0]['class_id2']]
-            : "";
-
-        // すべての組み合わせ数
-        $count = count($arrProductsClass);
-
-        $classcat_id1 = "";
-
-        $arrSele = array();
-        $arrList = array();
-
-        $list_id = 0;
-        $arrList[0] = "\tlist". $product_id. "_0 = new Array('選択してください'";
-        $arrVal[0] = "\tval". $product_id. "_0 = new Array(''";
-
-        for ($i = 0; $i < $count; $i++) {
-            // 在庫のチェック
-            if($arrProductsClass[$i]['stock'] <= 0 && $arrProductsClass[$i]['stock_unlimited'] != '1') {
-                continue;
-            }
-
-            $stock_find = true;
-
-            // 規格1のセレクトボックス用
-            if($classcat_id1 != $arrProductsClass[$i]['classcategory_id1']){
-                $arrList[$list_id].=");\n";
-                $arrVal[$list_id].=");\n";
-                $classcat_id1 = $arrProductsClass[$i]['classcategory_id1'];
-                $arrSele[$classcat_id1] = $arrClassCatName[$classcat_id1];
-                $list_id++;
-
-                $arrList[$list_id] = "";
-                $arrVal[$list_id] = "";
-            }
-
-            // 規格2のセレクトボックス用
-            $classcat_id2 = $arrProductsClass[$i]['classcategory_id2'];
-
-            // セレクトボックス表示値
-            if($arrList[$list_id] == "") {
-                $arrList[$list_id] = "\tlist". $product_id. "_". $list_id. " = new Array('選択してください', '". $arrClassCatName[$classcat_id2]. "'";
-            } else {
-                $arrList[$list_id].= ", '".$arrClassCatName[$classcat_id2]."'";
-            }
-
-            // セレクトボックスPOST値
-            if($arrVal[$list_id] == "") {
-                $arrVal[$list_id] = "\tval". $product_id. "_". $list_id. " = new Array('', '". $classcat_id2. "'";
-            } else {
-                $arrVal[$list_id].= ", '".$classcat_id2."'";
-            }
-        }
-
-        $arrList[$list_id].=");\n";
-        $arrVal[$list_id].=");\n";
-
-        // 規格1
-        $this->arrClassCat1[$product_id] = $arrSele;
-
-        $lists = "\tlists".$product_id. " = new Array(";
-        $no = 0;
-        foreach($arrList as $val) {
-            $this->tpl_javascript.= $val;
-            if ($no != 0) {
-                $lists.= ",list". $product_id. "_". $no;
-            } else {
-                $lists.= "list". $product_id. "_". $no;
-            }
-            $no++;
-        }
-        $this->tpl_javascript.= $lists.");\n";
-
-        $vals = "\tvals".$product_id. " = new Array(";
-        $no = 0;
-        foreach($arrVal as $val) {
-            $this->tpl_javascript.= $val;
-            if ($no != 0) {
-                $vals.= ",val". $product_id. "_". $no;
-            } else {
-                $vals.= "val". $product_id. "_". $no;
-            }
-            $no++;
-        }
-        $this->tpl_javascript.= $vals.");\n";
-
-        // 選択されている規格2ID
-        $classcategory_id = "classcategory_id". $product_id;
-
-        $classcategory_id_2 = $classcategory_id . "_2";
-        if (!isset($classcategory_id_2)) $classcategory_id_2 = "";
-        if (!isset($_POST[$classcategory_id_2])) $_POST[$classcategory_id_2] = "";
-
-        $this->tpl_onload .= "lnSetSelect('" . $classcategory_id ."_1', "
-            . "'" . $classcategory_id_2 . "',"
-            . "'" . $product_id . "',"
-            . "'" . $_POST[$classcategory_id_2] ."'); ";
-
-        // 規格1が設定されている
-        if($arrProductsClass[0]['classcategory_id1'] != '0') {
-            $classcat_find1 = true;
-        }
-
-        // 規格2が設定されている
-        if($arrProductsClass[0]['classcategory_id2'] != '0') {
-            $classcat_find2 = true;
-        }
-
-        $this->tpl_classcat_find1[$product_id] = $classcat_find1;
-        $this->tpl_classcat_find2[$product_id] = $classcat_find2;
-        $this->tpl_stock_find[$product_id] = $stock_find;
-    }
-
-    /* 商品規格情報の取得 */
-    function lfGetProductsClass($product_id) {
-        $arrRet = array();
-        if(SC_Utils_Ex::sfIsInt($product_id)) {
-            // 商品規格取得
-            $objQuery = new SC_Query();
-            $col = "product_class_id, classcategory_id1, classcategory_id2, class_id1, class_id2, stock, stock_unlimited";
-            $table = "vw_product_class AS prdcls";
-            $where = "product_id = ?";
-            $objQuery->setOrder("rank1 DESC, rank2 DESC");
-            $arrRet = $objQuery->select($col, $table, $where, array($product_id));
-        }
-        return $arrRet;
-    }
 }
 ?>
Index: branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php
===================================================================
--- branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php	(revision 18872)
+++ branches/version-2_5-dev/data/class/pages/admin/order/LC_Page_Admin_Order_Edit.php	(revision 18875)
@@ -214,8 +214,8 @@
             // POST情報で上書き
             $this->objFormParam->setParam($_POST);
-            if (!empty($_POST['add_product_id'])) {
-                $this->lfInsertProduct($_POST['add_product_id'], $_POST['add_classcategory_id1'], $_POST['add_classcategory_id2']);
-            } elseif (!empty($_POST['edit_product_id'])) {
-                $this->lfUpdateProduct($_POST['edit_product_id'], $_POST['edit_classcategory_id1'], $_POST['edit_classcategory_id2'], $_POST['no']);
+            if (!empty($_POST['add_product_class_id'])) {
+                $this->lfInsertProduct($_POST['add_product_class_id']);
+            } elseif (!empty($_POST['edit_product_class_id'])) {
+                $this->lfUpdateProduct($_POST['edit_product_class_id'], $_POST['no']);
             }
             $arrData = $_POST;
@@ -695,6 +695,7 @@
     }
 
-    function lfInsertProduct($product_id, $classcategory_id1, $classcategory_id2) {
-        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2);
+    function lfInsertProduct($product_class_id) {
+        $objProduct = new SC_Product();
+        $arrProduct = $this->lfGetProductsClass($objProduct->getDetailAndProductsClass($product_class_id));
         $this->arrForm = $this->objFormParam->getFormParamList();
         $existes = false;
@@ -704,5 +705,5 @@
             foreach ($this->arrForm['product_class_id']['value'] AS $key=>$val) {
                 // 既に同じ商品がある場合
-                if ($val == $product_id && $this->arrForm['product_id']['classcategory_id1'][$key] == $classcategory_id1 && $this->arrForm['product_id']['classcategory_id2'][$key] == $classcategory_id2) {
+                if ($val == $product_class_id) {
                     $existes = true;
                     $existes_key = $key;
@@ -720,6 +721,7 @@
     }
 
-    function lfUpdateProduct($product_id, $classcategory_id1, $classcategory_id2, $no) {
-        $arrProduct = $this->lfGetProductsClass($product_id, $classcategory_id1, $classcategory_id2);
+    function lfUpdateProduct($product_class_id, $no) {
+        $objProduct = new SC_Product();
+        $arrProduct = $this->lfGetProductsClass($objProduct->getDetailAndProductsClass($product_class_id));
         $this->arrForm = $this->objFormParam->getFormParamList();
         $this->lfSetProductData($arrProduct, $no);
@@ -732,28 +734,25 @@
             }
             if ($no === null) {
-                $this->arrForm[$key]['value'][] = $arrProduct[$key];
+                $this->arrForm[$key]['value'][] = $val;
             } else {
-                $this->arrForm[$key]['value'][$no] = $arrProduct[$key];
-            }
-        }
-    }
-
-    function lfGetProductsClass($product_class_id) {
-        $objDb = new SC_Helper_DB_Ex();
-        $arrClassCatName = $objDb->sfGetIDValueList("dtb_classcategory", "classcategory_id", "name");
-        $arrRet = $objDb->sfGetProductsClass(array($product_class_id), true);
-
-        $arrProduct['price'] = $arrRet['price02'];
+                $this->arrForm[$key]['value'][$no] = $val;
+            }
+        }
+    }
+
+    function lfGetProductsClass($productsClass) {
+        $arrProduct['price'] = $productsClass['price02'];
         $arrProduct['quantity'] = 1;
-        $arrProduct['product_id'] = $arrRet['product_id'];
-        $arrProduct['product_class_id'] = $arrRet['product_class_id'];
-        $arrProduct['point_rate'] = $arrRet['point_rate'];
-        $arrProduct['product_code'] = $arrRet['product_code'];
-        $arrProduct['product_name'] = $arrRet['name'];
-        $arrProduct['classcategory_name1'] = $arrClassCatName[$arrRet['classcategory_id1']];
-        $arrProduct['classcategory_name2'] = $arrClassCatName[$arrRet['classcategory_id2']];
+        $arrProduct['product_id'] = $productsClass['product_id'];
+        $arrProduct['product_class_id'] = $productsClass['product_class_id'];
+        $arrProduct['point_rate'] = $productsClass['point_rate'];
+        $arrProduct['product_code'] = $productsClass['product_code'];
+        $arrProduct['product_name'] = $productsClass['name'];
+        $arrProduct['classcategory_name1'] = $productsClass['classcategory_name1'];
+        $arrProduct['classcategory_name2'] = $productsClass['classcategory_name2'];
 
         return $arrProduct;
     }
+
 
     /**
