From ca20d29bd611dde2d434160fc2134766fe5de382 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=A4del?= Date: Tue, 26 Feb 2019 22:00:09 +0100 Subject: [PATCH] Show worked before grid status --- application/controllers/Logbook.php | 30 +++++++++++++++++++++++------ application/views/qso/index.php | 21 ++++++++++++++++++++ css/main.css | 11 +++++++++-- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index c3ce6eb6..a7079d9f 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -62,12 +62,13 @@ class Logbook extends CI_Controller { $return = [ "dxcc" => false, - "callsign_name" => "", - "callsign_qra" => "", - "callsign_qth" => "", - "callsign_iota" => "", - "bearing" => "" - ]; + "callsign_name" => "", + "callsign_qra" => "", + "callsign_qth" => "", + "callsign_iota" => "", + "bearing" => "", + "workedBefore" => false + ]; $return['dxcc'] = $this->find_dxcc($callsign); $return['partial'] = $this->partial($callsign); @@ -80,6 +81,7 @@ class Logbook extends CI_Controller { $return['callsign_qth'] = $this->logbook_model->call_qth($callsign); $return['callsign_iota'] = $this->logbook_model->call_iota($callsign); $return['bearing'] = $this->bearing($return['callsign_qra']); + $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']); echo json_encode($return, JSON_PRETTY_PRINT); return; } @@ -116,6 +118,7 @@ class Logbook extends CI_Controller { $return['callsign_qra'] = $callbook['gridsquare']; $return['callsign_qth'] = $callbook['city']; $return['callsign_iota'] = $callbook['iota']; + $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']); } $return['bearing'] = $this->bearing($return['callsign_qra']); @@ -123,6 +126,21 @@ class Logbook extends CI_Controller { return; } + function worked_grid_before($gridsquare) + { + if (strlen($gridsquare) < 4) + return false; + + $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) + { + return true; + } + return false; + } + + /* Used to generate maps for displaying on /logbook/ */ function qso_map() { $this->load->model('logbook_model'); diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 18277fc8..3458980c 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -464,6 +464,27 @@ if($('#locator').val() == "") { $('#locator').val(result.callsign_qra); $('#locator_info').html(result.bearing); + + if (result.callsign_qra != "") + { + if (result.workedBefore) + { + $('#locator').addClass("workedGrid"); + $('#locator').attr('title', 'Grid was already worked in the past'); + } + else + { + $('#locator').addClass("newGrid"); + $('#locator').attr('title', 'New grid!'); + } + } + else + { + $('#locator').removeClass("workedGrid"); + $('#locator').removeClass("newGrid"); + $('#locator').attr('title', ''); + } + } /* Find Operators Name */ diff --git a/css/main.css b/css/main.css index f7919a48..061e55b4 100644 --- a/css/main.css +++ b/css/main.css @@ -30,9 +30,16 @@ table .title { font-weight: bold; color: #439BF6; } #sat_name { text-transform: uppercase; } #sat_mode { text-transform: uppercase; } #iota_ref { text-transform: uppercase; } - +.workedGrid { + background-color: #B33A3A; + color: #FFF !important; +} +.newGrid { + background-color: #4BB543; + color: #FFF !important; +} input[type="text"] { - color: #000000 !important; + color: #000000; } .pull-right { color: #fff; }