/home/mjc1/public_html/j3demo/adm/board_comm.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
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
<?php
if($id!=''){
    
$comm_w_name_hidden 'screen_out';
}
$cominfo['w_name'] = $id_name;
?>
<style>
    .order-sheet tfoot th, .order-sheet tfoot td { border-bottom:1px solid #c0c0c0; }
    .cust_modal4 h4 {margin:5px;}
    .cust_modal4 table tr th, .cust_modal4 table tr td {text-align:left;padding-left:10px;}
    .cust_modal4 table tr th { position:relative;}
    .cust_modal4 table tr td { padding:7px; }
    .com_head_span_classs {position:absolute;font-weight:normal;right:10px;}
    .com_head_span_classs label { color:darkblue; cursor:pointer; }
    .comm_w_cont_class {width:90%;height:100px;margin-top:10px;}
    .comm_save_btn { position:relative;top:-40px;left:20px;width:60px;height:50px;}
</style>
<div class='cust_modal4'>
    <h4>댓글 정보</h4>
    <table class="order-sheet table-top-border" style='width:1160px;'>
        <caption class="screen_out">댓글</caption>
        <colgroup>
            <col style="width:200px;"><col style="width:800px;">
        </colgroup>
        <tbody class='comm_list_tbody'>
        
        </tbody>
        <tfoot class='comm_reg_tfoot'>
<form name='comm_reg_form' id='comm_reg_form' method='post' action='ajax.board_reg_process.php'>
<input type='hidden' name='b_table' value='<?php echo $b_table;?>'>
<input type='hidden' name='mode' value='comment'>
<input type='hidden' name='pcode' value='<?php echo $code;?>'>
<input type='hidden' name='idx' value=''>
<input type='hidden' name='c_mode' value=''>
<input type='hidden' name='w_ecode' value='<?php echo $id_code;?>'>
<input type='hidden' name='w_ccode' value='<?php echo $id_ccode;?>'>
<input type='hidden' name='w_login_id' value='<?php echo $id;?>'>

            <tr>
                <td>
                    <span class='<?php echo $comm_w_name_hidden;?>'>작성자 : <input type='text' name='w_name' value='<?php echo $cominfo['w_name']?>'> &nbsp;비밀번호 : <input type='password' name='w_passwd'><br></span>
                    <textarea name='w_content' class='comm_w_cont_class'></textarea>
                    <input type='button' value='저장' class='comm_save_btn'>
                </td>
            </tr>
</form>
        </tfoot>
    </table>
</div>
<script>
$(function(){
    $(".comm_reg_tfoot .comm_save_btn").click(function(){ // 댓글 저장
        if($(".comm_reg_tfoot .comm_w_cont_class").val()==''){
            alert('내용을 입력하세요.'); return;
        }
        form_data = $("#comm_reg_form").serialize();
        $.ajax({type:"post", url:"ajax.board_reg_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'){
                    comm_list_get();
                    $(".comm_w_cont_class").val("");
                } else {
                    alert(v_msg);
                }
            },
            error:function(rtn,status,error){    alert(error);        }
        });
    });

    $(document).on("click",".ccomm_class",function(){ // 대댓글 오픈
        $tr_obj = $(this).closest("tr");
        w_idx = $tr_obj.find("input[name='w_idx[]']").val();
        $form_obj = $("#ccomm_reg_form");
        $form_obj.find("input[name='pcode']").val(w_idx); // 댓글의 부모코드를 가져온다.
        $form_obj.find("input[name='c_mode']").val('ccom'); // 댓글모드 파라메터
        $form_obj.find(".comm_w_cont_class").val(''); // 내용 초기화
        $("#modal_member_box").dialog({
            resizable: true, height:320, width:1050, modal: true, title:"대댓글 [작성]",
            buttons: {
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });

    $(document).on("click",".ccomm_reg_tfoot .comm_save_btn",function(){ // 대댓글 저장
        if($(".ccomm_reg_tfoot .comm_w_cont_class").val()==''){
            alert('내용을 입력하세요.'); return;
        }
        form_data = $("form[name='ccomm_reg_form']").serialize();
        $.ajax({type:"post", url:"ajax.board_reg_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'){
                    $("#modal_member_box").dialog("close");
                    comm_list_get();
                    $(".comm_w_cont_class").val("");
                } else {
                    alert(v_msg);
                }
            },
            error:function(rtn,status,error){    alert(error);        }
        });
    });

    $(document).on("click",".ecomm_class",function(){ // 수정 오픈
        $tr_obj = $(this).closest("tr");
        w_idx = $tr_obj.find("input[name='w_idx[]']").val();
        w_name = $tr_obj.find("input[name='w_name[]']").val();
        w_content = $tr_obj.find("input[name='w_content[]']").val();

        $form_obj = $("#ccomm_reg_form");
        $form_obj.find("input[name='pcode']").val(w_idx); // 댓글의 부모코드를 가져온다.
        $form_obj.find("input[name='c_mode']").val('ecom'); // 댓글모드 파라메터
        $form_obj.find(".comm_w_name_class").val(w_name); // 작성자 입력
        $form_obj.find(".comm_w_cont_class").val(w_content); // 내용 입력
        $("#modal_member_box").dialog({
            resizable: true, height:320, width:1050, modal: true, title:"댓글 [수정]",
            buttons: {
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });

    $(document).on("click",".dcomm_class",function(){ // 삭제 오픈
        if(confirm('삭제하시겠습니까?')){
            $tr_obj = $(this).closest("tr");
            w_idx = $tr_obj.find("input[name='w_idx[]']").val();

            $form_obj = $("#dcomm_reg_form");
            $form_obj.find("input[name='pcode']").val(w_idx); // 댓글의 부모코드를 가져온다.
            $form_obj.find("input[name='c_mode']").val('dcom'); // 댓글모드 파라메터

            form_data = $("#dcomm_reg_form").serialize();

            //alert(form_data); return;
            $.ajax({type:"post", url:"ajax.board_reg_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'){
                        comm_list_get();
                    } else {
                        alert(v_msg);
                        $("#modal_member_box2").dialog({
                            resizable: true, height:200, width:1050, modal: true, title:"댓글비번 [삭제]",
                            buttons: {
                                삭제: function() {
                                    if($(".comm_del_passwd").val()==''){
                                        alert('비밀번호를 입력하세요.'); return;
                                    }
                                    comm_delete();
                                },
                                닫기: function() {
                                    $( this ).dialog( "close" );
                                }
                            }
                        });
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });
        }
    });
    comm_list_get();
});

function comm_delete(){ // 댓글 비번 삭제
    form_data = $("#dcomm_reg_form").serialize();

    //alert(form_data); return;
    $.ajax({type:"post", url:"ajax.board_reg_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'){
                $("#modal_member_box2").dialog("close");
                comm_list_get();
            } else {
                alert(v_msg);
            }
        },
        error:function(rtn,status,error){    alert(error);        }
    });
}

function comm_list_get(){
    $.get("board_comm_list.inc.php?b_table=<?php echo $b_table;?>&code=<?php echo $code;?>",function(rtn){
        $(".comm_list_tbody").html(rtn);
    });
}
</script>
<div id="modal_member_box" title="대댓글 및 수정용" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;">
    <div class='cust_modal3' style='width:100% !important;'>
        <h4>댓글 정보</h4>
<form name='ccomm_reg_form' id='ccomm_reg_form' method='post' action='ajax.board_reg_process.php'>
<input type='hidden' name='b_table' value='<?php echo $b_table;?>'>
<input type='hidden' name='mode' value='comment'>
<input type='hidden' name='pcode' value='<?php echo $code;?>'>
<input type='hidden' name='idx' value=''>
<input type='hidden' name='c_mode' value=''>
<input type='hidden' name='w_ecode' value='<?php echo $id_code;?>'>
<input type='hidden' name='w_ccode' value='<?php echo $id_ccode;?>'>
<input type='hidden' name='w_login_id' value='<?php echo $id;?>'>
        <table class="order-sheet table-top-border">
            <tfoot class='ccomm_reg_tfoot'>
            <tr>
                <td>
                    <span class='<?php echo $comm_w_name_hidden;?>'>작성자 : <input type='text' name='w_name' value='<?php echo $cominfo['w_name']?>' class='comm_w_name_class'> &nbsp;비밀번호 : <input type='password' name='w_passwd'><br></span>
                    <textarea name='w_content' class='comm_w_cont_class'></textarea>
                    <input type='button' value='저장' class='comm_save_btn'>
                </td>
            </tr>
            </tfoot>
        </table>
</form>
    </div>
</div>

<div id="modal_member_box2" title="삭제용" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF;position:relative;">
    <div class='cust_modal3' style='width:100% !important;'>
        <h4>댓글 정보</h4>
<form name='dcomm_reg_form' id='dcomm_reg_form' method='post' action='ajax.board_reg_process.php'>
<input type='hidden' name='b_table' value='<?php echo $b_table;?>'>
<input type='hidden' name='mode' value='comment'>
<input type='hidden' name='pcode' value='<?php echo $code;?>'>
<input type='hidden' name='idx' value=''>
<input type='hidden' name='c_mode' value='dcom'>
        <table class="order-sheet table-top-border">
            <tfoot class='ccomm_reg_tfoot'>
            <tr>
                <td>
                    비밀번호 : <input type='password' name='w_passwd' class='comm_del_passwd'>
                    <span class='help_info'>전체관리자는 아무비번 입력</span>
                </td>
            </tr>
            </tfoot>
        </table>
</form>
    </div>
</div>