From 56a1a20618c66ca189972eefdae28fbc0a3bd0e7 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Mon, 26 May 2025 18:40:48 +0200
Subject: [PATCH] Added query and result
---
application/models/Stats.php | 29 +++++++++
.../views/statistics/initialresult.php | 61 +++++++++++--------
assets/js/sections/initials.js | 4 +-
3 files changed, 65 insertions(+), 29 deletions(-)
diff --git a/application/models/Stats.php b/application/models/Stats.php
index 0af15f624..03c171f4e 100644
--- a/application/models/Stats.php
+++ b/application/models/Stats.php
@@ -920,8 +920,37 @@
}
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 col_call, min(col_time_on) firstworked, col_band 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();
}
+
}
?>
diff --git a/application/views/statistics/initialresult.php b/application/views/statistics/initialresult.php
index bf92b325d..df6339eb1 100644
--- a/application/views/statistics/initialresult.php
+++ b/application/views/statistics/initialresult.php
@@ -1,32 +1,39 @@
-
- ';
- echo ' | ';
- foreach($bands as $band) {
- echo '' . $band . ' | ';
- }
- echo ''.__("Total").' | ';
- echo '
-
- ';
- foreach ($qsoarray as $mode => $value) {
+ // 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 '
+
+
+ | # |
+ ' . __("Date") . ' |
+ ' . __("Callsign") . ' |
+ ' . __("Band") . ' |
+ ' . __("Mode") . ' |
+ ' . __("Show QSOs") . ' |
+
+
+ ';
+ $i = 1;
+ foreach ($intials_array as $line) {
+ $date_as_timestamp = strtotime($line->firstworked ?? '1970-01-01 00:00:00');
echo '
- | '. $mode .' | ';
- foreach ($value as $key => $val) {
- echo '' . $val . ' | ';
- }
- echo '' . $modetotal[$mode] . ' | ';
- echo '
';
- }
- echo '| '.__("Total").' | ';
+ ' . $i++ . ' |
+ ' . date($custom_date_format, $date_as_timestamp) . ' |
+ ' . $line->col_call . ' |
+ ' . $line->col_band . ' |
+ |
+ ' . __("Show") . ' |
+
';
+ }
- $grandtotal = 0;
- foreach ($bandtotal as $band => $value) {
- echo '' . $value . ' | ';
- $grandtotal += $value;
- }
- echo '' . $grandtotal . ' | ';
- echo '
';
+ echo '
';
+} else {
+ echo __("No EME QSO(s) was found.");
}
diff --git a/assets/js/sections/initials.js b/assets/js/sections/initials.js
index dd705367f..e12ab0500 100644
--- a/assets/js/sections/initials.js
+++ b/assets/js/sections/initials.js
@@ -15,8 +15,8 @@ $(".activatorstable").DataTable({
function showinitials() {
var data = {
- mode: $('#band').val(),
- band: $('#mode').val()
+ band: $('#band').val(),
+ mode: $('#mode').val()
};
$.ajax({