/home/mjc1/public_html/manage/m_menual_reg.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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<?
    
@session_start();
    include(
"./include/admin_include_header.php");
?>
<link rel='stylesheet' type='text/css' href='./css/new.css'>
<script src="../ckeditor/ckeditor.js"></script>
<?php
if($idx != "") {
    
$ttl_txt "¼öÁ¤Çϱâ";

    
$sql "select * from mBoard_menual where idx = '{$idx}'";
    
$res mysql_query($sql,$connect_web);
    
$info mysql_fetch_array($res);

    
// Áߺзù
    
$cat2_sql "SELECT a.idx, a.name FROM mBoard_menual_cate2 AS a WHERE pidx = '{$info[cidx_1]}' ORDER BY idx ASC";
    
$cat2_res mysql_query($cat2_sql,$connect_web);

    
// ¼ÒºÐ·ù
    
$cat3_sql "SELECT a.idx, a.name FROM mBoard_menual_cate3 AS a WHERE pidx = '{$info[cidx_2]}' ORDER BY idx ASC";
    
$cat3_res mysql_query($cat3_sql,$connect_web);

    
// ¸µÅ©
    
$link_sql "SELECT a.link, a.keyword, a.name FROM mBoard_menual_link AS a WHERE a.pidx = '{$idx}' ORDER BY idx ASC";
    
$link_res mysql_query($link_sql,$connect_web);

    
// ¸Å´º¾ó º»¹®
    
$con_sql "SELECT a.title, a.content, a.keyword FROM mBoard_menual_content AS a WHERE a.pidx = '{$idx}' ORDER BY idx ASC";
    
$con_res mysql_query($con_sql,$connect_web);

    
// faq
    
$faq_sql "SELECT * FROM mBoard_menual_faq AS a WHERE a.pidx = '{$idx}'";
    
$faq_res mysql_query($faq_sql,$connect_web);

} else {
    
$ttl_txt "µî·ÏÇϱâ";
}

// ´ëºÐ·ù
$cat1_sql "SELECT a.idx, a.name FROM mBoard_menual_cate1 AS a ORDER BY idx ASC";
$cat1_res mysql_query($cat1_sql,$connect_web);
?>


<style>
.wrap{height: auto !important;}

.editTable td{padding: 5px 10px !important;}
th{width: 12%;}
select{height: 28px !important;width: 140px !important;line-height: 28px !important;cursor: pointer;}
input{height: 28px !important;line-height: 26px;width: 800px !important;}

