Add DXCC satellite contact tracking and display
Introduces 'workedViaSatellite' status to DXCC tracking in both controller and model, including batch queries for satellite contacts. Updates the DXCC list view to show a badge when a country has been worked via satellite, improving visibility of satellite achievements.
这个提交包含在:
父节点
12127b8d85
当前提交
d1bb6ff3ea
共有 3 个文件被更改,包括 111 次插入 和 6 次删除
|
|
@ -69,7 +69,11 @@ class Workabledxcc extends CI_Controller
|
||||||
|
|
||||||
// Get DXCC status for this callsign
|
// Get DXCC status for this callsign
|
||||||
$entity = $dxccEntities[$index] ?? null;
|
$entity = $dxccEntities[$index] ?? null;
|
||||||
$worked = $entity && isset($dxccStatus[$entity]) ? $dxccStatus[$entity] : ['workedBefore' => false, 'confirmed' => false];
|
$worked = $entity && isset($dxccStatus[$entity]) ? $dxccStatus[$entity] : [
|
||||||
|
'workedBefore' => false,
|
||||||
|
'confirmed' => false,
|
||||||
|
'workedViaSatellite' => false
|
||||||
|
];
|
||||||
|
|
||||||
$requiredData[] = array(
|
$requiredData[] = array(
|
||||||
'clean_date' => $item['0'],
|
'clean_date' => $item['0'],
|
||||||
|
|
@ -80,6 +84,7 @@ class Workabledxcc extends CI_Controller
|
||||||
'callsign' => $item['callsign'],
|
'callsign' => $item['callsign'],
|
||||||
'workedBefore' => $worked['workedBefore'],
|
'workedBefore' => $worked['workedBefore'],
|
||||||
'confirmed' => $worked['confirmed'],
|
'confirmed' => $worked['confirmed'],
|
||||||
|
'workedViaSatellite' => $worked['workedViaSatellite'],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -93,6 +98,7 @@ class Workabledxcc extends CI_Controller
|
||||||
$return = [
|
$return = [
|
||||||
"workedBefore" => false,
|
"workedBefore" => false,
|
||||||
"confirmed" => false,
|
"confirmed" => false,
|
||||||
|
"workedViaSatellite" => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$user_default_confirmation = $this->session->userdata('user_default_confirmation');
|
$user_default_confirmation = $this->session->userdata('user_default_confirmation');
|
||||||
|
|
@ -101,6 +107,7 @@ class Workabledxcc extends CI_Controller
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
if (!empty($logbooks_locations_array)) {
|
if (!empty($logbooks_locations_array)) {
|
||||||
|
// Check terrestrial contacts
|
||||||
$this->db->where('COL_PROP_MODE !=', 'SAT');
|
$this->db->where('COL_PROP_MODE !=', 'SAT');
|
||||||
|
|
||||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
|
@ -112,6 +119,16 @@ class Workabledxcc extends CI_Controller
|
||||||
$return['workedBefore'] = true;
|
$return['workedBefore'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check satellite contacts
|
||||||
|
$this->db->where('COL_PROP_MODE', 'SAT');
|
||||||
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
$this->db->where('UPPER(COL_COUNTRY) = UPPER(?)', urldecode($country));
|
||||||
|
|
||||||
|
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||||
|
foreach ($query->result() as $satelliteRow) {
|
||||||
|
$return['workedViaSatellite'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$extrawhere = '';
|
$extrawhere = '';
|
||||||
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
||||||
$extrawhere = "COL_QSL_RCVD='Y'";
|
$extrawhere = "COL_QSL_RCVD='Y'";
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,11 @@ class Workabledxcc_model extends CI_Model
|
||||||
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
|
||||||
|
|
||||||
if (empty($logbooks_locations_array)) {
|
if (empty($logbooks_locations_array)) {
|
||||||
return array_fill_keys($entities, ['workedBefore' => false, 'confirmed' => false]);
|
return array_fill_keys($entities, [
|
||||||
|
'workedBefore' => false,
|
||||||
|
'confirmed' => false,
|
||||||
|
'workedViaSatellite' => false
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
@ -55,23 +59,80 @@ class Workabledxcc_model extends CI_Model
|
||||||
// Build confirmation criteria once
|
// Build confirmation criteria once
|
||||||
$confirmationCriteria = $this->buildConfirmationCriteria($user_default_confirmation);
|
$confirmationCriteria = $this->buildConfirmationCriteria($user_default_confirmation);
|
||||||
|
|
||||||
// Batch query for worked status
|
// Debug: Log entities being checked
|
||||||
|
log_message('debug', 'Workable DXCC: Checking entities: ' . implode(', ', $entities));
|
||||||
|
|
||||||
|
// Batch query for worked status (terrestrial)
|
||||||
$workedResults = $this->batchWorkedQuery($entities, $logbooks_locations_array);
|
$workedResults = $this->batchWorkedQuery($entities, $logbooks_locations_array);
|
||||||
|
|
||||||
// Batch query for confirmed status
|
// Batch query for confirmed status (terrestrial)
|
||||||
$confirmedResults = $this->batchConfirmedQuery($entities, $logbooks_locations_array, $confirmationCriteria);
|
$confirmedResults = $this->batchConfirmedQuery($entities, $logbooks_locations_array, $confirmationCriteria);
|
||||||
|
|
||||||
|
// Batch query for satellite contacts
|
||||||
|
$satelliteResults = $this->batchSatelliteQuery($entities, $logbooks_locations_array);
|
||||||
|
|
||||||
|
// Debug: Log results
|
||||||
|
log_message('debug', 'Workable DXCC: Worked results: ' . json_encode($workedResults));
|
||||||
|
log_message('debug', 'Workable DXCC: Confirmed results: ' . json_encode($confirmedResults));
|
||||||
|
log_message('debug', 'Workable DXCC: Satellite results: ' . json_encode($satelliteResults));
|
||||||
|
|
||||||
// Combine results
|
// Combine results
|
||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
$results[$entity] = [
|
$results[$entity] = [
|
||||||
'workedBefore' => isset($workedResults[$entity]),
|
'workedBefore' => isset($workedResults[$entity]),
|
||||||
'confirmed' => isset($confirmedResults[$entity])
|
'confirmed' => isset($confirmedResults[$entity]),
|
||||||
|
'workedViaSatellite' => isset($satelliteResults[$entity])
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch query to check which entities have been worked via satellite
|
||||||
|
*/
|
||||||
|
private function batchSatelliteQuery($entities, $logbooks_locations_array)
|
||||||
|
{
|
||||||
|
// Create case-insensitive matching for DXCC entities
|
||||||
|
$whereConditions = array();
|
||||||
|
foreach ($entities as $entity) {
|
||||||
|
$whereConditions[] = "UPPER(COL_COUNTRY) = UPPER('" . $this->db->escape_str($entity) . "')";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($whereConditions)) {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$whereClause = '(' . implode(' OR ', $whereConditions) . ')';
|
||||||
|
|
||||||
|
$this->db->select('COL_COUNTRY')
|
||||||
|
->distinct()
|
||||||
|
->from($this->config->item('table_name'))
|
||||||
|
->where('COL_PROP_MODE', 'SAT') // Only satellite contacts
|
||||||
|
->where_in('station_id', $logbooks_locations_array)
|
||||||
|
->where($whereClause);
|
||||||
|
|
||||||
|
$query = $this->db->get();
|
||||||
|
|
||||||
|
// Debug: Log the SQL query
|
||||||
|
log_message('debug', 'Workable DXCC satellite query: ' . $this->db->last_query());
|
||||||
|
|
||||||
|
$results = array();
|
||||||
|
|
||||||
|
foreach ($query->result() as $row) {
|
||||||
|
// Store with the original entity case for lookup
|
||||||
|
foreach ($entities as $entity) {
|
||||||
|
if (strtoupper($row->COL_COUNTRY) === strtoupper($entity)) {
|
||||||
|
$results[$entity] = true;
|
||||||
|
log_message('debug', 'Workable DXCC: Found satellite match: ' . $entity . ' matches ' . $row->COL_COUNTRY);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build confirmation criteria SQL based on user preferences
|
* Build confirmation criteria SQL based on user preferences
|
||||||
*/
|
*/
|
||||||
|
|
@ -120,6 +181,10 @@ class Workabledxcc_model extends CI_Model
|
||||||
->where($whereClause);
|
->where($whereClause);
|
||||||
|
|
||||||
$query = $this->db->get();
|
$query = $this->db->get();
|
||||||
|
|
||||||
|
// Debug: Log the SQL query
|
||||||
|
log_message('debug', 'Workable DXCC worked query: ' . $this->db->last_query());
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
|
|
||||||
foreach ($query->result() as $row) {
|
foreach ($query->result() as $row) {
|
||||||
|
|
@ -127,6 +192,7 @@ class Workabledxcc_model extends CI_Model
|
||||||
foreach ($entities as $entity) {
|
foreach ($entities as $entity) {
|
||||||
if (strtoupper($row->COL_COUNTRY) === strtoupper($entity)) {
|
if (strtoupper($row->COL_COUNTRY) === strtoupper($entity)) {
|
||||||
$results[$entity] = true;
|
$results[$entity] = true;
|
||||||
|
log_message('debug', 'Workable DXCC: Found worked match: ' . $entity . ' matches ' . $row->COL_COUNTRY);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -243,10 +309,15 @@ class Workabledxcc_model extends CI_Model
|
||||||
|
|
||||||
// Get DXCC status for this callsign
|
// Get DXCC status for this callsign
|
||||||
$entity = $dxccEntities[$index] ?? null;
|
$entity = $dxccEntities[$index] ?? null;
|
||||||
$worked = $entity && isset($dxccStatus[$entity]) ? $dxccStatus[$entity] : ['workedBefore' => false, 'confirmed' => false];
|
$worked = $entity && isset($dxccStatus[$entity]) ? $dxccStatus[$entity] : [
|
||||||
|
'workedBefore' => false,
|
||||||
|
'confirmed' => false,
|
||||||
|
'workedViaSatellite' => false
|
||||||
|
];
|
||||||
|
|
||||||
$record['workedBefore'] = $worked['workedBefore'];
|
$record['workedBefore'] = $worked['workedBefore'];
|
||||||
$record['confirmed'] = $worked['confirmed'];
|
$record['confirmed'] = $worked['confirmed'];
|
||||||
|
$record['workedViaSatellite'] = $worked['workedViaSatellite'];
|
||||||
|
|
||||||
$thisWeekRecords[] = $record;
|
$thisWeekRecords[] = $record;
|
||||||
}
|
}
|
||||||
|
|
@ -260,6 +331,7 @@ class Workabledxcc_model extends CI_Model
|
||||||
$return = [
|
$return = [
|
||||||
"workedBefore" => false,
|
"workedBefore" => false,
|
||||||
"confirmed" => false,
|
"confirmed" => false,
|
||||||
|
"workedViaSatellite" => false,
|
||||||
];
|
];
|
||||||
|
|
||||||
$user_default_confirmation = $this->session->userdata('user_default_confirmation');
|
$user_default_confirmation = $this->session->userdata('user_default_confirmation');
|
||||||
|
|
@ -268,6 +340,7 @@ class Workabledxcc_model extends CI_Model
|
||||||
$this->load->model('logbook_model');
|
$this->load->model('logbook_model');
|
||||||
|
|
||||||
if (!empty($logbooks_locations_array)) {
|
if (!empty($logbooks_locations_array)) {
|
||||||
|
// Check for terrestrial contacts
|
||||||
$this->db->where('COL_PROP_MODE !=', 'SAT');
|
$this->db->where('COL_PROP_MODE !=', 'SAT');
|
||||||
|
|
||||||
$this->db->where_in('station_id', $logbooks_locations_array);
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
|
@ -279,6 +352,16 @@ class Workabledxcc_model extends CI_Model
|
||||||
$return['workedBefore'] = true;
|
$return['workedBefore'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for satellite contacts
|
||||||
|
$this->db->where('COL_PROP_MODE', 'SAT');
|
||||||
|
$this->db->where_in('station_id', $logbooks_locations_array);
|
||||||
|
$this->db->where('UPPER(COL_COUNTRY) = UPPER(?)', urldecode($country));
|
||||||
|
|
||||||
|
$query = $this->db->get($this->config->item('table_name'), 1, 0);
|
||||||
|
foreach ($query->result() as $satelliteRow) {
|
||||||
|
$return['workedViaSatellite'] = true;
|
||||||
|
}
|
||||||
|
|
||||||
$extrawhere = '';
|
$extrawhere = '';
|
||||||
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
if (isset($user_default_confirmation) && strpos($user_default_confirmation, 'Q') !== false) {
|
||||||
$extrawhere = "COL_QSL_RCVD='Y'";
|
$extrawhere = "COL_QSL_RCVD='Y'";
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,11 @@ foreach ($grouped as $month => $dxccs) {
|
||||||
echo '<span class="badge bg-primary">Confirmed</span>';
|
echo '<span class="badge bg-primary">Confirmed</span>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add satellite badge if worked via satellite
|
||||||
|
if (isset($dxcc['workedViaSatellite']) && $dxcc['workedViaSatellite']) {
|
||||||
|
echo '<span class="badge bg-info">Worked via Satellite</span>';
|
||||||
|
}
|
||||||
|
|
||||||
echo '</td>
|
echo '</td>
|
||||||
<td>' . $dxcc['notes'] . '</td>
|
<td>' . $dxcc['notes'] . '</td>
|
||||||
</tr>';
|
</tr>';
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用