source: branches/version-2_13-dev/data/Smarty/templates/admin/order/product_select.tpl @ 23065

Revision 23065, 12.0 KB checked in by pineray, 11 years ago (diff)

#2342 JavaScript?のグローバルな宣言を減らす
商品関連.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-smarty-template; charset=UTF-8
Line 
1<!--{*
2/*
3 * This file is part of EC-CUBE
4 *
5 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
6 *
7 * http://www.lockon.co.jp/
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 */
23*}-->
24
25<!--{include file="`$smarty.const.TEMPLATE_ADMIN_REALDIR`admin_popup_header.tpl"}-->
26
27<script type="text/javascript">//<![CDATA[
28    self.moveTo(20,20);self.focus();
29
30    function func_submit(product_id, class_name1, class_name2) {
31        var err_text = '';
32        var fm = window.opener.document.form1;
33        var fm1 = window.opener.document;
34        var class1 = "classcategory_id" + product_id + "_1";
35        var class2 = "classcategory_id" + product_id + "_2";
36
37        var class1_id = document.getElementById(class1).value;
38        var class2_id = document.getElementById(class2).value;
39
40        var product_class_id = document.getElementById("product_class_id" + product_id).value;
41        var opner_product_id = 'add_product_id';
42        var opner_product_class_id = 'add_product_class_id';
43        var tpl_no = '<!--{$tpl_no}-->';
44        var shipping_id = '<!--{$shipping_id}-->';
45
46        if (tpl_no != '') {
47            opner_product_id = 'edit_product_id';
48            opner_product_class_id = 'edit_product_class_id';
49            fm1.getElementById("no").value = escape('<!--{$tpl_no}-->');
50        }
51        if (shipping_id != '') {
52            fm1.getElementById("select_shipping_id").value = escape('<!--{$shipping_id}-->');
53        }
54        if (document.getElementById(class1).type == 'select-one' && class1_id == '__unselected') {
55            err_text = class_name1 + "を選択してください。\n";
56        }
57        if (document.getElementById(class2).type == 'select-one' && class2_id == '') {
58            err_text = err_text + class_name2 + "を選択してください。\n";
59        }
60
61        if(!class1_id){
62            err_text = eccube.productsClassCategories[product_id]['__unselected2']['#0']['stock_find'] ? '' : '只今品切れ中です';
63        }else if(class1_id && !class2_id){
64            err_text = eccube.productsClassCategories[product_id][class1_id]['#0']['stock_find'] ? '' : '只今品切れ中です';
65        }else{
66            err_text = eccube.productsClassCategories[product_id][class1_id]['#' + class2_id]['stock_find'] ? '' : '只今品切れ中です';
67        }
68
69        if (err_text != '') {
70            alert(err_text);
71            return false;
72        }
73
74        fm1.getElementById(opner_product_id).value = product_id;
75        fm1.getElementById(opner_product_class_id).value = product_class_id;
76
77        fm.mode.value = 'select_product_detail';
78        fm.anchor_key.value = 'order_products';
79        fm.submit();
80        window.close();
81
82        return true;
83    }
84
85    // 規格2に選択肢を割り当てる。
86    function fnSetClassCategories(form, classcat_id2_selected) {
87        sele1 = form.classcategory_id1;
88        sele2 = form.classcategory_id2;
89        product_id = form.product_id.value;
90
91        if (sele1) {
92            if (sele2) {
93                // 規格2の選択肢をクリア
94                count = sele2.options.length;
95                for(i = count; i >= 0; i--) {
96                    sele2.options[i] = null;
97                }
98
99                // 規格2に選択肢を割り当てる
100                classcats = eccube.productsClassCategories[product_id][sele1.value];
101                i = 0;
102                for (var classcat_id2_key in classcats) {
103                    classcategory_id2 = classcats[classcat_id2_key].classcategory_id2;
104                    sele2.options[i] = new Option(classcats[classcat_id2_key].name, classcategory_id2);
105                    if (classcategory_id2 == classcat_id2_selected) {
106                        sele2.options[i].selected = true;
107                    }
108                    i++;
109                }
110            }
111            fnCheckStock(form);
112        }
113    }
114
115    function fnCheckStock(form) {
116        product_id = form.product_id.value;
117        classcat_id1 = form.classcategory_id1.value;
118        classcat_id2 = form.classcategory_id2 ? form.classcategory_id2.value : '';
119        classcat2 = eccube.productsClassCategories[product_id][classcat_id1]['#' + classcat_id2];
120        // 商品規格
121        eleDynamic = document.getElementById('product_class_id' + product_id);
122        if (
123            classcat2
124            && typeof classcat2.product_class_id != 'undefined'
125            && String(classcat2.product_class_id).length >= 1
126        ) {
127            eleDynamic.value = classcat2.product_class_id;
128        } else {
129            // 規格が1つのみの場合
130            classcat1 = eccube.productsClassCategories[product_id][classcat_id1]['#0'];
131            eleDynamic.value = classcat1.product_class_id;
132        }
133    }
134//]]></script>
135
136<!--▼検索フォーム-->
137<form name="form1" id="form1" method="post" action="?">
138    <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
139    <input name="mode" type="hidden" value="search" />
140    <input name="anchor_key" type="hidden" value="" />
141    <input name="search_pageno" type="hidden" value="" />
142    <input name="shipping_id" type="hidden" value="<!--{$shipping_id}-->" />
143    <input name="no" type="hidden" value="<!--{$tpl_no|h}-->" />
144    <table class="form">
145        <col width="20%" />
146        <col width="80%" />
147        <tr>
148            <th>カテゴリ</th>
149            <td>
150                <select name="search_category_id">
151                    <option value="" selected="selected">選択してください</option>
152                    <!--{html_options options=$arrCatList selected=$arrForm.search_category_id}-->
153                </select>
154            </td>
155        </tr>
156        <tr>
157            <th>商品名</th>
158            <td><input type="text" name="search_name" value="<!--{$arrForm.search_name|h}-->" size="35" class="box35" /></td>
159        </tr>
160        <tr>
161            <th>商品コード</th>
162            <td><input type="text" name="search_product_code" value="<!--{$arrForm.search_product_code|h}-->" size="35" class="box35" /></td>
163        </tr>
164    </table>
165    <div class="btn-area">
166        <ul>
167            <li><a class="btn-action" href="javascript:;" onclick="eccube.common.fnFormModeSubmit('form1', 'search', '', ''); return false;"><span class="btn-next">検索を開始</span></a></li>
168        </ul>
169    </div>
170</form>
171<!--▼検索結果表示-->
172<!--{if $tpl_linemax}-->
173    <p>
174        <!--{$tpl_linemax}-->件が該当しました。
175        <!--{$tpl_strnavi}-->
176    </p>
177
178    <!--▼検索後表示部分-->
179    <table class="list">
180    <col width="20%" />
181    <col width="20%" />
182    <col width="50%" />
183    <col width="10%" />
184        <tr>
185            <th class="image">商品画像</th>
186            <th class="id">商品コード</th>
187            <th class="name">商品名</th>
188            <th class="action">決定</th>
189        </tr>
190        <!--{section name=cnt loop=$arrProducts}-->
191            <!--{assign var=id value=$arrProducts[cnt].product_id}-->
192            <form name="product_form<!--{$id|h}-->" action="?" onsubmit="return false;">
193                <!--▼商品<!--{$smarty.section.cnt.iteration}-->-->
194                <!--{assign var=status value="`$arrProducts[cnt].status`"}-->
195                <tr style="background:<!--{$arrPRODUCTSTATUS_COLOR[$status]}-->;">
196                    <td class="center">
197                        <img src="<!--{$smarty.const.IMAGE_SAVE_URLPATH}--><!--{$arrProducts[cnt].main_list_image|sfNoImageMainList|h}-->" style="max-width: 65px;max-height: 65;" alt="<!--{$arrRecommend[$recommend_no].name|h}-->" />
198                    </td>
199                    <td>
200                        <input type="hidden" name="<!--{$smarty.const.TRANSACTION_ID_NAME}-->" value="<!--{$transactionid}-->" />
201                        <!--{assign var=codemin value=`$arrProducts[cnt].product_code_min`}-->
202                        <!--{assign var=codemax value=`$arrProducts[cnt].product_code_max`}-->
203                        <!--{* 商品コード *}-->
204                        <!--{if $codemin != $codemax}-->
205                            <!--{$codemin|h}-->~<!--{$codemax|h}-->
206                        <!--{else}-->
207                            <!--{$codemin|h}-->
208                        <!--{/if}-->
209                    </td>
210                    <td>
211                    <!--{$arrProducts[cnt].name|h}-->
212                    <!--{assign var=class1 value=classcategory_id`$id`_1}-->
213                    <!--{assign var=class2 value=classcategory_id`$id`_2}-->
214                    <!--{if $tpl_classcat_find1[$id]}-->
215                    <dl>
216                        <dt><!--{$tpl_class_name1[$id]|h}-->:</dt>
217                        <dd>
218                            <select name="classcategory_id1" id="<!--{$class1}-->" style="<!--{$arrErr[$class1]|sfGetErrorColor}-->"    onchange="fnSetClassCategories(this.form);">
219                                <!--{html_options options=$arrClassCat1[$id] selected=$arrForm[$class1]}-->
220                            </select>
221                            <!--{if $arrErr[$class1] != ""}-->
222                            <br /><span class="attention">※ <!--{$tpl_class_name1[$id]}-->を入力して下さい。</span>
223                            <!--{/if}-->
224                        </dd>
225                    </dl>
226                    <!--{else}-->
227                    <input type="hidden" name="<!--{$class1}-->" id="<!--{$class1}-->" value="" />
228                    <!--{/if}-->
229
230                    <!--{if $tpl_classcat_find2[$id]}-->
231                    <dl>
232                        <dt><!--{$tpl_class_name2[$id]|h}-->:</dt>
233                        <dd>
234                            <select name="classcategory_id2" id="<!--{$class2}-->" style="<!--{$arrErr[$class2]|sfGetErrorColor}-->" onchange="fnCheckStock(this.form);"></select>
235                            <!--{if $arrErr[$class2] != ""}-->
236                            <br /><span class="attention">※ <!--{$tpl_class_name2[$id]}-->を入力して下さい。</span>
237                            <!--{/if}-->
238                        </dd>
239                    </dl>
240                    <!--{else}-->
241                    <input type="hidden" name="<!--{$class2}-->" id="<!--{$class2}-->" value="" />
242                    <!--{/if}-->
243                    <!--{if !$tpl_stock_find[$id]}-->
244                        <div class="attention">只今品切れ中です。</div>
245                    <!--{/if}-->
246                    <input type="hidden" name="product_id" value="<!--{$id|h}-->" />
247                    <input type="hidden" name="product_class_id<!--{$id|h}-->" id="product_class_id<!--{$id|h}-->" value="<!--{$tpl_product_class_id[$id]}-->" />
248                    <input type="hidden" name="product_type" id="product_type<!--{$id|h}-->" value="<!--{$tpl_product_type[$id]}-->" />
249                    </td>
250                    <td class="center"><a href="javascript:;" onclick="return func_submit('<!--{$arrProducts[cnt].product_id}-->', '<!--{$tpl_class_name1[$id]}-->', '<!--{$tpl_class_name2[$id]}-->'); return false;">決定</a></td>
251                </tr>
252                <!--▲商品<!--{$smarty.section.cnt.iteration}-->-->
253            </form>
254        <!--{sectionelse}-->
255            <tr>
256                <td colspan="4">商品が登録されていません</td>
257            </tr>
258        <!--{/section}-->
259    </table>
260<!--{/if}-->
261<!--▲検索結果表示-->
262
263
264<!--{include file="`$smarty.const.TEMPLATE_ADMIN_REALDIR`admin_popup_footer.tpl"}-->
Note: See TracBrowser for help on using the repository browser.