/home/mjc1/public_html/ryunen/adm/coupon_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
<?php
$sub_menu 
"800300";
include(
"./_common.php");
include(
"./auth_check.php"); // 관리자 권한 체크
include($j3_adm_path."/shop_header.php");

if(
$code!=''){
    
$sql "select * from shop_coupon a where 1=1 and idx = '{$code}'";
    
$res mysql_query($sql,$connect_j3);
    
$cinfo mysql_fetch_array($res);
} else {
    
$cinfo['cp_sdate'] = "0000-00-00";
    
$cinfo['cp_edate'] = "0000-00-00";
    
$cinfo['cp_kind'] = "0";
    
$cinfo['cp_kind_des'] = "";
    
$cinfo['cp_mem_id'] = "전체회원";
    
$cinfo['cp_type'] = "0";
    
$cinfo['cp_cnt'] = "0";

    
$cinfo['cp_price'] = 0;
    
$cinfo['cp_min'] = 0;
}

$qstr $_SERVER['QUERY_STRING'];

?>
<?php
if($shop_du_size>$limit_mbyte){ 
?>
<script src="<?php echo $j3_lib_url?>/ckeditor-nf/ckeditor.js"></script>
<?php } else { ?>
<script src="<?php echo $j3_lib_url?>/ckeditor/ckeditor.js"></script>
<?php }?>
<div id="wrap" class='container_wrap'>
    <div id="sub-title">
        <h2>쿠폰정보 등록/수정</h2>
        <div class="sub-location">
            <a href="./index.php" class="home"><span class="screen_out">홈</span></a>
            <span class="location-gt"></span>
            <a>통계/마케팅</a>
            <span class="location-gt"></span>
            <a>쿠폰정보 등록/수정</a>
        </div>
    </div>
