Skip to content

Trim VUCC_GRIDS Grids #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/libraries/Qra.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function get_bearing($lat1, $lon1, $lat2, $lon2) {
}

function qra2latlong($strQRA) {
$strQRA=trim($strQRA);
$strQRA=preg_replace('/\s+/', '', $strQRA);
if (substr_count($strQRA, ',') > 0) {
if (substr_count($strQRA, ',') == 3) {
// Handle grid corners
Expand Down
8 changes: 4 additions & 4 deletions application/models/Logbook_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function create_qso() {

// Decide whether its single gridsquare or a multi which makes it vucc_grids
if (strpos(trim(xss_clean($this->input->post('locator')) ?? ''), ',') !== false) {
$data['COL_VUCC_GRIDS'] = strtoupper(trim(xss_clean($this->input->post('locator')) ?? ''));
$data['COL_VUCC_GRIDS'] = strtoupper(preg_replace('/\s+/', '', xss_clean($this->input->post('locator')) ?? ''));
} else {
$data['COL_GRIDSQUARE'] = strtoupper(trim(xss_clean($this->input->post('locator')) ?? ''));
}
Expand Down Expand Up @@ -1167,7 +1167,7 @@ function edit() {
'COL_RST_RCVD' => $this->input->post('rst_rcvd'),
'COL_RST_SENT' => $this->input->post('rst_sent'),
'COL_GRIDSQUARE' => strtoupper(trim($this->input->post('locator'))),
'COL_VUCC_GRIDS' => strtoupper(trim($this->input->post('vucc_grids'))),
'COL_VUCC_GRIDS' => strtoupper(preg_replace('/\s+/', '', $this->input->post('vucc_grids'))),
'COL_DISTANCE' => $this->input->post('distance'),
'COL_COMMENT' => $this->input->post('comment'),
'COL_NAME' => $this->input->post('name'),
Expand Down Expand Up @@ -3298,7 +3298,7 @@ function import($record, $station_id = "0", $skipDuplicate = false, $markClublog
if (isset($record['vucc_grids'])){
$a_grids=explode(',',$record['vucc_grids']); // Split at , if there are junctions
foreach ($a_grids as $singlegrid) {
$singlegrid=strtoupper($singlegrid);
$singlegrid=strtoupper(trim($singlegrid));
if (strlen($singlegrid) == 4) $singlegrid .= "LL"; // Only 4 Chars? Fill with center "LL" as only A-R allowed
if (strlen($singlegrid) == 6) $singlegrid .= "55"; // Only 6 Chars? Fill with center "55"
if (strlen($singlegrid) == 8) $singlegrid .= "LL"; // Only 8 Chars? Fill with center "LL" as only A-R allowed
Expand All @@ -3308,7 +3308,7 @@ function import($record, $station_id = "0", $skipDuplicate = false, $markClublog
if (!preg_match('/^[A-R]{2}[0-9]{2}[A-X]{2}[0-9]{2}[A-X]{2}$/', $singlegrid)) $record['vucc_grids']='';
}
}
$input_vucc_grids = $record['vucc_grids'];
$input_vucc_grids = preg_replace('/\s+/', '', $record['vucc_grids']);
} else {
$input_vucc_grids = NULL;
}
Expand Down
4 changes: 2 additions & 2 deletions application/views/view_log/qso.php
Original file line number Diff line number Diff line change
Expand Up @@ -433,9 +433,9 @@
$distancestring = "(Gridsquare: ".$row->COL_GRIDSQUARE." / distance: ".$distance.")";
} else {
if (substr_count($row->COL_VUCC_GRIDS, ',') == 1) {
$distancestring = "(Gridline: ".$row->COL_VUCC_GRIDS." / distance: ".$distance.")";
$distancestring = "(Gridline: ".preg_replace('/\s+/', '', $row->COL_VUCC_GRIDS)." / distance: ".$distance.")";
} else if (substr_count($row->COL_VUCC_GRIDS, ',') == 3) {
$distancestring = "(Gridcorner: ".$row->COL_VUCC_GRIDS." / distance: ".$distance.")";
$distancestring = "(Gridcorner: ".preg_replace('/\s+/', '', $row->COL_VUCC_GRIDS)." / distance: ".$distance.")";
} else {
$distancestring = "(Grids: ".$row->COL_VUCC_GRIDS.")";
}
Expand Down