+
+
+ session->flashdata('message')) { ?>
+
+
+
session->flashdata('message'); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ num_rows() > 0) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ num_rows() > 0) { ?>
+
+
+
+
+
+
+
+= 1) && ($is_admin)) { ?>
+
+
+
+
+
+
+
+
+
diff --git a/assets/css/general.css b/assets/css/general.css
index 1421d9925..23423e6f3 100644
--- a/assets/css/general.css
+++ b/assets/css/general.css
@@ -856,3 +856,8 @@ label {
background-color: rgb(254 243 199) !important;
--bs-badge-color: rgb(217 119 6) !important;
}
+
+.quickswitcher.disabled {
+ --bs-dropdown-link-disabled-color: initial !important;
+}
+
diff --git a/assets/js/sections/common.js b/assets/js/sections/common.js
index 64e8c2b63..ebff5fd61 100644
--- a/assets/js/sections/common.js
+++ b/assets/js/sections/common.js
@@ -601,8 +601,8 @@ function displayQsl(id) {
// [eQSL default msg] function to load default qslmsg to qslmsg field on qso add/edit //
function qso_set_eqsl_qslmsg(station_id, force_diff_to_origin=false, object='') {
$.ajax({
- url: base_url+'index.php/station/get_options',
- type: 'post', data: {'option_type':'eqsl_default_qslmsg','option_name':'key_station_id','option_key':station_id },
+ url: base_url+'index.php/qso/get_eqsl_default_qslmsg',
+ type: 'post', data: {'option_key':station_id },
success: function(res) {
if (typeof res.eqsl_default_qslmsg !== "undefined") {
object = (object!='')?(object+' '):'';
@@ -702,6 +702,55 @@ function statesDropdown(states, set_state = null) {
}
}
+// Location Quickswitcher
+function quickswitcher_show_activebadge(current_active) {
+ $('#quickswitcher_active_badge_' + current_active).removeClass('d-none');
+ $('#quickswitcher_list_button_' + current_active).addClass('disabled');
+}
+
+function current_active_ajax(callback) {
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/getActiveStation',
+ type: 'GET',
+ dataType: 'json',
+ success: function(response) {
+ var current_active = response;
+ callback(current_active);
+ }
+ });
+}
+
+function set_active_loc_quickswitcher(new_active) {
+ current_active_ajax(function(current_active) {
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/setActiveStation_json',
+ type: 'POST',
+ dataType: 'json',
+ data: {
+ id2setActive: new_active
+ },
+ success: function(response) {
+ $('[id^="quickswitcher_list_button_"]').not('#quickswitcher_list_button_' + new_active).removeClass('disabled');
+ $('[id^="quickswitcher_active_badge_"]').not('#quickswitcher_active_badge_' + new_active).addClass('d-none');
+
+ $('#quickswitcher_list_button_' + new_active).addClass('disabled');
+ $('#quickswitcher_active_badge_' + new_active).removeClass('d-none');
+
+
+ // if we are on the stationsetup page the function reloadStations exists and we can run it
+ if (typeof reloadStations === 'function') {
+ reloadStations();
+ }
+ },
+ error: function(xhr, status, error) {
+ console.error('Error while setting the new active location: ' + error);
+ }
+ });
+ });
+}
+
+
+
console.log("Ready to unleash your coding prowess and join the fun?\n\n" +
"Check out our GitHub Repository and dive into the coding adventure:\n\n" +
"🚀 https://www.github.com/wavelog/wavelog");
diff --git a/assets/js/sections/stationsetup.js b/assets/js/sections/stationsetup.js
new file mode 100644
index 000000000..a053b753a
--- /dev/null
+++ b/assets/js/sections/stationsetup.js
@@ -0,0 +1,309 @@
+$(document).ready(function () {
+ reloadStations();
+
+ $("#station_locations_table").DataTable({
+ stateSave: true,
+ language: {
+ url: getDataTablesLanguageUrl(),
+ },
+ });
+
+ $(document).on('click','.newLogbook', function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/newLogbook_json',
+ type: 'post',
+ data: {
+ 'stationLogbook_Name': $("#logbook_name").val(),
+ },
+ success: function(data) {
+ jdata=JSON.parse(data);
+ if (jdata.success == 1) {
+ $("#NewStationLogbookModal").modal('hide');
+ reloadLogbooks();
+ } else {
+ $("#flashdata").html(jdata.flashdata);
+ }
+ },
+ error: function(e) {
+ $("#flashdata").html("An unknown Error occured");
+ }
+ });
+
+ });
+
+ $(document).on('click', '.deleteLogbook', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ await do_ajax('deleteLogbook_json', 'id2delete', reloadLogbooks,e);
+ });
+
+ $(document).on('click', '.setActiveLogbook', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ await do_ajax('setActiveLogbook_json', 'id2setActive', reloadLogbooks,e);
+ });
+
+ $(document).on('click', '.setActiveStation', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ await do_ajax('setActiveStation_json', 'id2setActive', reloadStations,e);
+ });
+
+ $(document).on('click', '.DeleteStation', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ await do_ajax('DeleteStation_json', 'id2del', reloadStations,e);
+ });
+
+ $(document).on('click', '.EmptyStation', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ await do_ajax('EmptyStation_json', 'id2Empty', reloadStations,e);
+ });
+
+ $(document).on('click', '.setFavorite', async function (e) { // Dynamic binding, since element doesn't exists when loading this JS
+ await do_ajax('setFavorite_json', 'id2Favorite', reloadStations,e);
+ });
+
+ $("#station_logbooks_table").DataTable({
+ stateSave: true,
+ language: {
+ url: getDataTablesLanguageUrl(),
+ },
+ });
+});
+
+ async function do_ajax(ajax_uri, ajax_field, succ_callback, event_target) {
+ if (event_target.currentTarget.attributes.cnftext) {
+ if (!(confirm(event_target.currentTarget.attributes.cnftext.value))) {
+ return false;
+ }
+ }
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/' + ajax_uri,
+ type: 'post',
+ data: {
+ [ajax_field]: event_target.currentTarget.id,
+ },
+ success: function(data) {
+ jdata=JSON.parse(data);
+ if (jdata.success == 1) {
+ succ_callback();
+
+ // we also want to switch the active badge in the quickswitcher
+ set_active_loc_quickswitcher(event_target.currentTarget.id);
+ } else {
+ $("#flashdata").html(jdata.flashdata);
+ }
+ },
+ error: function(e) {
+ $("#flashdata").html("An unknown Error occured");
+ }
+ });
+ }
+
+
+function reloadLogbooks() {
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/fetchLogbooks',
+ type: 'post',
+ dataType: 'json',
+ success: function (data) {
+ loadLogbookTable(data);
+ },
+ error: function (data) {
+ 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;
+}
+function reloadStations() {
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/fetchLocations',
+ type: 'post',
+ dataType: 'json',
+ success: function (data) {
+ loadLocationTable(data);
+ },
+ error: function (data) {
+ 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;
+}
+
+function createStationLogbook() {
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/newLogbook',
+ type: 'post',
+ success: function (html) {
+ BootstrapDialog.show({
+ title: 'Create a new station logbook',
+ size: BootstrapDialog.SIZE_NORMAL,
+ cssClass: 'options',
+ id: "NewStationLogbookModal",
+ nl2br: false,
+ message: html,
+ onshown: function(dialog) {
+ },
+ buttons: [{
+ label: 'Save',
+ cssClass: 'btn-primary btn-sm newLogbook',
+ id: 'saveButtonNewLogbook',
+ },
+ {
+ label: lang_admin_close,
+ cssClass: 'btn-sm',
+ id: 'closeButton',
+ action: function (dialogItself) {
+ dialogItself.close();
+ }
+ }],
+ onhide: function(dialogRef){
+ $('#optionButton').prop("disabled", false);
+ },
+ });
+ }
+ });
+}
+
+function createStationLocation() {
+ $.ajax({
+ url: base_url + 'index.php/stationsetup/newLocation',
+ type: 'post',
+ success: function (html) {
+ BootstrapDialog.show({
+ title: 'Create a new station location',
+ size: BootstrapDialog.SIZE_EXTRAWIDE,
+ cssClass: 'options',
+ nl2br: false,
+ message: html,
+ onshown: function(dialog) {
+ },
+ buttons: [{
+ label: 'Save',
+ cssClass: 'btn-primary btn-sm',
+ id: 'saveButton',
+ action: function (dialogItself) {
+ dialogItself.close();
+ }
+ },
+ {
+ label: lang_admin_close,
+ cssClass: 'btn-sm',
+ id: 'closeButton',
+ action: function (dialogItself) {
+ dialogItself.close();
+ }
+ }],
+ onhide: function(dialogRef){
+ $('#optionButton').prop("disabled", false);
+ },
+ });
+ }
+ });
+}
+
+function loadLogbookTable(rows) {
+ var uninitialized = $('#station_logbooks_table').filter(function() {
+ return !$.fn.DataTable.fnIsDataTable(this);
+ });
+
+ uninitialized.each(function() {
+ $(this).DataTable({
+ searching: false,
+ responsive: false,
+ ordering: true,
+ "scrollY": window.innerHeight - $('#searchForm').innerHeight() - 250,
+ "scrollCollapse": true,
+ "paging": false,
+ "scrollX": true,
+ "language": {
+ url: getDataTablesLanguageUrl(),
+ },
+ });
+ });
+
+ var table = $('#station_logbooks_table').DataTable();
+
+ table.clear();
+
+ for (i = 0; i < rows.length; i++) {
+ let logbook = rows[i];
+
+ var data = [];
+ data.push(logbook.logbook_name);
+ data.push(logbook.logbook_state);
+ data.push(logbook.logbook_edit);
+ data.push(logbook.logbook_delete);
+ data.push(logbook.logbook_link);
+ data.push(logbook.logbook_publicsearch);
+
+ let createdRow = table.row.add(data).index();
+ }
+ table.draw();
+ $('[data-bs-toggle="tooltip"]').tooltip();
+}
+
+function loadLocationTable(rows) {
+ var uninitialized = $('#station_locations_table').filter(function() {
+ return !$.fn.DataTable.fnIsDataTable(this);
+ });
+
+ uninitialized.each(function() {
+ $(this).DataTable({
+ searching: false,
+ responsive: false,
+ ordering: true,
+ "scrollY": window.innerHeight - $('#searchForm').innerHeight() - 250,
+ "scrollCollapse": true,
+ "paging": false,
+ "scrollX": true,
+ "language": {
+ url: getDataTablesLanguageUrl(),
+ },
+ 'columnDefs': [
+ { 'targets':0,
+ 'createdCell': function (td, cellData, rowData, row, col) {
+ (td).attr('data-order', 1); // not sure how to add ID dynamic here
+ }
+ }
+ ]
+ });
+ });
+
+ var table = $('#station_locations_table').DataTable();
+
+ table.clear();
+
+ for (i = 0; i < rows.length; i++) {
+ let locations = rows[i];
+
+ var data = [];
+
+ data.push(locations.station_id);
+ data.push(locations.station_name);
+ data.push(locations.station_callsign);
+ data.push(locations.station_country);
+ data.push(locations.station_gridsquare);
+ data.push(locations.station_badge);
+ data.push(locations.station_edit);
+ data.push(locations.station_copylog);
+ if (locations.station_favorite != ''){
+ data.push(locations.station_favorite);
+ }
+ data.push(locations.station_emptylog);
+ data.push(locations.station_delete);
+
+ let createdRow = table.row.add(data).index();
+ }
+ table.draw();
+ $('[data-bs-toggle="tooltip"]').tooltip();
+}
+