From 0f81c3f6a8c4a7db7b53a20fc8dd2d2e4fb7bf3a Mon Sep 17 00:00:00 2001 From: Kim Huebel Date: Wed, 28 Aug 2019 21:13:24 +0200 Subject: [PATCH] Exporting QSO-Data for printing QSLs --- .gitignore | 1 + application/config/cloudlog.php | 4 +- application/controllers/Qslprint.php | 67 +++++++++++++++++++ application/models/Adif_data.php | 8 +++ application/models/Logbook_model.php | 5 ++ application/models/Qslprint_model.php | 22 ++++++ application/views/interface_assets/header.php | 2 + application/views/qslprint/data/csv.php | 4 ++ application/views/qslprint/index.php | 42 ++++++++++++ 9 files changed, 153 insertions(+), 2 deletions(-) create mode 100644 application/controllers/Qslprint.php create mode 100644 application/models/Qslprint_model.php create mode 100644 application/views/qslprint/data/csv.php create mode 100644 application/views/qslprint/index.php diff --git a/.gitignore b/.gitignore index 2b66db61..06f9d8da 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /updates/*.html .idea/* .DS_Store +sync.sh diff --git a/application/config/cloudlog.php b/application/config/cloudlog.php index 085dfe4e..12975035 100644 --- a/application/config/cloudlog.php +++ b/application/config/cloudlog.php @@ -32,7 +32,7 @@ $config['show_time'] = FALSE; | Default is: M | */ -$config['measurement_base'] = 'M'; +$config['measurement_base'] = 'K'; /* |-------------------------------------------------------------------------- @@ -59,4 +59,4 @@ $config['map_gridsquares'] = FALSE; | */ -$config['cat_timeout_interval'] = 300; \ No newline at end of file +$config['cat_timeout_interval'] = 300; diff --git a/application/controllers/Qslprint.php b/application/controllers/Qslprint.php new file mode 100644 index 00000000..3b0934ee --- /dev/null +++ b/application/controllers/Qslprint.php @@ -0,0 +1,67 @@ +load->helper(array('form', 'url')); + + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function index() + { + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + $data['page_title'] = "Export requested QSLs for printing"; + + $this->load->view('interface_assets/header', $data); + $this->load->view('qslprint/index'); + $this->load->view('interface_assets/footer'); + + } + + public function exportadif() + { + // Set memory limit to unlimited to allow heavy usage + ini_set('memory_limit', '-1'); + + $this->load->model('adif_data'); + + $data['qsos'] = $this->adif_data->export_printrequested(); + + $this->load->view('adif/data/exportall', $data); + } + + public function exportcsv() + { + // Set memory limit to unlimited to allow heavy usage + ini_set('memory_limit', '-1'); + + $this->load->model('logbook_model'); + + $data['qsos'] = $this->logbook_model->get_qsos_for_printing(); + + $this->load->view('qslprint/data/csv', $data); + } + + function qsl_printed() { + $this->load->model('qslprint_model'); + $this->load->model('user_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + + // Update Logbook to Mark Paper Card Received + + $this->qslprint_model->mark_qsos_printed(); + + $this->session->set_flashdata('notice', 'QSOs are marked as sent via buro'); + + redirect('logbook'); + } +} + +/* End of file welcome.php */ +/* Location: ./application/controllers/welcome.php */ \ No newline at end of file diff --git a/application/models/Adif_data.php b/application/models/Adif_data.php index a31581fc..4e2e0d63 100644 --- a/application/models/Adif_data.php +++ b/application/models/Adif_data.php @@ -16,6 +16,14 @@ class adif_data extends CI_Model { return $query; } + function export_printrequested() { + $this->db->where('COL_QSL_SENT', 'R'); + $this->db->order_by("COL_TIME_ON", "ASC"); + $query = $this->db->get($this->config->item('table_name')); + + return $query; + } + function sat_all() { $this->db->where('COL_PROP_MODE', 'SAT'); $this->db->order_by("COL_TIME_ON", "ASC"); diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 1ca2a8cf..c6be2481 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -495,6 +495,11 @@ class Logbook_model extends CI_Model { $this->db->update($this->config->item('table_name'), $data); } + function get_qsos_for_printing() { + $query = $this->db->query('SELECT COL_PRIMARY_KEY, COL_CALL, COL_QSL_VIA, COL_TIME_ON, COL_MODE, COL_FREQ, UPPER(COL_BAND) as COL_BAND, COL_RST_SENT, COL_SAT_NAME, COL_SAT_MODE, COL_QSL_RCVD, (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) AS COL_ROUTING, ADIF, ENTITY FROM '.$this->config->item('table_name').', dxcc_prefixes WHERE COL_QSL_SENT LIKE \'R\' and (CASE WHEN COL_QSL_VIA != \'\' THEN COL_QSL_VIA ELSE COL_CALL END) like CONCAT(dxcc_prefixes.call,\'%\') and (end is null or end > now()) ORDER BY adif, col_routing'); + //$query = $this->db->query('SELECT * FROM '.$this->config->item('table_name').' WHERE COL_TIME_ON between \''.$morning.'\' AND \''.$night.'\''); + return $query; + } function get_qsos($num, $offset) { $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME, COL_GRIDSQUARE, COL_QSL_RCVD, COL_EQSL_QSL_RCVD, COL_EQSL_QSL_SENT, COL_QSL_SENT, COL_STX, COL_STX_STRING, COL_SRX, COL_SRX_STRING, COL_OPERATOR, COL_STATION_CALLSIGN, COL_LOTW_QSL_SENT, COL_LOTW_QSL_RCVD, COL_VUCC_GRIDS'); diff --git a/application/models/Qslprint_model.php b/application/models/Qslprint_model.php new file mode 100644 index 00000000..92db5c31 --- /dev/null +++ b/application/models/Qslprint_model.php @@ -0,0 +1,22 @@ + date('Y-m-d'), + 'COL_QSL_SENT' => "Y", + 'COL_QSL_SENT_VIA' => "B", + ); + + $this->db->where("COL_QSL_SENT", "R"); + $this->db->update($this->config->item('table_name'), $data); + } +} + +?> \ No newline at end of file diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index cef6614b..67a57e0b 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -83,6 +83,8 @@ LoTW Import/Export eQSL Import/Export + + Print Requested QSLs Backup diff --git a/application/views/qslprint/data/csv.php b/application/views/qslprint/data/csv.php new file mode 100644 index 00000000..ec05d05d --- /dev/null +++ b/application/views/qslprint/data/csv.php @@ -0,0 +1,4 @@ +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; +result() as $qso) { ?> +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; ?>; + \ No newline at end of file diff --git a/application/views/qslprint/index.php b/application/views/qslprint/index.php new file mode 100644 index 00000000..180cb7a7 --- /dev/null +++ b/application/views/qslprint/index.php @@ -0,0 +1,42 @@ +
+ +
+ + session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +
+
+ +
+
+
+

+ Here you can export requested QSLs as CSV-file or ADIF and mark them as sent via buro in a mass transaction if you like. +

+ + + Export requested QSLs to CSV-file + + Export requested QSLs to ADIF-file + + Mark requested QSLs as sent + + +
+
+ +