From 831f2499388d7047925c2e95e41edb5b3f088a39 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 23 Aug 2021 17:34:00 +0100 Subject: [PATCH] Built interface to display station locations when editing Station Logbooks --- application/controllers/Logbooks.php | 2 ++ application/controllers/Station.php | 3 ++- application/models/Stations.php | 10 +++++----- application/views/logbooks/edit.php | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/application/controllers/Logbooks.php b/application/controllers/Logbooks.php index fbdda849..4a6cf7ad 100644 --- a/application/controllers/Logbooks.php +++ b/application/controllers/Logbooks.php @@ -54,12 +54,14 @@ class Logbooks extends CI_Controller { $this->load->library('form_validation'); $this->load->model('logbooks_model'); + $this->load->model('stations'); $station_logbook_id = $this->security->xss_clean($id); $station_logbook_details_query = $this->logbooks_model->logbook($station_logbook_id); $data['station_logbook_details'] = $station_logbook_details_query->row(); + $data['station_locations_list'] = $this->stations->all(); $data['page_title'] = "Edit Station Logbook"; diff --git a/application/controllers/Station.php b/application/controllers/Station.php index 3b332cc2..35ce839a 100644 --- a/application/controllers/Station.php +++ b/application/controllers/Station.php @@ -102,8 +102,9 @@ class Station extends CI_Controller { // $id is the profile id $this->load->model('stations'); $this->stations->claim_user($id); + + echo $this->session->userdata('user_id'); - //$this->stations->logbook_session_data(); redirect('station'); } diff --git a/application/models/Stations.php b/application/models/Stations.php index 57ffe5fc..d774656e 100644 --- a/application/models/Stations.php +++ b/application/models/Stations.php @@ -20,6 +20,7 @@ class Stations extends CI_Model { } function all() { + $this->db->where('station_profile.user_id', $this->session->userdata('user_id')); return $this->db->get('station_profile'); } @@ -117,13 +118,12 @@ class Stations extends CI_Model { } function claim_user($id) { - $data = array( - 'user_id' => $this->session->userdata('user_id') + 'user_id' => $this->session->userdata('user_id'), ); - - $this->db->where('station_id', xss_clean($id, true)); - $this->db->update('station_profile', $data); + + $this->db->where('station_id', $id); + $this->db->update('station_profile', $data); } function set_active($current, $new) { diff --git a/application/views/logbooks/edit.php b/application/views/logbooks/edit.php index 542984f2..d459cb87 100644 --- a/application/views/logbooks/edit.php +++ b/application/views/logbooks/edit.php @@ -36,6 +36,23 @@ + +
+
+
Station Locations
+
+
+ + + Hold down the Ctrl (windows) or Command (Mac) button to select multiple options. +
+
+
+