Merge pull request #349 from dg9vh/csvexport

optimized CSV Download
pull/352/head
Peter Goodhall 2019-09-12 15:54:05 +01:00 zatwierdzone przez GitHub
commit 9d23393d8d
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
2 zmienionych plików z 47 dodań i 8 usunięć

Wyświetl plik

@ -43,9 +43,52 @@ class QSLPrint extends CI_Controller {
$this->load->model('logbook_model');
$data['qsos'] = $this->logbook_model->get_qsos_for_printing();
$myData = $this->logbook_model->get_qsos_for_printing();
$this->load->view('qslprint/data/csv', $data);
// file name
$filename = 'qsl_export.csv';
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename");
header("Content-Type: application/csv;charset=iso-8859-1");
// file creation
$file = fopen('php://output', 'w');
$header = array("COL_CALL",
"COL_QSL_VIA",
"COL_TIME_ON",
"COL_MODE",
"COL_FREQ",
"COL_BAND",
"COL_RST_SENT",
"COL_SAT_NAME",
"COL_SAT_MODE",
"COL_QSL_RCVD",
"COL_ROUTING",
"ADIF",
"ENTITY");
fputcsv($file, $header);
foreach ($myData->result() as $qso) {
fputcsv($file,
array(str_replace("0", "Ø", $qso->COL_CALL),
$qso->COL_QSL_VIA!=""?"Via ".str_replace("0", "Ø", $qso->COL_QSL_VIA):"",
$qso->COL_TIME_ON,
$qso->COL_MODE,
$qso->COL_FREQ,
$qso->COL_BAND,
$qso->COL_RST_SENT,
$qso->COL_SAT_NAME,
$qso->COL_SAT_MODE,
$qso->COL_QSL_RCVD =='Y'?'TNX QSL':'PSE QSL',
$qso->COL_ROUTING,
$qso->ADIF,
$qso->ENTITY));
}
fclose($file);
exit;
}
function qsl_printed() {
@ -63,5 +106,5 @@ class QSLPrint extends CI_Controller {
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
/* End of file Qslprint.php */
/* Location: ./application/controllers/Qslprint.php */

Wyświetl plik

@ -1,4 +0,0 @@
COL_CALL;COL_QSL_VIA;COL_TIME_ON;COL_MODE;COL_FREQ;COL_BAND;COL_RST_SENT;COL_SAT_NAME;COL_SAT_MODE;COL_QSL_RCVD;COL_ROUTING;ADIF;ENTITY;
<?php foreach ($qsos->result() as $qso) { ?>
<?php echo str_replace("0", "Ø", $qso->COL_CALL); ?>;<?php echo $qso->COL_QSL_VIA!=""?"Via ".str_replace("0", "Ø", $qso->COL_QSL_VIA):""; ?>;<?php echo $qso->COL_TIME_ON; ?>;<?php echo $qso->COL_MODE; ?>;<?php echo $qso->COL_FREQ; ?>;<?php echo $qso->COL_BAND; ?>;<?php echo $qso->COL_RST_SENT; ?>;<?php echo $qso->COL_SAT_NAME; ?>;<?php echo $qso->COL_SAT_MODE; ?>;<?php echo $qso->COL_QSL_RCVD =='Y'?'TNX QSL':'PSE QSL'; ?>;<?php echo $qso->COL_ROUTING; ?>;<?php echo $qso->ADIF; ?>;<?php echo $qso->ENTITY; ?>;
<?php } ?>