/**
* 导出当日借阅归还书刊 csv
* by zhengjc 2010-10-18
*/
function export() {
$status = $_GET['status'];
if ( $status=="1" ){
$list = $this->bookMod->getBorrowTodayList();
$list = $this->addBookInfo( $list );
$list = $this->addUserInfo($list);
}else{
$list = $this->bookMod->getBorrowTodayList(1);
$list = $this->addBookInfo( $list );
$list = $this->addUserInfo($list);
}
$filePath = "D:/upload/contact/contact.csv"
$file = fopen($filePath, 'w');
$str = "";
$arrTmp = array(
iconv('UTF-8', 'GBK', "名称"),
iconv('UTF-8', 'GBK', "类型"),
iconv('UTF-8', 'GBK', "借阅者"),
iconv('UTF-8', 'GBK', "借阅时间"),
iconv('UTF-8', 'GBK', "归还时间")
);
fputcsv($file, $arrTmp);
foreach($list as $value) {
$arr = array(
iconv('UTF-8', 'GBK', $value['bookname']),
iconv('UTF-8', 'GBK', $value['booktype']=='0'?"图书":"杂志"),
iconv('UTF-8', 'GBK', $value['name']),
$value['borrowdate'],
$value['backdate']
);
fputcsv($file, $arr);
}
fclose($file);
// IE 中文乱码解决方法
$downloadName = $status=="1"?"当日借出书刊.csv":"当日归还书刊.csv";
if(preg_match('/MSIE/',$_SERVER['HTTP_USER_AGENT'])){
$downloadName = rawurlencode($downloadName);
}
header('Content-Type: text/csv');
header('Content-Description: File Transfer');
header('Content-Disposition: attachment; filename='.$downloadName);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($filePath));
readfile($filePath);
}
浙公网安备 33010602011771号