From aa051f7ffde225be6b9ff54d7c5a82ea1059bdc4 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 29 Jul 2023 20:02:18 +0200 Subject: [PATCH 1/8] [Labels] Added form to choose which label to start at --- application/controllers/Labels.php | 46 +++++++++++++----------- application/views/labels/index.php | 6 ++-- application/views/labels/startatform.php | 4 +++ assets/js/sections/labels.js | 29 +++++++++++++-- 4 files changed, 59 insertions(+), 26 deletions(-) create mode 100644 application/views/labels/startatform.php diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index ec83929d..f4a68464 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -1,4 +1,4 @@ -load->view('interface_assets/footer'); } else - { + { $this->load->model('labels_model'); $this->labels_model->addLabel(); @@ -114,16 +114,16 @@ class Labels extends CI_Controller { try { if ($label) { $pdf = new PDF_Label(array( - 'paper-size' => $label->paper_type, - 'metric' => $label->metric, - 'marginLeft' => $label->marginleft, - 'marginTop' => $label->margintop, - 'NX' => $label->nx, - 'NY' => $label->ny, - 'SpaceX' => $label->spacex, - 'SpaceY' => $label->spacey, - 'width' => $label->width, - 'height' => $label->height, + 'paper-size' => $label->paper_type, + 'metric' => $label->metric, + 'marginLeft' => $label->marginleft, + 'marginTop' => $label->margintop, + 'NX' => $label->nx, + 'NY' => $label->ny, + 'SpaceX' => $label->spacex, + 'SpaceY' => $label->spacey, + 'width' => $label->width, + 'height' => $label->height, 'font-size' => $label->font_size )); } else { @@ -132,7 +132,7 @@ class Labels extends CI_Controller { echo json_encode(array('message' => 'You need to create a label and set it to be used for print.')); return; } else { - $this->session->set_flashdata('error', 'You need to create a label and set it to be used for print.'); + $this->session->set_flashdata('error', 'You need to create a label and set it to be used for print.'); redirect('labels'); } } @@ -142,7 +142,7 @@ class Labels extends CI_Controller { echo json_encode(array('message' => 'Something went wrong! The label could not be generated. Check label size and font size.')); return; } else { - $this->session->set_flashdata('error', 'Something went wrong! The label could not be generated. Check label size and font size.'); + $this->session->set_flashdata('error', 'Something went wrong! The label could not be generated. Check label size and font size.'); redirect('labels'); } } @@ -165,7 +165,7 @@ class Labels extends CI_Controller { $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos); } } else { - $this->session->set_flashdata('message', '0 QSOs found for print!'); + $this->session->set_flashdata('message', '0 QSOs found for print!'); redirect('labels'); } $pdf->Output(); @@ -268,14 +268,14 @@ class Labels extends CI_Controller { public function updateLabel($id) { $this->load->model('labels_model'); $this->labels_model->updateLabel($id); - $this->session->set_flashdata('message', 'Label was saved.'); + $this->session->set_flashdata('message', 'Label was saved.'); redirect('labels'); } public function delete($id) { $this->load->model('labels_model'); $this->labels_model->deleteLabel($id); - $this->session->set_flashdata('warning', 'Label was deleted.'); + $this->session->set_flashdata('warning', 'Label was deleted.'); redirect('labels'); } @@ -285,4 +285,8 @@ class Labels extends CI_Controller { $this->labels_model->saveDefaultLabel($id); } + public function startAtLabel() { + $data['stationid'] = xss_clean(json_decode($this->input->post('stationid'))); + $this->load->view('labels/startatform', $data); + } } diff --git a/application/views/labels/index.php b/application/views/labels/index.php index 0b99b4b0..6e655133 100644 --- a/application/views/labels/index.php +++ b/application/views/labels/index.php @@ -27,7 +27,7 @@
Create New Label Type - +
';?> @@ -96,7 +96,7 @@ echo '' . $qso->station_gridsquare . ''; echo '' . $qso->count . ''; echo ''; - echo ''; + echo ''; echo ''; } ?> @@ -105,4 +105,4 @@
- \ No newline at end of file + diff --git a/application/views/labels/startatform.php b/application/views/labels/startatform.php new file mode 100644 index 00000000..15ba3b06 --- /dev/null +++ b/application/views/labels/startatform.php @@ -0,0 +1,4 @@ +
+ + +
diff --git a/assets/js/sections/labels.js b/assets/js/sections/labels.js index 62c6713f..d8f6d9be 100644 --- a/assets/js/sections/labels.js +++ b/assets/js/sections/labels.js @@ -2,7 +2,7 @@ $('.labeltable').on('click', 'input[type="checkbox"]', function() { var clickedlabelid = $(this).closest('tr').attr("class"); clickedlabelid = clickedlabelid.match(/\d+/)[0]; saveDefault(clickedlabelid); - $('input:checkbox').not(this).prop('checked', false); + $('input:checkbox').not(this).prop('checked', false); }); function saveDefault(id) { @@ -13,4 +13,29 @@ function saveDefault(id) { success: function (html) { } }); -} \ No newline at end of file +} + +function printat(stationid) { + $.ajax({ + url: base_url + 'index.php/labels/startAtLabel', + type: 'post', + data: {'stationid': stationid}, + success: function (html) { + BootstrapDialog.show({ + title: 'Start printing at which label?', + size: BootstrapDialog.SIZE_NORMAL, + cssClass: 'qso-dialog', + nl2br: false, + message: html, + onshown: function(dialog) { + }, + buttons: [{ + label: 'Close', + action: function (dialogItself) { + dialogItself.close(); + } + }] + }); + } + }); +} From 2543a721ad040f890c3190089eb395fede5e6bc1 Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sat, 29 Jul 2023 20:49:45 +0200 Subject: [PATCH 2/8] [Labels] Added support for label offset in backend --- application/controllers/Labels.php | 31 ++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index f4a68464..65d2aa5e 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -98,14 +98,15 @@ class Labels extends CI_Controller { public function print($station_id) { $clean_id = xss_clean($station_id); + $offset = xss_clean($this->input->post('startat')); $this->load->model('labels_model'); $result = $this->labels_model->export_printrequested($clean_id); - $this->prepareLabel($result); + $this->prepareLabel($result, false, $offset); } - function prepareLabel($qsos, $jscall = false) { + function prepareLabel($qsos, $jscall = false, $offset = 1) { $this->load->model('labels_model'); $label = $this->labels_model->getDefaultLabel(); $label->font='DejaVuSans'; // Fix font to DejaVuSans @@ -160,9 +161,9 @@ class Labels extends CI_Controller { if ($qsos->num_rows() > 0) { if ($label->qsos == 1) { - $this->makeMultiQsoLabel($qsos->result(), $pdf,1); + $this->makeMultiQsoLabel($qsos->result(), $pdf, 1, $offset); } else { - $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos); + $this->makeMultiQsoLabel($qsos->result(), $pdf, $label->qsos, $offset); } } else { $this->session->set_flashdata('message', '0 QSOs found for print!'); @@ -171,7 +172,7 @@ class Labels extends CI_Controller { $pdf->Output(); } - function makeMultiQsoLabel($qsos, $pdf, $numberofqsos) { + function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset) { $text = ''; $current_callsign = ''; $current_sat = ''; @@ -179,7 +180,7 @@ class Labels extends CI_Controller { foreach($qsos as $qso) { if (($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) { if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $offset); $qso_data = []; } $current_callsign = $qso->COL_CALL; @@ -198,12 +199,13 @@ class Labels extends CI_Controller { ]; } if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $offset); } } // New begin - function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label) { + function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label, $offset) { + $tableData = []; $count_qso = 0; $qso=[]; @@ -221,7 +223,7 @@ class Labels extends CI_Controller { $count_qso++; if($count_qso == $qso_per_label){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso, $offset); $tableData = []; // reset the data $count_qso = 0; // reset the counter } @@ -229,12 +231,17 @@ class Labels extends CI_Controller { } // generate label for remaining QSOs if($count_qso > 0){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso, $offset); $preliminaryData = []; // reset the data } } - function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso){ + function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso, $offset){ + if ($offset !== 1) { + for ($i = 1; $i < $offset; $i++) { + $pdf->Add_Label(''); + } + } $builder = new \AsciiTable\Builder(); $builder->addRows($tableData); $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; @@ -286,7 +293,7 @@ class Labels extends CI_Controller { } public function startAtLabel() { - $data['stationid'] = xss_clean(json_decode($this->input->post('stationid'))); + $data['stationid'] = xss_clean($this->input->post('stationid')); $this->load->view('labels/startatform', $data); } } From b5d73e50c3f29009c606a3c6c887cf1c616a22a0 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 30 Jul 2023 05:46:25 +0000 Subject: [PATCH 3/8] Fixed start_at --- application/controllers/Labels.php | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 65d2aa5e..1118a488 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -177,10 +177,15 @@ class Labels extends CI_Controller { $current_callsign = ''; $current_sat = ''; $qso_data = []; + if ($offset !== 1) { + for ($i = 1; $i < $offset; $i++) { + $pdf->Add_Label(''); + } + } foreach($qsos as $qso) { if (($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) { if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $offset); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); $qso_data = []; } $current_callsign = $qso->COL_CALL; @@ -194,17 +199,17 @@ class Labels extends CI_Controller { 'rst' => $qso->COL_RST_SENT, 'mygrid' => $qso->station_gridsquare, 'sat' => $qso->COL_SAT_NAME, - 'sat_mode' => $qso->COL_SAT_MODE, + 'sat_mode' => ($qso->COL_SAT_MODE ?? ''), 'qsl_recvd' => $qso->COL_QSL_RCVD ]; } if (!empty($qso_data)) { - $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos, $offset); + $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); } } // New begin - function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label, $offset) { + function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label) { $tableData = []; $count_qso = 0; @@ -222,8 +227,9 @@ class Labels extends CI_Controller { $tableData[] = $rowData; $count_qso++; + if($count_qso == $qso_per_label){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso, $offset); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso); $tableData = []; // reset the data $count_qso = 0; // reset the counter } @@ -231,17 +237,12 @@ class Labels extends CI_Controller { } // generate label for remaining QSOs if($count_qso > 0){ - $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso, $offset); + $this->generateLabel($pdf, $current_callsign, $tableData,$count_qso,$qso); $preliminaryData = []; // reset the data } } - function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso, $offset){ - if ($offset !== 1) { - for ($i = 1; $i < $offset; $i++) { - $pdf->Add_Label(''); - } - } + function generateLabel($pdf, $current_callsign, $tableData,$numofqsos,$qso){ $builder = new \AsciiTable\Builder(); $builder->addRows($tableData); $text = "Confirming QSO".($numofqsos>1 ? 's' : '')." with "; From 52b3d3585b8913ae70e1fe60a974ffb15fd03ed2 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 30 Jul 2023 06:08:01 +0000 Subject: [PATCH 4/8] Fixing of SATMode / BandRX --- application/controllers/Labels.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 1118a488..efa79b6c 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -176,6 +176,8 @@ class Labels extends CI_Controller { $text = ''; $current_callsign = ''; $current_sat = ''; + $current_sat_mode = ''; + $current_sat_bandrx = ''; $qso_data = []; if ($offset !== 1) { for ($i = 1; $i < $offset; $i++) { @@ -183,13 +185,15 @@ class Labels extends CI_Controller { } } foreach($qsos as $qso) { - if (($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) { + if (($qso->COL_SAT_MODE ?? '' !== $current_sat_mode) || ($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign) || (($qso->COL_SAT_NAME !== '') && ($col->COL_BAND_RX ?? '' !== $current_sat_bandrx))) { if (!empty($qso_data)) { $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); $qso_data = []; } $current_callsign = $qso->COL_CALL; $current_sat = $qso->COL_SAT_NAME; + $current_sat_mode = $qso->COL_SAT_MODE; + $current_sat_bandrx = $qso->COL_BAND_RX; } $qso_data[] = [ @@ -200,6 +204,7 @@ class Labels extends CI_Controller { 'mygrid' => $qso->station_gridsquare, 'sat' => $qso->COL_SAT_NAME, 'sat_mode' => ($qso->COL_SAT_MODE ?? ''), + 'sat_band_rx' => ($qso->COL_BAND_RX ?? ''), 'qsl_recvd' => $qso->COL_QSL_RCVD ]; } @@ -250,7 +255,13 @@ class Labels extends CI_Controller { $text .= "\n"; $text .= $builder->renderTable(); if($qso['sat'] != "") { - $text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.(strlen($qso['sat_mode']) == 2 ? (strtoupper($qso['sat_mode'][0]).'/'.strtoupper($qso['sat_mode'][1])) : strtoupper($qso['sat_mode'])); + if (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] !== '')) { + $text .= "\n".'Satellite: '.$qso['sat'].' Band RX: '.$qso['sat_band_rx']; + } elseif (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] == '')) { + $text .= "\n".'Satellite: '.$qso['sat']; + } else { + $text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.(strlen($qso['sat_mode']) == 2 ? (strtoupper($qso['sat_mode'][0]).'/'.strtoupper($qso['sat_mode'][1])) : strtoupper($qso['sat_mode'])); + } } $text .= "\nThanks for the QSO".($numofqsos>1 ? 's' : ''); $text .= " | ".($qso['qsl_recvd'] == 'Y' ? 'TNX' : 'PSE')." QSL"; From 21c29cc9da2b6cfa3f5da41dd06b3d26675f1282 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 30 Jul 2023 06:14:13 +0000 Subject: [PATCH 5/8] adjusted sorting for aggregation --- application/models/Labels_model.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/application/models/Labels_model.php b/application/models/Labels_model.php index bdce7eb8..41db763a 100644 --- a/application/models/Labels_model.php +++ b/application/models/Labels_model.php @@ -125,6 +125,8 @@ class Labels_model extends CI_Model { $this->db->order_by("COL_DXCC", "ASC"); $this->db->order_by("COL_CALL", "ASC"); $this->db->order_by("COL_SAT_NAME", "ASC"); + $this->db->order_by("COL_SAT_MODE", "ASC"); + $this->db->order_by("COL_BAND_RX", "ASC"); $this->db->order_by("COL_TIME_ON", "ASC"); $this->db->order_by("COL_MODE", "ASC"); $query = $this->db->get($this->config->item('table_name')); From be2478a3ae2bca0c72756aa088eac3db7efeec1a Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 30 Jul 2023 06:18:36 +0000 Subject: [PATCH 6/8] Respect different BAND_RX only when working SAT --- application/controllers/Labels.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index efa79b6c..551c5eee 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -193,7 +193,7 @@ class Labels extends CI_Controller { $current_callsign = $qso->COL_CALL; $current_sat = $qso->COL_SAT_NAME; $current_sat_mode = $qso->COL_SAT_MODE; - $current_sat_bandrx = $qso->COL_BAND_RX; + $current_sat_bandrx = ($qso->COL_SAT_MODE !== '' ? $qso->COL_BAND_RX : ''); // do this only when working sat } $qso_data[] = [ From 33d469f4b8b8ca9994e12f35d8e1482444bb7700 Mon Sep 17 00:00:00 2001 From: int2001 Date: Sun, 30 Jul 2023 06:50:08 +0000 Subject: [PATCH 7/8] Fixed detection of new QSO --- application/controllers/Labels.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 551c5eee..977e5a6b 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -185,15 +185,17 @@ class Labels extends CI_Controller { } } foreach($qsos as $qso) { - if (($qso->COL_SAT_MODE ?? '' !== $current_sat_mode) || ($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign) || (($qso->COL_SAT_NAME !== '') && ($col->COL_BAND_RX ?? '' !== $current_sat_bandrx))) { + if (($this->pretty_sat_mode($qso->COL_SAT_MODE) !== $current_sat_mode) || ($qso->COL_SAT_NAME !== $current_sat) || ($qso->COL_CALL !== $current_callsign) || // Call, SAT or SAT-Mode differs? + ( ($qso->COL_BAND_RX !== $current_sat_bandrx) && ($this->pretty_sat_mode($qso->COL_SAT_MODE) !== '')) ) { + // ((($qso->COL_SAT_NAME ?? '' !== $current_sat) || ($qso->COL_CALL !== $current_callsign)) && ($qso->COL_SAT_NAME ?? '' !== '') && ($col->COL_BAND_RX ?? '' !== $current_sat_bandrx))) { if (!empty($qso_data)) { $this->finalizeData($pdf, $current_callsign, $qso_data, $numberofqsos); $qso_data = []; } $current_callsign = $qso->COL_CALL; $current_sat = $qso->COL_SAT_NAME; - $current_sat_mode = $qso->COL_SAT_MODE; - $current_sat_bandrx = ($qso->COL_SAT_MODE !== '' ? $qso->COL_BAND_RX : ''); // do this only when working sat + $current_sat_mode = $this->pretty_sat_mode($qso->COL_SAT_MODE); + $current_sat_bandrx = $qso->COL_BAND_RX ?? ''; } $qso_data[] = [ @@ -203,7 +205,7 @@ class Labels extends CI_Controller { 'rst' => $qso->COL_RST_SENT, 'mygrid' => $qso->station_gridsquare, 'sat' => $qso->COL_SAT_NAME, - 'sat_mode' => ($qso->COL_SAT_MODE ?? ''), + 'sat_mode' => $this->pretty_sat_mode($qso->COL_SAT_MODE ?? ''), 'sat_band_rx' => ($qso->COL_BAND_RX ?? ''), 'qsl_recvd' => $qso->COL_QSL_RCVD ]; @@ -213,6 +215,9 @@ class Labels extends CI_Controller { } } // New begin + function pretty_sat_mode($sat_mode) { + return(strlen($sat_mode) == 2 ? (strtoupper($sat_mode[0]).'/'.strtoupper($sat_mode[1])) : strtoupper($sat_mode)); + } function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label) { @@ -260,7 +265,7 @@ class Labels extends CI_Controller { } elseif (($qso['sat_mode'] == '') && ($qso['sat_band_rx'] == '')) { $text .= "\n".'Satellite: '.$qso['sat']; } else { - $text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.(strlen($qso['sat_mode']) == 2 ? (strtoupper($qso['sat_mode'][0]).'/'.strtoupper($qso['sat_mode'][1])) : strtoupper($qso['sat_mode'])); + $text .= "\n".'Satellite: '.$qso['sat'].' Mode: '.$qso['sat_mode']; } } $text .= "\nThanks for the QSO".($numofqsos>1 ? 's' : ''); From 4387a5b2ed10ec04edb3f77531df8977e7048b7a Mon Sep 17 00:00:00 2001 From: Andreas <6977712+AndreasK79@users.noreply.github.com> Date: Sun, 30 Jul 2023 09:59:38 +0200 Subject: [PATCH 8/8] Fixed error when sat_mode is null --- application/controllers/Labels.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/controllers/Labels.php b/application/controllers/Labels.php index 977e5a6b..a6826bf3 100644 --- a/application/controllers/Labels.php +++ b/application/controllers/Labels.php @@ -216,7 +216,7 @@ class Labels extends CI_Controller { } // New begin function pretty_sat_mode($sat_mode) { - return(strlen($sat_mode) == 2 ? (strtoupper($sat_mode[0]).'/'.strtoupper($sat_mode[1])) : strtoupper($sat_mode)); + return(strlen($sat_mode ?? '') == 2 ? (strtoupper($sat_mode[0]).'/'.strtoupper($sat_mode[1])) : strtoupper($sat_mode ?? '')); } function finalizeData($pdf, $current_callsign, &$preliminaryData, $qso_per_label) {