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

if(
$order_key==''){ 
    
$order_key 'a.code1 desc'
}

$where2 "  ";

if(
$ordstate_tab!=''){
    if(
$ordstate_tab=='9'){
        
$where2 .= " and ord_cancel = '1' ";
    } else if(
strlen($ordstate_tab)==1){
        
$where2 .= " and ordstate = '".substr($ordstate_tab,0,1)."' and ord_cancel = 0";
    } else {
        
$where2 .= " and ordstate = '".substr($ordstate_tab,0,1)."' and deposit = '".substr($ordstate_tab,1,1)."' and ord_cancel = 0";
    }
}

if(
$sdate!=''){
    
$where2 .= " and b.orddate >= '{$sdate}' ";
}
if(
$edate!=''){
    
$where2 .= " and b.orddate <= '{$edate}' ";
}
if(
$pay_type!=''){
    
$where2 .= " and pay_type = '{$pay_type}' ";
}

$stx urldecode($stx);
if(
$stx!=''){
    if(
$sti=='pname'){ // 상품명일때 처리
        
$pname_s $stx;
    } else {
        
$where2 .= " and {$sti} like '%{$stx}%' ";
    }
}

if (
$page 1) { $page 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$list_array customer_order_list($pname_s$where2$page$config['page_line']); // 주문정보를 가져온다.

$total_page $list_array[0]['total_page'];
$list_num $list_array[0]['list_num'];
$total_count $list_array[0]['total_count'];

$qstr $_SERVER['QUERY_STRING'];

// 상품그룹 가져오기
/*$sql = "select a.* from product_category2 a where 1=1 order by code";
$result      =    mysql_query($sql,$connect_j3);
while($cus_info=mysql_fetch_array($result)){
    $cate2_array[] = $cus_info;
}*/

?>
<!--<div id="contents" style="background:#999"><img src="http://placehold.it/960x150" alt="롤링배너"></div>-->

<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>
<form name='order_search_form' method='get'>
    <input type='hidden' name='ordstate_tab' size='' value='<?php echo $ordstate_tab;?>'>
    <div id="sub-contents-area">
        <div class="sub-btn-area">
            <div class="sub-btn">
                <!--<a class="lignt-blue-btn" id='btn_order_new'>신규등록</a><a class="blue-btn" id='sel_edit'>선택수정</a><a class="blue-btn">주문복사</a><?php if($Orow['ordstate']==0){ ?><a class="black-btn">전체삭제</a><?php }?><a class="gray-btn" id='buy_print'>인쇄</a>--><a class="gray-btn" id='xls_down'>엑셀</a><!--<a class="black-btn" id='sel_delete'>선택삭제</a>-->
<?php //if($ordstate_tab==='1' || $ordstate_tab>'1'){  ?>
                <a class="black-btn" id='xls_list_down'>상세엑셀</a>
<?php //} ?>
            </div>
        </div>
        <div class="sub-btn-area">
            <div class="sub-btn sub-btn-search">
                <select name='pay_type'>
                    <option value=''>모든결제</option>
                    <option value='무통장' <?php if($pay_type=='무통장'){ echo "selected"; }?>>무통장</option>
                    <option value='카드' <?php if($pay_type=='카드'){ echo "selected"; }?>>카드</option>
                    <option value='계좌이체' <?php if($pay_type=='계좌이체'){ echo "selected"; }?>>계좌이체</option>
                    <option value='가상계좌' <?php if($pay_type=='가상계좌'){ echo "selected"; }?>>가상계좌</option>
                </select>
                주문일자 <input type='text' name='sdate' id='sdate' value='<?php echo $sdate?>' class='width_80'> ~ <input type='text' name='edate' id='edate' value='<?php echo $edate?>' class='width_80'>&nbsp;
                <select name='sti'>
                    <option value='s_name' <?php if($sti=='s_name'){?>selected<?php }?>>주문자</option>
                    <option value='od_id' <?php if($sti=='od_id'){?>selected<?php }?>>주문번호</option>
                    <option value='pname' <?php if($sti=='pname'){?>selected<?php }?>>상품명</option>
                    <option value='login_id' <?php if($sti=='login_id'){?>selected<?php }?>>회원ID</option>
                    <option value='s_hpno' <?php if($sti=='s_hpno'){?>selected<?php }?>>주문자핸드폰</option>
                    <option value='consignee_name' <?php if($sti=='consignee_name'){?>selected<?php }?>>배송자명</option>
                    <option value='consignee_hpno' <?php if($sti=='consignee_hpno'){?>selected<?php }?>>배송자핸드폰</option>
                </select>
                <input type='text' id='stx' name='stx' size='' value='<?php echo $stx;?>' class="stx_class">&nbsp;<a href="#" class="black-btn" id='search_btn_press'>검색</a>
            </div>
        </div>
    </div>
</form>
    <div class="item_tab">
        <div class="item_tab_navi">
            <a value='' class="<?php if($ordstate_tab==''){ echo "on"; }?>"><span>전제</span></a>
            <a value='00'  class="<?php if($ordstate_tab==='00'){ echo "on"; }?>"><span>미입금</span></a>
            <a value='01'  class="<?php if($ordstate_tab==='01'){ echo "on"; }?>"><span>입금</span></a>
            <a value='1'  class="<?php if($ordstate_tab==='1'){ echo "on"; }?>"><span>배송준비</span></a>
            <a value='2'  class="<?php if($ordstate_tab==='2'){ echo "on"; }?>"><span>배송중</span></a>
            <a value='3'  class="<?php if($ordstate_tab==='3'){ echo "on"; }?>"><span>배송완료</span></a>
            <a value='9'  class="<?php if($ordstate_tab==='9'){ echo "on"; }?>"><span>취소</span></a>
        </div>
    </div>

<form name='order_list_form' id='order_list_form' method='post'>
    <input type='hidden' name='omode' value=''>
<?php if($ordstate_tab==='00'){  ?>
<Br>주문상태 변경 : <input type='checkbox' name='ch_od_state' value='01'> '미입금'상태에서 '<span class='font-weight-bold'>입금</span>'상태로 변경합니다. 
&nbsp;<input type='checkbox' name='s_mail' value='Y'> 입금안내 메일 <input type='checkbox' name='s_sms' value='Y'> 입금안내 SMS
&nbsp;<input type='button' value='선택수정' class='ch_red_btn change_ordstate_class'>
<?php }?>
<?php 
if($ordstate_tab==='01'){  ?>
<Br>주문상태 변경 : <input type='checkbox' name='ch_od_state' value='1'> '입금'상태에서 '<span class='font-weight-bold'>배송준비중</span>'상태로 변경합니다. <input type='button' value='선택수정' class='ch_red_btn change_ordstate_class'>
<?php }?>
<?php 
if($ordstate_tab==='1'){  ?>
<Br>주문상태 변경 : <input type='checkbox' name='ch_od_state' value='2'> '배송준비중'상태에서 '<span class='font-weight-bold'>배송중</span>'상태로 변경합니다. 
&nbsp;<input type='checkbox' name='s_mail' value='Y'> 배송안내 메일 <input type='checkbox' name='s_sms' value='Y'> 배송안내 SMS
<input type='button' value='선택수정' class='ch_red_btn change_ordstate_class'>
<?php }?>
<?php 
if($ordstate_tab==='2'){  ?>
<Br>주문상태 변경 : <input type='checkbox' name='ch_od_state' value='3'> '배송중'상태에서 '<span class='font-weight-bold'>배송완료</span>'상태로 변경합니다. <input type='button' value='선택수정' class='ch_red_btn change_ordstate_class'>
<?php }?>
<input type='hidden' name='sel_del' value=''>
    <div class="div-list-area">
        <div class="cust-list-area">
            <table class="order-sheet2">
                <caption class="screen_out">매입처 원장 조회<caption>
                <colgroup>
                <col style="width:30px;">
                <col style="width:100px;"><col style="width:80px;"><col style="width:80px;">
                <col style="width:80px;"><col style="width:70px;"><col style="width:80px;">
                <col style="width:50px;"><col style="width:80px;"><col style="width:80px;">
                <col style="width:60px;">
<?php if($app_id=='mjflower'){  ?>
                <col style="width:100px;">
<?php ?>
<?php 
if(!($ordstate_tab==='1' || $ordstate_tab>'1')){  ?>
                <col style="width:60px;"><col style="width:100px;">
<?php ?>
<?php 
if($ordstate_tab==='1' || $ordstate_tab>'1'){  ?>
                <col style="width:70px;"><col style="width:90px;">
                <col style="width:110px;"><col style="width:110px;">
<?php }?>
                </colgroup>

                <thead>
                    <tr>
                        <th scope="col"><input type='checkbox' name='ck_all' class='check_all_class'></th>
                        <th scope="col">주문번호</th><th scope="col">회원ID</th><th scope="col">주문자</th>
                        <th scope="col">핸드폰</th><th scope="col">상품건수<br>(상품보기)</th><th scope="col">상품금액</th>
                        <th scope="col">배송비</th><th scope="col">결제할금액</th><th scope="col">입금금액</th>
                        <th scope="col">결제방법</th>
<?php if($app_id=='mjflower'){  ?>
                        <th scope="col">배송희망일</th>
<?php ?>
<?php 
if(!($ordstate_tab==='1' || $ordstate_tab>'1')){  ?>
                        <th scope="col">주문상태</th><th scope="col">주문일시</th>
<?php ?>
<?php 
if($ordstate_tab==='1' || $ordstate_tab>'1'){  ?>
                        <th scope="col">배송자</th><th scope="col">배송연락처</th>
                        <th scope="col">배송업체</th><th scope="col">운송장번호</th>
<?php }?>
                    </tr>
                </thead>
                <tbody class='change_check_class'>
<?php 
    
for($i=0;$i<count($list_array);$i++){ 
        
$info $list_array[$i];
        if(
$info['midx']!=''){
            if(
$info['deli_company']==''){ $info['deli_company'] = $configshop['deli_company']; }

            if(
$info['order_id']!=''){ $info['login_id'] = $info['order_id']."(비회원)"; }
?>
                    <tr>
                        <td class="tcenter ">
                            <input type='checkbox' name='code_idx[]' value='<?php echo $i;?>' class='code_idx_calss'>
                            <input type='hidden' name='codes[]' value='<?php echo $info['midx'];?>'>
                        </td>
                        <td class="tcenter click_edit"><?php echo $info['od_id'];?></td>
                        <td class="tcenter"><?php echo $info['login_id'];?></td>
                        <td class="tcenter"><?php echo $info['s_name'];?></td>
                        <td class="tcenter"><?php echo $info['s_hpno'];?></td>
                        <td class="tcenter click_edit2"><?php echo $info['sum_qty'];?></td>
                        <td class="cost"><?php echo number_format($info['cart_price']);?></td>
                        <td class="cost"><?php echo number_format($info['deli_price']);?></td>
                        <td class="cost"><?php echo number_format($info['wdeposit_price']);?></td>
                        <td class="cost"><?php echo number_format($info['deposit_price']);?></td>
                        <td class="tcenter"><?php echo $info['pay_type'];?></td>
<?php if($app_id=='mjflower'){  ?>
                        <td class="tcenter"><?php echo $info['s_telno'];?></td>
<?php ?>
<?php 
if(!($ordstate_tab==='1' || $ordstate_tab>'1')){  ?>
                        <td class="tcenter"><?php echo $info['od_state'];?></td>
                        <td class="tcenter"><?php echo substr($info['data_created'],0,19);?></td>
<?php } else {?>
                        <td class="tcenter"><?php echo $info['consignee_name'];?></td>
                        <td class="tcenter"><?php echo $info['consignee_telno'];?><br><?php echo $info['consignee_hpno'];?></td>
<?php ?>
<?php 
if($ordstate_tab==='1'){  ?>
                        <td class="tcenter">
                            <select name='deli_company[]'><?php echo get_delivery_company($info['deli_company']); ?></select>
                        </td>
                        <td class="tcenter"><input type='text' name='tracking_number[]' value='<?php echo $info['tracking_number'];?>' class='width_100'></td>
<?php }?>
<?php 
if($ordstate_tab>='2'){  ?>
                        <td class="tcenter">
                            <?php echo $info['deli_company']; ?>
                        </td>
                        <td class="tcenter"><?php echo $info['tracking_number'];?></td>
<?php }?>
                    </tr>
<?php 
        
}
    } 
?>
                </tbody>
            </table>
        </div>
    </div>
<?php if($ordstate_tab==='00'){  ?>
<br>주문을 삭제합니다. 삭제는 미입금상태만 가능합니다. <input type='button' value='선택삭제' class='ch_red_btn sel_delete_class'>
<?php }?>
</form>

    <div class='pg_wrap' style='padding-top:0px;'>
        <?php echo get_paging($list_num$page$total_page"?$qstr");?>
    </div>

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

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

    $(".item_tab_navi a").click(function(){ //네비게이션 탭 처리
        v = $(this).attr("value");
        document.location.href="?ordstate_tab="+v;
    });

    $(".click_edit").css("cursor","pointer").click(function(){ // 주문 상세보기
        setsave("qstr",qstr,1);
        $midx = $(this).closest("tr").find("input[name='codes[]']").val();
        document.location.href="orderview.php?idx="+$midx;
    });

    $(".click_edit2").css("cursor","pointer").click(function(){ // 상품 요약보기
        $midx = $(this).closest("tr").find("input[name='codes[]']").val();
        $.get("order_product.inc.php?idx="+$midx,function(rtn){
            $("#modal_member_box").html(rtn).dialog({
                resizable: true, height:700, width:900, modal: true, title:"주문 [상품]",
                buttons: {
                    닫기: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    });

    $(".change_ordstate_class").click(function(){ // 주문상태 변경
        $ck_cnt = 0; deli_no_flag = 0;
        $(".code_idx_calss").each(function(){
            if($(this).is(":checked")){ 
                $ck_cnt++; 
                if($("input[name='ch_od_state']").val()=='2'){
                    $deli_num = $(this).closest("tr").find("input[name='tracking_number[]']").val();
                    if($deli_num==''){ alert('운송장번호를 입력하시기 바랍니다.'); deli_no_flag++; return; }
                }
            }
        });
        if(deli_no_flag>0){ return; }
        if($ck_cnt==0){ alert('수정하실 주문을 선택하시기 바랍니다. '); return; }
        if(!$("input[name='ch_od_state']").is(":checked")){ alert('주문상태 변경에 체크하시기 바랍니다.'); return; }
        if(confirm('주문상태를 변경하시겠습니까?')){
            $form_obj = $("#order_list_form");
            $form_obj.find("input[name='omode']").val('deli_change');
            form_data = $form_obj.serialize();
            $.ajax({type:"post", url:"ajax.order_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'){
                        document.location.reload();
                    } else {
                        alert(v_msg);
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });

        }
    });

    $(".sel_delete_class").click(function(){ // 주문삭제
        if(confirm('정말로 삭제하시겠습니까?')){
            $form_obj = $("#order_list_form");
            $form_obj.find("input[name='omode']").val('ord_delete');
            form_data = $form_obj.serialize();
            $.ajax({type:"post", url:"ajax.order_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'){
                        document.location.reload();
                    } else {
                        alert(v_msg);
                    }
                },
                error:function(rtn,status,error){    alert(error);        }
            });
        }
    });

    $("#xls_down").click(function(){ // 엑셀다운로드
        document.order_search_form.action='order.xls.php';
        document.order_search_form.target = '_blank';
        document.order_search_form.submit();
        document.order_search_form.action='?';
        document.order_search_form.target = '';
    });

    $("#xls_list_down").click(function(){ // 엑셀다운로드
        document.order_search_form.action='order.xls_list.php';
        document.order_search_form.target = '_blank';
        document.order_search_form.submit();
        document.order_search_form.action='?';
        document.order_search_form.target = '';
    });

    $("#search_btn_press").click(function(){ // 검색버튼 누를때
        document.order_search_form.action='?';
        document.order_search_form.target = '';
        document.order_search_form.submit();
    });

});
</script>
<?php 
    
//_pr($_COOKIE['qstr']);
    
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>