Fix QSL label sorting to prioritize QSL VIA over call sign#3301
Merged
Conversation
Co-authored-by: magicbug <84308+magicbug@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] QSL Label Print Order
Fix QSL label sorting to prioritize QSL VIA over call sign
Jul 30, 2025
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes QSL label sorting to comply with ARRL Outgoing QSL Bureau requirements by prioritizing QSL VIA call signs over worked call signs in the sorting order.
- Updated sorting logic to use QSL VIA call sign when available, falling back to worked call sign
- Applied consistent sorting across both QSL label export functions
- Maintains existing DXCC-first sorting structure
| $this->db->where_in('COL_QSL_SENT', array('R', 'Q')); | ||
| $this->db->order_by("COL_DXCC", "ASC"); | ||
| $this->db->order_by("COL_CALL", "ASC"); | ||
| $this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC"); |
There was a problem hiding this comment.
The complex CASE statement is duplicated in both functions. Consider extracting this SQL expression into a private method or class constant to improve maintainability and reduce code duplication.
Suggested change
| $this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC"); | |
| $this->db->order_by($this->_get_case_order_by_expression(), "ASC"); |
| $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); | ||
| $this->db->where_in('COL_PRIMARY_KEY', $ids); | ||
| $this->db->order_by("COL_DXCC", "ASC"); | ||
| $this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC"); |
There was a problem hiding this comment.
This function is missing the satellite-related order_by clauses that are present in export_printrequested(). Consider whether COL_SAT_NAME, COL_SAT_MODE, and COL_BAND_RX sorting should also be applied here for consistency.
Suggested change
| $this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "ASC"); | |
| $this->db->order_by("CASE WHEN COL_QSL_VIA IS NOT NULL AND COL_QSL_VIA != '' THEN COL_QSL_VIA ELSE COL_CALL END", "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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change addresses the ARRL Outgoing QSL Bureau requirement that QSL cards be sorted by parent prefix with QSL VIA call signs taking priority over the station worked call sign.
Problem
The current QSL label printing functionality sorts labels by DXCC and then by the worked call sign (
COL_CALL). However, the ARRL Outgoing QSL Bureau wants cards sorted by the QSL VIA call sign when available, as that's how they process and route the cards.Solution
Modified the sorting logic in
Labels_model.phpto use a SQL CASE statement that prioritizes QSL VIA over the worked call sign:Changes Made
export_printrequested()function to sort by QSL VIA when available, falling back to call signexport_printrequestedids()function with the same sorting logicResult
QSL labels now print in the correct order for the ARRL Outgoing QSL Bureau:
This ensures that cards going through QSL managers are properly grouped together as expected by the bureau's processing workflow.
Fixes #3041.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.