From 91cdec23df799b30fda03fd9fc162042cb91e7e5 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Sun, 14 Dec 2025 11:34:45 +0100
Subject: [PATCH] Moved function from model, and added userid
---
application/models/Logbook_model.php | 44 -------------------
application/models/Logbookadvanced_model.php | 46 ++++++++++++++++++++
2 files changed, 46 insertions(+), 44 deletions(-)
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index 6935ca62f..bfa3a0657 100644
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -5996,50 +5996,6 @@ class Logbook_model extends CI_Model {
return '';
}
- public function check_missing_grid_id($all) {
- // get all records with no COL_GRIDSQUARE
- $this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF");
-
- $this->db->where("(COL_GRIDSQUARE is NULL or COL_GRIDSQUARE = '') AND (COL_VUCC_GRIDS is NULL or COL_VUCC_GRIDS = '')");
-
- $r = $this->db->get($this->config->item('table_name'));
-
- $count = 0;
- $this->db->trans_start();
- if ($r->num_rows() > 0) {
- foreach ($r->result_array() as $row) {
- $callsign = $row['COL_CALL'];
- if (!$this->load->is_loaded('callbook')) {
- $this->load->library('callbook');
- }
-
- $callbook = $this->callbook->getCallbookData($callsign);
-
- if (isset($callbook)) {
- if (isset($callbook['error'])) {
- printf("Error: " . $callbook['error'] . "
");
- } else {
- $return['callsign_qra'] = $callbook['gridsquare'];
- if ($return['callsign_qra'] != '') {
- $sql = sprintf(
- "update %s set COL_GRIDSQUARE = '%s' where COL_PRIMARY_KEY=%d",
- $this->config->item('table_name'),
- $return['callsign_qra'],
- $row['COL_PRIMARY_KEY']
- );
- $this->db->query($sql);
- printf("Updating %s to %s\n
", $row['COL_PRIMARY_KEY'], $return['callsign_qra']);
- $count++;
- }
- }
- }
- }
- }
- $this->db->trans_complete();
-
- print("$count updated\n");
- }
-
public function check_for_station_id() {
$this->db->select('COL_PRIMARY_KEY, COL_TIME_ON, COL_CALL, COL_MODE, COL_BAND, COL_STATION_CALLSIGN');
$this->db->where('station_id =', NULL);
diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php
index ae1090534..4ee468e17 100644
--- a/application/models/Logbookadvanced_model.php
+++ b/application/models/Logbookadvanced_model.php
@@ -1689,4 +1689,50 @@ class Logbookadvanced_model extends CI_Model {
return null;
}
}
+
+ public function check_missing_grid_id($all) {
+ // get all records with no COL_GRIDSQUARE
+ $this->db->select("COL_PRIMARY_KEY, COL_CALL, COL_TIME_ON, COL_TIME_OFF");
+ $this->db->join('station_profile', 'station_profile.station_id = ' . $this->config->item('table_name') . '.station_id');
+ $this->db->where("station_profile.user_id", $this->session->userdata('user_id'));
+
+ $this->db->where("(COL_GRIDSQUARE is NULL or COL_GRIDSQUARE = '') AND (COL_VUCC_GRIDS is NULL or COL_VUCC_GRIDS = '')");
+
+ $r = $this->db->get($this->config->item('table_name'));
+
+ $count = 0;
+ $this->db->trans_start();
+ if ($r->num_rows() > 0) {
+ foreach ($r->result_array() as $row) {
+ $callsign = $row['COL_CALL'];
+ if (!$this->load->is_loaded('callbook')) {
+ $this->load->library('callbook');
+ }
+
+ $callbook = $this->callbook->getCallbookData($callsign);
+
+ if (isset($callbook)) {
+ if (isset($callbook['error'])) {
+ printf("Error: " . $callbook['error'] . "
");
+ } else {
+ $return['callsign_qra'] = $callbook['gridsquare'];
+ if ($return['callsign_qra'] != '') {
+ $sql = sprintf(
+ "update %s set COL_GRIDSQUARE = '%s' where COL_PRIMARY_KEY=%d",
+ $this->config->item('table_name'),
+ $return['callsign_qra'],
+ $row['COL_PRIMARY_KEY']
+ );
+ $this->db->query($sql);
+ printf("Updating %s to %s\n
", $row['COL_PRIMARY_KEY'], $return['callsign_qra']);
+ $count++;
+ }
+ }
+ }
+ }
+ }
+ $this->db->trans_complete();
+
+ print("$count updated\n");
+ }
}