Skip to content

Commit 36ae819

Browse files
committed
Show callsign for new DXCC and grid entries in report
Adds callsign information to new DXCC and grid entries in the monthly report, both in the backend data and frontend display. Also updates JSON export to include a filename for downloads. This provides more detailed context for each new entity or grid worked during the month.
1 parent 4449a91 commit 36ae819

3 files changed

Lines changed: 58 additions & 28 deletions

File tree

application/controllers/Monthlyreport.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ public function export_json()
143143
);
144144

145145
// Set headers for JSON download
146+
$filename = "monthly_report_{$year}_{$month}.json";
146147
$this->output
147148
->set_content_type('application/json')
149+
->set_header('Content-Disposition: attachment; filename="' . $filename . '"')
148150
->set_output(json_encode($export, JSON_PRETTY_PRINT));
149151
}
150152

application/models/Monthlyreport_model.php

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,8 @@ private function get_new_dxcc_by_band($locations, $start_date, $end_date, $prev_
201201
$band = $band_row->COL_BAND;
202202
$new_dxcc_by_band[$band] = array();
203203

204-
// Get all unique DXCC entities worked on this band this month (group by DXCC)
205-
$this->db->select('COL_DXCC, MAX(COL_COUNTRY) as COL_COUNTRY', FALSE);
204+
// Get all unique DXCC entities worked on this band this month (group by DXCC, get earliest callsign)
205+
$this->db->select('COL_DXCC, MAX(COL_COUNTRY) as COL_COUNTRY, MIN(COL_TIME_ON) as FIRST_QSO', FALSE);
206206
$this->db->from($this->config->item('table_name'));
207207
$this->db->where_in('station_id', $locations);
208208
$this->db->where('COL_TIME_ON >=', $start_date);
@@ -228,9 +228,22 @@ private function get_new_dxcc_by_band($locations, $start_date, $end_date, $prev_
228228

229229
// If not worked before on this band, it's new
230230
if ($prev_row->count == 0) {
231+
// Get the callsign from the first QSO with this DXCC on this band
232+
$this->db->select('COL_CALL');
233+
$this->db->from($this->config->item('table_name'));
234+
$this->db->where_in('station_id', $locations);
235+
$this->db->where('COL_DXCC', $row->COL_DXCC);
236+
$this->db->where('COL_BAND', $band);
237+
$this->db->where('COL_TIME_ON', $row->FIRST_QSO);
238+
$this->db->limit(1);
239+
240+
$call_query = $this->db->get();
241+
$call_row = $call_query->row();
242+
231243
$new_dxcc_by_band[$band][] = array(
232244
'dxcc_id' => $row->COL_DXCC,
233-
'name' => $row->COL_COUNTRY
245+
'name' => $row->COL_COUNTRY,
246+
'callsign' => $call_row ? $call_row->COL_CALL : ''
234247
);
235248
}
236249
}
@@ -297,20 +310,23 @@ private function get_new_gridsquares($locations, $start_date, $end_date, $prev_m
297310
$new_grids = array();
298311

299312
// Get all gridsquares worked this month (including VUCC grids)
300-
$this->db->select('COL_GRIDSQUARE, COL_VUCC_GRIDS');
313+
$this->db->select('COL_CALL, COL_GRIDSQUARE, COL_VUCC_GRIDS, COL_TIME_ON');
301314
$this->db->from($this->config->item('table_name'));
302315
$this->db->where_in('station_id', $locations);
303316
$this->db->where('COL_TIME_ON >=', $start_date);
304317
$this->db->where('COL_TIME_ON <=', $end_date);
318+
$this->db->order_by('COL_TIME_ON', 'ASC');
305319

306320
$query = $this->db->get();
307-
$all_grids = array();
321+
$grid_callsigns = array();
308322

309323
foreach ($query->result() as $row) {
310324
// Process main gridsquare (first 4 characters only)
311325
if (!empty($row->COL_GRIDSQUARE) && strlen($row->COL_GRIDSQUARE) >= 4) {
312326
$grid_4char = strtoupper(substr($row->COL_GRIDSQUARE, 0, 4));
313-
$all_grids[$grid_4char] = true;
327+
if (!isset($grid_callsigns[$grid_4char])) {
328+
$grid_callsigns[$grid_4char] = $row->COL_CALL;
329+
}
314330
}
315331

316332
// Process VUCC grids (comma-separated, first 4 characters only)
@@ -320,16 +336,18 @@ private function get_new_gridsquares($locations, $start_date, $end_date, $prev_m
320336
$grid = trim($grid);
321337
if (strlen($grid) >= 4) {
322338
$grid_4char = strtoupper(substr($grid, 0, 4));
323-
$all_grids[$grid_4char] = true;
339+
if (!isset($grid_callsigns[$grid_4char])) {
340+
$grid_callsigns[$grid_4char] = $row->COL_CALL;
341+
}
324342
}
325343
}
326344
}
327345
}
328346

329347
// Check each grid to see if it's new
330-
foreach (array_keys($all_grids) as $grid) {
348+
foreach ($grid_callsigns as $grid => $callsign) {
331349
if ($this->is_grid_new($locations, $grid, $start_date)) {
332-
$new_grids[] = array('grid' => $grid);
350+
$new_grids[] = array('grid' => $grid, 'callsign' => $callsign);
333351
}
334352
}
335353

@@ -348,21 +366,24 @@ private function get_new_gridsquares_by_prop($locations, $start_date, $end_date,
348366
$new_grids = array();
349367

350368
// Get all gridsquares worked this month with this prop mode
351-
$this->db->select('COL_GRIDSQUARE, COL_VUCC_GRIDS');
369+
$this->db->select('COL_CALL, COL_GRIDSQUARE, COL_VUCC_GRIDS, COL_TIME_ON');
352370
$this->db->from($this->config->item('table_name'));
353371
$this->db->where_in('station_id', $locations);
354372
$this->db->where('COL_TIME_ON >=', $start_date);
355373
$this->db->where('COL_TIME_ON <=', $end_date);
356374
$this->db->where('COL_PROP_MODE', $prop_mode);
375+
$this->db->order_by('COL_TIME_ON', 'ASC');
357376

358377
$query = $this->db->get();
359-
$all_grids = array();
378+
$grid_callsigns = array();
360379

361380
foreach ($query->result() as $row) {
362381
// Process main gridsquare (first 4 characters only)
363382
if (!empty($row->COL_GRIDSQUARE) && strlen($row->COL_GRIDSQUARE) >= 4) {
364383
$grid_4char = strtoupper(substr($row->COL_GRIDSQUARE, 0, 4));
365-
$all_grids[$grid_4char] = true;
384+
if (!isset($grid_callsigns[$grid_4char])) {
385+
$grid_callsigns[$grid_4char] = $row->COL_CALL;
386+
}
366387
}
367388

368389
// Process VUCC grids (first 4 characters only)
@@ -372,16 +393,18 @@ private function get_new_gridsquares_by_prop($locations, $start_date, $end_date,
372393
$grid = trim($grid);
373394
if (strlen($grid) >= 4) {
374395
$grid_4char = strtoupper(substr($grid, 0, 4));
375-
$all_grids[$grid_4char] = true;
396+
if (!isset($grid_callsigns[$grid_4char])) {
397+
$grid_callsigns[$grid_4char] = $row->COL_CALL;
398+
}
376399
}
377400
}
378401
}
379402
}
380403

381404
// Check each grid to see if it's new for this prop mode
382-
foreach (array_keys($all_grids) as $grid) {
405+
foreach ($grid_callsigns as $grid => $callsign) {
383406
if ($this->is_grid_new_for_prop($locations, $grid, $start_date, $prop_mode)) {
384-
$new_grids[] = array('grid' => $grid);
407+
$new_grids[] = array('grid' => $grid, 'callsign' => $callsign);
385408
}
386409
}
387410

@@ -400,21 +423,24 @@ private function get_new_gridsquares_hf($locations, $start_date, $end_date, $pre
400423
$new_grids = array();
401424

402425
// Get all gridsquares worked this month via HF
403-
$this->db->select('COL_GRIDSQUARE, COL_VUCC_GRIDS');
426+
$this->db->select('COL_CALL, COL_GRIDSQUARE, COL_VUCC_GRIDS, COL_TIME_ON');
404427
$this->db->from($this->config->item('table_name'));
405428
$this->db->where_in('station_id', $locations);
406429
$this->db->where('COL_TIME_ON >=', $start_date);
407430
$this->db->where('COL_TIME_ON <=', $end_date);
408431
$this->db->where("(COL_PROP_MODE IS NULL OR COL_PROP_MODE = '' OR COL_PROP_MODE NOT IN ('SAT','EME'))");
432+
$this->db->order_by('COL_TIME_ON', 'ASC');
409433

410434
$query = $this->db->get();
411-
$all_grids = array();
435+
$grid_callsigns = array();
412436

413437
foreach ($query->result() as $row) {
414438
// Process main gridsquare (first 4 characters only)
415439
if (!empty($row->COL_GRIDSQUARE) && strlen($row->COL_GRIDSQUARE) >= 4) {
416440
$grid_4char = strtoupper(substr($row->COL_GRIDSQUARE, 0, 4));
417-
$all_grids[$grid_4char] = true;
441+
if (!isset($grid_callsigns[$grid_4char])) {
442+
$grid_callsigns[$grid_4char] = $row->COL_CALL;
443+
}
418444
}
419445

420446
// Process VUCC grids (first 4 characters only)
@@ -424,16 +450,18 @@ private function get_new_gridsquares_hf($locations, $start_date, $end_date, $pre
424450
$grid = trim($grid);
425451
if (strlen($grid) >= 4) {
426452
$grid_4char = strtoupper(substr($grid, 0, 4));
427-
$all_grids[$grid_4char] = true;
453+
if (!isset($grid_callsigns[$grid_4char])) {
454+
$grid_callsigns[$grid_4char] = $row->COL_CALL;
455+
}
428456
}
429457
}
430458
}
431459
}
432460

433461
// Check each grid to see if it's new for HF
434-
foreach (array_keys($all_grids) as $grid) {
462+
foreach ($grid_callsigns as $grid => $callsign) {
435463
if ($this->is_grid_new_for_hf($locations, $grid, $start_date)) {
436-
$new_grids[] = array('grid' => $grid);
464+
$new_grids[] = array('grid' => $grid, 'callsign' => $callsign);
437465
}
438466
}
439467

application/views/monthlyreport/report.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
<?php foreach ($dxcc_list as $dxcc) { ?>
130130
<div class="col-md-4 mb-2">
131131
<span class="badge bg-success fs-6">
132-
<i class="fas fa-star"></i> <?php echo $dxcc['name']; ?>
132+
<i class="fas fa-star"></i> <?php echo $dxcc['name']; ?><?php if (!empty($dxcc['callsign'])) echo ' (' . $dxcc['callsign'] . ')'; ?>
133133
</span>
134134
</div>
135135
<?php } ?>
@@ -195,8 +195,8 @@
195195
<h6 class="text-muted"><i class="fas fa-tower-broadcast"></i> HF/VHF Terrestrial (<?php echo count($report['new_grids_hf']); ?>)</h6>
196196
<div class="row">
197197
<?php foreach ($report['new_grids_hf'] as $grid) { ?>
198-
<div class="col-md-2 col-sm-3 col-6 mb-2">
199-
<span class="badge bg-info fs-6"><?php echo $grid['grid']; ?></span>
198+
<div class="col-md-3 col-sm-4 col-6 mb-2">
199+
<span class="badge bg-primary fs-6"><?php echo $grid['grid']; ?> (<?php echo $grid['callsign']; ?>)</span>
200200
</div>
201201
<?php } ?>
202202
</div>
@@ -208,8 +208,8 @@
208208
<h6 class="text-muted"><i class="fas fa-satellite-dish"></i> Satellite (<?php echo count($report['new_grids_satellite']); ?>)</h6>
209209
<div class="row">
210210
<?php foreach ($report['new_grids_satellite'] as $grid) { ?>
211-
<div class="col-md-2 col-sm-3 col-6 mb-2">
212-
<span class="badge bg-success fs-6"><?php echo $grid['grid']; ?></span>
211+
<div class="col-md-3 col-sm-4 col-6 mb-2">
212+
<span class="badge bg-success fs-6"><?php echo $grid['grid']; ?> (<?php echo $grid['callsign']; ?>)</span>
213213
</div>
214214
<?php } ?>
215215
</div>
@@ -221,8 +221,8 @@
221221
<h6 class="text-muted"><i class="fas fa-moon"></i> EME (Moonbounce) (<?php echo count($report['new_grids_eme']); ?>)</h6>
222222
<div class="row">
223223
<?php foreach ($report['new_grids_eme'] as $grid) { ?>
224-
<div class="col-md-2 col-sm-3 col-6 mb-2">
225-
<span class="badge bg-warning text-dark fs-6"><?php echo $grid['grid']; ?></span>
224+
<div class="col-md-3 col-sm-4 col-6 mb-2">
225+
<span class="badge bg-warning text-dark fs-6"><?php echo $grid['grid']; ?> (<?php echo $grid['callsign']; ?>)</span>
226226
</div>
227227
<?php } ?>
228228
</div>

0 commit comments

Comments
 (0)