diff --git a/application/controllers/Qso.php b/application/controllers/Qso.php index b633c4be..c0f49820 100755 --- a/application/controllers/Qso.php +++ b/application/controllers/Qso.php @@ -207,6 +207,16 @@ class QSO extends CI_Controller { echo "Macros Saved, Press Close and lets get sending!"; } + function cwmacros_json() { + // Load model Winkey + $this->load->model('winkey'); + + header('Content-Type: application/json; charset=utf-8'); + + // Call settings_json from model winkey + echo $this->winkey->settings_json($this->session->userdata('user_id'), $this->session->userdata('station_profile_id')); + } + function edit_ajax() { $this->load->model('logbook_model'); diff --git a/application/models/Winkey.php b/application/models/Winkey.php index 94c96009..43938fd4 100644 --- a/application/models/Winkey.php +++ b/application/models/Winkey.php @@ -7,7 +7,7 @@ class Winkey extends CI_Model $this->db->where('user_id', $user_id); $this->db->where('station_location_id', $station_location_id); $query = $this->db->get('cwmacros'); - + if ($query->num_rows() > 0) { return $query->row(); } else { @@ -15,6 +15,21 @@ class Winkey extends CI_Model } } + public function settings_json($user_id, $station_location_id) + { + $this->db->where('user_id', $user_id); + $this->db->where('station_location_id', $station_location_id); + $query = $this->db->get('cwmacros'); + + if ($query->num_rows() > 0) { + // return $query->row() as json + return json_encode($query->row()); + } else { + // return json with status not found + return json_encode(array('status' => 'not found')); + } + } + public function save($data) { $this->db->where('user_id', $data['user_id']);