From 192a63ad4bb631a44728ca5fe6fe26601191bb00 Mon Sep 17 00:00:00 2001 From: Kim Huebel Date: Sun, 13 Oct 2019 22:42:41 +0200 Subject: [PATCH] Added indicators, if callsign/dxcc is worked on band and mode like the locator-input the callsign-input is colored in red or green the country-label is enabled with a label that tells us about worked/not wkd --- application/controllers/Logbook.php | 68 +++++++++++++++++ application/views/interface_assets/footer.php | 75 +++++++++++++++++++ 2 files changed, 143 insertions(+) diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index f93b0bbd..5c50a805 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -221,6 +221,74 @@ class Logbook extends CI_Controller { return; } + function jsonlookupdxcc($country, $type, $band, $mode) { + + $return = [ + "workedBefore" => false, + ]; + + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + } else { + $this->db->where('COL_MODE', $mode); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + + } + + $this->db->where('station_id', $station_id); + $this->db->where('COL_COUNTRY', urldecode($country)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) + { + $return['workedBefore'] = true; + } + + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + + return; + } + + function jsonlookupcallsign($callsign, $type, $band, $mode) { + + $return = [ + "workedBefore" => false, + ]; + + $CI =& get_instance(); + $CI->load->model('Stations'); + $station_id = $CI->Stations->find_active(); + + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + } else { + $this->db->where('COL_MODE', $mode); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + + } + + $this->db->where('station_id', $station_id); + $this->db->where('COL_CALL', strtoupper($callsign)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) + { + $return['workedBefore'] = true; + } + + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + + return; + } + /* Used to generate maps for displaying on /logbook/ */ function qso_map() { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 7f0e814c..cf28593d 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -389,6 +389,81 @@ $(document).on('keypress',function(e) { if(result.dxcc.entity != undefined) { $('#country').val(convert_case(result.dxcc.entity)); $('#callsign_info').text(convert_case(result.dxcc.entity)); + + if($("#sat_name" ).val() != "") { + //logbook/jsonlookupgrid/io77/SAT/0/0 + $.getJSON('logbook/jsonlookupcallsign/' + $("#callsign").val().toUpperCase() + '/SAT/0/0', function(result) + { + // Reset CSS values before updating + $('#callsign').removeClass("workedGrid"); + $('#callsign').removeClass("newGrid"); + $('#callsign').attr('title', ''); + + if (result.workedBefore) + { + $('#callsign').addClass("workedGrid"); + $('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!'); + } + else + { + $('#callsign').addClass("newGrid"); + $('#callsign').attr('title', 'New Callsign!'); + } + }) + } else { + $.getJSON('logbook/jsonlookupcallsign/' + $("#callsign").val().toUpperCase() + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) + { + // Reset CSS values before updating + $('#callsign').removeClass("workedGrid"); + $('#callsign').removeClass("newGrid"); + $('#callsign').attr('title', ''); + + if (result.workedBefore) + { + $('#callsign').addClass("workedGrid"); + $('#callsign').attr('title', 'Callsign was already worked in the past on this band and mode!'); + } + else + { + $('#callsign').addClass("newGrid"); + $('#callsign').attr('title', 'New Callsign!'); + } + }) + } + + + + if($("#sat_name" ).val() != "") { + //logbook/jsonlookupgrid/io77/SAT/0/0 + $.getJSON('logbook/jsonlookupdxcc/' + convert_case(result.dxcc.entity) + '/SAT/0/0', function(result) + { + $('#callsign_info').attr('title', ''); + + if (result.workedBefore) + { + $('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); + } + else + { + $('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); + } + }) + } else { + $.getJSON('logbook/jsonlookupdxcc/' + convert_case(result.dxcc.entity) + '/0/' + $("#band").val() +'/' + $("#mode").val(), function(result) + { + // Reset CSS values before updating + $('#callsign_info').attr('title', ''); + + if (result.workedBefore) + { + $('#callsign_info').attr('title', 'DXCC was already worked in the past on this band and mode!'); + } + else + { + $('#callsign_info').attr('title', 'New DXCC, not worked on this band and mode!'); + } + }) + } } if(result.lotw_member == "active") {