diff --git a/application/config/migration.php b/application/config/migration.php
index ad5f2d9e3..c52d5d72d 100644
--- a/application/config/migration.php
+++ b/application/config/migration.php
@@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
*/
-$config['migration_version'] = 184;
+$config['migration_version'] = 185;
/*
|--------------------------------------------------------------------------
diff --git a/application/controllers/Band.php b/application/controllers/Band.php
index d56e7a05d..0bedbad6a 100644
--- a/application/controllers/Band.php
+++ b/application/controllers/Band.php
@@ -20,7 +20,7 @@ class Band extends CI_Controller {
$this->load->model('bands');
$data['bands'] = $this->bands->get_all_bands_for_user();
-
+
// Render Page
$data['page_title'] = "Bands";
$this->load->view('interface_assets/header', $data);
@@ -28,7 +28,7 @@ class Band extends CI_Controller {
$this->load->view('interface_assets/footer');
}
- public function create()
+ public function create()
{
$this->load->model('bands');
$this->load->library('form_validation');
@@ -41,7 +41,7 @@ class Band extends CI_Controller {
$this->load->view('bands/create', $data);
}
else
- {
+ {
$this->bands->add();
}
}
@@ -55,7 +55,7 @@ class Band extends CI_Controller {
$band_query = $this->bands->getband($item_id_clean);
$data['my_band'] = $band_query->row();
-
+
$data['page_title'] = "Edit Band";
$this->load->view('bands/edit', $data);
@@ -122,8 +122,11 @@ class Band extends CI_Controller {
$band['cq'] = $this->security->xss_clean($this->input->post('cq'));
$band['dok'] = $this->security->xss_clean($this->input->post('dok'));
$band['dxcc'] = $this->security->xss_clean($this->input->post('dxcc'));
- $band['helvetia'] = $this->security->xss_clean($this->input->post('helvetia'));
+ $band['helvetia'] = $this->security->xss_clean($this->input->post('helvetia'));
$band['iota'] = $this->security->xss_clean($this->input->post('iota'));
+ $band['jcc'] = $this->security->xss_clean($this->input->post('jcc'));
+ $band['pota'] = $this->security->xss_clean($this->input->post('pota'));
+ $band['rac'] = $this->security->xss_clean($this->input->post('rac'));
$band['sig'] = $this->security->xss_clean($this->input->post('sig'));
$band['sota'] = $this->security->xss_clean($this->input->post('sota'));
$band['uscounties'] = $this->security->xss_clean($this->input->post('uscounties'));
@@ -131,11 +134,10 @@ class Band extends CI_Controller {
$band['wwff'] = $this->security->xss_clean($this->input->post('wwff'));
$band['vucc'] = $this->security->xss_clean($this->input->post('vucc'));
$band['waja'] = $this->security->xss_clean($this->input->post('waja'));
- $band['pota'] = $this->security->xss_clean($this->input->post('pota'));
-
+
$this->load->model('bands');
$this->bands->saveBand($id, $band);
-
+
header('Content-Type: application/json');
echo json_encode(array('message' => 'OK'));
return;
@@ -144,10 +146,10 @@ class Band extends CI_Controller {
public function saveBandAward() {
$award = $this->security->xss_clean($this->input->post('award'));
$status = $this->security->xss_clean($this->input->post('status'));
-
+
$this->load->model('bands');
$this->bands->saveBandAward($award, $status);
-
+
header('Content-Type: application/json');
echo json_encode(array('message' => 'OK'));
return;
diff --git a/application/controllers/Clublog.php b/application/controllers/Clublog.php
index b7bcf21fb..5aa2b630d 100644
--- a/application/controllers/Clublog.php
+++ b/application/controllers/Clublog.php
@@ -6,6 +6,16 @@
class Clublog extends CI_Controller {
+ function __construct()
+ {
+ parent::__construct();
+
+ if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
+ echo "Maintenance Mode is active. Try again later.\n";
+ redirect('user/login');
+ }
+ }
+
// Show frontend if there is one
public function index() {
$this->config->load('config');
diff --git a/application/controllers/Dxcluster.php b/application/controllers/Dxcluster.php
index 0e399cbf7..3a642256c 100644
--- a/application/controllers/Dxcluster.php
+++ b/application/controllers/Dxcluster.php
@@ -13,10 +13,10 @@ class Dxcluster extends CI_Controller {
function spots($band,$age = '', $de = '') {
if ($age == '') {
- $age = $this->optionslib->get_option('dxcluster_maxage');
+ $age = $this->optionslib->get_option('dxcluster_maxage') ?? 60;
}
if ($de == '') {
- $de = $this->optionslib->get_option('dxcluster_decont');
+ $de = $this->optionslib->get_option('dxcluster_decont') ?? 'EU';
}
$calls_found=$this->dxcluster_model->dxc_spotlist($band, $age, $de);
header('Content-Type: application/json');
diff --git a/application/controllers/Eqsl.php b/application/controllers/Eqsl.php
index 9f93cbb8a..f82a1d9c8 100644
--- a/application/controllers/Eqsl.php
+++ b/application/controllers/Eqsl.php
@@ -4,8 +4,15 @@ class eqsl extends CI_Controller {
/* Controls who can access the controller and its functions */
function __construct() {
+
parent::__construct();
+
$this->load->helper(array('form', 'url'));
+
+ if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
+ echo "Maintenance Mode is active. Try again later.\n";
+ redirect('user/login');
+ }
}
// Default view when loading controller.
diff --git a/application/controllers/Hrdlog.php b/application/controllers/Hrdlog.php
index 934cd1b2e..2b3182b49 100644
--- a/application/controllers/Hrdlog.php
+++ b/application/controllers/Hrdlog.php
@@ -11,6 +11,17 @@ class Hrdlog extends CI_Controller {
* When called from the url wavelog/hrdlog/upload, the function loops through all station_id's with a hrdlog code defined.
* All QSOs not previously uploaded, will then be uploaded, one at a time
*/
+
+ function __construct()
+ {
+ parent::__construct();
+
+ if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
+ echo "Maintenance Mode is active. Try again later.\n";
+ redirect('user/login');
+ }
+ }
+
public function upload() {
$this->setOptions();
@@ -34,7 +45,6 @@ class Hrdlog extends CI_Controller {
echo "No station profiles with a hrdlog Code found.";
log_message('error', "No station profiles with a hrdlog Code found.");
}
-
}
function setOptions() {
diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php
index 7b82ca5fb..dd48d3c98 100644
--- a/application/controllers/Logbook.php
+++ b/application/controllers/Logbook.php
@@ -851,7 +851,7 @@ class Logbook extends CI_Controller {
if($callsign['callsign']['error'] == "Session does not exist or expired") {
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
- $callsign['callsign'] = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
+ $callsign['callsign'] = $this->hamqth->search($id, $this->session->userdata('hamqth_session_key'));
}
if (isset($data['callsign']['gridsquare'])) {
$this->load->model('logbook_model');
diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php
index 1925f0ad5..615e0c061 100644
--- a/application/controllers/Logbookadvanced.php
+++ b/application/controllers/Logbookadvanced.php
@@ -414,14 +414,14 @@ class Logbookadvanced extends CI_Controller {
$data['datetime'] = date($custom_date_format, strtotime($qso['COL_TIME_ON'])). date(' H:i',strtotime($qso['COL_TIME_ON']));
$data['satname'] = $qso['COL_SAT_NAME'];
$data['confirmed'] = ($this->logbook_model->qso_is_confirmed($qso)==true) ? true : false;
-
+
return $data;
}
public function calculateCoordinates($qso, $lat, $long, $mygrid, $measurement_base, $var_dist, $custom_date_format) {
$this->load->library('Qra');
$this->load->model('logbook_model');
-
+
$latlng1 = $this->qra->qra2latlong($mygrid);
$latlng2[0] = $lat;
$latlng2[1] = $long;
@@ -486,6 +486,7 @@ class Logbookadvanced extends CI_Controller {
$json_string['iota']['show'] = $this->input->post('iota');
$json_string['pota']['show'] = $this->input->post('pota');
$json_string['operator']['show'] = $this->input->post('operator');
+ $json_string['comment']['show'] = $this->input->post('comment');
$obj['column_settings']= json_encode($json_string);
diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php
index 61938f5c5..0f8306b94 100644
--- a/application/controllers/Logbooks.php
+++ b/application/controllers/Logbooks.php
@@ -27,7 +27,7 @@ class Logbooks extends CI_Controller {
$this->load->view('interface_assets/footer');
}
- public function create()
+ public function create()
{
$this->load->library('form_validation');
@@ -41,11 +41,11 @@ class Logbooks extends CI_Controller {
$this->load->view('interface_assets/footer');
}
else
- {
+ {
$this->load->model('logbooks_model');
$this->logbooks_model->add();
-
- redirect('logbooks');
+
+ redirect('stationsetup');
}
}
@@ -65,7 +65,7 @@ class Logbooks extends CI_Controller {
$data['station_locations_list'] = $this->stations->all_of_user();
$data['station_locations_linked'] = $this->logbooks_model->list_logbooks_linked($station_logbook_id);
-
+
$data['page_title'] = "Edit Station Logbook";
$this->form_validation->set_rules('station_logbook_id', 'Station Logbook Name', 'required');
@@ -99,27 +99,27 @@ class Logbooks extends CI_Controller {
$this->logbooks_model->set_logbook_active($id);
$this->user_model->update_session($this->session->userdata('user_id'));
- redirect('logbooks');
+ redirect('stationsetup');
}
public function delete($id) {
$this->load->model('logbooks_model');
$this->logbooks_model->delete($id);
-
- redirect('logbooks');
+
+ redirect('stationsetup');
}
public function delete_relationship($logbook_id, $station_id) {
$this->load->model('logbooks_model');
$this->logbooks_model->delete_relationship($logbook_id, $station_id);
-
+
redirect('logbooks/edit/'.$logbook_id);
}
public function publicslug_validate() {
$this->load->model('logbooks_model');
$result = $this->logbooks_model->is_public_slug_available($this->input->post('public_slug'));
-
+
if($result == true) {
$data['slugAvailable'] = true;
} else {
@@ -151,8 +151,8 @@ class Logbooks extends CI_Controller {
{
$this->load->model('logbooks_model');
$result = $this->logbooks_model->is_public_slug_available($this->input->post('public_slug'));
-
-
+
+
if($result == true) {
$returndata = $this->logbooks_model->save_public_slug($this->input->post('public_slug'), $this->input->post('logbook_id'));
echo "
Public Slug Saved
";
diff --git a/application/controllers/Lotw.php b/application/controllers/Lotw.php
index 24a569dc4..ffdea9090 100644
--- a/application/controllers/Lotw.php
+++ b/application/controllers/Lotw.php
@@ -26,6 +26,11 @@ class Lotw extends CI_Controller {
// Load language files
$this->lang->load('lotw');
+
+ if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
+ echo "Maintenance Mode is active. Try again later.\n";
+ redirect('user/login');
+ }
}
/*
@@ -352,7 +357,7 @@ class Lotw extends CI_Controller {
/*
| Download QSO Matches from LoTW
- */
+ */
if ($this->user_model->authorize(2)) {
echo "
";
$sync_user_id=$this->session->userdata('user_id');
diff --git a/application/controllers/Qrz.php b/application/controllers/Qrz.php
index 557a8a6b8..a4507bdd9 100644
--- a/application/controllers/Qrz.php
+++ b/application/controllers/Qrz.php
@@ -6,6 +6,16 @@
class Qrz extends CI_Controller {
+ function __construct()
+ {
+ parent::__construct();
+
+ if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
+ echo "Maintenance Mode is active. Try again later.\n";
+ redirect('user/login');
+ }
+ }
+
// Show frontend if there is one
public function index() {
$this->config->load('config');
@@ -38,7 +48,6 @@ class Qrz extends CI_Controller {
echo "No station profiles with a QRZ API Key found.";
log_message('error', "No station profiles with a QRZ API Key found.");
}
-
}
function setOptions() {
@@ -247,7 +256,7 @@ class Qrz extends CI_Controller {
} else {
echo "Downloaded QRZ report contains no matches.";
}
- }
+ }
}
function mass_download_qsos($qrz_api_key = '', $lastqrz = '1900-01-01', $trusted = false) {
diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php
index f04a8c29e..b197537bb 100755
--- a/application/controllers/Qso.php
+++ b/application/controllers/Qso.php
@@ -583,6 +583,17 @@ class QSO extends CI_Controller {
$this->load->view('qso/components/previous_contacts', $data);
}
+ public function get_eqsl_default_qslmsg() { // Get ONLY Default eQSL-Message with this function. This is ONLY for QSO relevant!
+ $return_json = array();
+ $option_key = $this->input->post('option_key');
+ if ($option_key > 0) {
+ $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg', array('option_name' => 'key_station_id', 'option_key' => $option_key))->result();
+ $return_json['eqsl_default_qslmsg'] = (isset($options_object[0]->option_value)) ? $options_object[0]->option_value : '';
+ }
+ header('Content-Type: application/json');
+ echo json_encode($return_json);
+ }
+
function check_locator($grid) {
$grid = $this->input->post('locator');
// Allow empty locator
diff --git a/application/controllers/Station.php b/application/controllers/Station.php
index 5c8b5d6a8..fd82eb55a 100644
--- a/application/controllers/Station.php
+++ b/application/controllers/Station.php
@@ -57,15 +57,8 @@ class Station extends CI_Controller
$this->load->view('station_profile/create');
$this->load->view('interface_assets/footer');
} else {
- if (($station_id = $this->stations->add()) !== false) {
- // [eQSL default msg] ADD to user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id; option_value=value) //
- $eqsl_default_qslmsg = xss_clean($this->input->post('eqsl_default_qslmsg', true));
- if (!empty(trim($eqsl_default_qslmsg))) {
- $this->load->model('user_options_model');
- $this->user_options_model->set_option('eqsl_default_qslmsg', 'key_station_id', array($station_id => $eqsl_default_qslmsg));
- }
- }
- redirect('station');
+ $this->stations->add();
+ redirect('stationsetup');
}
}
@@ -77,32 +70,17 @@ class Station extends CI_Controller
$data['page_title'] = lang('station_location_edit') . $data['my_station_profile']->station_profile_name;
if ($this->form_validation->run() == FALSE) {
- // [eQSL default msg] GET from user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id) //
- $this->load->model('user_options_model');
- $options_object = $this->user_options_model->get_options('eqsl_default_qslmsg', array('option_name' => 'key_station_id', 'option_key' => $id))->result();
- $data['eqsl_default_qslmsg'] = (isset($options_object[0]->option_value)) ? $options_object[0]->option_value : '';
-
$this->load->view('interface_assets/header', $data);
$this->load->view('station_profile/edit');
$this->load->view('interface_assets/footer');
} else {
- if ($this->stations->edit() !== false) {
- // [eQSL default msg] ADD to user options (option_type='eqsl_default_qslmsg'; option_name='key_station_id'; option_key=station_id; option_value=value) //
- $eqsl_default_qslmsg = xss_clean($this->input->post('eqsl_default_qslmsg', true));
- $this->load->model('user_options_model');
- if (!empty(trim($eqsl_default_qslmsg))) {
- $this->user_options_model->set_option('eqsl_default_qslmsg', 'key_station_id', array($id => $eqsl_default_qslmsg));
- } else {
- $this->user_options_model->del_option('eqsl_default_qslmsg', 'key_station_id', array('option_key' => $id));
- }
+ if ($this->stations->edit()) {
+ $data['notice'] = lang('station_location') . $this->security->xss_clean($this->input->post('station_profile_name', true)) . " Updated";
}
-
- $data['notice'] = lang('station_location') . $this->security->xss_clean($this->input->post('station_profile_name', true)) . " Updated";
-
- redirect('station');
+ redirect('stationsetup');
}
} else {
- redirect('station');
+ redirect('stationsetup');
}
}
@@ -125,22 +103,19 @@ class Station extends CI_Controller
} else {
$this->stations->add();
- redirect('station');
+ redirect('stationsetup');
}
} else {
- redirect('station');
+ redirect('stationsetup');
}
}
- public function edit_favorite($id)
+ public function edit_favourite($id)
{
- $is_favorite = $this->user_options_model->get_options('station_location', array('option_name'=>'is_favorite', 'option_key'=>$id))->row()->option_value ?? 'false';
- if ($is_favorite == 'true') {
- $this->user_options_model->del_option('station_location', 'is_favorite', array('option_key'=>$id));
- } else if ($is_favorite == 'false') {
- $this->user_options_model->set_option('station_location', 'is_favorite', array($id=>'true'));
- }
- redirect('station');
+ $this->load->model('stations');
+ $this->stations->edit_favourite($id);
+
+ redirect('stationsetup');
}
function load_station_for_editing($id): array
@@ -155,9 +130,7 @@ class Station extends CI_Controller
$item_id_clean = $this->security->xss_clean($id);
- $station_profile_query = $this->stations->profile($item_id_clean);
-
- $data['my_station_profile'] = $station_profile_query->row();
+ $data['my_station_profile'] = $this->stations->profile_full($item_id_clean);
$data['dxcc_list'] = $this->dxcc->list();
@@ -176,19 +149,19 @@ class Station extends CI_Controller
}
//$this->stations->logbook_session_data();
- redirect('station');
+ redirect('stationsetup');
}
function set_active($current, $new, $is_ajax = null)
{
$this->load->model('stations');
$this->stations->set_active($current, $new);
-
+
if ($is_ajax != null) {
return;
}
-
- redirect('station');
+
+ redirect('stationsetup');
}
public function delete($id)
@@ -196,11 +169,8 @@ class Station extends CI_Controller
$this->load->model('stations');
if ($this->stations->check_station_is_accessible($id)) {
$this->stations->delete($id);
- // [eQSL default msg] DELETE user options //
- $this->load->model('user_options_model');
- $this->user_options_model->del_option('eqsl_default_qslmsg', 'key_station_id', array('option_key' => $id));
}
- redirect('station');
+ redirect('stationsetup');
}
public function deletelog($id)
@@ -209,7 +179,7 @@ class Station extends CI_Controller
if ($this->stations->check_station_is_accessible($id)) {
$this->stations->deletelog($id);
}
- redirect('station');
+ redirect('stationsetup');
}
/*
@@ -246,19 +216,4 @@ class Station extends CI_Controller
echo json_encode($json);
}
- // [eQSL default msg] Function return options from this station (but can be general use) //
- public function get_options()
- {
- $return_json = array();
- $option_type = $this->input->post('option_type');
- $option_name = $this->input->post('option_name');
- $option_key = $this->input->post('option_key');
- if (!empty($option_type) && !empty($option_name) && ($option_key > 0)) {
- $this->load->model('user_options_model');
- $options_object = $this->user_options_model->get_options($option_type, array('option_name' => $option_name, 'option_key' => $option_key))->result();
- $return_json[$option_type] = (isset($options_object[0]->option_value)) ? $options_object[0]->option_value : '';
- }
- header('Content-Type: application/json');
- echo json_encode($return_json);
- }
}
diff --git a/application/controllers/Stationsetup.php b/application/controllers/Stationsetup.php
new file mode 100644
index 000000000..0d0fca6c7
--- /dev/null
+++ b/application/controllers/Stationsetup.php
@@ -0,0 +1,321 @@
+load->helper(array('form', 'url'));
+
+ $this->load->model('user_model');
+ if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
+ }
+
+ public function index() {
+ $this->load->model('stations');
+ $this->load->model('Logbook_model');
+ $this->load->model('logbooks_model');
+
+ $data['my_logbooks'] = $this->logbooks_model->show_all();
+
+ $data['stations'] = $this->stations->all_with_count();
+ $data['current_active'] = $this->stations->find_active();
+ $data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
+
+ $footerData = [];
+ $footerData['scripts'] = [
+ 'assets/js/sections/stationsetup.js?' . filemtime(realpath(__DIR__ . "/../../assets/js/sections/stationsetup.js")),
+ ];
+
+ // Render Page
+ $data['page_title'] = "Station Setup";
+ $this->load->view('interface_assets/header', $data);
+ $this->load->view('stationsetup/stationsetup');
+ $this->load->view('interface_assets/footer', $footerData);
+ }
+
+ public function DeleteStation_json() {
+ $id2del=xss_clean($this->input->post('id2del',true));
+ if ($id2del ?? '' != '') {
+ $this->load->model('stations');
+ if ($this->stations->check_station_is_accessible($id2del)) {
+ $this->stations->delete($id2del);
+ $data['success']=1;
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Not allowed';
+ }
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Error';
+ }
+ echo json_encode($data);
+ }
+
+ public function EmptyStation_json() {
+ $id2empty=xss_clean($this->input->post('id2Empty',true));
+ if ($id2empty ?? '' != '') {
+ $this->load->model('stations');
+ if ($this->stations->check_station_is_accessible($id2empty)) {
+ $this->stations->deletelog($id2empty);
+ $data['success']=1;
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Not allowed';
+ }
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Error';
+ }
+ echo json_encode($data);
+ }
+
+ public function setActiveStation_json() {
+ $id2act=xss_clean($this->input->post('id2setActive',true));
+ if ($id2act ?? '' != '') {
+ $this->load->model('stations');
+ $current=$this->stations->find_active();
+ $this->stations->set_active($current, $id2act);
+ $data['success']=1;
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Error';
+ }
+ echo json_encode($data);
+ }
+
+ // get active station for quickswitcher
+ public function getActiveStation() {
+ $active_loc = $this->stations->find_active();
+ echo json_encode($active_loc);
+ }
+
+ public function setFavorite_json() {
+ $id2fav = xss_clean($this->input->post('id2Favorite', true));
+ if ($id2fav ?? '' != '') {
+ $this->load->model('stations');
+ $this->stations->edit_favourite($id2fav);
+ $data['success'] = 1;
+ } else {
+ $data['success'] = 0;
+ $data['flashdata'] ='Error';
+ }
+ echo json_encode($data);
+ }
+
+ public function setActiveLogbook_json() {
+ $id2act=xss_clean($this->input->post('id2setActive',true));
+ if ($id2act ?? '' != '') {
+ $this->load->model('logbooks_model');
+ $this->logbooks_model->set_logbook_active($id2act);
+ $data['success']=1;
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Error';
+ }
+ echo json_encode($data);
+ }
+
+ public function deleteLogbook_json() {
+ $id2del=xss_clean($this->input->post('id2delete',true));
+ if ($id2del ?? '' != '') {
+ $this->load->model('logbooks_model');
+ $this->logbooks_model->delete($id2del);
+ $data['success']=1;
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Error';
+ }
+ echo json_encode($data);
+ }
+
+ public function newLogbook_json() {
+ $this->load->library('form_validation');
+
+ $this->form_validation->set_rules('stationLogbook_Name', 'Station Logbook Name', 'required');
+
+ if ($this->form_validation->run() == FALSE) {
+ $data['flashdata']=validation_errors();
+ $data['success']=0;
+ echo json_encode($data);
+ } else {
+ $this->load->model('logbooks_model');
+ $newId=$this->logbooks_model->add(xss_clean($this->input->post('stationLogbook_Name', true)));
+ if ($newId > 0) {
+ $data['success']=1;
+ } else {
+ $data['success']=0;
+ $data['flashdata']='Error';
+ }
+ echo json_encode($data);
+ }
+ }
+
+ public function newLogbook() {
+ $data['page_title'] = "Create Station Logbook";
+ $this->load->view('stationsetup/create', $data);
+ }
+
+ public function newLocation() {
+ $this->load->model('stations');
+ $this->load->model('dxcc');
+ $data['dxcc_list'] = $this->dxcc->list();
+
+ $this->load->model('logbook_model');
+ $data['iota_list'] = $this->logbook_model->fetchIota();
+
+ $data['page_title'] = lang('station_location_create_header');
+ $this->load->view('station_profile/create', $data);
+ }
+
+ public function fetchLogbooks() {
+ $this->load->model('logbooks_model');
+ $hres=[];
+ $result = $this->logbooks_model->show_all()->result();
+ foreach ($result as $entry) {
+ $single=(Object)[];
+ $single->logbook_id=$entry->logbook_id;
+ $single->logbook_name=$entry->logbook_name;
+ $single->logbook_state=$this->lbstate2html($entry->logbook_id);
+ $single->logbook_edit=$this->lbedit2html($entry->logbook_id,$entry->logbook_name);
+ $single->logbook_delete=$this->lbdel2html($entry->logbook_id,$entry->logbook_name);
+ $single->logbook_link=$this->lblnk2html($entry->public_slug,$entry->logbook_name);
+ $single->logbook_publicsearch = $this->lbpublicsearch2html($entry->public_search);
+ array_push($hres,$single);
+ }
+ echo json_encode($hres);
+ }
+
+ private function lbpublicsearch2html($publicsearch) {
+ return ($publicsearch=='1' ? 'Enabled' : 'Disabled');
+
+ }
+
+ private function lbstate2html($id) {
+ if($this->session->userdata('active_station_logbook') != $id) {
+ $htmret='';
+ } else {
+ $htmret="" . lang('station_logbooks_active_logbook') . "";
+ }
+ return $htmret;
+ }
+
+ private function lbdel2html($id, $logbook_name) {
+ if($this->session->userdata('active_station_logbook') != $id) {
+ $htmret='';
+ } else {
+ $htmret='';
+ }
+ return $htmret;
+ }
+
+ private function lblnk2html($public_slug, $logbook_name) {
+ if($public_slug != '') {
+ $htmret='';
+ } else {
+ $htmret='';
+ }
+ return $htmret;
+ }
+
+ private function lbps2html($id, $logbook_name) {
+ return '';
+ }
+
+ private function lbedit2html($id, $logbook_name) {
+ return '';
+ }
+
+ public function fetchLocations() {
+ $this->load->model('stations');
+ $this->load->model('Logbook_model');
+
+ $result = $this->stations->all_with_count()->result();
+ $current_active = $this->stations->find_active();
+ $data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id();
+
+ $quickswitch_enabled = ($this->user_options_model->get_options('header_menu', array('option_name'=>'locations_quickswitch'))->row()->option_value ?? 'false');
+
+ $hres=[];
+ foreach ($result as $entry) {
+ $single=(Object)[];
+ $single->station_id = $this->stationid2html($entry->station_id);
+ $single->station_name = $entry->station_profile_name;
+ $single->station_callsign = $entry->station_callsign;
+ $single->station_country = $this->stationcountry2html($entry->station_country, $entry->dxcc_end);
+ $single->station_gridsquare = $entry->station_gridsquare;
+ $single->station_badge = $this->stationbadge2html($entry->station_active, $entry->qso_total, $current_active, $entry->station_profile_name,$entry->station_id);
+ $single->station_edit = $this->stationedit2html($entry->station_id);
+ $single->station_emptylog = $this->stationemptylog2html($entry->station_id);
+ $single->station_copylog = $this->stationcopy2html($entry->station_id);
+ $single->station_delete = $this->stationdelete2html($entry->station_id, $entry->station_profile_name, $entry->station_active);
+ $single->station_favorite = $this->stationfavorite2html($entry->station_id, $quickswitch_enabled);
+ array_push($hres,$single);
+ }
+ echo json_encode($hres);
+ }
+
+ private function stationfavorite2html($id, $quickswitch_enabled) {
+ if ($quickswitch_enabled == 'false') {
+ return '';
+ }
+
+ $locationFavorite = ($this->user_options_model->get_options('station_location', array('option_name'=>'is_favorite', 'option_key'=>$id))->row()->option_value ?? 'false');
+ if ($locationFavorite == 'true') {
+ $favStarClasses = 'class="setFavorite fas fa-star btn btn-sm" style="color: #ffc82b;"';
+ } else {
+ $favStarClasses = 'class="setFavorite far fa-star btn btn-sm" style="color: #a58118;"';
+ }
+ return '