diff --git a/application/controllers/Backup.php b/application/controllers/Backup.php index 2a34eacf..60aac213 100644 --- a/application/controllers/Backup.php +++ b/application/controllers/Backup.php @@ -10,7 +10,7 @@ class Backup extends CI_Controller { public function index() { $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'); } + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } $data['page_title'] = "Backup"; @@ -23,7 +23,7 @@ class Backup extends CI_Controller { public function adif($key = null){ if ($key == null) { $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'); } + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } } $this->load->helper('file'); @@ -58,7 +58,7 @@ class Backup extends CI_Controller { public function notes($key = null) { if ($key == null) { $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'); } + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } } $this->load->helper('file'); diff --git a/application/controllers/Maintenance.php b/application/controllers/Maintenance.php new file mode 100644 index 00000000..0e0deb2f --- /dev/null +++ b/application/controllers/Maintenance.php @@ -0,0 +1,56 @@ +load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $this->load->model('Logbook_model'); + $this->load->model('Stations'); + $data['stations']=$this->Stations->all(); + $data['page_title'] = "Maintenance"; + $data['is_there_qsos_with_no_station_id'] = $this->Logbook_model->check_for_station_id(); + if ($data['is_there_qsos_with_no_station_id']) { + $data['calls_wo_sid']=$this->Logbook_model->calls_without_station_id(); + } + $this->load->view('interface_assets/header', $data); + $this->load->view('maintenance/main'); + $this->load->view('interface_assets/footer'); + } + + public function reassign() { + $this->load->model('user_model'); + if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); } + $this->load->model('Logbook_model'); + $this->load->model('Stations'); + $call = xss_clean(($this->input->post('call'))); + $station_profile_id = xss_clean(($this->input->post('station_id'))); + + // Check if target-station-id exists + $allowed=false; + $status=false; + $stations=$this->Stations->all(); + foreach ($stations->result() as $station) { + if ($station->station_id == $station_profile_id) { $allowed=true; } + } + if ($allowed) { + log_message("error",$call." to ".$station_profile_id); + $status=$this->Logbook_model->update_all_station_ids($station_profile_id,$call); + } else { + $status=false; + } + + header('Content-Type: application/json'); + echo json_encode(array('status' => $status)); + return; + + } + +} + +/* End of file Backup.php */ diff --git a/application/controllers/Station.php b/application/controllers/Station.php index b0e8ceb4..c037bbbb 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -19,6 +19,9 @@ class Station extends CI_Controller { { $this->load->model('stations'); $this->load->model('Logbook_model'); + $this->load->model('user_model'); + + $data['is_admin'] = ($this->user_model->authorize(99)); $data['stations'] = $this->stations->all_with_count(); $data['current_active'] = $this->stations->find_active(); @@ -156,13 +159,6 @@ class Station extends CI_Controller { redirect('station'); } - function assign_all() { - $this->load->model('Logbook_model'); - $this->Logbook_model->update_all_station_ids(); - - redirect('station'); - } - public function delete($id) { $this->load->model('stations'); if ($this->stations->check_station_is_accessible($id)) { @@ -171,7 +167,7 @@ class Station extends CI_Controller { redirect('station'); } - public function deletelog($id) { + public function deletelog($id) { $this->load->model('stations'); if ($this->stations->check_station_is_accessible($id)) { $this->stations->deletelog($id); diff --git a/application/language/english/menu_lang.php b/application/language/english/menu_lang.php index 7b72a7f6..7a02243b 100644 --- a/application/language/english/menu_lang.php +++ b/application/language/english/menu_lang.php @@ -83,3 +83,5 @@ $lang['menu_hardware_interfaces'] = 'Hardware Interfaces'; $lang['menu_help'] = 'Help'; $lang['menu_forum'] = 'Forum'; $lang['menu_logout'] = 'Logout'; + +$lang['menu_maintenance']='Maintenance'; diff --git a/application/language/german/menu_lang.php b/application/language/german/menu_lang.php index 1efedc0a..899d5e29 100644 --- a/application/language/german/menu_lang.php +++ b/application/language/german/menu_lang.php @@ -83,3 +83,5 @@ $lang['menu_hardware_interfaces'] = 'Hardware-Schnittstellen'; $lang['menu_help'] = 'Hilfe'; $lang['menu_forum'] = 'Forum'; $lang['menu_logout'] = 'Logout'; + +$lang['menu_maintenance'] = 'Wartung'; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index fa43b050..8ee41eae 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -3850,6 +3850,12 @@ class Logbook_model extends CI_Model { $this->db->trans_complete(); } + public function calls_without_station_id() { + $query=$this->db->query("select distinct COL_STATION_CALLSIGN from ".$this->config->item('table_name')." where station_id is null or station_id = ''"); + $result = $query->result_array(); + return $result; + } + public function check_for_station_id() { $this->db->where('station_id =', NULL); $query = $this->db->get($this->config->item('table_name')); @@ -3909,14 +3915,20 @@ class Logbook_model extends CI_Model { } } - public function update_all_station_ids() { + public function update_all_station_ids($station_id,$station_callsign) { - $data = array( - 'station_id' => '1', - ); + $data = array( + 'station_id' => $station_id, + ); - $this->db->where(array('station_id' => NULL)); - return $this->db->update($this->config->item('table_name'), $data); + $this->db->where(array('station_id' => NULL)); + $this->db->where('col_station_callsign', $station_callsign); + $this->db->update($this->config->item('table_name'), $data); + if ($this->db->affected_rows() > 0) { + return TRUE; + } else { + return FALSE; + } } public function parse_frequency($frequency) diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index fb39c023..9c9e2afe 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -77,6 +77,10 @@ function load_was_map() { +uri->segment(1) == "maintenance" ) { ?> + + + uri->segment(1) == "adif" ) { ?> diff --git a/application/views/interface_assets/header.php b/application/views/interface_assets/header.php index c2adedfc..9c2fe0f7 100644 --- a/application/views/interface_assets/header.php +++ b/application/views/interface_assets/header.php @@ -182,6 +182,10 @@ + + + + diff --git a/application/views/maintenance/main.php b/application/views/maintenance/main.php new file mode 100644 index 00000000..bcc2b22a --- /dev/null +++ b/application/views/maintenance/main.php @@ -0,0 +1,57 @@ +
+
+ session->flashdata('message')) { ?> + +
+

session->flashdata('message'); ?>

+
+ + +

+ +
+
+ Maintenance +
+= 1) { ?> + +
+

Please reassign those QSOs to an existing station location:

+ + +
+ + + + + + + + + + '; + } ?> +
CallTarget LocationReassign
'.$call['COL_STATION_CALLSIGN'].'
+
+
+ + + + +
+ + +
+ diff --git a/application/views/station_profile/index.php b/application/views/station_profile/index.php index 99fa96b7..9ec57b3e 100644 --- a/application/views/station_profile/index.php +++ b/application/views/station_profile/index.php @@ -29,11 +29,11 @@ - = 1) { ?> + = 1) && ($is_admin)) { ?> @@ -68,9 +68,6 @@ Active Station - = 1) { ?> - Reassign -
ID: station_id;?> qso_total;?> QSOs diff --git a/assets/js/sections/maintenance.js b/assets/js/sections/maintenance.js new file mode 100644 index 00000000..69cb91e3 --- /dev/null +++ b/assets/js/sections/maintenance.js @@ -0,0 +1,12 @@ +function reassign(call,target_profile_id) { + $.ajax({ + url: base_url + 'index.php/maintenance/reassign', + type: 'post', + data: {'call': call, 'station_id': target_profile_id}, + success: function (resu) { + if (resu.status) { + location.reload(); + } + } + }); +}