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

if(
$datemode==''){
    
$datemode 'day';
}

$where "  ";

if(
$stx!=''){
    
$where .= " and {$sti} like '%{$stx}%' ";
}

if(
$datemode=='day'){
    if(
$sdate==''){ $sdate date("Ym01",time()); }
    if(
$edate==''){ $edate date("Ymd",time()); }
    
    
$date_title "일자";
    
$tab_class1 "on";
    
$sql "select b.orddate, count(*) as cnt, sum(cart_price+deli_price-dc_price-use_point) as sum_price,
                    sum(a.deposit) as depo_cnt, sum(a.deposit_price ) as depo_price, 
                    sum(if(b.ordstate=1,1,0)) as deli_cnt, sum(if(b.ordstate=2,1,0)) as send_cnt, sum(if(b.ordstate=3,1,0)) as comp_cnt, sum(a.ord_cancel) as cancel_cnt
                from sale_ord_s a left join sale_ord_m b on a.midx = b.midx
                where 1=1 and b.orddate >= '
{$sdate}' and b.orddate <= '{$edate}
                group by b.orddate
                "
;
} else if(
$datemode=='month'){
    if(
$sdate==''){ $sdate date("Y-01-01",time()); }
    if(
$edate==''){ $edate date("Y-m-31",time()); }

    
$date_title "월";
    
$tab_class2 "on";
    
$sql "select substring(b.orddate,1,7) as orddate, count(*) as cnt, sum(cart_price+deli_price-dc_price-use_point) as sum_price,
                    sum(a.deposit) as depo_cnt, sum(a.deposit_price ) as depo_price, 
                    sum(if(b.ordstate=1,1,0)) as deli_cnt, sum(if(b.ordstate=2,1,0)) as send_cnt, sum(if(b.ordstate=3,1,0)) as comp_cnt, sum(a.ord_cancel) as cancel_cnt
                from sale_ord_s a left join sale_ord_m b on a.midx = b.midx
                where 1=1 and substring(b.orddate,1,7) >= '"
.substr($sdate,0,7)."' and substring(b.orddate,1,7) <= '".substr($edate,0,7)."' 
                group by substring(b.orddate,1,7)"
;
} else if(
$datemode=='year'){
    if(
$sdate==''){ $sdate date("Y-01-01",time()); }
    if(
$edate==''){ $edate date("Y-m-31",time()); }
    
$date_title "년도";
    
$tab_class3 "on";
    
$sql "select substring(b.orddate,1,4) as orddate, count(*) as cnt, sum(cart_price+deli_price-dc_price-use_point) as sum_price,
                    sum(a.deposit) as depo_cnt, sum(a.deposit_price ) as depo_price, 
                    sum(if(b.ordstate=1,1,0)) as deli_cnt, sum(if(b.ordstate=2,1,0)) as send_cnt, sum(if(b.ordstate=3,1,0)) as comp_cnt, sum(a.ord_cancel) as cancel_cnt
                from sale_ord_s a left join sale_ord_m b on a.midx = b.midx
                where 1=1 and substring(b.orddate,1,4) >= '"
.substr($sdate,0,4)."' and substring(b.orddate,1,4) <= '".substr($edate,0,4)."' 
                group by substring(b.orddate,1,4)"
;
}
$result      =    mysql_query($sql,$connect_j3);

//_pr($sql);
$sum_cnt 0;
while(
$cus_info=mysql_fetch_array($result)){
    
$sum_cnt += $cus_info['cnt'];
    
$list_array[] = $cus_info;

    
$d1 .= "{$cus_info['sum_price']},";
    
$d2 .= "{$cus_info['cnt']},";
    
$l1 .= "'{$cus_info['orddate']}',";
}

$d1 "[".substr($d1,0,strlen($d1)-1)."]";
$d2 "[".substr($d2,0,strlen($d2)-1)."]";
$l1 "[".substr($l1,0,strlen($l1)-1)."]";

