diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index 545b92c5..5ffeac2d 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -337,6 +337,35 @@ class QSO extends CI_Controller { echo json_encode($json); } + public function get_wwff() { + $json = []; + + if(!empty($this->input->get("query"))) { + $query = isset($_GET['query']) ? $_GET['query'] : FALSE; + $wwff = strtoupper($query); + + $file = 'assets/json/wwff.txt'; + + if (is_readable($file)) { + $lines = file($file, FILE_IGNORE_NEW_LINES); + $input = preg_quote($wwff, '~'); + $reg = '~^'. $input .'(.*)$~'; + $result = preg_grep($reg, $lines); + $json = []; + $i = 0; + foreach ($result as &$value) { + // Limit to 100 as to not slowdown browser too much + if (count($json) <= 100) { + $json[] = ["name"=>$value]; + } + } + } + } + + header('Content-Type: application/json'); + echo json_encode($json); + } + /* * Function is used for autocompletion of DOK in the QSO entry form */ diff --git a/application/controllers/Update.php b/application/controllers/Update.php index 06ba2aae..0133ba4c 100644 --- a/application/controllers/Update.php +++ b/application/controllers/Update.php @@ -376,6 +376,47 @@ class Update extends CI_Controller { } } + /* + * Pulls the WWFF directory for autocompletion in QSO dialogs + */ + public function update_wwff() { + $csvfile = 'https://wwff.co/wwff-data/wwff_directory.csv'; + + $wwfffile = './assets/json/wwff.txt'; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $csvfile); + curl_setopt($ch, CURLOPT_HEADER, false); + curl_setopt($ch, CURLOPT_USERAGENT, 'Cloudlog Updater'); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); + $csv = curl_exec($ch); + curl_close($ch); + + $wwfffilehandle = fopen($wwfffile, 'w'); + $data = str_getcsv($csv,"\n"); + foreach ($data as $idx => $row) { + if ($idx == 0) continue; // Skip line we are not interested in + $row = str_getcsv($row, ','); + if ($row[0]) { + fwrite($wwfffilehandle, $row[0].PHP_EOL); + } + } + + fclose($wwfffilehandle); + if (file_exists($wwfffile)) + { + $nCount = count(file($wwfffile)); + if ($nCount > 0) + { + echo "DONE: " . number_format($nCount) . " WWFF's saved"; + } else { + echo"FAILED: Empty file"; + } + } else { + echo"FAILED: Could not create wwff.txt file locally"; + } + } + } ?> diff --git a/application/language/english/general_words_lang.php b/application/language/english/general_words_lang.php index 90fbf0b1..210dc704 100644 --- a/application/language/english/general_words_lang.php +++ b/application/language/english/general_words_lang.php @@ -103,6 +103,7 @@ $lang['gen_hamradio_dok'] = 'DOK'; $lang['gen_hamradio_state'] = 'State'; $lang['gen_hamradio_iota'] = 'IOTA'; $lang['gen_hamradio_sota'] = 'SOTA'; +$lang['gen_hamradio_wwff'] = 'WWFF'; $lang['gen_hamradio_gridsquare'] = 'Gridsquare'; $lang['gen_hamradio_operator'] = 'Operator'; @@ -119,4 +120,4 @@ $lang['gen_from_date'] = 'From date'; $lang['gen_this_qso_was_confirmed_on'] = 'This QSO was confirmed on'; -$lang['error_no_logbook_found'] = 'No logbooks were found. You need to define a logbook under Station Logbooks! Do it here:'; \ No newline at end of file +$lang['error_no_logbook_found'] = 'No logbooks were found. You need to define a logbook under Station Logbooks! Do it here:'; diff --git a/application/language/english/qso_lang.php b/application/language/english/qso_lang.php index 86ee6413..e3613182 100644 --- a/application/language/english/qso_lang.php +++ b/application/language/english/qso_lang.php @@ -12,9 +12,10 @@ $lang['qso_title_image'] = 'Profile Picture'; $lang['qso_transmit_power_helptext'] = 'Give power value in Watts. Include only numbers in the input.'; $lang['qso_sota_ref_helptext'] = 'For example: GM/NS-001.'; +$lang['qso_wwff_ref_helptext'] = 'For example: DLFF-0069.'; -$lang['qso_sig_helptext'] = 'For example: WWFF or POTA'; -$lang['qso_sig_info_helptext'] = 'For example: DLFF-0029'; +$lang['qso_sig_helptext'] = 'For example: POTA'; +$lang['qso_sig_info_helptext'] = 'For example: PA-0150'; $lang['qso_dok_helptext'] = 'For example: Q03'; diff --git a/application/language/german/qso_lang.php b/application/language/german/qso_lang.php index 129fe752..e45cb586 100644 --- a/application/language/german/qso_lang.php +++ b/application/language/german/qso_lang.php @@ -12,9 +12,10 @@ $lang['qso_title_image'] = 'Profilbild'; $lang['qso_transmit_power_helptext'] = 'Gib die Ausgangsleistung in Watt an. Erfasse nur Zahlen bei der Eingabe.'; $lang['qso_sota_ref_helptext'] = 'Zum Beispiel: GM/NS-001.'; +$lang['qso_wwff_ref_helptext'] = 'Zum Beispiel: DLFF-0069.'; -$lang['qso_sig_helptext'] = 'Zum Beispiel: WWFF oder POTA'; -$lang['qso_sig_info_helptext'] = 'Zum Beispiel: DLFF-0029'; +$lang['qso_sig_helptext'] = 'Zum Beispiel: POTA'; +$lang['qso_sig_info_helptext'] = 'Zum Beispiel: PA-0150'; $lang['qso_dok_helptext'] = 'Zum Beispiel: Q03'; diff --git a/application/libraries/AdifHelper.php b/application/libraries/AdifHelper.php index 60bf9565..9bddfe9d 100644 --- a/application/libraries/AdifHelper.php +++ b/application/libraries/AdifHelper.php @@ -87,6 +87,7 @@ class AdifHelper { 'SILENT_KEY', 'SKCC', 'SOTA_REF', + 'WWFF_REF', 'SRX', 'SRX_STRING', 'STATE', @@ -188,6 +189,8 @@ class AdifHelper { $line .= $this->getAdifFieldLine("MY_SOTA_REF", $qso->station_sota); + $line .= $this->getAdifFieldLine("MY_WWFF_REF", $qso->station_wwff); + $line .= $this->getAdifFieldLine("MY_CQ_ZONE", $qso->station_cq); $line .= $this->getAdifFieldLine("MY_ITU_ZONE", $qso->station_itu); diff --git a/application/migrations/096_add_wwff_columns.php b/application/migrations/096_add_wwff_columns.php new file mode 100644 index 00000000..85c85eb9 --- /dev/null +++ b/application/migrations/096_add_wwff_columns.php @@ -0,0 +1,46 @@ +db->field_exists('COL_WWFF_REF', 'TABLE_HRD_CONTACTS_V01')) { + $fields = array( + 'COL_WWFF_REF VARCHAR(30) DEFAULT NULL', + 'COL_MY_WWFF_REF VARCHAR(50) DEFAULT NULL', + ); + $this->dbforge->add_column('TABLE_HRD_CONTACTS_V01', $fields, 'COL_VUCC_GRIDS'); + + // Now copy over data from SIG_INFO fields and remove COL_SIG and COL_SIG_INFO only if COL_SIG is WWFF + // This cannot be reverted on downgrade to prevent overwriting of other COL_SIG information + $this->db->set('COL_WWFF_REF', 'COL_SIG_INFO', FALSE); + $this->db->set('COL_SIG_INFO', ''); + $this->db->set('COL_SIG', ''); + $this->db->where('COL_SIG', 'WWFF'); + $this->db->update('TABLE_HRD_CONTACTS_V01'); + + // Add MY_WWFF_REF to station profile + $fields = array( + 'station_wwff varchar(50) DEFAULT NULL', + ); + $this->dbforge->add_column('station_profile', $fields); + } + } + + public function down() + { + $this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_WWFF_REF'); + $this->dbforge->drop_column('TABLE_HRD_CONTACTS_V01', 'COL_MY_WWFF_REF'); + $this->dbforge->drop_column('station_profile', 'station_wwff'); + } +} diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index f06cda11..5c900aa4 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -177,6 +177,7 @@ class Logbook_model extends CI_Model { 'COL_STATE' => trim($this->input->post('usa_state')), 'COL_CNTY' => $clean_county_input, 'COL_SOTA_REF' => trim($this->input->post('sota_ref')), + 'COL_WWFF_REF' => trim($this->input->post('wwff_ref')), 'COL_SIG' => trim($this->input->post('sig')), 'COL_SIG_INFO' => trim($this->input->post('sig_info')), 'COL_DARC_DOK' => strtoupper(trim($darc_dok)), @@ -209,6 +210,7 @@ class Logbook_model extends CI_Model { $data['COL_MY_CITY'] = strtoupper(trim($station['station_city'])); $data['COL_MY_IOTA'] = strtoupper(trim($station['station_iota'])); $data['COL_MY_SOTA_REF'] = strtoupper(trim($station['station_sota'])); + $data['COL_MY_WWFF_REF'] = strtoupper(trim($station['station_wwff'])); $data['COL_STATION_CALLSIGN'] = strtoupper(trim($station['station_callsign'])); $data['COL_MY_DXCC'] = strtoupper(trim($station['station_dxcc'])); @@ -283,8 +285,7 @@ class Logbook_model extends CI_Model { $this->db->where('COL_SOTA_REF', $searchphrase); break; case 'WWFF': - $this->db->where('COL_SIG', 'WWFF'); - $this->db->where('COL_SIG_INFO', $searchphrase); + $this->db->where('COL_WWFF_REF', $searchphrase); break; } @@ -661,6 +662,7 @@ class Logbook_model extends CI_Model { 'COL_LOTW_QSL_RCVD' => $this->input->post('lotw_recv'), 'COL_IOTA' => $this->input->post('iota_ref'), 'COL_SOTA_REF' => $this->input->post('sota_ref'), + 'COL_WWFF_REF' => $this->input->post('wwff_ref'), 'COL_TX_PWR' => $txpower, 'COL_SIG' => $this->input->post('sig'), 'COL_SIG_INFO' => $this->input->post('sig_info'), @@ -2608,6 +2610,7 @@ class Logbook_model extends CI_Model { 'COL_MY_SIG_INFO_INTL' => (!empty($record['my_sig_info_intl'])) ? $record['my_sig_info_intl'] : '', 'COL_MY_SIG_INTL' => (!empty($record['my_sig_intl'])) ? $record['my_sig_intl'] : '', 'COL_MY_SOTA_REF' => (!empty($record['my_sota_ref'])) ? $record['my_sota_ref'] : '', + 'COL_MY_WWFF_REF' => (!empty($record['my_wwff_ref'])) ? $record['my_wwff_ref'] : '', 'COL_MY_STATE' => (!empty($record['my_state'])) ? $record['my_state'] : '', 'COL_MY_STREET' => (!empty($record['my_street'])) ? $record['my_street'] : '', 'COL_MY_STREET_INTL' => (!empty($record['my_street_intl'])) ? $record['my_street_intl'] : '', @@ -2656,6 +2659,7 @@ class Logbook_model extends CI_Model { 'COL_SILENT_KEY' => (!empty($record['silent_key'])) ? $record['silent_key'] : '', 'COL_SKCC' => (!empty($record['skcc'])) ? $record['skcc'] : '', 'COL_SOTA_REF' => (!empty($record['sota_ref'])) ? $record['sota_ref'] : '', + 'COL_WWFF_REF' => (!empty($record['wwff_ref'])) ? $record['wwff_ref'] : '', 'COL_SRX' => (!empty($record['srx'])) ? $record['srx'] : null, 'COL_SRX_STRING' => (!empty($record['srx_string'])) ? $record['srx_string'] : '', 'COL_STATE' => (!empty($record['state'])) ? strtoupper($record['state']) : '', @@ -2693,6 +2697,7 @@ class Logbook_model extends CI_Model { $data['COL_MY_CITY'] = trim($row['station_city']); $data['COL_MY_IOTA'] = strtoupper(trim($row['station_iota'])); $data['COL_MY_SOTA_REF'] = strtoupper(trim($row['station_sota'])); + $data['COL_MY_WWFF_REF'] = strtoupper(trim($row['station_wwff'])); $data['COL_STATION_CALLSIGN'] = strtoupper(trim($row['station_callsign'])); $data['COL_MY_DXCC'] = strtoupper(trim($row['station_dxcc'])); diff --git a/application/models/Stations.php b/application/models/Stations.php index 9b01ff74..7dcfc8fc 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -64,6 +64,7 @@ class Stations extends CI_Model { 'station_city' => xss_clean($this->input->post('city', true)), 'station_iota' => xss_clean(strtoupper($this->input->post('iota', true))), 'station_sota' => xss_clean(strtoupper($this->input->post('sota', true))), + 'station_wwff' => xss_clean(strtoupper($this->input->post('wwff', true))), 'station_sig' => xss_clean(strtoupper($this->input->post('sig', true))), 'station_sig_info' => xss_clean(strtoupper($this->input->post('sig_info', true))), 'station_callsign' => xss_clean($this->input->post('station_callsign', true)), @@ -89,6 +90,7 @@ class Stations extends CI_Model { 'station_city' => xss_clean($this->input->post('city', true)), 'station_iota' => xss_clean($this->input->post('iota', true)), 'station_sota' => xss_clean($this->input->post('sota', true)), + 'station_wwff' => xss_clean($this->input->post('wwff', true)), 'station_sig' => xss_clean($this->input->post('sig', true)), 'station_sig_info' => xss_clean($this->input->post('sig_info', true)), 'station_callsign' => xss_clean($this->input->post('station_callsign', true)), @@ -242,6 +244,10 @@ class Stations extends CI_Model { $this->db->where('COL_MY_SOTA_REF', $row->station_sota); } + if($row->station_wwff != "") { + $this->db->where('COL_MY_WWFF_REF', $row->station_wwff); + } + if($row->station_sig != "") { $this->db->where('COL_MY_SIG', $row->station_sig); } diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 024fb36b..9f96239a 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -7,6 +7,7 @@ function echo_table_header_col($ctx, $name) { case 'Country': echo '