/home/mjc1/public_html/j3demo/adm/order.xls.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
<?php
include("./_common.php");

if(
$order_key==''){ 
    if(
$_COOKIE['ok_product']!=''){
        
$_COOKIE['ok_product'] = str_replace("%20"," ",$_COOKIE['ok_product']);
        
$order_key $_COOKIE['ok_product']; 
    } else {
        
$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$page999999); // 주문정보를 가져온다.

$col_cnt $list_array[0]['col_cnt'];
array_pop($list_array[0]); // col_cnt 받아오고 배열에서 날려버림


$qstr $_SERVER['QUERY_STRING'];

$title_array = Array("주문번호","회원ID","상품건수","상품금액","배송비","결제할금액","입금금액","결제방법","주문상태","할인금액","포인트사용금액","적립포인트","주문자명","주문전화번호","주문핸드폰","주문우편번호","주문주소","주문자이메일","배송자명","배송전화번호","배송핸드폰","배송우편번호","배송주소","배송메모","배송회사","운송장번호");

require_once 
$j3_lib_path."/phpexcel/PHPExcel.php";

$objPHPExcel = new PHPExcel();

$objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:j1');
$objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1','* 주문 리스트 엑셀');
$objPHPExcel->getActiveSheet()->getStyle('A1:AZ1')->getAlignment()->setWrapText(true); // 워드랩 기능 추가
$objPHPExcel->getActiveSheet()->getStyle('A1:AZ1')->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);

$objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(140); // 높이 조절

for($i=0;$i<$col_cnt;$i++){
    if(
$i>25){
        
$vv floor($i/26);
        
$v $i-(26*$vv);
        
$alpha chr(65+$v);
        
$alpha chr(64+$vv).$alpha;
    } else {
        
$alpha chr(65+$i);
    }
    
$objPHPExcel->getActiveSheet()->getColumnDimension($alpha)->setAutoSize(true);
}

for(
$i=0;$i<$col_cnt;$i++){
    if(
$i>25){
        
$vv floor($i/26);
        
$v $i-(26*$vv);
        
$alpha chr(65+$v);
        
$alpha chr(64+$vv).$alpha;
    } else {
        
$alpha chr(65+$i);
    }
    
$objPHPExcel->setActiveSheetIndex(0)
            ->
setCellValue($alpha.'2'$title_array[$i]);
}

for(
$i=0;$i<count($list_array);$i++){
    
$info $list_array[$i];
    
$x 0;
    foreach(
$info as $key => $val){
        if(
$x>25){
            
$vv floor($x/26);
            
$v $x-(26*$vv);
            
$alpha chr(65+$v);
            
$alpha chr(64+$vv).$alpha;
        } else {
            
$alpha chr(65+$x);
        }
        
//if($x==16){ $val = addslashes($val); }

        
if($alpha=="A"){
            
$objPHPExcel->getActiveSheet()->setCellValueExplicit($alpha.($i+3), $val,PHPExcel_Cell_DataType::TYPE_STRING); 
        } else {
            
$objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha.($i+3), $val);
        }
        
$x++;
    }
}


$objPHPExcel->getActiveSheet()->setTitle('주문리스트');
$objPHPExcel->setActiveSheetIndex(0);

// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="orderlist_xls'.$limit.'.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');

// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

$objWriter PHPExcel_IOFactory::createWriter($objPHPExcel'Excel5');
$objWriter->save('php://output');
?>