/home/mjc1/public_html/otms_old/product_view.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
<?php
$dir 
".";
include_once(
$dir."/_common.php");
include(
'./header.php'); 

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

if(
$idx!='' || $code!=''){
    if(
$idx!=''){ $where " a.idx = '{$idx}' "; }
    if(
$code!=''){ $where " a.p_code = '{$code}' "; }
    
$sql "select a.*, b.c_name, c.opt_qty from zom_product a left join zom_category b on a.c_code = b.c_code left join zom_product_opt c on a.p_code = c.p_code and c.opt_id = '' where 1=1 and {$where} ";
    
$cinfo sql_fetch($sql,$connect_om);
    
//_pr($cinfo);

    
$sql "select * from zom_product_opt where om_site = '{$cinfo['om_site']}' and p_code = '{$cinfo['p_code']}' and opt_no <> 'addopt' and opt_id <> '' order by seq";
    
$res mysql_query($sql,$connect_om);
    while(
$info=mysql_fetch_array($res)){
        
$opt_array[] = $info;
    }
    
$cinfo['opt'] = $opt_array;

    
$sql "select * from zom_product_opt where om_site = '{$cinfo['om_site']}' and p_code = '{$cinfo['p_code']}' and opt_no = 'addopt' order by seq";
    
$res mysql_query($sql,$connect_om);
    while(
$info=mysql_fetch_array($res)){
        
$addopt_array[] = $info;
    }
    
$cinfo['addopt'] = $addopt_array;
}


$qstr $_SERVER['QUERY_STRING'];
?>
<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:130px;"><col style="width:260px;">
                    <col style="width:130px;"><col style="width:260px;">
                    <col style="width:130px;"><col style="width:260px;">
                </colgroup>

                <tbody>
                <tr>
                    <th>사이트</th>
                    <td class='linetxt'><?php echo $site_name[$cinfo['om_site']];?></td>
                    <th >분류</th>
                    <td colspan=3 class='linetxt'><?php echo "{$cinfo['c_name']} ({$cinfo['c_code']})" ?></td>
                </tr>
                <tr>
                    <th>상품코드</th>
                    <td class='linetxt'><?php echo "{$cinfo['p_code']}?></td>
                    <th>상품명</th>
                    <td class='linetxt'><input type='text' name='p_name' value='<?php echo $cinfo['p_name'];?>' class='width_200' ></td>
                    <th>가격</th>
                    <td class='linetxt'><input type='text' name='p_price' value='<?php echo number_format($cinfo['p_price']);?>' class='width_200 number_class' ></td>
                </tr>
                <tr>
                    <th>게시시작일</th>
                    <td class='linetxt'><input type='text' name='start_date' value='<?php echo $cinfo['start_date'];?>' class='width_120'></td>
                    <th>게시종료일</th>
                    <td class='linetxt'><input type='text' name='end_date' value='<?php echo $cinfo['end_date'];?>' class='width_120'></td>
                    <th>상태</th>
                    <td class='linetxt'><?php echo $state_11_array[$cinfo['p_state_code']]?></td>
                <tr>
                    <th>재고</th>
                    <td class='linetxt'>
                        <?php 
                            
if($cinfo['opt_qty']==''){
                                echo 
"옵션 상품<input type='hidden' name='opt_qty' value='opt'>";
                            }  else {
                                echo 
"<input type='text' name='opt_qty' value='{$cinfo['opt_qty']}'>";
                            }
                        
