Skip to content

Commit 9d10ba3

Browse files
authored
2.8.0
2.8.0
2 parents 8d33c4d + a3669f9 commit 9d10ba3

24 files changed

Lines changed: 1500 additions & 87 deletions

File tree

application/config/migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
|
2323
*/
2424

25-
$config['migration_version'] = 233;
25+
$config['migration_version'] = 235;
2626

2727
/*
2828
|--------------------------------------------------------------------------

application/controllers/Dashboard.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -227,11 +227,14 @@ function upcoming_dxcc_component()
227227

228228
$data['thisWeekRecords'] = $thisWeekRecords;
229229

230-
usort($data['thisWeekRecords'], function ($a, $b) {
231-
$dateA = new DateTime($a['1']);
232-
$dateB = new DateTime($b['1']);
233-
return $dateA <=> $dateB;
234-
});
230+
// Only sort if we have valid records (not an error)
231+
if (!isset($thisWeekRecords['error']) && !empty($thisWeekRecords)) {
232+
usort($data['thisWeekRecords'], function ($a, $b) {
233+
$dateA = new DateTime($a['1']);
234+
$dateB = new DateTime($b['1']);
235+
return $dateA <=> $dateB;
236+
});
237+
}
235238

236239
$this->load->view('components/upcoming_dxccs', $data);
237240
}

application/controllers/Dxcluster.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function __construct()
1414
function index()
1515
{
1616
$data['page_title'] = "DX Cluster Spots";
17+
18+
// Load radio data for CAT control
19+
$this->load->model('cat');
20+
$data['radios'] = $this->cat->radios();
1721

1822
/// Load layout
1923

@@ -124,4 +128,95 @@ public function qsy() {
124128
echo json_encode(['success' => false, 'message' => 'Failed to queue QSY command']);
125129
}
126130
}
131+
132+
/*
133+
* Check if callsigns have been worked
134+
* POST /dxcluster/check_worked
135+
*/
136+
public function check_worked() {
137+
header('Content-Type: application/json');
138+
139+
$this->load->model('logbook_model');
140+
$this->load->model('logbooks_model');
141+
142+
// Get JSON input
143+
$input = json_decode(file_get_contents("php://input"), true);
144+
145+
if (!isset($input['callsigns']) || !is_array($input['callsigns'])) {
146+
http_response_code(400);
147+
echo json_encode(['success' => false, 'message' => 'Missing or invalid callsigns array']);
148+
return;
149+
}
150+
151+
// Limit batch size to prevent excessive load
152+
$max_batch_size = 50;
153+
if (count($input['callsigns']) > $max_batch_size) {
154+
$input['callsigns'] = array_slice($input['callsigns'], 0, $max_batch_size);
155+
}
156+
157+
// Get logbook locations for the active logbook
158+
$logbook_id = $this->session->userdata('active_station_logbook');
159+
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);
160+
161+
if (!$logbooks_locations_array) {
162+
http_response_code(500);
163+
echo json_encode(['success' => false, 'message' => 'No logbook locations found']);
164+
return;
165+
}
166+
167+
$results = [];
168+
169+
foreach ($input['callsigns'] as $item) {
170+
$callsign = $item['callsign'];
171+
$band = isset($item['band']) ? $item['band'] : null;
172+
173+
// Get DXCC entity for this callsign
174+
$dxcc_info = $this->logbook_model->dxcc_lookup($callsign, date('Ymd'));
175+
$dxcc = isset($dxcc_info['adif']) ? $dxcc_info['adif'] : null;
176+
177+
// Check if worked on this band
178+
$worked_on_band = false;
179+
if ($band) {
180+
$worked_on_band = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, $band) > 0;
181+
}
182+
183+
// Check if worked on any band
184+
$worked_overall = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, null) > 0;
185+
186+
// Check if DXCC entity is worked on this band
187+
$dxcc_worked_on_band = false;
188+
if ($dxcc && $band) {
189+
$this->db->select('COL_DXCC');
190+
$this->db->where_in('station_id', $logbooks_locations_array);
191+
$this->db->where('COL_DXCC', $dxcc);
192+
$this->db->where('COL_BAND', $band);
193+
$this->db->limit(1);
194+
$query = $this->db->get($this->config->item('table_name'));
195+
$dxcc_worked_on_band = $query->num_rows() > 0;
196+
}
197+
198+
// Check if DXCC entity is worked on any band
199+
$dxcc_worked_overall = false;
200+
if ($dxcc) {
201+
$this->db->select('COL_DXCC');
202+
$this->db->where_in('station_id', $logbooks_locations_array);
203+
$this->db->where('COL_DXCC', $dxcc);
204+
$this->db->limit(1);
205+
$query = $this->db->get($this->config->item('table_name'));
206+
$dxcc_worked_overall = $query->num_rows() > 0;
207+
}
208+
209+
$results[$callsign] = [
210+
'worked_on_band' => $worked_on_band,
211+
'worked_overall' => $worked_overall,
212+
'band' => $band,
213+
'dxcc' => $dxcc,
214+
'dxcc_worked_on_band' => $dxcc_worked_on_band,
215+
'dxcc_worked_overall' => $dxcc_worked_overall,
216+
'country' => isset($dxcc_info['entity']) ? $dxcc_info['entity'] : null
217+
];
218+
}
219+
220+
echo json_encode(['success' => true, 'results' => $results]);
221+
}
127222
}

0 commit comments

Comments
 (0)