Merge pull request #1997 from AndreasK79/emeinitials

[EME Initials] Created link and view
This commit is contained in:
Andreas Kristiansen
2025-05-27 10:06:45 +02:00
committed by GitHub
7 changed files with 253 additions and 1 deletions

View File

@@ -120,7 +120,7 @@ class Statistics extends CI_Controller {
//get year if present
$yr = xss_clean($this->input->post('yr')) ?? 'All';
//load stats
$total_operators = $this->logbook_model->total_operators($yr);
@@ -307,4 +307,35 @@ class Statistics extends CI_Controller {
$this->load->view('statistics/details', $data);
}
public function initials() {
$this->load->model('stats');
$this->load->model('bands');
$data['modes'] = $this->stats->get_eme_modes();
$data['worked_bands'] = $this->bands->get_worked_bands_eme();
// Set Page Title
$data['page_title'] = __("EME Initials");
$footerData = [];
$footerData['scripts'] = [
'assets/js/sections/initials.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/initials.js")),
];
// Load Views
$this->load->view('interface_assets/header', $data);
$this->load->view('statistics/initials');
$this->load->view('interface_assets/footer', $footerData);
}
public function getInitials() {
$band = xss_clean($this->input->post('band'));
$mode = xss_clean($this->input->post('mode'));
$this->load->model('stats');
$data['intials_array'] = $this->stats->getInitialsFromDb($band, $mode);
$this->load->view('statistics/initialresult', $data);
}
}

View File

@@ -391,6 +391,25 @@ class Bands extends CI_Model {
return $worked_slots;
}
function get_worked_bands_eme() {
if (!$this->logbooks_locations_array) {
return array();
}
$location_list = "'".implode("','",$this->logbooks_locations_array)."'";
// get all worked slots from database
$data = $this->db->query(
"SELECT distinct LOWER(`COL_BAND`) as `COL_BAND` FROM `".$this->config->item('table_name')."` WHERE station_id in (" . $location_list . ") AND COL_PROP_MODE = 'EME'"
);
$worked_slots = array();
foreach($data->result() as $row){
array_push($worked_slots, $row->COL_BAND);
}
return $worked_slots;
}
}
?>

View File

@@ -918,6 +918,96 @@
return $this->db->get($this->config->item('table_name'));
}
public function getInitialsFromDb($band, $mode) {
$binding = [];
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$sql = "select thcv.col_call, thcv.col_time_on, thcv.col_band, thcv.col_mode, thcv.col_submode, thcv.col_primary_key, thcv.col_vucc_grids, thcv.col_gridsquare FROM ". $this->config->item('table_name') . " thcv";
$sql .= " join (SELECT col_call, min(col_time_on) firstworked, col_band, min(col_primary_key) qsoid FROM ".$this->config->item('table_name');
$sql .= " where station_id in (" . implode(',',$logbooks_locations_array) . ") and col_prop_mode ='EME'";
if ($mode != 'All') {
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $mode;
$binding[] = $mode;
}
if ($band != 'All') {
$sql .= " and col_band = ?";
$binding[] = $band;
}
$sql .= " group by col_call, col_band order by firstworked) x on thcv.col_primary_key = x.qsoid";
$result = $this->db->query($sql, $binding);
return $result->result();
}
public function getInitialsFromDb2($band, $mode) {
$binding = [];
$this->load->model('logbooks_model');
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
if (!$logbooks_locations_array) {
return null;
}
$sql = "SELECT col_call, min(col_time_on) firstworked, col_band, min(col_primary_key) qsoid FROM ".$this->config->item('table_name');
$sql .= " where station_id in (" . implode(',',$logbooks_locations_array) . ") and col_prop_mode ='EME'";
if ($mode != 'All') {
$sql .= " and (col_mode = ? or col_submode = ?)";
$binding[] = $mode;
$binding[] = $mode;
}
if ($band != 'All') {
$sql .= " and col_band = ?";
$binding[] = $band;
}
$sql .= " group by col_call, col_band order by firstworked";
$result = $this->db->query($sql, $binding);
return $result->result();
}
function get_eme_modes() {
$modes = array();
$this->db->select('distinct col_mode, coalesce(col_submode, "") col_submode', FALSE);
$this->db->join('station_profile', 'station_profile.station_id = '.$this->config->item('table_name').'.station_id');
$this->db->where('station_profile.user_id', $this->session->userdata('user_id'));
$this->db->where($this->config->item('table_name').'.col_prop_mode', 'EME');
$this->db->order_by('col_mode, col_submode', 'ASC');
$query = $this->db->get($this->config->item('table_name'));
foreach($query->result() as $mode){
if ($mode->col_submode == null || $mode->col_submode == "") {
array_push($modes, $mode->col_mode);
} else {
array_push($modes, $mode->col_submode);
}
}
return $modes;
}
}
?>

