增加下载全部离线数据功能,CSV格式
This commit is contained in:
parent
ed327cdeb3
commit
46b905d728
|
@ -137,6 +137,7 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$add=(int)$this->_getParam('add');
|
$add=(int)$this->_getParam('add');
|
||||||
$edit=(int)$this->_getParam('edit');
|
$edit=(int)$this->_getParam('edit');
|
||||||
$delete=(int)$this->_getParam('delete');
|
$delete=(int)$this->_getParam('delete');
|
||||||
|
$down=(int)$this->_getParam('down');
|
||||||
if ($add) {
|
if ($add) {
|
||||||
$form=new OfflinelogForm();
|
$form=new OfflinelogForm();
|
||||||
$form->pdf->setDestination($this->view->config->offline->savepath);
|
$form->pdf->setDestination($this->view->config->offline->savepath);
|
||||||
|
@ -195,6 +196,26 @@ class Admin_DataController extends Zend_Controller_Action
|
||||||
$this->messenger->addMessage($e->getMessage());
|
$this->messenger->addMessage($e->getMessage());
|
||||||
}
|
}
|
||||||
$this->_redirect("/admin/data/offline");
|
$this->_redirect("/admin/data/offline");
|
||||||
|
} elseif ($down) {
|
||||||
|
$this->_helper->layout->disableLayout();
|
||||||
|
$this->_helper->viewRenderer->setNoRender();
|
||||||
|
$sql="select * from offlineapp where ts_approved is not null and pdflink is not null order by ts_created desc";
|
||||||
|
$rows=$this->db->fetchAll($sql);
|
||||||
|
foreach($rows as $row){
|
||||||
|
$content.='"'.$row['username'].'","'.$row['unit'].'","'.$row['phone'].'","'.$row['address'].'","'.$row['postcoe'].'","'.$row['project'].'","'.$row['datalist'].'","'.$row['email'].'",'.$row['ts_approved']."\n";
|
||||||
|
}
|
||||||
|
$this->getResponse()->setHeader('Content-Type', 'application/octet-stream')
|
||||||
|
->setHeader('Content-Disposition','attachment; filename="offlineapp.csv"')
|
||||||
|
->setHeader('Content-Length', strlen($content))
|
||||||
|
->setHeader('Content-Type','application/force-download')
|
||||||
|
->setHeader('Content-Type','application/download')
|
||||||
|
->setHeader('Content-Description','File Transfer')
|
||||||
|
->setHeader('Content-Transfer-Encoding','binary')
|
||||||
|
->setHeader('Expires',0)
|
||||||
|
->setHeader('Cache-Control','must-revalidate, post-check=0, pre-check=0')
|
||||||
|
->setHeader('Pragma','public')
|
||||||
|
->setBody($content);
|
||||||
|
|
||||||
}
|
}
|
||||||
$select=$this->db->select();
|
$select=$this->db->select();
|
||||||
$select->from('offlineapp')->where('ts_approved is not null')->where('pdflink is not null')->order('ts_created desc');
|
$select->from('offlineapp')->where('ts_approved is not null')->where('pdflink is not null')->order('ts_created desc');
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
<?php endforeach;endif; ?>
|
<?php endforeach;endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<a href="/admin/data/offline/add/1">添加新的离线服务记录</a>
|
<a href="/admin/data/offline/add/1">添加新的离线服务记录</a> | <a href="/admin/data/offline/down/1">下载所有离线服务记录</a>
|
||||||
<?= $this->paginator; ?>
|
<?= $this->paginator; ?>
|
||||||
<?php if (count($this->paginator)): ?>
|
<?php if (count($this->paginator)): ?>
|
||||||
<table class="offline" cellspacing=0>
|
<table class="offline" cellspacing=0>
|
||||||
|
|
Loading…
Reference in New Issue