?>
                    </td>
                    <th>업데이트 일시</th>
                    <td class='linetxt'><?php echo $cinfo['update_date'?></td>
                    <th>묶음배송 여부</th>
                    <td class='linetxt'><?php echo $cinfo['bind_deli'?></td>
                </tr>
                <tr>
                    <th>상세내용</th>
                    <td colspan=5 class='linetxt' style='padding:8px;'>
                        <textarea name='html_detail' id='html_detail'><?php echo $cinfo['html_detail'?></textarea>                        
                    </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_price_save">가격수정</a>
                <?php if($cinfo['opt_qty']!=''){?>
                    <a class="lignt-blue-btn btn_qty_save">재고수정</a>
                <?php ?>
                <a class="gray-btn btn_detail_save">상세내용수정</a>
                <a class="gray-btn btn_prod_get">상품가져오기</a>
                <a class="gray-btn btn_cancel_save">목록</a>
            </div>
        </div>
</div>

<?php
    
if(count($cinfo['opt'])>0){
?>
        <h4 style='font-size:14px; font-weight:bold;margin-top:10px;'>옵션 정보</h4>
        <div class="cust-list-area" style='margin-top:5px;'>
            <table class="order-sheet2 buy_sale_table">
                <caption class="screen_out">매출전표등록<caption>
                <colgroup>
                <col style="width:30px;">
                <col style="width:160px;"><col style="width:130px;"><col style="width:80px;">
                <col style="width:120px;"><col style="width:80px;"><col style="width:75px;">
                <col style="width:110px;">
                </colgroup>

                <thead>
                    <tr>
                        <th scope="col"><input type='checkbox' name='ck_all' class='check_all_class'></th>
                        <th scope="col">옵션아이디</th><th scope="col">옵션그룹</th><th scope="col">옵션No</th>
                        <th scope="col">재고코드</th><th scope="col">옵션가</th><th scope="col">옵션재고</th>
                        <th scope="col">업데이트 일시</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    $i
=0;
    foreach(
$cinfo['opt'] as $key=>$info){
?>
                    <tr>
                        <td class="tcenter ">
                            <input type='checkbox' name='seq_idx[]' value='<?php echo $i;?>'>
                            <input type='hidden' name='seqs[]' value='<?php echo $info['seq'];?>'>
                            <input type='hidden' name='pcode[]' value='<?php echo $info['idx'];?>'>
                        </td>
                        <td class="linetxt "><input type='text' name='opt_id[]' class='width_pname' value='<?php echo $info['opt_id'];?>'></td>
                        <td class="linetxt "><input type='text' name='opt_grp[]' class='width_pnorm' value='<?php echo $info['opt_grp'];?>'></td>
                        <td class="tcenter "><input type='text' name='opt_no[]' class='width_pprice' value='<?php echo $info['opt_no'];?>'></td>
                        <td class="tcenter"><input type='text' name='prdstockno[]' class='width_pname number_class' value='<?php echo $info['prdstockno'];?>'></td>
                        <td class="tcenter "><input type='text' name='opt_price[]' class='width_pprice number_class' value='<?php echo number_format($info['opt_price']);?>'></td>
                        <td class="tcenter "><input type='text' name='opt_qty[]' class='width_psump_amt number_class' value='<?php echo $info['opt_qty'];?>'></td>
                        <td class="tcenter "><?php echo $info['update_date'];?></td>
                    </tr>
<?php 
        $i
++;
    } 
?>
                </tbody>
            </table>
        </div>
<?php
    
}
?>

<div id="sub-contents-area" style='padding-left:500px;padding-top:20px;width:100%;'>
        <div class="sub-btn-area">
            <div class="sub-btn">
                <!--<a class="lignt-blue-btn" id='btn_office_save'>저장</a>-->
                <?php if($cinfo['opt_qty']==''){?>
                    <a class="lignt-blue-btn btn_qty_save">옵션재고수정</a>
                <?php ?>
            </div>
        </div>
</div>

<?php
    
if(count($cinfo['addopt'])>0){
?>
        <h4 style='font-size:14px; font-weight:bold;margin-top:10px;'>추가 옵션 정보</h4>
        <div class="cust-list-area" style='margin-top:5px;'>
            <table class="order-sheet2 buy_sale_table">
                <caption class="screen_out">매출전표등록<caption>
                <colgroup>
                <col style="width:30px;">
                <col style="width:160px;"><col style="width:130px;"><col style="width:80px;">
                <col style="width:120px;"><col style="width:80px;"><col style="width:75px;">
                <col style="width:110px;">
                </colgroup>

                <thead>
                    <tr>
                        <th scope="col"><input type='checkbox' name='ck_all' class='check_all_class2'></th>
                        <th scope="col">옵션아이디</th><th scope="col">옵션그룹</th><th scope="col">옵션No</th>
                        <th scope="col">재고코드</th><th scope="col">옵션가</th><th scope="col">옵션재고</th>
                        <th scope="col">업데이트 일시</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    
foreach($cinfo['addopt'] as $key=>$info){
?>
                    <tr>
                        <td class="tcenter ">
                            <input type='checkbox' name='seq_idx2[]' value='<?php echo $i;?>'>
                            <input type='hidden' name='seqs[]' value='<?php echo $info['seq'];?>'>
                            <input type='hidden' name='pcode[]' value='<?php echo $info['idx'];?>'>
                        </td>
                        <td class="linetxt "><input type='text' name='opt_id[]' class='width_pname' value='<?php echo $info['opt_id'];?>'></td>
                        <td class="linetxt "><input type='text' name='opt_grp[]' class='width_pnorm' value='<?php echo $info['opt_grp'];?>'></td>
                        <td class="tcenter "><input type='text' name='opt_no[]' class='width_pprice' value='<?php echo $info['opt_no'];?>'></td>
                        <td class="tcenter"><input type='text' name='prdstockno[]' class='width_pname number_class' value='<?php echo $info['prdstockno'];?>'></td>
                        <td class="tcenter "><input type='text' name='opt_price[]' class='width_pprice number_class' value='<?php echo number_format($info['opt_price']);?>'></td>
                        <td class="tcenter "><input type='text' name='opt_qty[]' class='width_psump_amt number_class' value='<?php echo $info['opt_qty'];?>'></td>
                        <td class="tcenter "><?php echo $info['update_date'];?></td>
                    </tr>
<?php 
        $i
++;
    } 
?>
                </tbody>
            </table>
        </div>
<?php
    
}
    echo 
"상품 등록시 정보 : {$cinfo['p_code']}";
    
$jsons json_decode($cinfo['reg_json']);
    
$jsons json2array($jsons);
    
_pr($jsons);

?>


</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_price_save").click(function(){ // 가격수정
        $form_obj = $("#product_form");
        if(confirm('가격 수정을 하시겠습니까?')){
            $form_obj.find("input[name='sel_del']").val("price_update");
            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_cnt = $(xml).find("prd_cnt").text();
                    var v_use_time = $(xml).find("use_time").text();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        alert('처리되었습니다.'+v_use_time+'초');
                        document.location.reload();
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });        
        }
    });

    $(".btn_qty_save").click(function(){ // 재고수정
        $form_obj = $("#product_form");
        if(confirm('재고 수정을 하시겠습니까?')){
            $form_obj.find("input[name='sel_del']").val("qty_update");
            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_cnt = $(xml).find("prd_cnt").text();
                    var v_use_time = $(xml).find("use_time").text();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        alert('처리되었습니다.'+v_use_time+'초');
                        document.location.reload();
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });        
        }
    });

    $(".btn_prod_get").click(function(){ // 상품 가져오기
        $form_obj = $("#product_form");
        if(confirm('다시 상품을 갱신하시겠습니까?')){
            form_data = "sel_del=prod_get&p_code=<?php echo $cinfo['p_code'];?>";
            $.ajax({type:"post", url:"ajax.11.product_update.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_cnt = $(xml).find("prd_cnt").text();
                    var v_use_time = $(xml).find("use_time").text();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        alert('처리되었습니다.'+v_use_time+'초');
                        document.location.reload();
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });        
        }    
    });

    $(".btn_detail_save").click(function(){ // 상품 상세내용 수정
        $form_obj = $("#product_form");
        if(confirm('상세내용을 갱신하시겠습니까?')){
            $form_obj.find("input[name='sel_del']").val("detail_update");
            v1 = CKEDITOR.instances.html_detail.getData();
            $("#html_detail").val(v1);

            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_cnt = $(xml).find("prd_cnt").text();
                    var v_use_time = $(xml).find("use_time").text();
                    if(v_mode_ok!='Y'){
                        alert(v_msg);
                    } else {
                        alert('처리되었습니다.'+v_use_time+'초');
                        document.location.reload();
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });        
        }    
    });

    CKEDITOR.replace( 'html_detail', {    height: 350    } );
});
</script>
<?php include('./footer.php'); ?>