diff --git a/application/config/migration.php b/application/config/migration.php index 70bc112e..51eebc64 100644 --- a/application/config/migration.php +++ b/application/config/migration.php @@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE; | */ -$config['migration_version'] = 137; +$config['migration_version'] = 138; /* |-------------------------------------------------------------------------- diff --git a/application/controllers/User_options.php b/application/controllers/User_options.php new file mode 100755 index 00000000..3aa337de --- /dev/null +++ b/application/controllers/User_options.php @@ -0,0 +1,52 @@ +load->model('user_model'); + $this->load->model('user_options_model'); + if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + } + + public function add_edit_fav() { + $obj = json_decode(file_get_contents("php://input"), true); + foreach($obj as $option_key => $option_value) { + $obj[$option_key]=$this->security->xss_clean($option_value); + } + if ($obj['sat_name'] ?? '' != '') { + $option_name=$obj['sat_name'].'/'.$obj['mode']; + } else { + $option_name=$obj['band'].'/'.$obj['mode']; + } + $this->user_options_model->set_option('Favourite',$option_name, $obj); + $jsonout['success']=1; + header('Content-Type: application/json'); + echo json_encode($jsonout); + } + + public function get_fav() { + $result=$this->user_options_model->get_options('Favourite'); + $jsonout=[]; + foreach($result->result() as $options) { + $jsonout[$options->option_name][$options->option_key]=$options->option_value; + } + header('Content-Type: application/json'); + echo json_encode($jsonout); + } + + public function del_fav() { + $result=$this->user_options_model->get_options('Favourite'); + $obj = json_decode(file_get_contents("php://input"), true); + if ($obj['option_name'] ?? '' != '') { + $option_name=$this->security->xss_clean($obj['option_name']); + $this->user_options_model->del_option('Favourite',$option_name); + } + $jsonout['success']=1; + header('Content-Type: application/json'); + echo json_encode($jsonout); + } +} + + +?> diff --git a/application/language/english/qso_lang.php b/application/language/english/qso_lang.php index 3b27929f..c8acea22 100644 --- a/application/language/english/qso_lang.php +++ b/application/language/english/qso_lang.php @@ -32,3 +32,4 @@ $lang['qso_btn_edit_qso'] = 'Edit QSO'; // QSO Details $lang['qso_details'] = 'QSO Details'; +$lang['fav_add'] = 'Add Band/Mode to Favs'; diff --git a/application/language/german/qso_lang.php b/application/language/german/qso_lang.php index 0f1b0949..d7dfd357 100644 --- a/application/language/german/qso_lang.php +++ b/application/language/german/qso_lang.php @@ -32,3 +32,5 @@ $lang['qso_btn_edit_qso'] = 'Editiere QSO'; // QSO Details $lang['qso_details'] = 'QSO Details'; + +$lang['fav_add'] = 'Band/Mode zu Favoriten hinzufügen'; diff --git a/application/migrations/138_user_options_table.php b/application/migrations/138_user_options_table.php new file mode 100644 index 00000000..8961d37d --- /dev/null +++ b/application/migrations/138_user_options_table.php @@ -0,0 +1,19 @@ +db->table_exists('user_options')) { + $this->db->query("CREATE TABLE `user_options` ( `user_id` int(11) NOT NULL, `option_type` varchar(45) NOT NULL, `option_name` varchar(45) NOT NULL, `option_key` varchar(45) NOT NULL, `option_value` varchar(45) DEFAULT NULL, PRIMARY KEY (`user_id`,`option_type`,`option_key`,`option_name`))"); + } + + } + + public function down(){ + if ($this->db->table_exists('user_options')) { + $this->dbforge->drop_table('user_options'); + } + } +} diff --git a/application/models/User_options_model.php b/application/models/User_options_model.php new file mode 100644 index 00000000..9a383338 --- /dev/null +++ b/application/models/User_options_model.php @@ -0,0 +1,33 @@ +db->where('user_id', $this->session->userdata('user_id')); + $this->db->where('option_type', $option_type); + return $this->db->get('user_options'); + } + + public function set_option($option_type, $option_name, $option_array) { + $uid=$this->session->userdata('user_id'); + $sql='insert into user_options (user_id,option_type,option_name,option_key,option_value) values (?,?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?'; + foreach($option_array as $option_key => $option_value) { + $query = $this->db->query($sql, array($uid, $option_type, $option_name, $option_key, $option_value, $option_value)); + } + } + + public function get_options($option_type) { + $uid=$this->session->userdata('user_id'); + $sql='select option_name,option_key,option_value from user_options where user_id=? and option_type=?'; + return $this->db->query($sql, array($uid, $option_type)); + } + + public function del_option($option_type, $option_name) { + $uid=$this->session->userdata('user_id'); + $sql='delete from user_options where user_id=? and option_type=? and option_name=?'; + return $this->db->query($sql, array($uid, $option_type,$option_name)); + } + +} + +?> diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 4a8ac031..a977cc9b 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -34,7 +34,17 @@ - + + + +
diff --git a/assets/css/general.css b/assets/css/general.css index b9ad60e1..053fd499 100644 --- a/assets/css/general.css +++ b/assets/css/general.css @@ -520,4 +520,11 @@ div#station_logbooks_linked_table_paginate { #advancedmap { height: calc(100vh - 280px) !important; max-height: 1000px !important; + +.lotw-cert-list table { + margin-bottom: 0px; +} + +.qso_panel a i.fa.fa-star:hover { + color: #FFD700 !important; } \ No newline at end of file diff --git a/assets/js/sections/qso.js b/assets/js/sections/qso.js index a558465b..9e2c92d2 100644 --- a/assets/js/sections/qso.js +++ b/assets/js/sections/qso.js @@ -1,5 +1,81 @@ $( document ).ready(function() { +var favs={}; + get_fav(); + + $('#fav_add').click(function (event) { + save_fav(); + }); + + $(document).on("click", "#fav_del", function (event) { + del_fav($(this).attr('name')); + }); + + $(document).on("click", "#fav_recall", function (event) { + $('#sat_name').val(favs[this.innerText].sat_name); + $('#sat_mode').val(favs[this.innerText].sat_mode); + $('#band_rx').val(favs[this.innerText].band_rx); + $('#band').val(favs[this.innerText].band); + $('#frequency_rx').val(favs[this.innerText].frequency_rx); + $('#frequency').val(favs[this.innerText].frequency); + $('#selectPropagation').val(favs[this.innerText].prop_mode); + $('#mode').val(favs[this.innerText].mode); + }); + + + function del_fav(name) { + if (confirm("Are you sure to delete Fav?")) { + $.ajax({ + url: base_url+'index.php/user_options/del_fav', + method: 'POST', + dataType: 'json', + contentType: "application/json; charset=utf-8", + data: JSON.stringify({ "option_name": name }), + success: function(result) { + get_fav(); + } + }); + } + } + + function get_fav() { + $.ajax({ + url: base_url+'index.php/user_options/get_fav', + method: 'GET', + dataType: 'json', + contentType: "application/json; charset=utf-8", + success: function(result) { + $("#fav_menu").empty(); + for (const key in result) { + $("#fav_menu").append(''); + } + favs=result; + } + }); + } + + function save_fav() { + var payload={}; + payload.sat_name=$('#sat_name').val(); + payload.sat_mode=$('#sat_mode').val(); + payload.band_rx=$('#band_rx').val(); + payload.band=$('#band').val(); + payload.frequency_rx=$('#frequency_rx').val(); + payload.frequency=$('#frequency').val(); + payload.prop_mode=$('#selectPropagation').val(); + payload.mode=$('#mode').val(); + $.ajax({ + url: base_url+'index.php/user_options/add_edit_fav', + method: 'POST', + dataType: 'json', + contentType: "application/json; charset=utf-8", + data: JSON.stringify(payload), + success: function(result) { + get_fav(); + } + }); + } + var bc_bandmap = new BroadcastChannel('qso_window'); bc_bandmap.onmessage = function (ev) {