/home/mjc1/public_html/j3demo/shop/item.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
<?php
include_once("./_common.php");
$prodinfo product_info_get($code); // 제품정보 가져옴 og:처리를 위해서 헤더위쪽에 위치함

if($configshop['gust_price_view']=='1' && ($id_ccode=='' || $id_ccode=='0')){
    
$prodinfo['p_price_tel'] = '1';
    
$prodinfo['price_msg'] = $configshop['gust_price_text'];
} else {
    
$prodinfo['price_msg'] = "전화문의";
}
include_once(
$j3_shop_path."/shop_header.php");

//$custinfo = customer_info_get($id_ccode);
$custinfo $cinfo;
if(
$custinfo['pt_index']!='2'){ $configshop['po_use'] = '0'; }

$cateinfo cate_info_get($prodinfo['code2']); // 분류정보 가져옴
$hasWishcnt prod_wish_heart($prodinfo['code']);

if(
$prodinfo['p_use']=='0'){ alert("판매중인 상품이 아닙니다."); }

$is_soldout false;
if(
$prodinfo['opt_yn']==1){ // 옵션 상품 일 경우
    
$opt_array prod_opt_get($prodinfo['code'], "" ,""); // 상품옵션 가져옴
} else {
    if(
$prodinfo['jego']<='0' || $prodinfo['p_soldout']=='1'){ // 품절 체크
        
$is_soldout true;
    }
}
$addopt_array prod_addopt_get($prodinfo['code'], "" ,""); // 추가상품옵션 가져옴

//$_SESSION['stv'] = null; $_SESSION['stv_img'] = null; $_SESSION['stv_url'] = null;
$stv $_SESSION['stv'];
$stv_img $_SESSION['stv_img'];
$stv_url $_SESSION['stv_url'];
$stv_add "Y";
foreach(
$stv as $k=>$v){
    if(
$v==$code){ $stv_add "N"; }
}
if(
$stv_add=="Y"){ 
    
$thum_img_url get_it_thumbnail($prodinfo['code'],$prodinfo['pic1'],67,67);
    
$stv[] = $code
    
$stv_img[] = $thum_img_url
    
$stv_url[] = $j3_shop_url."/item.php?code=".$code
    
$_SESSION['stv'] =  $stv
    
$_SESSION['stv_img'] =  $stv_img
    
$_SESSION['stv_url'] =  $stv_url
}

//_pr($opt_array);

if($app_id=='lulucosmetic'){ // 루루코스매틱일때 롤링을 위해서 최대 40개 허용
    
$use_img_cnt 40;
} else {
    
$use_img_cnt 8;
}

