From fac37ca657ca3aa595677bc39fd7a7cb26f714dd Mon Sep 17 00:00:00 2001 From: int2001 Date: Tue, 1 Aug 2023 08:42:34 +0000 Subject: [PATCH] Added controller --- application/controllers/Maintenance.php | 56 +++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 application/controllers/Maintenance.php 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 */