Return macros as json

这个提交包含在:
Peter Goodhall 2023-08-01 11:40:32 +01:00
父节点 43bacdc62a
当前提交 9ddcb70588
共有 2 个文件被更改,包括 26 次插入1 次删除

查看文件

@ -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');

查看文件

@ -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']);