if(
$configshop['item_use_type']!='0'){
    if(
$configshop['item_use_type']=='2'){ // 관리자 승인한것만 보일시
        
$sql "select * from (select count(*) as use_total from shop_prod_use where pcode = '{$prodinfo['code']}' and iu_view = '1') a
            left join (select count(*) as use_1 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '1' and iu_view = '1') b1 on 1
            left join (select count(*) as use_2 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '2' and iu_view = '1') b2 on 1
            left join (select count(*) as use_3 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '3' and iu_view = '1') b3 on 1
            left join (select count(*) as use_4 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '4' and iu_view = '1') b4 on 1
            left join (select count(*) as use_5 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '5' and iu_view = '1') b5 on 1
        "
;

        
$sql_img "select ct_idx from shop_prod_use where pcode = '{$prodinfo['code']}' and iu_view = '1' order by idx desc limit {$use_img_cnt}";
    } else {
        
$sql "select * from (select count(*) as use_total from shop_prod_use where pcode = '{$prodinfo['code']}') a
            left join (select count(*) as use_1 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '1') b1 on 1
            left join (select count(*) as use_2 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '2') b2 on 1
            left join (select count(*) as use_3 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '3') b3 on 1
            left join (select count(*) as use_4 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '4') b4 on 1
            left join (select count(*) as use_5 from shop_prod_use where pcode = '
{$prodinfo['code']}' and iu_score = '5') b5 on 1
        "
;
        
$sql_img "select idx,ct_idx from shop_prod_use where pcode = '{$prodinfo['code']}' order by idx desc limit {$use_img_cnt}";
    }
    
$res mysql_query($sql,$connect_j3);
    
$use_cnt_info mysql_fetch_array($res);
    if(
$use_cnt_info['use_total']>0){
        
$use_pt = ($use_cnt_info['use_1']*1)+($use_cnt_info['use_2']*2)+($use_cnt_info['use_3']*3)+($use_cnt_info['use_4']*4)+($use_cnt_info['use_5']*5);
        
$v $use_pt/($use_cnt_info['use_total']*5)*5;
        
$use_cnt_info['use_pt'] = round($v,1);
    } else {
        
$use_cnt_info['use_pt'] = 0;
    }

    
$use_img_array null;
    
$res mysql_query($sql_img,$connect_j3);
    while(
$ct_info mysql_fetch_array($res)){
        if(
file_exists($j3_data_path."/item_use/iu_".$ct_info['ct_idx'])){
            
$use_img_array[$ct_info['idx']] = $j3_data_url."/item_use/iu_".$ct_info['ct_idx'];
        }
    }
}

?>
<link href="<?php echo $j3_lib_url;?>/ckeditor/contents2.css" rel="stylesheet" />
<input type='hidden' name='tmp_prod_name' value='<?php echo $prodinfo['name'];?>'>
<?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="container">
    <div id="wrapper">
<!-- 상단 카테고리 내 위치 -->
<?php
    skin_module_show
("item",$sample_idx); // 상품 상세 스킨을 불러온다.
?>
    </div><!-- #wrapper -->
</div><!-- #container -->

<form name='use_list_form' id='use_list_form' method='get'> <!-- 후기 페이징용 폼 -->
    <input type='hidden' name='code' value='<?php echo $prodinfo['code'];?>' size=2>
    <input type='hidden' name='page' value='1' size=2>
    <input type='hidden' name='total_page' value='0' size=2>
    <input type='hidden' name='list_num' value='0' size=2>
    <input type='hidden' name='total_count' value='0' size=2>
</form>

<form name='qa_list_form' id='qa_list_form' method='get'> <!-- 문의 페이징용 폼 -->
    <input type='hidden' name='code' value='<?php echo $prodinfo['code'];?>' size=2>
    <input type='hidden' name='page' value='1' size=2>
    <input type='hidden' name='total_page' value='0' size=2>
    <input type='hidden' name='list_num' value='0' size=2>
    <input type='hidden' name='total_count' value='0' size=2>
</form>

<script>
$(function () {
    $(document).on("click","#sit_pvi_thumb a",function(){ // 이미지 썸네일 처리
        var path = $(this).attr("href");
        $("#sit_pvi_big > img").attr({ src: path }).css("opacity","0").stop().animate({opacity:1},1000);
        //console.log( path );
        return false;
    });

    var select = $("#opt, #opt_add"); // 옵션 셀렉트 처리
    select.change(function(){
        var select_name = $(this).children("option:selected").text();
        $(this).siblings("label").text(select_name);

        code = $(this).val();
        if($(this).attr("id")=='opt'){
            mode = 'opt';
        } else {
            mode = 'addopt';
        }
        add_opt_info_get(code,mode);
    });

    // ***********************************
    // 옵션 수량변경(+,-)과 옵션상품 삭제는 common.js로 옮겼음
    // ***********************************


    $(".prod_qa_new_class").click(function(){ // 상품문의하기 신규
        $.get("item_qa_new.inc.php?code=<?php echo $prodinfo['code'];?>",function(rtn){
            $("#modal_member_box").html(rtn).dialog({
                resizable: true, height:820, width:1050, modal: true, title:"상품문의 [작성]",
                buttons: {
                    저장: function() {
                        prod_qa_save();
                    },
                    닫기: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    });

    $("#sit_btn_buy").click(function(){ // 상품바로구매 버튼
        cart_order_process("direct");
    });

    $("#sit_btn_cart").click(function(){ // 장바구니 버튼
        cart_order_process("");
    });

    $("#sit_btn_wish").click(function(){ // 즐겨찾기 버튼
        $form_obj = $("#item_cart_form");
        if('<?php echo $id_ccode;?>'==''){ alert('즐겨찾기는 회원만 가능합니다.'); document.location.href='login.php'; return; }

        if('<?php echo $hasWishcnt;?>'>'0'){ return; } // 이미 위시리스트 있으면 동작 안함

        $v = prod_add_cnt($form_obj);
        if($v=='0'){ alert('상품을 선택하시기 바랍니다. 참고로 품절상품은 추가가 안됩니다.'); return; }
        form_data = $form_obj.serialize();

        $.ajax({type:"post", url:"ajax.prod_wish_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('위시리스트에 저장되었습니다.');
                    $(".wish_ico_off").addClass("wish_ico_on").removeClass("wish_ico_off");
                }
            },
            error:function(rtn,status,error){    alert(error);        }
        });
    });

    $(document).on("click",".prod_qa_view_class",function(){ // 상품문의 보기 처리
        $tr_obj = $(this).closest("tr");
        $idx = $tr_obj.find("input[name='code_idx[]']").val();
        qa_view_get($idx);
    });

    $(document).on("click",".prod_use_view_class",function(){ // 상품후기 보기 처리
        $tr_obj = $(this).closest("tr");
        $idx = $tr_obj.find("input[name='code_idx[]']").val();
        $.get("item_use_view.inc.php?idx="+$idx,function(rtn){
            $("#modal_member_box").html(rtn).dialog({
                resizable: true, height:820, width:1050, modal: true, title:"상품후기 [보기]",
                buttons: {
                    닫기: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    });

    $(".use_img_class").click(function(){
        $idx = $(this).data("idx");
        $.get("item_use_view.inc.php?idx="+$idx,function(rtn){
            $("#modal_member_box").html(rtn).dialog({
                resizable: true, height:820, width:1050, modal: true, title:"상품후기 [보기]",
                buttons: {
                    닫기: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    });

    if('<?php echo $prodinfo['opt_yn'];?>'=='0' && '<?php echo $prodinfo['jego'];?>'>'0' && '<?php echo $prodinfo['p_price_tel'];?>'!='1'){
        add_opt_info_get("<?php echo $prodinfo['code'];?>","");
    }
    $.get("ajax.pic_list_get.php?code=<?php echo $prodinfo['code'];?>",function(rtn){ // 이미지 리스트 가져옴
        //alert(rtn);
        $(".img_list_class").append(rtn);
    });
    $.get("ajax.rel_list_get.php?code=<?php echo $prodinfo['code'];?>",function(rtn){ // 관련상품 리스트 가져옴
        //alert(rtn);
        $("#sit_rel_list").append(rtn);
    });

    qa_list_get(1); // 상품문의 정보 가져옴
<?php if($configshop['item_use_type']!='0'){ // 후기 사용안함이 아닐때만 동작?>
    use_list_get(1); // 상품후기 정보 가져옴
<?php }?>

});

function add_opt_info_get(code,mode){ // 옵션 상품 정보 가져옴
    if(code==''){ return; }
    $.get("ajax.opt_sel_get.php?code="+code+"&mode="+mode+"&ev_code=<?php echo $ev_code;?>",function(rtn){
        $v = rtn.split("§§§");
        $pcode = $v[0];
        $rtn = $v[1];
        if($pcode==0){ if($rtn!=''){ alert($rtn); } return; } // 품절 상품일 경우 처리
        $dflag = 0;
        $(".opt_sel_class").find("input[name='opt_code[]']").each(function(){ // 기존 옵션 중복 체크
            if($pcode==$(this).val()){    $dflag = 1; }
        });
        if($dflag==0){
            $(".opt_sel_class").append($rtn);
            sum_opt_price();
        }
    });
}

function sum_opt_price(){ // 합산처리
    $sum_price = 0;
    $cnt = 0;
    $(".sit_sel_option_class").each(function(){
        $price = $(this).find("input[name='opt_price[]']").val();
        $qty = $(this).find("input[name='qty[]']").val();
        $sum_price = $sum_price + (parseInt($price)*parseInt($qty));
        $cnt++;
    });
    //alert($sum_price);
    $(".all_qty_class").html($cnt);
    $(".all_price_class").html(formatCurrency($sum_price));
}

function cart_order_process($mode){ // 장바구니 / 바로구매 처리

    if($mode=='direct'){ $("input[name='dmode']").val($mode);    } // 바로구매일때 처리
    $form_obj = $("#item_cart_form");
    form_data = $form_obj.serialize();

    $v = prod_add_cnt($form_obj);
    if($v=='0'){ alert('상품을 선택하시기 바랍니다.'); return; }

    $.ajax({type:"post", url:"ajax.prod_cart_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_dmode = $(xml).find("dmode").text();
            if(v_mode_ok=='L'){
                alert(v_msg);
                document.location.href='login.php';
            } else if(v_mode_ok!='Y'){
                alert(v_msg);
            } else {
                if(v_dmode=='direct'){ // 바로구매모드일 경우
                    document.location.href='orderform.php?dmode=direct';
                } else {
                    right_cart_get();
                    $("#modal_member_box5").dialog({
                        resizable: true, height:180, width:360, modal: true, title:"",
                        buttons: {
                            예: function() {
                                document.location.href='cart.php';
                            },
                            아니오: function() {
                                $( this ).dialog( "close" );
                            }
                        }
                    });
                }
            }
        },
        error:function(rtn,status,error){    alert(error);        }
    });
}

function qa_list_get(page){ // 상품문의 리스트 가져오기
    if(page!=''){ $("#qa_list_form input[name='page']").val(page); } // 페이지 넘어왔을때 페이지 세팅
    var form_data = $("#qa_list_form").serialize();
    $.get("ajax.prod_qa_list_get.php?"+form_data,function(rtn){ // 상품문의 정보 가져옴
        $v = rtn.split("§§§");
        $(".prod_qa_tbody_class").html($v[0]);
        $(".item_qa_cnt_class").html($v[4]);
        $("#qa_list_form input[name='total_page']").val($v[2]);
        $("#qa_list_form input[name='list_num']").val($v[3]);
        $("#qa_list_form input[name='total_count']").val($v[4]);
        $(".qa_paging_class").html($v[5]);
    });
}

function use_list_get(page){ // 상품후기 리스트 가져오기
    if(page!=''){ $("#use_list_form input[name='page']").val(page); } // 페이지 넘어왔을때 페이지 세팅
    var form_data = $("#use_list_form").serialize();
    $.get("ajax.prod_use_list_get.php?"+form_data,function(rtn){ // 상품문의 정보 가져옴
        $v = rtn.split("§§§");
        $(".prod_use_tbody_class").html($v[0]);
        $(".item_use_cnt_class").html($v[4]);
        $("#use_list_form input[name='total_page']").val($v[2]);
        $("#use_list_form input[name='list_num']").val($v[3]);
        $("#use_list_form input[name='total_count']").val($v[4]);
        $(".use_paging_class").html($v[5]);
    });
}

function qa_view_get($idx){ // 상품문의 보기 보이기
    $.get("item_qa_view.inc.php?idx="+$idx,function(rtn){
        if(rtn=='secret'){ alert('비밀글입니다.'); return; } // 권한없는 글일경우 차단
        if(rtn=='password'){ // 비회원 패스워드 입력글일 경우
            $.get("item_qa_pw.inc.php?idx="+$idx,function(rtn){
                $("#modal_member_box").html(rtn).dialog({
                    resizable: true, height:300, width:600, modal: true, title:"상품문의 [비밀번호]",
                    buttons: {
                        확인: function() {
                            form_data = $("#prod_qa_password_form").serialize();
                            $.get("ajax.prod_qa_pw_ck.php?"+form_data,function(rtn2){
                                if(rtn2=='fail'){ alert('비밀번호가 틀렸습니다.'); }
                                else { qa_view_get(rtn2); }
                            });

                        },
                        닫기: function() {
                            $( this ).dialog( "close" );
                        }
                    }
                });
            })
            return;
        }
        $("#modal_member_box").html(rtn).dialog({
            resizable: true, height:820, width:1050, modal: true, title:"상품문의 [보기]",
            buttons: {
                닫기: function() {
                    $( this ).dialog( "close" );
                }
            }
        });
    });
}

function prod_qa_save(){ // 상품문의 작성 저장
    $form_obj = $("#prod_qa_reg_form");
    if($form_obj.find("input[name='iq_name']").val()==''){
        alert('작성자를 입력하세요.'); return;
    }
    if($form_obj.find("input[name='iq_subject']").val()==''){
        alert('문의제목을 입력하세요.'); return;
    }
    v1 = CKEDITOR.instances.iq_question.getData();
    $("#iq_question").val(v1);
    if($form_obj.find("textarea[name='iq_question']").val()==''){
        alert('문의내용을 입력하세요.'); return;
    }
<?php if($id_ccode==''){ // 비회원일경우 ?>
    if($form_obj.find("input[name='iq_password']").val()==''){
        alert('비밀번호를 입력하세요.'); return;
    }
    if($form_obj.find("input[name='captcha_input']").val()==''){
        alert('스팸방지보안을 입력하세요.'); return;
    }
<?php }?>
    if(confirm($("input[name='tmp_prod_name']").val()+'의 상품문의를 작성하시겠습니까?')){
        form_data = $form_obj.serialize();
        $.ajax({type:"post", url:"ajax.prod_qa_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 {
                    qa_list_get(1);
                    $("#modal_member_box").dialog("close");
                }
            },
            error:function(rtn,status,error){    alert(error);        }
        });
    }
}
</script>
<?php
include_once($j3_shop_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>
<div id="modal_member_box5" style="display:none;width:100%; height:100%; padding-top:3px;padding-left:3px;background-color:#FFFFFF; text-align:center; padding-top:20px; ">
    <p style='font-size:14px; font-weight:bold;margin-bottom:5px; ' id='modal_box_p'>상품이 장바구니에 담겼습니다.</p>
    <p class='dialog_css_p'>바로 확인 하시겠습니까?</p>    
</div>