2024-02-09 11:05:28 +01:00
|
|
|
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
2019-01-01 19:14:25 +00:00
|
|
|
|
|
|
|
|
/*
|
2019-05-14 11:25:57 +01:00
|
|
|
Handles Displaying of information for station tools.
|
2019-01-01 19:14:25 +00:00
|
|
|
*/
|
|
|
|
|
|
2024-02-09 11:05:28 +01:00
|
|
|
class Station extends CI_Controller
|
|
|
|
|
{
|
2019-01-01 19:14:25 +00:00
|
|
|
|
2019-01-08 22:54:29 +00:00
|
|
|
function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->load->helper(array('form', 'url'));
|
|
|
|
|
|
|
|
|
|
$this->load->model('user_model');
|
2024-02-09 11:05:28 +01:00
|
|
|
if (!$this->user_model->authorize(2)) {
|
2024-08-16 10:08:44 +02:00
|
|
|
$this->session->set_flashdata('error', __("You're not allowed to do that!"));
|
2024-02-09 11:05:28 +01:00
|
|
|
redirect('dashboard');
|
|
|
|
|
}
|
2019-01-08 22:54:29 +00:00
|
|
|
}
|
|
|
|
|
|
2024-02-09 11:05:28 +01:00
|
|
|
public function create()
|
|
|
|
|
{
|
2019-01-01 19:14:25 +00:00
|
|
|
$this->load->model('stations');
|
|
|
|
|
$this->load->model('dxcc');
|
|
|
|
|
$data['dxcc_list'] = $this->dxcc->list();
|
|
|
|
|
|
2023-07-30 09:05:51 +00:00
|
|
|
$this->load->model('logbook_model');
|
|
|
|
|
$data['iota_list'] = $this->logbook_model->fetchIota();
|
2020-10-06 23:47:39 +02:00
|
|
|
|
2019-01-01 19:14:25 +00:00
|
|
|
$this->load->library('form_validation');
|
|
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('station_profile_name', 'Station Profile Name', 'required');
|
2024-10-09 07:51:49 +00:00
|
|
|
$this->form_validation->set_rules('dxcc', 'DXCC', 'required');
|
2019-01-01 19:14:25 +00:00
|
|
|
|
2024-02-09 11:05:28 +01:00
|
|
|
if ($this->form_validation->run() == FALSE) {
|
2024-06-06 21:32:42 +02:00
|
|
|
$data['page_title'] = __("Create Station Location");
|
2019-01-09 15:18:46 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2019-01-01 19:14:25 +00:00
|
|
|
$this->load->view('station_profile/create');
|
2019-01-09 15:18:46 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2024-02-09 11:05:28 +01:00
|
|
|
} else {
|
2024-03-03 21:52:51 +01:00
|
|
|
$this->stations->add();
|
|
|
|
|
redirect('stationsetup');
|
2019-01-01 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
public function edit($id) {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2023-07-30 09:05:51 +00:00
|
|
|
$this->load->model('stations');
|
|
|
|
|
if ($this->stations->check_station_is_accessible($id)) {
|
|
|
|
|
$data = $this->load_station_for_editing($id);
|
2024-06-06 21:32:42 +02:00
|
|
|
$data['page_title'] = __("Edit Station Location: ") . $data['my_station_profile']->station_profile_name;
|
2022-08-17 08:16:44 +02:00
|
|
|
|
2024-10-09 07:51:49 +00:00
|
|
|
$this->form_validation->set_rules('dxcc', 'DXCC', 'required');
|
2023-07-30 09:05:51 +00:00
|
|
|
if ($this->form_validation->run() == FALSE) {
|
|
|
|
|
$this->load->view('interface_assets/header', $data);
|
|
|
|
|
$this->load->view('station_profile/edit');
|
|
|
|
|
$this->load->view('interface_assets/footer');
|
|
|
|
|
} else {
|
2024-03-03 21:52:51 +01:00
|
|
|
if ($this->stations->edit()) {
|
2024-06-06 21:32:42 +02:00
|
|
|
$data['notice'] = __("Station Location") . $this->security->xss_clean($this->input->post('station_profile_name', true)) . " Updated";
|
2023-11-29 14:17:58 +01:00
|
|
|
}
|
2024-11-11 20:33:17 +01:00
|
|
|
// Also clean up static map images
|
2024-10-31 10:26:59 +01:00
|
|
|
if (!$this->load->is_loaded('staticmap_model')) {
|
|
|
|
|
$this->load->model('staticmap_model');
|
|
|
|
|
}
|
|
|
|
|
$this->staticmap_model->remove_static_map_image($id);
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2023-07-30 09:05:51 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2022-08-17 08:16:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
public function copy($id) {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2023-07-30 09:05:51 +00:00
|
|
|
$this->load->model('stations');
|
|
|
|
|
if ($this->stations->check_station_is_accessible($id)) {
|
|
|
|
|
$data = $this->load_station_for_editing($id);
|
2024-06-08 11:01:59 +02:00
|
|
|
$data['page_title'] = __("Duplicate Station Location:"). "{$data['my_station_profile']->station_profile_name}";
|
2023-07-30 09:05:51 +00:00
|
|
|
|
|
|
|
|
// we NULLify station_id and station_profile_name to make sure we are creating a new station
|
|
|
|
|
$data['copy_from'] = $data['my_station_profile']->station_id;
|
|
|
|
|
$data['my_station_profile']->station_id = NULL;
|
|
|
|
|
$data['my_station_profile']->station_profile_name = '';
|
|
|
|
|
|
2024-02-09 11:05:28 +01:00
|
|
|
if ($this->form_validation->run() == FALSE) {
|
2023-07-30 09:05:51 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
|
|
|
|
$this->load->view('station_profile/edit');
|
|
|
|
|
$this->load->view('interface_assets/footer');
|
2024-02-09 11:05:28 +01:00
|
|
|
} else {
|
2023-07-30 09:05:51 +00:00
|
|
|
$this->stations->add();
|
|
|
|
|
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2023-07-30 09:05:51 +00:00
|
|
|
}
|
|
|
|
|
} else {
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2022-08-17 08:16:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
public function edit_favourite($id) {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2024-03-03 21:52:51 +01:00
|
|
|
$this->load->model('stations');
|
|
|
|
|
$this->stations->edit_favourite($id);
|
|
|
|
|
|
|
|
|
|
redirect('stationsetup');
|
2024-02-09 11:05:28 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
function load_station_for_editing($id): array {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2019-10-03 22:18:14 +01:00
|
|
|
$this->load->library('form_validation');
|
|
|
|
|
|
|
|
|
|
$this->load->model('stations');
|
|
|
|
|
$this->load->model('dxcc');
|
2022-08-17 08:16:44 +02:00
|
|
|
$this->load->model('logbook_model');
|
2020-10-06 23:47:39 +02:00
|
|
|
|
2022-08-17 08:16:44 +02:00
|
|
|
$data['iota_list'] = $this->logbook_model->fetchIota();
|
2019-10-03 22:18:14 +01:00
|
|
|
|
2019-10-05 19:16:05 +01:00
|
|
|
$item_id_clean = $this->security->xss_clean($id);
|
|
|
|
|
|
2024-03-03 21:52:51 +01:00
|
|
|
$data['my_station_profile'] = $this->stations->profile_full($item_id_clean);
|
2019-10-03 22:18:14 +01:00
|
|
|
|
2022-08-17 08:16:44 +02:00
|
|
|
$data['dxcc_list'] = $this->dxcc->list();
|
2019-10-03 22:18:14 +01:00
|
|
|
|
|
|
|
|
$this->form_validation->set_rules('station_profile_name', 'Station Profile Name', 'required');
|
|
|
|
|
|
2022-08-17 08:16:44 +02:00
|
|
|
return $data;
|
2019-01-01 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
2021-08-23 15:50:19 +01:00
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
function reassign_profile($id) {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2024-02-07 17:29:32 +00:00
|
|
|
// $id is the profile that needs reassigned to QSOs // ONLY Admin can do that!
|
2019-09-23 17:29:22 +01:00
|
|
|
$this->load->model('stations');
|
2024-02-07 17:29:32 +00:00
|
|
|
if ($this->user_model->authorize(99)) {
|
|
|
|
|
$this->stations->reassign($id);
|
|
|
|
|
}
|
2022-08-17 08:16:44 +02:00
|
|
|
|
2019-09-23 17:29:22 +01:00
|
|
|
//$this->stations->logbook_session_data();
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2019-09-23 17:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
function set_active($current, $new, $is_ajax = null) {
|
|
|
|
|
$current = $this->security->xss_clean($current);
|
|
|
|
|
$new = $this->security->xss_clean($new);
|
2019-09-23 17:29:22 +01:00
|
|
|
$this->load->model('stations');
|
|
|
|
|
$this->stations->set_active($current, $new);
|
2024-03-03 21:52:51 +01:00
|
|
|
|
2024-02-09 11:05:28 +01:00
|
|
|
if ($is_ajax != null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-03 21:52:51 +01:00
|
|
|
|
|
|
|
|
redirect('stationsetup');
|
2019-09-23 17:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
public function delete($id) {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2019-01-01 19:14:25 +00:00
|
|
|
$this->load->model('stations');
|
2023-07-30 09:05:51 +00:00
|
|
|
if ($this->stations->check_station_is_accessible($id)) {
|
|
|
|
|
$this->stations->delete($id);
|
|
|
|
|
}
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2019-01-01 19:14:25 +00:00
|
|
|
}
|
|
|
|
|
|
2024-10-31 10:26:59 +01:00
|
|
|
public function deletelog($id) {
|
|
|
|
|
$id = $this->security->xss_clean($id);
|
2024-02-09 11:05:28 +01:00
|
|
|
$this->load->model('stations');
|
|
|
|
|
if ($this->stations->check_station_is_accessible($id)) {
|
|
|
|
|
$this->stations->deletelog($id);
|
|
|
|
|
}
|
2024-03-03 21:52:51 +01:00
|
|
|
redirect('stationsetup');
|
2023-07-30 09:05:51 +00:00
|
|
|
}
|
2020-02-07 14:54:49 +01:00
|
|
|
|
2022-08-17 08:16:44 +02:00
|
|
|
}
|