diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 13e3970d9..6f13af8e1 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -162,21 +162,25 @@ class Logbook extends CI_Controller { $measurement_base = $this->session->userdata('user_measurement_base'); } - $return['callsign_name'] = $this->nval($callbook['name'] ?? '', $this->logbook_model->call_name($callsign)); - $return['callsign_qra'] = $this->nval($callbook['gridsquare'] ?? '', $this->logbook_model->call_qra($callsign)); + // Fill in the return array with callbook data, using database values as fallback + // Callbook data takes precedence over database values + // Logic updated to use nval() function to prioritize callbook data + // Added callsign_email field + $return['callsign_name'] = $this->nval($this->logbook_model->call_name($callsign), $callbook['name'] ?? ''); + $return['callsign_qra'] = $this->nval($this->logbook_model->call_qra($callsign), $callbook['gridsquare'] ?? ''); $return['callsign_geoloc'] = $callbook['geoloc'] ?? ''; $return['callsign_distance'] = $this->distance($return['callsign_qra'], $station_id); - $return['callsign_qth'] = $this->nval($callbook['city'] ?? '', $this->logbook_model->call_qth($callsign)); - $return['callsign_iota'] = $this->nval($callbook['iota'] ?? '', $this->logbook_model->call_iota($callsign)); - $return['callsign_email'] = $this->nval($callbook['email'] ?? '', $this->logbook_model->call_email($callsign)); - $return['qsl_manager'] = $this->nval($callbook['qslmgr'] ?? '', $this->logbook_model->call_qslvia($callsign)); - $return['callsign_state'] = $this->nval($callbook['state'] ?? '', $this->logbook_model->call_state($callsign)); - $return['callsign_us_county'] = $this->nval($callbook['us_county'] ?? '', $this->logbook_model->call_us_county($callsign)); - $return['callsign_ituz'] = $this->nval($callbook['ituz'] ?? '', $this->logbook_model->call_ituzone($callsign)); - $return['callsign_cqz'] = $this->nval($callbook['cqz'] ?? '', $this->logbook_model->call_cqzone($callsign)); + $return['callsign_qth'] = $this->nval($this->logbook_model->call_qth($callsign), $callbook['city'] ?? ''); + $return['callsign_iota'] = $this->nval($this->logbook_model->call_iota($callsign), $callbook['iota'] ?? ''); + $return['callsign_email'] = $this->nval($this->logbook_model->call_email($callsign), $callbook['email'] ?? ''); + $return['qsl_manager'] = $this->nval($this->logbook_model->call_qslvia($callsign), $callbook['qslmgr'] ?? ''); + $return['callsign_state'] = $this->nval($this->logbook_model->call_state($callsign), $callbook['state'] ?? ''); + $return['callsign_us_county'] = $this->nval($this->logbook_model->call_us_county($callsign), $callbook['us_county'] ?? ''); + $return['callsign_ituz'] = $this->nval($this->logbook_model->call_ituzone($callsign), $callbook['ituz'] ?? ''); + $return['callsign_cqz'] = $this->nval($this->logbook_model->call_cqzone($callsign), $callbook['cqz'] ?? ''); $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra'], $band, $mode); - $return['confirmed'] = $this->confirmed_grid_before($return['callsign_qra'], $band, $mode); - $return['timesWorked'] = $this->logbook_model->times_worked($lookupcall); + $return['confirmed'] = $this->confirmed_grid_before($return['callsign_qra'], $band, $mode); + $return['timesWorked'] = $this->logbook_model->times_worked($lookupcall); if ($this->session->userdata('user_show_profile_image')) { if (isset($callbook) && isset($callbook['image'])) { @@ -188,6 +192,31 @@ class Logbook extends CI_Controller { } else { $return['image'] = "n/a"; } + + // Additional profile information from QRZ + $return['profile_url'] = $callbook['url'] ?? ''; + $return['profile_class'] = $callbook['class'] ?? ''; + $return['profile_born'] = $callbook['born'] ?? ''; + $return['profile_eqsl'] = $callbook['eqsl'] ?? ''; + $return['profile_lotw'] = $callbook['lotw'] ?? ''; + $return['profile_mqsl'] = $callbook['mqsl'] ?? ''; + $return['profile_fname'] = $callbook['fname'] ?? ''; + $return['profile_name_last'] = $callbook['name_last'] ?? ''; + $return['profile_nickname'] = $callbook['nickname'] ?? ''; + $return['profile_aliases'] = $callbook['aliases'] ?? ''; + $return['profile_p_call'] = $callbook['p_call'] ?? ''; + $return['profile_addr1'] = $callbook['addr1'] ?? ''; + $return['profile_addr2'] = $callbook['addr2'] ?? ''; + $return['profile_state'] = $callbook['state'] ?? ''; + $return['profile_zip'] = $callbook['zip'] ?? ''; + $return['profile_country'] = $callbook['country'] ?? ''; + $return['profile_dxcc'] = $callbook['dxcc'] ?? ''; + $return['profile_lat'] = $callbook['lat'] ?? ''; + $return['profile_lon'] = $callbook['lon'] ?? ''; + $return['profile_efdate'] = $callbook['efdate'] ?? ''; + $return['profile_expdate'] = $callbook['expdate'] ?? ''; + $return['profile_GMTOffset'] = $callbook['GMTOffset'] ?? ''; + $return['profile_qslmgr'] = $callbook['qslmgr'] ?? ''; } if ($return['callsign_qra'] != "" || $return['callsign_qra'] != null) { diff --git a/application/libraries/Qrz.php b/application/libraries/Qrz.php index 3e8d5f21c..a5c237dcc 100644 --- a/application/libraries/Qrz.php +++ b/application/libraries/Qrz.php @@ -91,60 +91,99 @@ class Qrz { return $data['error'] = $xml->Session->Error; } - // Return Required Fields + // Map all QRZ XML fields according to API specification $data['callsign'] = (string)$xml->Callsign->call; - - if ($use_fullname === true) { - $data['name'] = (string)$xml->Callsign->fname. ' ' . (string)$xml->Callsign->name; - } else { - $data['name'] = (string)$xml->Callsign->fname; - } - + $data['xref'] = (string)$xml->Callsign->xref; + $data['aliases'] = (string)$xml->Callsign->aliases; + $data['dxcc'] = (string)$xml->Callsign->dxcc; + $data['fname'] = (string)$xml->Callsign->fname; + $data['name_last'] = (string)$xml->Callsign->name; + $data['addr1'] = (string)$xml->Callsign->addr1; + $data['addr2'] = (string)$xml->Callsign->addr2; + $data['state'] = (string)$xml->Callsign->state; + $data['zip'] = (string)$xml->Callsign->zip; + $data['country'] = (string)$xml->Callsign->country; + $data['ccode'] = (string)$xml->Callsign->ccode; + $data['lat'] = (string)$xml->Callsign->lat; + $data['lon'] = (string)$xml->Callsign->lon; + $data['grid'] = (string)$xml->Callsign->grid; + $data['county'] = (string)$xml->Callsign->county; + $data['fips'] = (string)$xml->Callsign->fips; + $data['land'] = (string)$xml->Callsign->land; + $data['efdate'] = (string)$xml->Callsign->efdate; + $data['expdate'] = (string)$xml->Callsign->expdate; + $data['p_call'] = (string)$xml->Callsign->p_call; + $data['class'] = (string)$xml->Callsign->class; + $data['codes'] = (string)$xml->Callsign->codes; + $data['qslmgr'] = (string)$xml->Callsign->qslmgr; $data['email'] = (string)$xml->Callsign->email; + $data['url'] = (string)$xml->Callsign->url; + $data['u_views'] = (string)$xml->Callsign->u_views; + $data['bio'] = (string)$xml->Callsign->bio; + $data['biodate'] = (string)$xml->Callsign->biodate; + $data['image'] = (string)$xml->Callsign->image; + $data['imageinfo'] = (string)$xml->Callsign->imageinfo; + $data['serial'] = (string)$xml->Callsign->serial; + $data['moddate'] = (string)$xml->Callsign->moddate; + $data['MSA'] = (string)$xml->Callsign->MSA; + $data['AreaCode'] = (string)$xml->Callsign->AreaCode; + $data['TimeZone'] = (string)$xml->Callsign->TimeZone; + $data['GMTOffset'] = (string)$xml->Callsign->GMTOffset; + $data['DST'] = (string)$xml->Callsign->DST; + $data['eqsl'] = (string)$xml->Callsign->eqsl; + $data['mqsl'] = (string)$xml->Callsign->mqsl; + $data['cqzone'] = (string)$xml->Callsign->cqzone; + $data['ituzone'] = (string)$xml->Callsign->ituzone; + $data['born'] = (string)$xml->Callsign->born; + $data['user'] = (string)$xml->Callsign->user; + $data['lotw'] = (string)$xml->Callsign->lotw; + $data['iota'] = (string)$xml->Callsign->iota; + $data['geoloc'] = (string)$xml->Callsign->geoloc; + $data['attn'] = (string)$xml->Callsign->attn; + $data['nickname'] = (string)$xml->Callsign->nickname; + $data['name_fmt'] = (string)$xml->Callsign->name_fmt; + // Build legacy 'name' field for backward compatibility + if ($use_fullname === true) { + $data['name'] = $data['fname']. ' ' . $data['name_last']; + } else { + $data['name'] = $data['fname']; + } // we always give back the name, no matter if reduced data or not $data['name'] = trim($data['name']); // Sanitize gridsquare to allow only up to 8 characters - $unclean_gridsquare = (string)$xml->Callsign->grid; // Get the gridsquare from QRZ convert to string - $clean_gridsquare = strlen($unclean_gridsquare) > 8 ? substr($unclean_gridsquare,0,8) : $unclean_gridsquare; // Trim gridsquare to 8 characters max + $unclean_gridsquare = $data['grid']; + $clean_gridsquare = strlen($unclean_gridsquare) > 8 ? substr($unclean_gridsquare,0,8) : $unclean_gridsquare; - if ($reduced == false) { - - $data['gridsquare'] = $clean_gridsquare; - $data['geoloc'] = (string)$xml->Callsign->geoloc; - $data['city'] = (string)$xml->Callsign->addr2; - $data['lat'] = (string)$xml->Callsign->lat; - $data['long'] = (string)$xml->Callsign->lon; - $data['dxcc'] = (string)$xml->Callsign->dxcc; - $data['state'] = (string)$xml->Callsign->state; - $data['iota'] = (string)$xml->Callsign->iota; - $data['qslmgr'] = (string)$xml->Callsign->qslmgr; - $data['image'] = (string)$xml->Callsign->image; - $data['ituz'] = (string)$xml->Callsign->ituzone; - $data['cqz'] = (string)$xml->Callsign->cqzone; - - if ($xml->Callsign->country == "United States") { - $data['us_county'] = (string)$xml->Callsign->county; - } else { - $data['us_county'] = null; - } + // Map fields for backward compatibility with existing code + $data['gridsquare'] = $clean_gridsquare; + $data['city'] = $data['addr2']; + $data['long'] = $data['lon']; + $data['ituz'] = $data['ituzone']; + $data['cqz'] = $data['cqzone']; + if ($data['country'] == "United States") { + $data['us_county'] = $data['county']; } else { + $data['us_county'] = null; + } + if ($reduced == true) { + // Clear location-specific fields for reduced mode $data['gridsquare'] = ''; $data['city'] = ''; $data['lat'] = ''; $data['long'] = ''; + $data['lon'] = ''; $data['dxcc'] = ''; $data['state'] = ''; $data['iota'] = ''; - $data['qslmgr'] = (string)$xml->Callsign->qslmgr; - $data['image'] = (string)$xml->Callsign->image; $data['us_county'] = ''; $data['ituz'] = ''; $data['cqz'] = ''; - + $data['ituzone'] = ''; + $data['cqzone'] = ''; } } finally { diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index e0857360a..c06cdb7aa 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -93,6 +93,23 @@ var lang_qso_lookup_summit_info = ""; var lang_qso_lookup_reference_info = ""; var lang_qso_error_loading_bearing = ""; + var lang_qso_profile_aliases = ""; + var lang_qso_profile_previously = ""; + var lang_qso_profile_born = ""; + var lang_qso_profile_years_old = ""; + var lang_qso_profile_license = ""; + var lang_qso_profile_from = ""; + var lang_qso_profile_years = ""; + var lang_qso_profile_expired_on = ""; + var lang_qso_profile_website = ""; + var lang_qso_profile_local_time = ""; + var lang_qso_profile_qsl = ""; + var lang_qso_profile_view_location_maps = ""; + var lang_qso_profile_license_novice = ""; + var lang_qso_profile_license_technician = ""; + var lang_qso_profile_license_general = ""; + var lang_qso_profile_license_advanced = ""; + var lang_qso_profile_license_extra = ""; var lang_qso_gridsquare_formatting = ""; var lang_qso_gridsquare_help = ""; diff --git a/application/views/qso/index.php b/application/views/qso/index.php index d97c8127c..977a3fda4 100644 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -828,10 +828,19 @@ switch ($date_format) { session->userdata('user_show_profile_image')) { ?>