From 044e1b2da4b50149f713f740bc609e131fe8b11e Mon Sep 17 00:00:00 2001 From: HB9HIL Date: Sat, 17 Feb 2024 15:42:00 +0100 Subject: [PATCH] get state list in lookup --- application/controllers/Lookup.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/application/controllers/Lookup.php b/application/controllers/Lookup.php index 933fa4ff7..d92be2bb7 100644 --- a/application/controllers/Lookup.php +++ b/application/controllers/Lookup.php @@ -129,4 +129,26 @@ class Lookup extends CI_Controller { } } + public function get_state_list() { + $this->load->library('subdivisions'); + + $dxcc = $this->input->post('dxcc'); + $states_result = $this->subdivisions->get_state_list($dxcc); + $subdivision_name = $this->subdivisions->get_primary_subdivision_name($dxcc); + + if ($states_result->num_rows() > 0) { + $states_array = $states_result->result_array(); + $result = array( + 'status' => 'ok', + 'subdivision_name' => $subdivision_name, + 'data' => $states_array + ); + header('Content-Type: application/json'); + echo json_encode($result); + } else { + header('Content-Type: application/json'); + echo json_encode(array('status' => 'No States for this DXCC in Database')); + } + } + }