diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 2ed4684b..0eb0c665 100644 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -35,6 +35,7 @@ class Logbook extends CI_Controller } $this->load->model('logbook_model'); + $this->load->model('logbooks_model'); $this->load->library('pagination'); $config['base_url'] = base_url() . 'index.php/logbook/index/'; @@ -72,6 +73,10 @@ class Logbook extends CI_Controller + // Get available logbooks and stations for the switcher + $data['available_logbooks'] = $this->logbooks_model->show_all(); + $data['available_stations'] = $this->stations->all_of_user(); + // load the view $data['page_title'] = "Logbook"; diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php index d99baa8b..70457660 100644 --- a/application/controllers/Logbooks.php +++ b/application/controllers/Logbooks.php @@ -183,4 +183,40 @@ class Logbooks extends CI_Controller { } } + public function switch_logbook_location() { + $this->load->model('logbooks_model'); + $this->load->model('stations'); + + $logbook_id = $this->input->post('logbook_id'); + $station_id = $this->input->post('station_id'); + + $success = true; + $messages = array(); + + // Switch logbook if provided and different from current + if ($logbook_id && $logbook_id != $this->session->userdata('active_station_logbook')) { + $this->logbooks_model->set_logbook_active($logbook_id); + $messages[] = 'Logbook switched to: ' . $this->logbooks_model->find_name($logbook_id); + } + + // Switch station location if provided and different from current + if ($station_id && $station_id != $this->stations->find_active()) { + $current_station = $this->stations->find_active(); + $this->stations->set_active($current_station, $station_id); + $station_name = $this->stations->profile_clean($station_id); + $messages[] = 'Location switched to: ' . $station_name->station_profile_name; + } + + // Update session data + $this->user_model->update_session($this->session->userdata('user_id')); + + // Set flash message + if (!empty($messages)) { + $this->session->set_flashdata('notice', implode('. ', $messages)); + } + + // Redirect back to logbook view + redirect('logbook'); + } + } diff --git a/application/views/view_log/index.php b/application/views/view_log/index.php index 5cd0afa1..fe8b6128 100644 --- a/application/views/view_log/index.php +++ b/application/views/view_log/index.php @@ -1,7 +1,42 @@ @@ -23,3 +58,30 @@
load->view('view_log/partial/log_ajax') ?> + + diff --git a/cloudlog-switcher-both-changed.png b/cloudlog-switcher-both-changed.png new file mode 100644 index 00000000..387780a2 Binary files /dev/null and b/cloudlog-switcher-both-changed.png differ diff --git a/cloudlog-switcher-changed.png b/cloudlog-switcher-changed.png new file mode 100644 index 00000000..acf65381 Binary files /dev/null and b/cloudlog-switcher-changed.png differ diff --git a/cloudlog-switcher-demo.png b/cloudlog-switcher-demo.png new file mode 100644 index 00000000..28d1f402 Binary files /dev/null and b/cloudlog-switcher-demo.png differ