/home/mjc1/public_html/emillennium/product_group.inc.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
<?php
$dir 
".";
include_once(
$dir."/_common.php");

$sql "select * from product_category2 a where 1=1 order by code";
$result      =    mysql_query($sql,$connect_e1000y);

while(
$cus_info=mysql_fetch_array($result)){
    
$list_array[] = $cus_info;
}
?>
<style>
    .sub-btn a { color:white;}
</style>
<div id="sub-contents-area">
    <div class="sub-btn-area">
        <div class="sub-btn">
            <a class="lignt-blue-btn" id='btn_order_new_group'>신규등록</a><a class="black-btn" id='sel_delete_group'>선택삭제</a>
        </div>
    </div>
</div>

<form name='product_group_form' method='post'>
<input type='hidden' name='sel_del' value=''>
    <div class="div-list-area">
        <div class="cust-list-area">
            <table class="order-sheet2">
                <caption class="screen_out">매입처 원장 조회<caption>
                <colgroup>
                <col style="width:30px;">
                <col style="width:100px;"><col style="width:200px;">
                <col style="width:260px;">
                </colgroup>

                <thead>
                    <tr>
                        <th scope="col"><input type='checkbox' name='ck_all' class='check_all_class'></th>
                        <th scope="col">코드</th><th scope="col">그룹명</th>    <th scope="col">비고</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    
for($i=0;$i<count($list_array);$i++){ 
        
$info $list_array[$i];
?>
                    <tr <?php if($i==0){?>class='group_first_tr'<?php }?>>
                        <td class="tcenter ">
                            <input type='checkbox' name='code_idx[]' value='<?php echo $i;?><?php if($i==0){?>disabled class='not_check'<?php }?>>
                            <input type='hidden' name='codes[]' value='<?php echo $info['code'];?>'>
                        </td>
                        <td class="linetxt "><?php echo $info['code1'];?></td>
                        <td class="linetxt "><input type='text' name='name[]' value='<?php echo $info['name'];?>' style='width:180px;'></td>
                        <td class="linetxt"><input type='text' name='remarks[]' value='<?php echo $info['remarks'];?>' style='width:240px;'></td>
                    </tr>
<?php 
    

?>
                </tbody>
            </table>
        </div>
    </div>
</form>
<script>
$(function(){

    $("#btn_order_new_group").click(function(){ // 그룹 추가하기
        html = "<tr>\n";
        html += "<tr>\n";
        html += "    <td class='tcenter '>\n";
        html += "        <input type='checkbox' name='code_idx[]' value='' checked>\n";
        html += "        <input type='hidden' name='codes[]' value=''>\n";
        html += "    </td>\n";
        html += "    <td class='linetxt'>신규등록</td>\n";
        html += "    <td class='linetxt'><input type='text' name='name[]' value='' style='width:180px;'></td>\n";
        html += "    <td class='linetxt'><input type='text' name='remarks[]' value='' style='width:240px;'></td>\n";
        html += "</tr>\n";
        if($(".group_first_tr").size()==0){
            $("form[name='product_group_form'] .order-sheet2 tbody").append(html);
            var idx = 0;
        } else {
            $(".group_first_tr").after(html);
            var idx = 0;
        }
        $("form[name='product_group_form'] input[name='code_idx[]']").each(function(){
            $(this).val(idx);
            idx++;
        });
    });



    $("form[name='product_group_form'] .check_all_class").click(function(){ // 전체 선택하기
        if($(this).is(":checked")){
            $("form[name='product_group_form'] input[name='code_idx[]']").not(".not_check").prop("checked",true);
        } else {
            $("form[name='product_group_form'] input[name='code_idx[]']").prop("checked",false);            
        }    
    });

    $("#sel_delete_group").click(function(){ // 선택 삭제
        var idx_cnt = 0;
        $("form[name='product_group_form'] input[name='code_idx[]']").each(function(){
            if($(this).is(":checked")){ idx_cnt++; }
        });
        if(idx_cnt==0){
            alert('삭제하실 상품그룹을 선택하세요.'); return;
        }

        if(confirm("정말로 삭제하시겠습니까?")){
            $("form[name='product_group_form'] input[name='sel_del']").val("Y");
            var form_data = $("form[name='product_group_form']").serialize();

            $.ajax({type:"post", url:"ajax.product_group_process.php", data:form_data, async:false, dataType : "xml", 
                success:function(xml){    
                    var v_mode = $(xml).find("mode").text();
                    var v_mode_ok = $(xml).find("mode_ok").text();
                    var v_msg = $(xml).find("msg").text();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        $("form[name='product_group_form'] input[name='code_idx[]']").each(function(){
                            if($(this).is(":checked")){ 
                                var tr_obj = $(this).closest("tr").remove();
                            }
                        });
                        $.get("ajax.product_group.option.php",function(rtn){
                            $("select[name='prod_cate_code2']").find("option").remove();
                            $("select[name='prod_cate_code2']").append(rtn);
                            $("#modal_member_box2").dialog("close");
                        });
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });    
        }
    });
});

function group_form_save(){ // 상품그룹 폼 저장하기
    $("form[name='product_group_form'] input[name='code_idx[]']").not(".not_check").prop("checked",true);

    $("form[name='product_group_form'] input[name='sel_del']").val("");
    var form_data = $("form[name='product_group_form']").serialize();

    $.ajax({type:"post", url:"ajax.product_group_process.php", data:form_data, async:false, dataType : "xml", 
        success:function(xml){    
            var v_mode = $(xml).find("mode").text();
            var v_mode_ok = $(xml).find("mode_ok").text();
            var v_msg = $(xml).find("msg").text();
            if(v_mode_ok!='Y'){
                alert(v_msg);
            } else {
                $.get("ajax.product_group.option.php",function(rtn){
                    $("select[name='prod_cate_code2']").find("option").remove();
                    $("select[name='prod_cate_code2']").append(rtn);
                    $("#modal_member_box2").dialog("close");
                });
            }
        },
        error:function(rtn,status,error){    alert(error);        }
    });
}
</script>