diff --git a/application/config/migration.php b/application/config/migration.php index f46573a92..d68749818 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 238; +$config['migration_version'] = 239; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index cef23c86d..92eff29a4 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -156,6 +156,24 @@ class Lookup extends CI_Controller { } } + public function ham_of_note($call) { + session_write_close(); + + if($call) { + $call = str_replace("-","/",$call); + $uppercase_callsign = strtoupper($call); + } + + $this->load->model('Pota'); + $query = $this->Pota->ham_of_note($uppercase_callsign); + if ($query->row()) { + header('Content-Type: application/json'); + echo json_encode($query->row()); + } else { + return null; + } + } + public function get_state_list() { $this->load->library('subdivisions'); diff --git a/application/controllers/Update.php b/application/controllers/Update.php index c883e1b9c..ceeef55a3 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -489,6 +489,15 @@ class Update extends CI_Controller { $this->load->view('interface_assets/footer'); } + public function update_hamsofnote() { + $this->load->model('Update_model'); + $bodyData['satupdates'] = $this->Update_model->update_hams_of_note(); + $data['page_title'] = __("Update of Hams of Note"); + $this->load->view('interface_assets/header', $data); + $this->load->view('update/hamsofnote', $bodyData); + $this->load->view('interface_assets/footer'); + } + function version_check() { // set the last run in cron table for the correct cron id $this->load->model('cron_model'); diff --git a/application/migrations/239_add_hams_of_note.php b/application/migrations/239_add_hams_of_note.php new file mode 100644 index 000000000..1eb092f00 --- /dev/null +++ b/application/migrations/239_add_hams_of_note.php @@ -0,0 +1,52 @@ +db->table_exists('hams_of_note')) { + $this->dbforge->add_field(array( + 'id' => array( + 'type' => 'INT', + 'constraint' => 20, + 'unsigned' => TRUE, + 'auto_increment' => TRUE, + 'unique' => TRUE + ), + 'callsign' => array( + 'type' => 'VARCHAR', + 'constraint' => 32, + 'unsigned' => TRUE, + ), + 'description' => array( + 'type' => 'VARCHAR', + 'constraint' => 256, + 'unsigned' => TRUE, + ), + 'linkname' => array( + 'type' => 'VARCHAR', + 'constraint' => 256, + 'unsigned' => TRUE, + 'null' => TRUE, + 'default' => '', + ), + 'link' => array( + 'type' => 'VARCHAR', + 'constraint' => 256, + 'unsigned' => TRUE, + 'null' => TRUE, + 'default' => '', + ), + )); + $this->dbforge->add_key('id', TRUE); + $this->dbforge->create_table('hams_of_note'); + $this->db->query("ALTER TABLE hams_of_note ADD INDEX `callsign` (`callsign`)"); + } + } + + public function down() { + if ($this->db->table_exists('hams_of_note')) { + $this->dbforge->drop_table('hams_of_note'); + } + } +} diff --git a/application/models/Pota.php b/application/models/Pota.php index 2a3329392..066663484 100644 --- a/application/models/Pota.php +++ b/application/models/Pota.php @@ -23,6 +23,14 @@ class Pota extends CI_Model { return $this->db->get($this->config->item('table_name')); } + + function ham_of_note($callsign) { + $this->db->where('callsign', $callsign); + $this->db->limit(1); + + return $this->db->get('hams_of_note'); + } + } ?> diff --git a/application/models/Update_model.php b/application/models/Update_model.php index 29fa27b5b..c9b6d3d7b 100644 --- a/application/models/Update_model.php +++ b/application/models/Update_model.php @@ -484,4 +484,37 @@ class Update_model extends CI_Model { return; } + function update_hams_of_note() { + $this->db->empty_table("hams_of_note"); + $this->db->query("ALTER TABLE hams_of_note AUTO_INCREMENT 1"); + $file = 'https://www.ham2k.com/data/hams-of-note.txt'; + $handle = fopen($file, "r"); + $i = 0; + while (false !== ($data = fgets($handle))) { + $line = trim($data); + if ($line != "" && $line[0] != '#') { + $index = strpos($line, ' '); + $call = substr($line, 0, $index); + $name = substr($line, strpos($line, ' ')); + $linkname = $link = ''; + if (strpos($name, '[')) { + $linkname = substr($name, strpos($name, '[')+1, (strpos($name, ']') - strpos($name, '[')-1)); + $link= substr($name, strpos($name, '(')+1, (strpos($name, ')') - strpos($name, '(')-1)); + $name = substr($name, 0, strpos($name, '[')); + } + $hon[$i]['callsign'] = $call; + $hon[$i]['description'] = $name; + $hon[$i]['linkname'] = $linkname; + $hon[$i]['link'] = $link; + if (($i % 100) == 0) { + $this->db->insert_batch('hams_of_note', $hon); + unset($hon); + } + $i++; + } + } + $this->db->insert_batch('hams_of_note', $hon); + return; + } + } diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 993934697..ce2700421 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -131,6 +131,7 @@ + diff --git a/application/views/update/hamsofnote.php b/application/views/update/hamsofnote.php new file mode 100644 index 000000000..6d63a9610 --- /dev/null +++ b/application/views/update/hamsofnote.php @@ -0,0 +1,17 @@ +
+

+ +'; + echo ''.__('Name').''.__('Display Name').''.__('Start Date').''.__('End Date').''.__('Status').''; + foreach ($satupdates as $sat) { + echo(''.$sat['name'].''.$sat['displayname'].''.$sat['startDate'].''.$sat['endDate'].''.$sat['status'].''); + } + echo ''; +} else { + echo 'No updates found or file could not be parsed.'; +} +?> + +
diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index 7d5559efd..387a11dad 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -526,6 +526,10 @@ function reset_fields() { $('#continent').val(""); $('#email').val(""); $('#region').val(""); + $('#ham_of_note_info').text(""); + $('#ham_of_note_link').html(""); + $('#ham_of_note_link').removeAttr('href'); + $('#ham_of_note_line').hide(); $('#lotw_info').text(""); $('#lotw_info').attr('data-bs-original-title', ""); $('#lotw_info').removeClass("lotw_info_red"); @@ -724,6 +728,15 @@ $("#callsign").on("focusout", function () { dok_selectize.clear(); } + $.getJSON(base_url + 'index.php/lookup/ham_of_note/' + $('#callsign').val().toUpperCase().replaceAll('Ø', '0').replaceAll('/','-'), function (result) { + if (result) { + $('#ham_of_note_info').text(result.description); + $('#ham_of_note_link').html(result.linkname); + $('#ham_of_note_link').attr('href', result.link); + $('#ham_of_note_line').show("slow"); + } + }); + $('#dxcc_id').val(result.dxcc.adif).multiselect('refresh'); await updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit'); if (result.callsign_cqz != '' && (result.callsign_cqz >= 1 && result.callsign_cqz <= 40)) {