/home/mjc1/public_html/adm/shop_admin/itemsupply2_div.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<script>
    function urlencode(str) {
        str = (str + '').toString();
        return encodeURIComponent(str)
            .replace(/!/g, '%21')
            .replace(/'/g, '%27')
            .replace(/\(/g, '%28')
            .replace(/\)/g, '%29')
            .replace(/\*/g, '%2A')
            .replace(/%20/g, '+');
    }

    function urldecode(str) {
        return decodeURIComponent((str + '')
            .replace(/%(?![\da-f]{2})/gi, function() {
                return '%25';
            })
            .replace(/\+/g, '%20'));
    }


    function show_member(){

        $("#table_mem_list").empty();
        var form_val = $('#modal_member_form').serialize();
        $.ajax({
            type : "POST",    url : "<?php echo G5_ADMIN_URL?>/shop_admin/itemsupply2.php",    data: form_val, dataType : "html",    
            success : function(xml){
                f = document.all;
                $("textarea[name=xml_temp]").val(xml);
                xml_obj = xml;
                ml_it_id = $(xml).find("it_id").text();
                ml_it_name = $(xml).find("it_name");
                ml_it_price = $(xml).find("it_price");
                ml_it_buyprice = $(xml).find("it_buyprice");
                ml_io_id = $(xml).find("io_id");
                ml_it_qty = $(xml).find("it_qty");
                ml_it_img = $(xml).find("it_img");

                member_cnt = $(xml).find("member_cnt").text();
                page_div = $(xml).find("page_div").text();
                for(i=0;i<member_cnt;i++){
                    $("#table_mem_list").append("<tr class='bg1' align=center id='trid_"+$(ml_it_id).eq(i).text()+"_"+$(ml_io_id).eq(i).text()+"'><td class='td_id'>"+urldecode($(ml_it_img).eq(i).text())+"</td><td class='td_id'>"+$(ml_it_name).eq(i).text()+"</td><td class='td_id'>"+$(ml_io_id).eq(i).text()+"</td><td class='td_id'>"+$(ml_it_price).eq(i).text()+"</td><td class='td_id'>"+$(ml_it_buyprice).eq(i).text()+"</td><td class='td_id'>"+$(ml_it_qty).eq(i).text()+"</td><td class='td_id' style='width:60px;'><span onclick=\"sel_member("+i+",'a')\" class='' style='cursor:pointer;'>[상품정보가져오기]</span></td></tr>");
                }
                //alert(page_div.html());
                //page_div.replace
                $("#dialog_paging").html(page_div);
            },    
            error : function(v){ alert('실패!'); }
        });

        $("#modal_member_box" ).dialog({
            resizable: true, height:630, width:880, modal: true,
            buttons: {
                Close: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    }
    function search_member(){
        f = document.modal_member_form;
        show_member();
    }
    function search_member_key(){
        if(event.keyCode==13){ show_member(); }
    }
    function ch_page(v){
        document.modal_member_form.page.value = v;
        show_member()
    }

    function sel_member(i,t){
        $(".sit_option_frm_wrapper").show();
        f = document.fregisterform;
        //xml = $("textarea[name=xml_temp]").val();
        xml = xml_obj;
        ml_it_id = $(xml).find("it_id").eq(i).text();
        ml_it_name = $(xml).find("it_name").eq(i).text();
        ml_it_price = $(xml).find("it_price").eq(i).text().replace(/,/g,"");
        ml_it_buyprice = $(xml).find("it_buyprice").eq(i).text().replace(/,/g,"");
        ml_io_id = $(xml).find("io_id").eq(i).text();
        ml_it_qty = $(xml).find("it_qty").eq(i).text();
        ml_it_img = urldecode($(xml).find("it_img").eq(i).text());

        ml_field_name = $(xml).find("field_name").text();
        ml_fn = ml_field_name.split("_");

        //alert(ml_field_name);        alert(ml_fn[3]);

        // 추가항목 필드에 해당 상품명과 코드를 집어 넣는다.
        spl_name = ml_it_name;
        if(ml_io_id!=''){ spl_name = spl_name +"▶옵션 "+ml_io_id+""; }

        spl_code = ml_it_id;
        if(ml_io_id!=''){ spl_code = spl_code +"§"+ml_io_id; }
        spl_qty = ml_it_qty;
        spl_price = ml_it_price;
        spl_buyprice = ml_it_buyprice;

        vv_name = $("#spl_item_"+ml_fn[3]).val();
        vv_code = $("#spl_item_code_"+ml_fn[3]).val();
        vv_qty = $("#spl_item_qty_"+ml_fn[3]).val();
        vv_price = $("#spl_item_price_"+ml_fn[3]).val();
        vv_buyprice = $("#spl_item_buyprice_"+ml_fn[3]).val();
        vv_list = vv_code.split(",");
        flag1 = 0;
        for(i=0;i<vv_list.length;i++){
            //alert(vv_list[i]+" "+spl_code);
            if(vv_list[i]==spl_code){ flag1 = 1; break;}
        }
        if(flag1==0){
            vvv_name = vv_name+spl_name+",";
            vvv_code = vv_code+spl_code+",";
            vvv_qty = vv_qty+spl_qty+",";
            vvv_price = vv_price+spl_price+",";
            vvv_buyprice = vv_buyprice+spl_buyprice+",";
            $("#spl_item_"+ml_fn[3]).val(vvv_name);
            $("#spl_item_code_"+ml_fn[3]).val(vvv_code);
            $("#spl_item_qty_"+ml_fn[3]).val(vvv_qty);
            $("#spl_item_price_"+ml_fn[3]).val(vvv_price);
            $("#spl_item_buyprice_"+ml_fn[3]).val(vvv_buyprice);
        }

        /*var url = "./itemsupply.php";
        var form_val = $('#fitemform').serialize();
        $.post(url,form_val,function(rtn){
            alert(rtn);
        });*/

        create_supply_table();
    }

    function create_supply_table(){
        var it_id = $.trim($("input[name=it_id]").val());
        var subject = new Array();
        var supply = new Array();
        var supply_code = new Array();
        var supply_qty = new Array();
        var supply_price = new Array();
        var supply_buyprice = new Array();
        var subj, spl;
        var count = 0;
        var $el_subj = $("input[name='spl_subject[]']");
        var $el_spl = $("input[name='spl[]']");
        var $el_spl_code = $("input[name='spl_code[]']");
        var $el_spl_qty = $("input[name='spl_qty[]']");
        var $el_spl_price = $("input[name='spl_prices[]']");
        var $el_spl_buyprice = $("input[name='spl_buyprices[]']");
        var $supply_table = $("#sit_option_addfrm");

        $el_subj.each(function(index) {
            subj = $.trim($(this).val());
            spl = $.trim($el_spl.eq(index).val());
            spl_code = $.trim($el_spl_code.eq(index).val());
            spl_qty = $.trim($el_spl_qty.eq(index).val());
            spl_price = $.trim($el_spl_price.eq(index).val());
            spl_buyprice = $.trim($el_spl_buyprice.eq(index).val());

            if(subj && spl) {
                subject.push(subj);
                supply.push(spl);
                supply_code.push(spl_code);
                supply_qty.push(spl_qty);
                supply_price.push(spl_price);
                supply_buyprice.push(spl_buyprice);
                count++;
            }
        });

        if(!count) {
            alert("추가옵션명과 추가옵션항목을 입력해 주십시오.");
            return false;
        }

        $.post(
            "<?php echo G5_ADMIN_URL?>/shop_admin/itemsupply.php",
            { it_id: it_id, w: "<?php echo $w?>", 'subject[]': subject, 'supply[]': supply, 'supply_code[]': supply_code, 'supply_qty[]': supply_qty, 'supply_price[]': supply_price, 'supply_buyprice[]': supply_buyprice },
            function(data) {
                $supply_table.empty().html(data);
            }
        );
    }
</script>
<textarea name='xml_temp' style='display:none;width:600px;height:300px;' ></textarea>
<link rel="stylesheet" href="<?php echo G5_PLUGIN_URL ?>/jquery-ui/jquery-ui.css">
<!--<textarea name='xml_temp' style='display:none;'></textarea>-->
<div id="modal_member_box" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;">
    <p class='dialog_css_p'>상품추가옵션 상품찾기</p>
    <form name='modal_member_form' id='modal_member_form' onsubmit="return false;" onkeypress='search_member_key();'>
        <input type='hidden' name='mode' value='reg_volume'>
        <input type='hidden' name='page' value='1'>
        <input type='hidden' name='field_name' value=''>
        <input type='hidden' name='it_id' value='<?php echo $it_id?>'>
        <div style='padding-left:5px;padding-bottom:8px; color:#787878;'>
            <select name='searchkey' class="dialog_select">
                <option value='it_name'>상품명
                <option value='it_id'>상품코드
                <option value='ca_name'>분류명
            </select>&nbsp;
            <input type='text' name='wordkey' class='frm_input' style='width:100px; line-height:24px;'>&nbsp;
            <span onclick='search_member()' class='btn_frmline'>검색</span>
            &nbsp; : 검색으로 상품을 찾으시기 바랍니다.
        </div>
        <div class="tbl_head01 tbl_wrap dialog_table">
            <table>
                <caption>상품 목록</caption>
                <thead>
                <tr>
                    <th scope="col">이미지</th>
                    <th scope="col">상품명</th>
                    <th scope="col">옵션</th>
                    <th scope="col">가격</th>
                    <th scope="col">구입가</th>
                    <th scope="col">재고</th>
                    <th scope="col" style="width:120px;">선택</th>
                </tr>
                </thead>
                <tbody id='table_mem_list'>

                </tbody>
            </table>
            <div id='dialog_paging'></div>
        </div>
    </form>
</div>