<style>
    .cust_modal1, 
    .cust_modal2 { border:0px solid #e1e1e1; width:1200px; padding:10px; font-size:13px }
    .cust_modal1 h4, 
    .cust_modal2 h4 { position:relative; top:-5px; font-size:14px; font-weight:bold; }
    .cust_modal2 { margin-top:0px; }
    .table-top-border tbody { border-top:1px solid #e1e1e1;}
    .cust_modal1 table tbody td,
    .cust_modal2 table tbody td { text-align:left; padding-left:5px;  }
    .cust_modal1 table tbody td input,
    .cust_modal2 table tbody td input{ border:1px solid #e9e9e9;  }
    .input_readonly {background:#E9E9E9; }
    .width_500 { width:500px !important; }
    .width_80 { width:80px !important; }
    .width_120 { width:120px !important; }
</style>
<form name='popup_reg_form' method='post' action='' enctype="multipart/form-data">
<input type='hidden' name='qstr' value=''>
<input type='hidden' name='code' value='<?php echo $cinfo['idx'];?>'>

<input type='hidden' name='cp_kind' value='<?php echo $cinfo['cp_kind'];?>'><!-- 쿠폰종류(0:주문금액할인) -->
<input type='hidden' name='cp_kind_des' value='<?php echo $cinfo['cp_kind_des'];?>'><!-- 쿠폰종류대상(특정상품이나 분류 : 개발예정) -->
<input type='hidden' name='cp_mem_id' value='<?php echo $cinfo['cp_mem_id'];?>'><!-- 쿠폰대상아이디(전체:전체회원) -->
<input type='hidden' name='cp_type' value='<?php echo $cinfo['cp_type'];?>'><!-- 쿠폰타입(0:정액할인, 1:정율할인(예정)) -->
<input type='hidden' name='cp_cnt' value='<?php echo $cinfo['cp_cnt'];?>'><!-- 쿠폰발행가능 횟수(0:무제한) -->
<br><br>
<div class='cust_modal1'>
    <h4>기본정보</h4>
    <table class="order-sheet table-top-border">
        <caption class="screen_out">기본정보</caption>
        <colgroup>
            <col style="width:150px;"><col style="width:1050px;">
        </colgroup>

        <tbody>
        <tr>
            <th>쿠폰번호</th>
            <td colspan=3>
                <input type='text' name='cp_id' class='width_200' value='<?php echo $cinfo['cp_id'];?>' maxlength=16 <?php if($code!=''){?>readonly<?php }?>>
                <?php if($code==''){?>&nbsp;<input type='checkbox' class='cp_auto_add' value='cp<?php echo time();?>'>랜덤입력
                <br><span class='help_info'>원하시는 쿠폰번호를 입력하시면 됩니다. 쿠폰 적정 자릿수10~15사이</span><?php }?>
            </td>
        </tr>
        <tr>
            <th>쿠폰명</th>
            <td colspan=3><input type='text' name='cp_name' class='width_200' value='<?php echo $cinfo['cp_name'];?>'></td>
        </tr>
        <tr>
            <th>쿠폰설명</th>
            <td colspan=3>
                <textarea name='cp_memo' style='width:600px;height:100px;'><?php echo $cinfo['cp_memo'];?></textarea>
            </td>
        </tr>
        <tr>
            <th>쿠폰일자</th>
            <td colspan=3>
                <input type='text' name='cp_sdate' id='cp_sdate' class='width_100' value='<?php echo $cinfo['cp_sdate'];?>'> ~ <input type='text' name='cp_edate' id='cp_edate' class='width_100' value='<?php echo $cinfo['cp_edate'];?>'>
                &nbsp;<span class='help_info'>시작일이나 종료일이 0000-00-00이면 일자가 제한없음</span>
            </td>
        </tr>
        <tr>
            <th>쿠폰금액</th>
            <td colspan=3><input type='text' name='cp_price' class='width_60' value='<?php echo $cinfo['cp_price'];?>'>원</td>
        </tr>
        <tr>
            <th>쿠폰적용가능 최저금액</th>
            <td colspan=3>
                <input type='text' name='cp_min' class='width_60' value='<?php echo $cinfo['cp_min'];?>'> 원
                &nbsp;<span class='help_info'>0원일경우 제한 없음</span>
            </td>
        </tr>
        <tr>
            <th>쿠폰 사용여부</th>
            <td colspan=3>
                <input type='radio' name='cp_use' value='1' <?php if($cinfo['cp_use']=='1' || $cinfo['cp_use']==''){?>checked<?php }?>> 사용함 
                <input type='radio' name='cp_use' value='0' <?php if($cinfo['cp_use']=='0'){?>checked<?php }?>> 사용안함 
            </td>
        </tr>
    </table>
</div>
<div id="sub-contents-area" style='padding-left:500px;padding-top:20px;'>
        <div class="sub-btn-area">
            <div class="sub-btn">
                <a class="lignt-blue-btn" id='btn_popup_save'>저장</a>
                <a class="gray-btn" id='btn_cancel_save'>취소</a>
            </div>
        </div>
    </div>
</form>
<script>
$(function(){
    $("#btn_cancel_save").click(function(){ // 취소 버튼
        document.location.href='coupon.php?<?php echo $_COOKIE['qstr'];?>';    
    });    

    $("#btn_popup_save").click(function(){ // 저장 버튼
        form_save();
    });    

    $(".cp_auto_add").click(function(){
        $("input[name='cp_id']").val($(this).val());
    });

    $("#cp_sdate").datepicker({
        showOn: "button",
        buttonImage: "./img/calendar.png",
        buttonImageOnly: true,
        buttonText: "Select date",
        dateFormat: "yy-mm-dd",
        changeMonth: true,
        changeYear: true,
            monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
            monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
            dayNames: ['일','월','화','수','목','금','토'],
            dayNamesShort: ['일','월','화','수','목','금','토'],
            dayNamesMin: ['일','월','화','수','목','금','토'],
            showMonthAfterYear: true,
            yearSuffix: '년'
    });    

    $("#cp_edate").datepicker({
        showOn: "button",
        buttonImage: "./img/calendar.png",
        buttonImageOnly: true,
        buttonText: "Select date",
        dateFormat: "yy-mm-dd",
        changeMonth: true,
        changeYear: true,
            monthNames: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
            monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
            dayNames: ['일','월','화','수','목','금','토'],
            dayNamesShort: ['일','월','화','수','목','금','토'],
            dayNamesMin: ['일','월','화','수','목','금','토'],
            showMonthAfterYear: true,
            yearSuffix: '년'
    });    
});


function form_save(){
    var form_obj = $("form[name='popup_reg_form']");
    if($(form_obj).find("input[name='cp_id']").val()==''){
        alert('쿠폰번호를 입력하세요.'); return;
    }
    if($(form_obj).find("input[name='cp_name']").val()==''){
        alert('쿠폰명을 입력하세요.'); return;
    }
    if($(form_obj).find("input[name='cp_price']").val()=='0'){
        alert('쿠폰금액을 입력하세요.'); return;
    }
    $(form_obj).find("input[name='qstr']").val('<?php echo $qstr;?>');
    if(confirm('저장하시겠습니까?')){
        var form_data = $(form_obj).serialize();

        $.ajax({type:"post", url:"ajax.coupon_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();
                var v_after_add = $(xml).find("after_add").text();
                if(v_mode_ok!='Y'){
                    alert(v_msg);
                } else {
                    document.location.href='coupon.php?<?php echo $_COOKIE['qstr'];?>';    
                }
            },
            error:function(rtn,status,error){    alert(error);        }
        });
    }
}

<?php if($shop_du_size>$limit_mbyte){ ?>
    CKEDITOR.replace( 'pu_content', {    height: 270, filebrowserUploadUrl:""    } );
<?php } else { ?>
    CKEDITOR.replace( 'pu_content', {    height: 270    } );
<?php ?>


</script>

<?php
include($j3_adm_path."/shop_footer.php");
?>
<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>