View File

@@ -164,6 +164,8 @@
<li><a class="dropdown-item" href="<?php echo site_url('continents'); ?>" title="Continents"><i class="fas fa-globe-europe"></i> <?= __("Continents"); ?></a></li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item" href="<?php echo site_url('callstats'); ?>" title="Callsign Statistics"><i class="fas fa-chart-area"></i> <?= __("Callsign Statistics"); ?></a></li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item" href="<?php echo site_url('statistics/initials'); ?>" title="EME Initials"><i class="fas fa-chart-area"></i> <?= __("EME Initials"); ?></a></li>
</ul>
</li>
<li class="nav-item dropdown"> <!-- AWARDS -->

View File

@@ -0,0 +1,41 @@
<?php
if ($intials_array) {
// Get Date format
if($this->session->userdata('user_date_format')) {
// If Logged in and session exists
$custom_date_format = $this->session->userdata('user_date_format');
} else {
// Get Default date format from /config/wavelog.php
$custom_date_format = $this->config->item('qso_date_format');
}
echo '<table style="width:100%" class="table table-sm intialstable table-bordered table-hover table-striped table-condensed text-center">
<thead>
<tr>
<th>#</th>
<th>' . __("Date") . '</th>
<th>' . __("Time") . '</th>
<th>' . __("Callsign") . '</th>
<th>' . __("Band") . '</th>
<th>' . __("Mode") . '</th>
<th>' . __("Gridsquare") . '</th>
</tr>
</thead>
<tbody>';
$i = 1;
foreach ($intials_array as $line) {
$date_as_timestamp = strtotime($line->col_time_on ?? '1970-01-01 00:00:00');
echo '<tr>
<td>' . $i++ . '</td>
<td>' . date($custom_date_format, $date_as_timestamp) . '</td>
<td>' . date('H:i', $date_as_timestamp) . '</td>
<td><a href=javascript:displayQso(' . $line->col_primary_key . ')>' . $line->col_call . '</a></td>
<td>' . $line->col_band . '</td>
<td>' . (empty($line->col_submode) ? ($line->col_mode ?? '') : $line->col_submode) . '</td>
<td>' . (empty($line->col_vucc_grids) ? ($line->col_gridsquare ?? '') : $line->col_vucc_grids) . '</td>
</tr>';
}
echo '</tbody></table>';
} else {
echo __("No EME QSO(s) was found.");
}

View File

@@ -0,0 +1,39 @@
<div class="container">
<h1><?php echo $page_title; ?></h1>
<?php if ($worked_bands) { ?>
<form>
<!-- Select Basic -->
<div class="mb-3 d-flex align-items-center row">
<label class="w-auto control-label" for="band"><?= __("Band") ?></label>
<div class="w-auto">
<select id="band" name="band" class="form-select form-select-sm">
<?php foreach($worked_bands as $band) {
echo '<option value="' . $band . '">' . $band . '</option>'."\n";
} ?>
</select>
</div>
<label class="w-auto control-label" for="mode"><?= __("Mode") ?></label>
<div class="w-auto">
<select id="mode" name="mode" class="form-select form-select-sm">
<option value="All" <?php if ($this->input->post('mode') == "All" || $this->input->method() !== 'post') echo ' selected'; ?> ><?= __("All") ?></option>
<?php
foreach($modes as $mode){
echo '<option value="' . $mode . '">' . $mode . '</option>'."\n";
}
?>
</select>
</div>
<label class="w-auto control-label" for="button1id"></label>
<div class="w-auto">
<button onclick="showinitials();" type="button" name="button1id" class="btn btn-sm btn-primary"><?= __("Show") ?></button>
</div>
</div>
</form>
<div class="resulttable"></div>
<?php } else {
echo __("No EME QSO(s) was found.");
} ?>
</div>

View File

@@ -0,0 +1,30 @@
function showinitials() {
var data = {
band: $('#band').val(),
mode: $('#mode').val()
};
$.ajax({
url: base_url + "index.php/statistics/getInitials",
type: "post",
data: data,
success: function (html) {
$(".resulttable").empty();
$(".resulttable").html(html);
$(".intialstable").DataTable({
pageLength: 25,
responsive: false,
ordering: false,
scrollY: "500px",
scrollCollapse: true,
paging: false,
scrollX: true,
language: {
url: getDataTablesLanguageUrl(),
},
dom: "Bfrtip",
buttons: ["csv"],
});
},
});
}