.reg_tit{font-size: 20px;font-weight: bold;height: 40px;line-height: 40px;border: 1px solid #d1d7de;background: #dbe2e9;}

.btn1Warp{width: 190px !important;}
.add_menual, .cancel_menual, .add_menual_content, .del_menual_content{height: 35px;line-height: 32px;width: 90px;font-size: 12px;font-weight: bold;letter-spacing: -1px;border: 1px solid #9faebe;cursor: pointer;background: linear-gradient(to bottom,  rgba(219,226,233,1) 0%,rgba(209,215,222,1) 100%);text-align: center;display: inline-block;}

/* FAQÀÛ¼º */
.faq_section{margin-top: 50px;}
.faq_hd{text-align: right;}
.faq_hd::after{content: '';display: block;clear: both;}
.faq_hd p{font-size: 20px;font-weight: bold;height: 40px;line-height: 40px;border: 1px solid #9faebe;background: #dbe2e9;padding: 0px 10px;text-align: center;}

.add_faq{display: inline-block;width: 100px;height: 30px;line-height: 28px;border: 1px solid #9faebe;background: linear-gradient(to bottom,  rgba(219,226,233,1) 0%,rgba(209,215,222,1) 100%);text-align: center;margin-bottom: 10px;font-weight: bold;cursor: pointer;}

.faq_ul::after{content: '';display: block;clear: both;}
.faq_ul li{width: 100%;box-sizing: border-box;line-height: 52px;height: 52px;font-size: 16px;border-bottom: 1px solid #d1d7de;padding: 0px 10px;cursor: pointer;}
.faq_ul li:hover{font-weight: bold;}

.del_link {display: inline-block;}
.linkbtn {display: inline-block;width: 100px;text-align: center;background: #999;color: #fff;font-weight: bold;}
</style>

<div class="container">
    <div class="border_contents">
        <div class="admin_table" style="padding-bottom: 120px;">
            <h3 class="list_ttl">
                ¸Å´º¾ó <?php echo $ttl_txt?>
                <span class="list_sub_ttl bgb">°ü¸®ÀÚ°¡ ¸Å´º¾óÀ» µî·ÏÇϴ ÆäÀÌÁö ÀÔ´Ï´Ù.</span>
            </h3>
            <form name="menual_reg_form" id="menual_reg_form" method="post">
                <input type="hidden" name="idx" value="<?php echo $idx?>">
                <h3 class="reg_tit" style="text-align: center;">¸Å´º¾ó</h3>
                <div class="editWarp" style="width: 100%;">
                    <table class="editTable">
                        <tr>
                            <th>´ëºÐ·ù</th>
                            <td>
                                <select name="cate1">
                                    <option value="">==¼±ÅÃÇϼ¼¿ä.==</option>
                                    <?php while($cat1_info mysql_fetch_array($cat1_res)) { 
                                        if(
$info['cidx_1'] == $cat1_info['idx']) { $selected "selected"; } else { $selected ""; }
                                    
?>
                                    <option value="<?php echo $cat1_info['idx']; ?><?php echo $selected?>><?php echo $cat1_info['name']; ?></option>
                                    <?php ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>Áߺзù</th>
                            <td>
                                <select name="cate2">
                                    <option value="">==¼±ÅÃÇϼ¼¿ä.==</option>
                                    <?php while($cat2_info mysql_fetch_array($cat2_res)) { 
                                        if(
$info['cidx_2'] == $cat2_info['idx']) { $selected "selected"; } else { $selected ""; }
                                    
?>
                                    <option value="<?php echo $cat2_info['idx']; ?><?php echo $selected?>><?php echo $cat2_info['name']; ?></option>
                                    <?php ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>¼ÒºÐ·ù</th>
                            <td>
                                <select name="cate3">
                                    <option value="">==¼±ÅÃÇϼ¼¿ä.==</option>
                                    <?php while($cat3_info mysql_fetch_array($cat3_res)) { 
                                        if(
$info['cidx_3'] == $cat3_info['idx']) { $selected "selected"; } else { $selected ""; }
                                    
?>
                                    <option value="<?php echo $cat3_info['idx']; ?><?php echo $selected?>><?php echo $cat3_info['name']; ?></option>
                                    <?php ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <th>Á¦¸ñ</th>
                            <td>
                                <input type="text" name="title" value="<?php echo $info['title']; ?>">
                            </td>
                        </tr>
                        <tr>
                            <th>µ¿¿µ»ó°­ÀÇ</th>
                            <td>
                                <p class="red">* ¸µÅ©¸¦ ³ÖÀ»¶§´Â https://www.youtube.com/embed/¿µ»ó°íÀ¯¹øÈ£ Çü½ÄÀ¸·Î ³Ö¾îÁּžߠÇÕ´Ï´Ù.</p>
                                <p class="red">* ¿¬°üŰ¿öµå´Â, ¸Å´º¾ó¿¡¼­ °Ë»öÇÒ ¶§ ºñ½ÁÇÑ °Ë»ö¾î¶óµµ °Ë»öµÇµµ·Ï ÇÕ´Ï´Ù.</p>
                                <div style="text-align:right;">
                                    <p class="add_link linkbtn">¸µÅ©Ãß°¡</p>
                                    <p class="del_link linkbtn">¸µÅ©»èÁ¦</p>
                                </div>
                                <?php while($link mysql_fetch_array($link_res)){ ?>
                                <div>
                                    <input type="checkbox" name="link_no[]" style='width:20px !important;vertical-align: middle;' value=''>
                                    <input type="text" name="link[]" style="margin-top:5px;width:250px !important;" value="<?php echo $link['link']; ?>" placeholder="À¯Æ©ºê ÁÖ¼Ò¸¦ ³Ö¾îÁÖ¼¼¿ä.">
                                    <input type="text" name="link_name[]" style="margin-top:5px;width:250px !important;" value="<?php echo $link['name']; ?>" placeholder="À¯Æ©ºê Á¦¸ñ¸¦ ³Ö¾îÁÖ¼¼¿ä.">
                                    ¿¬°üŰ¿öµå : <input type="text" name="link_keyword[]" style="width:220px !important;" value="<?php echo $link['keyword']; ?>" placeholder=",·Î ±¸ºÐÇÏ¿© ³Ö¾îÁÖ¼¼¿ä. ex) °¨ÀÚ,¿Á¼ö¼ö">
                                </div>
                                <?php ?>
                            </td>
                        </tr>
                        <?php 
                            $cnt 
1;
                            
$con_cnt mysql_num_rows($con_res);
                            while(
$content mysql_fetch_array($con_res)){ 
                        
?>
                        <tr>
                            <th>¸Å´º¾ó º»¹®<br/><input type='checkbox' name='con_no[]' style='width:20px !important;' value=''></th>
                            <td style="padding: 10px !important;">
                                
                                ¸Å´º¾ó º»¹® Á¦¸ñ : <input type="text" name="menu_title[]" style="margin-bottom:5px;width: 749px !important;" value="<?php echo $content['title']; ?>" placeholder="º»¹®¿¡ »ç¿ëµÉ Å«Á¦¸ñÀ» ³Ö¾îÁÖ¼¼¿ä.">
                                <textarea name="content_<?php echo $cnt?>" class="<?php echo $cnt?>"><?php echo $content['content']; ?></textarea>
                                <input type="hidden" name="menu_content[]" value="">
                                ¿¬°üŰ¿öµå : <input type="text" name="menu_keyword[]" value="<?php echo $content['keyword']; ?>" style="width: 781px !important;margin-top:5px;" placeholder=",·Î ±¸ºÐÇÏ¿© ³Ö¾îÁÖ¼¼¿ä. ex) °¨ÀÚ,¿Á¼ö¼ö">
                            </td>
                        </tr>
                        <?php 
                            $cnt
++; 
                            } 
                        
?>
                    </table>
                </div>
                <div style="text-align:right;margin-top:20px;">
                    <p class="add_menual_content linkbtn" style="width:120px;">¸Å´º¾ó º»¹® Ãß°¡Çϱâ</p>
                    <p class="del_menual_content linkbtn" style="width:120px;">¼±ÅÃÇÑ º»¹® »èÁ¦Çϱâ</p>
                </div>

                <div class="btn1Warp">
                    <p class="add_menual">µî·ÏÇϱâ</p>
                    <p class="cancel_menual">Ãë¼ÒÇϱâ</p>
                </div>
            </form>
            <div class="faq_section">
                <div class="faq_hd">
                    <span class="add_faq">FAQ µî·ÏÇϱâ</span>
                    <p>FAQ ¸®½ºÆ®</p>
                </div>
                <ul class="faq_ul">
                    <?php while($faq_info mysql_fetch_array($faq_res)) { ?>
                    <li class="edit_click">
                        <input type="hidden" name="fidx" value="<?php echo $faq_info['idx']; ?>">
                        <?php echo $faq_info['question']; ?>
                    </li>
                    <?php ?>
                </ul>
            </div>
        </div>
    </div><!-- //border_contents -->
</div><!-- //container -->


<script>
$(function(){

    var ac = "<?php echo $con_cnt?>";
    if(ac > 0) {
        for(var a = 1; a <= ac; a++) {
            CKEDITOR.replace( 'content_'+a, {    height: 250    } );
        }
    }

    $("select[name='cate1']").change(function(){ // ´ëºÐ·ù º¯°æ ½Ã
        var idx = $(this).val();
        $.get("./m_menual_process.php?idx="+idx+"&type=select_cat1", function(rtn){
            $("select[name='cate2'] option").remove();
            $("select[name='cate2']").append(rtn);
        });
    });

    $("select[name='cate2']").change(function(){ // Áߺзù º¯°æ ½Ã
        var idx = $(this).val();
        $.get("./m_menual_process.php?idx="+idx+"&type=select_cat2", function(rtn){
            $("select[name='cate3'] option").remove();
            $("select[name='cate3']").append(rtn);
        });
    });

    $(".add_menual").click(function(){ // ¸Å´º¾ó µî·ÏÇϱâ

        if($("select[name='cate1']").val() == "") {
            alert("´ëºÐ·ù¸¦ ¼±ÅÃÇØÁֽʽÿÀ."); return;
        }
        if($("input[name='title']").val() == "") {
            alert("Á¦¸ñÀ» ÀÔ·ÂÇØÁֽʽÿÀ."); return;
        }

        var arr = [];

        for (instance in CKEDITOR.instances){
            v = CKEDITOR.instances[instance].getData();
            $("form[name='menual_reg_form']").find("textarea[name="+instance+"]").closest("tr").find("input[name='menu_content[]']").val(v);
        }
    
        var form_data = $("form[name='menual_reg_form']").serialize();

        $.ajax({type:"post", url:"m_menual_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 {
                    alert("ÀúÀåÇß½À´Ï´Ù.");
                    document.location.href = "./m_menual.php";
                }
            },
            error:function(rtn,status,error){    alert("Error : "+error); console.log(error);    }
        });
    });

    $(".cancel_menual").click(function(){ // ¸Å´º¾ó Ãë¼ÒÇϱâ
        document.location.href = "./m_menual.php";
    });

    $(".add_menual_content").click(function(){ // ¸Å´º¾ó º»¹® Ãß°¡Çϱâ
        var val = $(this).closest("form").find(".editTable tbody tr").last().find("textarea").attr("class");
        if(isNaN(val)) { val = 0; }
        val = Number(val) + 1;

        rtn = "<tr>";
        rtn += "<th>¸Å´º¾ó º»¹®<br/><input type='checkbox' style='width:20px !important;' name='con_no[]' value=''></th>";
        rtn += "<td style='padding: 10px !important;'>";
        rtn += "º»¹® ¸Å´º¾ó Á¦¸ñ : <input type='text' name='menu_title[]' style='margin-bottom:5px;width: 749px !important;' value='' placeholder='º»¹®¿¡ »ç¿ëµÉ Å«Á¦¸ñÀ» ³Ö¾îÁÖ¼¼¿ä.'>";
        rtn += "<textarea name='content_"+val+"' class='"+val+"'></textarea>";
        rtn += "<input type='hidden' name='menu_content[]' value=''>";
        rtn += "¿¬°üŰ¿öµå : <input type='text' name='menu_keyword[]' style='width: 781px !important;margin-top:5px;' value='' placeholder=',·Î ±¸ºÐÇÏ¿© ³Ö¾îÁÖ¼¼¿ä. ex) °¨ÀÚ,¿Á¼ö¼ö'>";
        rtn += "</td>";
        rtn += "</tr>";
        $(".editTable tbody").append(rtn);
        CKEDITOR.replace( 'content_'+val, {    height: 250    } );
    });

    $(".del_menual_content").click(function(){ // ¼±ÅÃÇÑ ¸Å´º¾ó º»¹® »èÁ¦Çϱâ
        var ck_cnt = 0;
        var v = $("input[name='con_no[]']").each(function(){
            if($(this).is(":checked")) { ck_cnt++; }
        });
        if(ck_cnt == 0) { alert("»èÁ¦ÇϽǠ°Ô½Ã¹°À» ¼±ÅÃÇØÁÖ¼¼¿ä."); return; }

        if(confirm("¼±ÅÃÇϽŠ"+ck_cnt+" °³ÀÇ °Ô½Ã¹°À» »èÁ¦ÇϽðڽÀ´Ï±î?")) {
            $("input[name='con_no[]']").each(function(){
                if($(this).is(":checked")){
                    $(this).closest("tr").remove();
                }
            });
        }
    });

    $(".add_link").click(function(){
        rtn = "<div>";
        rtn += "<input type='checkbox' name='link_no[]' style='width:20px !important;vertical-align: middle;' value=''>";
        rtn += "&nbsp;";
        rtn += "<input type='text' name='link[]' value='' style='margin-top:5px;width:250px !important;' placeholder='À¯Æ©ºê ÁÖ¼Ò¸¦ ³Ö¾îÁÖ¼¼¿ä.'>";
        rtn += "&nbsp;";
        rtn += "<input type='text' name='link_name[]' style='margin-top:5px;width:250px !important;' value='' placeholder='À¯Æ©ºê Á¦¸ñ¸¦ ³Ö¾îÁÖ¼¼¿ä.'>";
        rtn += " ¿¬°üŰ¿öµå : <input type='text' name='link_keyword[]' style='width:220px !important;' value='' placeholder=',·Î ±¸ºÐÇÏ¿© ³Ö¾îÁÖ¼¼¿ä. ex) °¨ÀÚ,¿Á¼ö¼ö'>";
        rtn += "</div>";
        $(this).closest("td").append(rtn);
    });

    $(".del_link").click(function(){
        if(confirm("ÇØ´ç ¸µÅ©¸¦ »èÁ¦ÇϽðڽÀ´Ï±î?")) {
            $("input[name='link_no[]']").each(function(){
                if($(this).is(":checked")){
                    $(this).closest("div").remove();
                }
            });
        }
    });

    $(".edit_click").click(function(){ // FAQ ¼öÁ¤Çϱâ
        var val = $(this).find("input[name='fidx']").val();
        $.get("m_menual_faq.php",{"pidx":"<?php echo $idx?>", "fidx":val },function(rtn){
            $("#modal_member_box").html(rtn).dialog({
                resizable: true, height:580, width:900, modal: true, title: "FAQ",
                buttons: {
                    ÀúÀå: function() {
                        v = CKEDITOR.instances.answer.getData();
                        $("form[name='faq_reg_form']").find("textarea[name='answer']").val(v);

                        var form_data = $("form[name='faq_reg_form']").serialize();

                        $.ajax({type:"post", url:"m_menual_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 {
                                    alert("ÀúÀåÇß½À´Ï´Ù.");
                                }
                            },
                            error:function(rtn,status,error){    alert("Error : "+error);    }
                        });
                        $( this ).dialog( "close" );
                    },
                    ´Ý±â: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    });

    $(".add_faq").click(function(){ // FAQ µî·ÏÇϱâ
        $.get("m_menual_faq.php",{"pidx":"<?php echo $idx?>" },function(rtn){
            $("#modal_member_box").html(rtn).dialog({
                resizable: true, height:580, width:900, modal: true, title: "FAQ",
                buttons: {
                    ÀúÀå: function() {
                        v = CKEDITOR.instances.answer.getData();
                        $("form[name='faq_reg_form']").find("textarea[name='answer']").val(v);

                        var form_data = $("form[name='faq_reg_form']").serialize();

                        $.ajax({type:"post", url:"m_menual_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 {
                                    alert("ÀúÀåÇß½À´Ï´Ù.");
                                }
                            },
                            error:function(rtn,status,error){    alert("Error : "+error);    }
                        });
                        
                        var fidx_val = $('form[name="faq_reg_form"]').find('[name="fidx"]').val();
                        var content = $('form[name="faq_reg_form"]').find('[name="question"]').val();

                        faq_list =  '<li class="edit_click">';
                        faq_list += '<input type="hidden" name="fidx" value="' + fidx_val + '">';
                        faq_list += content;
                        faq_list += '</li>';

                        $('.faq_ul').append(faq_list);

                        $( this ).dialog( "close" );
                    },
                    ´Ý±â: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    });
});
</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>