$qstr $_SERVER['QUERY_STRING'];

?>
<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='content_search_form' method='get'>
    <input type='hidden' name='datemode' size='' value='<?php echo $datemode;?>'>
    <input type='hidden' name='page' size='' value='<?php echo $page;?>'>
    <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">주문복사</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>-->
            </div>
        </div>
        <div class="sub-btn-area">
            <div class="sub-btn sub-btn-search">
                접속일자 <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='a.vi_ip' <?php if($sti=='a.vi_ip'){?>selected<?php }?>>아이피</option>
                    <option value='a.vi_referer' <?php if($sti=='a.vi_referer'){?>selected<?php }?>>경로</option>
                    <option value='a.vi_agent' <?php if($sti=='a.vi_agent'){?>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='1' class="<?php echo $tab_class1;?>"><span>일별 통계</span></a>
            <a value='2' class="<?php echo $tab_class2;?>"><span>월별 통계</span></a>
            <a value='3' class="<?php echo $tab_class3;?>"><span>년별 통계</span></a>
        </div>
    </div><!--//item_tab-->
<!-- 탭 구분 영역 끝 -->

    <form name='kword_list_form' method='post'>
    <input type='hidden' name='sel_del' value=''>
    <input type='hidden' name='b_table' value='<?php echo $b_table;?>'>
    <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:100px;"><col style="width:100px;">
                <col style="width:100px;"><col style="width:100px;"><col style="width:100px;">
                <col style="width:100px;"><col style="width:100px;"><col style="width:100px;">
                </colgroup>

                <thead>
                    <tr>
                        <th scope="col"><input type='checkbox' name='ck_all' class='check_all_class'></th>
                        <th scope="col"><?php echo $date_title;?></th><th scope="col">주문수</th><th scope="col">주문금액</th>
                        <th scope="col">입금 주문수</th><th scope="col">입금액</th><th scope="col">배송준비 주문수</th>
                        <th scope="col">배송중 주문수</th><th scope="col">배송완료 주문수</th><th scope="col">취소 주문수</th>
                    </tr>
                </thead>
                <tbody>
<?php 
    
for($i=0;$i<count($list_array);$i++){ // 게시물 처리
        
$info $list_array[$i];
        
$all_cnt += $info['cnt'];
        
$all_price += $info['sum_price'];
        
$all_depo_cnt += $info['depo_cnt'];
        
$all_depo_price += $info['depo_price'];
        
$all_deli += $info['deli_cnt'];
        
$all_send += $info['send_cnt'];
        
$all_comp += $info['comp_cnt'];
        
$all_cancel += $info['cancel_cnt'];

?>
                    <tr>
                        <td class="tcenter ">
                            <input type='checkbox' name='code_idx[]' value='<?php echo $i;?>' class='code_idx_class'>
                            <input type='hidden' name='codes[]' value='<?php echo $info['idx'];?>'>
                        </td>
                        <td class="tcenter "><?php echo $info['orddate'];?></td>
                        <td class="tcenter "><?php echo number_format($info['cnt']);?></td>
                        <td class="cost "><?php echo number_format($info['sum_price']);?></td>
                        <td class="tcenter"><?php echo number_format($info['depo_cnt']);?></td>
                        <td class="cost"><?php echo number_format($info['depo_price']);?></td>
                        <td class="tcenter"><?php echo number_format($info['deli_cnt']);?></td>
                        <td class="tcenter"><?php echo number_format($info['send_cnt']);?></td>
                        <td class="tcenter"><?php echo number_format($info['comp_cnt']);?></td>
                        <td class="tcenter"><?php echo number_format($info['cancel_cnt']);?></td>
                    </tr>
<?php 
    

?>
                    <tr>
                        <th class="tcenter " colspan=2>합계</th>
                        <th class="tcenter "><?php echo number_format($all_cnt);?></th>
                        <th class="cost "><?php echo number_format($all_price);?></th>
                        <th class="tcenter"><?php echo number_format($all_depo_cnt);?></th>
                        <th class="cost"><?php echo number_format($all_depo_price);?></th>
                        <th class="tcenter"><?php echo number_format($all_deli);?></th>
                        <th class="tcenter"><?php echo number_format($all_send);?></th>
                        <th class="tcenter"><?php echo number_format($all_comp);?></th>
                        <th class="tcenter"><?php echo number_format($all_cancel);?></th>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    </form>

    <script type="text/javascript" src="<?php echo $j3_js_url;?>/jqplot/jquery.jqplot.min.js"></script>
    <script type="text/javascript" src="<?php echo $j3_js_url;?>/jqplot/plugins/jqplot.barRenderer.min.js"></script>
    <script type="text/javascript" src="<?php echo $j3_js_url;?>/jqplot/plugins/jqplot.categoryAxisRenderer.min.js"></script>
    <script type="text/javascript" src="<?php echo $j3_js_url;?>/jqplot/plugins/jqplot.pointLabels.min.js"></script>
    <script type="text/javascript" src="<?php echo $j3_js_url;?>/jqplot/plugins/jqplot.cursor.min.js"></script>
    <link rel="stylesheet" type="text/css" href="<?php echo $j3_js_url;?>/jqplot/jquery.jqplot.min.css" />

    <div id='sub-title'>
        <h2 class=''>주문통계 그래프</h2>
    </div>
    <div class="jqPlot" id="chart1" style="width:100%; height:250px; "></div>

</div><!--//wrap-->
<script>
var qstr = '<?php echo $qstr;?>';
$(function(){
    $(".item_tab_navi a").click(function(){ //네비게이션 탭 처리
        v = $(this).attr("value");
        if(v=='1'){
            document.location.href='?datemode=day';
        } else if(v=='2'){
            document.location.href='?datemode=month';
        } else if(v=='3'){
            document.location.href='?datemode=year';
        }
    });

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

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

    graph1('chart1','주문현황');

});

function graph1(chart_name,title){
    var s1 = <?php echo $d1;?>;
    var s2 = <?php echo $d2;?>;
    var ticks = <?php echo $l1;?>;
     
    plot1 = $.jqplot("chart1", [s2, s1], {
        // Turns on animatino for all series in this plot.
        animate: true,
        // Will animate plot on calls to plot1.replot({resetAxes:true})
        animateReplot: true,
        cursor: {
            show: true,
            zoom: true,
            looseZoom: true,
            showTooltip: false
        },
        series:[
            {
                label: '주문', 
                pointLabels: {
                    show: true
                },
                renderer: $.jqplot.BarRenderer,
                showHighlight: false,
                yaxis: 'y2axis',
                rendererOptions: {
                    // Speed up the animation a little bit.
                    // This is a number of milliseconds.  
                    // Default for bar series is 3000.  
                    animation: {
                        speed: 2500
                    },
                    barWidth: 15,
                    barPadding: -15,
                    barMargin: 0,
                    highlightMouseOver: false
                }
            }, 
            {
                pointLabels: {
                    show: true
                },
                rendererOptions: {
                    // speed up the animation a little bit.
                    // This is a number of milliseconds.
                    // Default for a line series is 2500.
                    animation: {
                        speed: 2000
                    }
                }
            }
        ],
        axesDefaults: {
            pad: 0
        },
        axes: {
            // These options will set up the x axis like a category axis.
            xaxis: {
                renderer: $.jqplot.CategoryAxisRenderer,
                ticks: ticks
            },
            yaxis: {
               tickOptions: {
                    formatString: "%'d원"
                },
                rendererOptions: {
                    forceTickAt0: true
                }
            },
            y2axis: {
                tickOptions: {
                    formatString: "주문수 %'d"
                },
                rendererOptions: {
                    // align the ticks on the y2 axis with the y axis.
                    alignTicks: true,
                    forceTickAt0: true
                }
            }
        }
    });
}

</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>