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
|
<?php include("./_common.php");
if($app_id=='ryunen' || $app_id=='lulucosmetic'){ // 루루코스매틱만 단가등급 보임 $configshop['danganame_view'] = "1"; }
if($order_key==''){ if($_COOKIE['ok_customer']!=''){ $order_key = $_COOKIE['ok_customer']; } else { $order_key = 'a.data_created'; } }
if($order_key == 'a.data_created'){ $order_key .= ' desc'; }
$where = " and login_id <> '' and ocode = '{$configshop['office_code']}' "; if($biztype=='' || $biztype=='1'){ $where .= " and biztype = '1' "; $biztype = "1"; } else if($biztype=='0'){ $where .= " and biztype = '0' "; } else if($biztype=='2'){ $where .= " and biztype = '2' "; }
if($stx!=''){ $where .= " and {$sti} like '%{$stx}%' "; }
$sql = "select count(*) as cnt from customers a WHERE 1=1 $where "; $result = mysql_query($sql,$connect_j3); $row = mysql_fetch_array($result); $total_count = $row['cnt'];
$list_num = $config['page_line']; if($_COOKIE['page_line']!=''){ $list_num = $_COOKIE['page_line']; } $total_page = ceil($total_count / $list_num); // 전체 페이지 계산 if ($page < 1) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지) $from_record = ($page - 1) * $list_num; // 시작 열을 구함
$limit_sql = ""; if($limit==''){ $limit_cnt = 10000; $row_cnt = $total_count; if($row_cnt>$limit_cnt){ $row_page = (floor($row_cnt/$limit_cnt))+1; echo "<script>"; for($i=0;$i<=count($row_page);$i++){ echo "window.open('?$qstr&limit=".($i*$limit_cnt)."','','');".chr(10); } echo "window.close();"; echo "</script>"; exit; } } else { $limit_sql = " limit $limit, $limit_cnt"; }
if($config['recom_name_use']=='1'){ $select_field = "a.code1, a.comp_name, a.login_id, a.login_passwd, a.ceo_name, a.comp_sn, a.sub_comp_sn, a.telno, a.hpno, a.faxno, a.biz_status, a.biz_item, a.zipcode, a.addr_m, a.addr_d, a.email, c.recom_name, c.sms_ok, c.mail_ok, c.deli_free, c.mb_lv, b.begin_pt, a.pt_index, a.pt_cash, a.pt_card, a.sale_dcrate, a.hidden, a.data_created "; } else { $select_field = "a.code1, a.comp_name, a.login_id, a.login_passwd, a.ceo_name, a.comp_sn, a.sub_comp_sn, a.telno, a.hpno, a.faxno, a.biz_status, a.biz_item, a.zipcode, a.addr_m, a.addr_d, a.email, c.sms_ok, c.mail_ok, c.deli_free, c.mb_lv, b.begin_pt, a.pt_index, a.pt_cash, a.pt_card, a.sale_dcrate, a.hidden, a.data_created "; }
if($configshop['danganame_view']=='1'){ $select_field .= ", a.code "; }
$sql = "select {$select_field} from customers a left join customer_begin_balance b on a.code = b.ccode left join customers_s c on a.code = c.ccode WHERE 1=1 $where order by $order_key {$limit_sql}"; $result = mysql_query($sql,$connect_j3);
//_pr($sql); while($cus_info=mysql_fetch_object($result)){ $info = null; $col_cnt = 0; foreach($cus_info as $key=>$val){ if($configshop['danganame_view']=='1' && $key=='code'){ $val = get_multi_price_name($val); } $info[$key] = $val; $col_cnt++; } $list_array[] = $info; }
//_pr($list_array);
if($config['recom_name_use']=='1'){ $title_array = Array("코드","상호명","아이디","비밀번호","대표자","사업자번호","종사업자번호","전화번호","핸드폰","팩스","업태","종목","우편번호","주소1","주소2","이메일","추천인아이디","sms수신여부(0,1)","email수신여부(0,1)","무료배송여부(0,1)","회원권한","기초포인트","포인트적용법(0,1,2)","현금포인트율","카드포인트율","매출할인율", "관리여부(0,1)","회원가입일시"); } else { $title_array = Array("코드","상호명","아이디","비밀번호","대표자","사업자번호","종사업자번호","전화번호","핸드폰","팩스","업태","종목","우편번호","주소1","주소2","이메일","sms수신여부(0,1)","email수신여부(0,1)","무료배송여부(0,1)","회원권한","기초포인트","포인트적용법(0,1,2)","현금포인트율","카드포인트율","매출할인율", "관리여부(0,1)","회원가입일시"); }
if($configshop['danganame_view']=='1'){
$title_array[count($title_array)] = "단가등급"; $dv_cnt = $col_cnt; $col_cnt++; }
require_once $j3_lib_path."/phpexcel/PHPExcel.php";
$objPHPExcel = new PHPExcel();
$objPHPExcel->setActiveSheetIndex(0)->mergeCells('A1:P1'); $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($config['recom_name_use']=='1'){ $ii = 1; } else { $ii = 0; } 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); } if($i>=16+$ii && $i<=18+$ii){ $objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha."1", "0 : 사용안함".chr(10)."1 : 사용함"); } else if($i==19+$ii){ $objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha."1", "권한 1~5".chr(10)."1=비회원"); } else if($i==21+$ii){ $objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha."1", "0 : 적용안함".chr(10)."1 : 거래처별".chr(10)."2 : 상품별"); } else if($i==23+$ii || $i==24+$ii){ $objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha."1", "%"); } else if($i==25+$ii){ $objPHPExcel->setActiveSheetIndex(0)->setCellValue($alpha."1", "0 : 사용함".chr(10)."1 : 관리안함(숨김)"); } //$objPHPExcel->getActiveSheet()->getColumnDimension('D')->setWidth(12); $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); }
$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="customerlist_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'); ?>
|