/home/mjc1/public_html/otms_old/product_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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<?php
$dir 
".";
include_once(
$dir."/_common.php");
include(
'./header.php'); 

$create_sql "CREATE TABLE `zom_prod_noti` (
  `idx` int(11) NOT NULL AUTO_INCREMENT,
  `type_code` int(11) DEFAULT '0',
  `type_name` varchar(250) DEFAULT '',
  `item_code` int(11) DEFAULT '0',
  `item_desc` varchar(250) DEFAULT '',
  `item_type` varchar(50) DEFAULT '',
  `item_bigo` varchar(250) DEFAULT '',
  PRIMARY KEY (`idx`),
  KEY `idx_type_code` (`type_code`),
  KEY `idx_item_code` (`item_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='상품정보제공고시'"
;

function 
base_cont_select($bkey,$skey,$style=""){
    Global 
$base_cont;
    
$html "<select name='{$bkey}' class='{$bkey}_class' style=\"{$style}\">";
    foreach(
$base_cont[$bkey] as $key=>$info){
        if(
$skey==$info['base_cont_no']){ $std "selected"; } else { $std ""; }
        
$html .= "<option value='{$info['base_cont_no']}{$std}>{$info['base_cont_name']}</option>";
    }
    
$html .= "</select>";

    return 
$html;
}

if(
$eid==''){
    
alert('로그인 후에 이용가능합니다.',"index.php"); exit;
}

if(
$idx!=''){

} else {
    
$cinfo['rmaterialTypCd'] = "04";
    
$cinfo['beefTraceStat'] = "02";
    
$cinfo['useGiftYn'] = "N";
    
$cinfo['gblDlvYn'] = "N";
    
$cinfo['bndlDlvCnYn'] = "N";
    
$cinfo['selTermUseYn'] = "N";

    
$cinfo['prdNm'] = "테스트 마우스 3";
    
$cinfo['brand'] = "엠제이";
    
$cinfo['selPrc'] = "1030";
    
$cinfo['prdSelQty'] = "30";
    
$cinfo['asDetail'] = ".";
    
$cinfo['rtngExchDetail'] = ".";
    
$cinfo['prdImage01'] = "http://shop.mjsoft.co/j3/hjwcs3/data/product/34/34_pic1_420_420";
    
$cinfo['certKey'] = "12123123";
    
$cinfo['htmlDetail'] = ".";

    
$cinfo['p_code'] = '1949348157';
    
$cinfo['c_code'] = '1013176';
}

$sql "select * from zom_base_cont where om_site = '11' order by seq, idx"// 주요 상품관련 선택옵션들 가져옴
$res mysql_query($sql,$connect_om);
while(
$info=mysql_fetch_array($res)){
    
$base_cont[$info['base_key']][] = $info;
}

$sql "select a.type_code, a.type_name from zom_prod_noti a where 1=1 group by a.type_code, a.type_name"// 상품정보제공고시 가져옴
$res mysql_query($sql,$connect_om);
$prod_noti_html "<select name='ProductNotification' class='ProductNotification_class' style='width:300px;'><option value=''>-선택-</option>";
while(
$info=mysql_fetch_array($res)){
    
$prod_noti_html .= "<option value='{$info['type_code']}'>{$info['type_name']}</option>";
    
$prod_noti[] = $info;
}
$prod_noti_html .= "</select>";


$qstr $_SERVER['QUERY_STRING'];
?>
<style>
.cate1_code_class, .cate2_code_class, .cate3_code_class, .cate4_code_class { width:150px;}
</style>
<script src="./lib/ckeditor/ckeditor.js"></script>
<!--<div id="contents" style="background:#999"><img src="http://placehold.it/960x150" alt="롤링배너"></div>-->
<div id="contents" style="height:2px;border-bottom:1px solid #eee;background:#2f6ba9">
    <span class="screen_out">header 하단 선</span>
</div>

<div id="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>

<form name='product_form' id="product_form" method='post' action="" enctype="multipart/form-data" onsubmit='return false;'>
    <input type='hidden' name='sel_del' value=''>
    <input type='hidden' name='all_del' value=''>
    <input type='hidden' name='idx' value='<?php echo $idx;?>'>

    
    <div class="sub-write-area" style='display:block;width:1200px;'>
        <h4 style='font-size:14px; font-weight:bold;margin-top:10px;'>기본 정보</h4>
        <div class="order-sheet-area" style='width:1200px;'>
            <table class="order-sheet">
                <caption class="screen_out">기본 정보</caption>
                <colgroup>
                    <col style="width:150px;"><col style="width:350px;">
                    <col style="width:150px;"><col style="width:350px;">
                </colgroup>

                <tbody>
                <tr>
                    <th>분류(카테고리)</th>
                    <td colspan=3 class='linetxt'>
                        <span class='cate1_span'></span>&nbsp;
                        <span class='cate2_span'></span>&nbsp;
                        <span class='cate3_span'></span>&nbsp;
                        <span class='cate4_span'></span>&nbsp;
                        <Br>카테고리 수정시엔 상위분류는 변경이 안된 최하위 분류내에서만 변경됨
                    </td>
                </tr>
                <tr>
                    <th>판매방식</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("selMthdCd",$cinfo['selMthdCd']);?>
                    </td>
                    <th >서비스 상품 코드</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("prdTypCd",$cinfo['prdTypCd']);?>
                    </td>
                </tr>
                <tr>
                    <th>상품명</th>
                    <td class='linetxt'>
                        <input type='text' name='prdNm' value='<?php echo $cinfo['prdNm'];?>' class='width_200'>
                    </td>
                    <th >브랜드</th>
                    <td class='linetxt'>
                        <input type='text' name='brand' value='<?php echo $cinfo['brand'];?>' class='width_200'>
                    </td>
                </tr>
                <tr>
                    <th>원재료 유형 코드</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("rmaterialTypCd",$cinfo['rmaterialTypCd'],"width:200px;");?>
                    </td>
                    <th >원산지 코드</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("orgnTypCd",$cinfo['orgnTypCd'],"width:300px;");?>
                    </td>
                </tr>
                <tr>
                    <th>축산물 이력번호</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("beefTraceStat",$cinfo['beefTraceStat'],"width:170px;");?>
                    </td>
                    <th >부가세/면세상품코드</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("suplDtyfrPrdClfCd",$cinfo['suplDtyfrPrdClfCd']);?>
                    </td>
                </tr>
                <tr>
                    <th>해외구매대행상품 여부</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("forAbrdBuyClf",$cinfo['forAbrdBuyClf'],"width:150px;");?>
                    </td>
                    <th >상품상태</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("prdStatCd",$cinfo['prdStatCd'],"width:300px;");?>
                    </td>
                </tr>
                <tr>
                    <th>미성년자 구매가능</th>
                    <td class='linetxt' colspan=3>
                        <?php echo base_cont_select("minorSelCnYn",$cinfo['minorSelCnYn'],"width:150px;");?>
                    </td>
                <tr>
                    <th >판매기간</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("selTermUseYn",$cinfo['selTermUseYn'],"width:300px;");?>
                    </td>
                    <th>판매기간코드/예약기간코드</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("selPrdClfCd",$cinfo['selPrdClfCd'],"width:300px;");?>
                    </td>
                </tr>
                <tr>
                    <th >판매 시작일/예약 시작일</th>
                    <td class='linetxt'>
                        <input type='text' name='aplBgnDy' value='<?php echo $cinfo['aplBgnDy'];?>' style='width:80px;' class=''> <span class='help_info'>ex)20170101</span>
                    </td>
                    <th >판매 종료일/예약 종료일</th>
                    <td class='linetxt'>
                        <input type='text' name='aplEndDy' value='<?php echo $cinfo['aplEndDy'];?>' style='width:80px;' class=''> <span class='help_info'>ex)20170101</span>
                    </td>
                </tr>
                <tr>
                    <th >사은품 정보 사용여부</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("useGiftYn",$cinfo['useGiftYn'],"width:100px;");?>
                    </td>
                    <th>전세계배송 이용여부</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("gblDlvYn",$cinfo['gblDlvYn'],"width:100px;");?>
                    </td>
                </tr>
                <tr>
                    <th >배송가능지역 코드</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("dlvCnAreaCd",$cinfo['dlvCnAreaCd'],"width:200px;");?>
                    </td>
                    <th>배송방법</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("dlvWyCd",$cinfo['dlvWyCd'],"width:150px;");?>
                    </td>
                </tr>
                <tr>
                    <th >배송비 종류</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("dlvCstInstBasiCd",$cinfo['dlvCstInstBasiCd'],"width:200px;");?>
                    </td>
                    <th>묶음배송 여부</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("bndlDlvCnYn",$cinfo['bndlDlvCnYn'],"width:150px;");?>
                    </td>
                </tr>
                <tr>
                    <th >배송비 결제방법</th>
                    <td class='linetxt' colspan=3>
                        <?php echo base_cont_select("dlvCstPayTypCd",$cinfo['dlvCstPayTypCd'],"width:200px;");?>
                    </td>
                </tr>
                <tr>
                    <th>판매가격</th>
                    <td class='linetxt' >
                        <input type='text' name='selPrc' value='<?php echo $cinfo['selPrc'];?>' class='width_200 number_class'>
                    </td>
                    <th >재고</th>
                    <td class='linetxt'>
                        <input type='text' name='prdSelQty' value='<?php echo $cinfo['prdSelQty'];?>' class='width_200 number_class'>
                    </td>
                </tr>
                <tr>
                    <th >A/S 안내</th>
                    <td class='linetxt' colspan=3>
                        <input type='text' name='asDetail' value='<?php echo $cinfo['asDetail'];?>' class='width_500'> <span class='help_info'>공백허용 안됨, 점이라도 찍어줘야됨</span>
                    </td>
                </tr>
                <tr>
                    <th >교환/반품 안내</th>
                    <td class='linetxt' colspan=3>
                        <input type='text' name='rtngExchDetail' value='<?php echo $cinfo['rtngExchDetail'];?>' class='width_500'> <span class='help_info'>공백허용 안됨, 점이라도 찍어줘야됨</span>
                    </td>
                </tr>
                <tr>
                    <th >상품이미지1</th>
                    <td class='linetxt' colspan=3>
                        <input type='text' name='prdImage01' value='<?php echo $cinfo['prdImage01'];?>' class='width_500'> <span class='help_info'>이미지url입력, jpg,png만 가능</span>
                    </td>
                </tr>
                <tr>
                    <th >인증유형</th>
                    <td class='linetxt'>
                        <?php echo base_cont_select("certTypeCd",$cinfo['certTypeCd'],"width:200px;");?>
                    </td>
                    <th>인증번호</th>
                    <td class='linetxt'>
                        <input type='text' name='certKey' value='<?php echo $cinfo['certKey'];?>' class='width_200'>
                    </td>
                </tr>
                <tr>
                    <th >상품정보제공고시</th>
                    <td class='linetxt' colspan=3>
                        <?php echo $prod_noti_html;?>
                    </td>
                </tr>
                <tr>
                    <th >상품정보제공고시 항목</th>
                    <td class='linetxt' colspan=3 class=''>
                        <span class='prod_noti_class'></span>
                    </td>
                </tr>
                <tr>
                    <th >상세설명</th>
                    <td class='linetxt' colspan=3>
                        <textarea name='htmlDetail' id='htmlDetail'><?php echo $cinfo['htmlDetail'?></textarea>
                        <span class='help_info'>공백허용 안됨, 점이라도 찍어줘야됨</span>
                    </td>
                </tr>
                <tr>
                    <th>수정상품코드</th>
                    <td class='linetxt' >
                        <input type='text' name='p_code' id='p_code' value='<?php echo $cinfo['p_code'];?>' class='width_200'>
                    </td>
                    <th ></th>
                    <td class='linetxt'>

                    </td>
                </tr>
            </table>
        </div>
        

        <div id="sub-contents-area" style='padding-left:400px;padding-top:20px;width:100%;'>
        <div class="sub-btn-area">
            <div class="sub-btn">
                <a class="lignt-blue-btn btn_prod_save">등록/수정하기</a>
                <a class="gray-btn btn_cancel_save">목록</a>
            </div>
        </div>
</div>

</form>

</div><!--//wrap-->

<script>
var qstr = '<?php echo $qstr;?>';
$(function(){
    $(".check_all_class").click(function(){ // 전체선택 전체선택 해제
        if($(this).is(":checked")){
            $("input[name='seq_idx[]']").prop("checked",true);
        } else {
            $("input[name='seq_idx[]']").prop("checked",false);            
        }
    });

    $(".btn_cancel_save").click(function(){ // 목록으로
        document.location.href='product.php?<?php echo $qstr."&time=".time();?>';
    });

    $(".btn_prod_save").click(function(){ // 상품 등록
        $form_obj = $("#product_form");

        if($form_obj.find("input[name='prdNm']").val()==''){
            alert('상품명을 입력하세요.'); return;
        }

        if($form_obj.find("input[name='selPrc']").val()==''){
            alert('판매가격을 입력하세요.'); return;
        }

        if($form_obj.find("input[name='prdSelQty']").val()==''){
            alert('재고를 입력하세요.'); return;
        }

        if($form_obj.find("input[name='asDetail']").val()==''){
            alert('A/S안내를 입력하세요.'); return;
        }

        if($form_obj.find("input[name='rtngExchDetail']").val()==''){
            alert('교환/반품 안내를 입력하세요.'); return;
        }

        if($form_obj.find("input[name='prdImage01']").val()==''){
            alert('상품이미지1을 입력하세요.'); return;
        }

        if($form_obj.find(".ProductNotification_class option:selected").val()==''){
            alert('상품정보제공 고시를 선택하세요.'); return;
        } else {
            $flag1 = 1;
            $("input[name='item_desc[]']").each(function(){
                if($(this).val()==''){ $flag1 = 0; }
            });
            if($flag1!=1){
                alert('상품정보제공 고시의 항목을 입력하세요.'); return;
            }
        }

        if(confirm('상품 등록을 하시겠습니까?')){
            v1 = CKEDITOR.instances.htmlDetail.getData();
            $("#htmlDetail").val(v1);

            if($("#p_code").val()!=''){
                $form_obj.find("input[name='sel_del']").val("prod_mod");
            } else {
                $form_obj.find("input[name='sel_del']").val("prod_reg");
            }
            form_data = $form_obj.serialize();
            $.ajax({type:"post", url:"ajax.11.product_process.php", data:form_data, async:true, 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_prd_no = $(xml).find("prd_no").text();
                    var v_use_time = $(xml).find("use_time").text();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        //$.post("ajax.11.product_update.php",{sel_del:"prod_get",p_code:v_prd_no});
                        alert('처리되었습니다.'+v_use_time+'초');
                        //document.location.href='product.php?<?php echo $qstr."&time=".time();?>';
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });        
        }
    });

    $(".ProductNotification_class").change(function(){
        $v = $(this).val();
        $.get("ajax.11.prod_noti_get.php?type_code="+$v,function(rtn){
            $(".prod_noti_class").html(rtn);
        });
    });

    $(document).on("change",".cate1_code_class",function(){
        cate2_get();
    });
    $(document).on("change",".cate2_code_class",function(){
        cate3_get();
    });
    $(document).on("change",".cate3_code_class",function(){
        cate4_get();
    });

    cate1_get();
    
    CKEDITOR.replace( 'htmlDetail', {    height: 350    } );
});

function cate1_get(){
    $.get("ajax.11.cate_get.php?depth=1",function(rtn){
        $(".cate1_span").html(rtn);
    });
}

function cate2_get(){
    $v = $(".cate1_code_class option:selected").val();
    $.get("ajax.11.cate_get.php?depth=2&pcode="+$v,function(rtn){
        $(".cate2_span").html(rtn);
        $(".cate3_span, .cate4_span").html('');
    });
}

function cate3_get(){
    $v = $(".cate2_code_class option:selected").val();
    $.get("ajax.11.cate_get.php?depth=3&pcode="+$v,function(rtn){
        $(".cate3_span").html(rtn);
        $(".cate4_span").html('');
    });
}

function cate4_get(){
    $v = $(".cate3_code_class option:selected").val();
    $.get("ajax.11.cate_get.php?depth=4&pcode="+$v,function(rtn){
        $(".cate4_span").html(rtn);
    });
}
</script>
<?php include('./footer.php'); ?>