From 36de0301518c862bc0aa7d67f8f98077681d2a78 Mon Sep 17 00:00:00 2001
From: Andreas <6977712+AndreasK79@users.noreply.github.com>
Date: Thu, 9 Feb 2023 12:35:30 +0100
Subject: [PATCH] [Continents] Added band and mode filter
---
application/controllers/Continents.php | 13 +++-
application/models/Logbook_model.php | 19 +++++-
application/views/continents/index.php | 94 +++++++++++++++++---------
assets/js/sections/continents.js | 67 ++++++++++++------
4 files changed, 138 insertions(+), 55 deletions(-)
diff --git a/application/controllers/Continents.php b/application/controllers/Continents.php
index a3f48ff8..5858652d 100644
--- a/application/controllers/Continents.php
+++ b/application/controllers/Continents.php
@@ -6,6 +6,11 @@ class Continents extends CI_Controller {
{
$this->load->model('user_model');
$this->load->model('bands');
+ $this->load->model('logbookadvanced_model');
+
+ $data['bands'] = $this->bands->get_worked_bands();
+ $data['modes'] = $this->logbookadvanced_model->get_modes();
+
if(!$this->user_model->authorize($this->config->item('auth_mode'))) {
if($this->user_model->validate_session()) {
$this->user_model->clear_session();
@@ -27,11 +32,17 @@ class Continents extends CI_Controller {
public function get_continents() {
+
+ $searchCriteria = array(
+ 'mode' => xss_clean($this->input->post('mode')),
+ 'band' => xss_clean($this->input->post('band')),
+ );
+
$this->load->model('logbook_model');
$continentsstats = array();
- $total_continents = $this->logbook_model->total_continents();
+ $total_continents = $this->logbook_model->total_continents($searchCriteria);
$i = 0;
if ($total_continents) {
diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php
index 6a94d771..5dbe5e8e 100755
--- a/application/models/Logbook_model.php
+++ b/application/models/Logbook_model.php
@@ -1631,7 +1631,7 @@ class Logbook_model extends CI_Model {
}
/* Return total number of QSOs per continent */
- function total_continents() {
+ function total_continents($searchCriteria) {
$CI =& get_instance();
$CI->load->model('logbooks_model');
@@ -1645,6 +1645,23 @@ class Logbook_model extends CI_Model {
$this->db->where_in('station_id', $logbooks_locations_array);
$this->db->where('COL_CONT is not null');
$this->db->where('COL_CONT !=', '');
+
+ if ($searchCriteria['mode'] !== '') {
+ $this->db->group_start();
+ $this->db->where('COL_MODE', $searchCriteria['mode']);
+ $this->db->or_where('COL_SUBMODE', $searchCriteria['mode']);
+ $this->db->group_end();
+ }
+
+ if ($searchCriteria['band'] !== '') {
+ if($searchCriteria['band'] != "SAT") {
+ $this->db->where('COL_BAND', $searchCriteria['band']);
+ $this->db->where('COL_PROP_MODE != "SAT"');
+ } else {
+ $this->db->where('COL_PROP_MODE', 'SAT');
+ }
+ }
+
$this->db->order_by('count DESC');
$this->db->group_by('COL_CONT');
$query = $this->db->get($this->config->item('table_name'));
diff --git a/application/views/continents/index.php b/application/views/continents/index.php
index da349ee2..a03b8d3f 100644
--- a/application/views/continents/index.php
+++ b/application/views/continents/index.php
@@ -1,38 +1,70 @@
-
-
-
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
- | # |
- Continent |
- # of QSO's worked |
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ | # |
+ Continent |
+ # of QSO's worked |
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/js/sections/continents.js b/assets/js/sections/continents.js
index e58a2422..0b53400e 100644
--- a/assets/js/sections/continents.js
+++ b/assets/js/sections/continents.js
@@ -1,19 +1,49 @@
-totalContinentQsos();
+$(document).ready(function () {
+ // Needed for continentstable header fix, will be squished without
+ $("a[href='#continents']").on('shown.bs.tab', function(e) {
+ $(".continentstable").DataTable().columns.adjust();
+ });
-// Needed for continentstable header fix, will be squished without
-$("a[href='#continents']").on('shown.bs.tab', function(e) {
- $(".continentstable").DataTable().columns.adjust();
+ $('#searchForm').submit(function (e) {
+ $('#searchButton').prop("disabled", true);
+
+ $.ajax({
+ url: this.action,
+ type: 'post',
+ data: {
+ mode: this.mode.value,
+ band: this.band.value,
+ },
+ dataType: 'json',
+ success: function (data) {
+ $('#searchButton').prop("disabled", false);
+ totalContinentQsos(data);
+ },
+ error: function (data) {
+ $('#searchButton').prop("disabled", false);
+ BootstrapDialog.alert({
+ title: 'ERROR',
+ message: 'An error ocurred while making the request',
+ type: BootstrapDialog.TYPE_DANGER,
+ closable: false,
+ draggable: false,
+ callback: function (result) {
+ }
+ });
+ },
+ });
+ return false;
+ });
+
+ $('#searchForm').submit();
});
-function totalContinentQsos() {
+function totalContinentQsos(data) {
// using this to change color of legend and label according to background color
var color = ifDarkModeThemeReturn('white', 'grey');
- $.ajax({
- url: base_url+'index.php/continents/get_continents',
- type: 'post',
- success: function (data) {
if (data.length > 0) {
+ $('.continentstable > tbody').empty();
$('.tabs').removeAttr('hidden');
var labels = [];
@@ -47,6 +77,12 @@ function totalContinentQsos() {
});
const COLORS = ["#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", "#b82e2e", "#316395", "#994499"]
+
+ let chartStatus = Chart.getChart("continentChart"); //