diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index a7079d9f..07a00f79 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -3,75 +3,75 @@ class Logbook extends CI_Controller { - function index() - { - $this->load->model('user_model'); - if(!$this->user_model->authorize($this->config->item('auth_mode'))) { - if($this->user_model->validate_session()) { - $this->user_model->clear_session(); - show_error('Access denied
Click here to log in as another user', 403); - } else { - redirect('user/login'); - } - } + function index() + { + $this->load->model('user_model'); + if(!$this->user_model->authorize($this->config->item('auth_mode'))) { + if($this->user_model->validate_session()) { + $this->user_model->clear_session(); + show_error('Access denied
Click here to log in as another user', 403);
+ } else {
+ redirect('user/login');
+ }
+ }
- $this->load->library('pagination');
- $config['base_url'] = base_url().'index.php/logbook/index/';
- $config['total_rows'] = $this->db->count_all($this->config->item('table_name'));
- $config['per_page'] = '25';
- $config['num_links'] = 6;
- $config['full_tag_open'] = '';
- $config['full_tag_close'] = '';
- $config['cur_tag_open'] = '';
- $config['cur_tag_close'] = '';
+ $this->load->library('pagination');
+ $config['base_url'] = base_url().'index.php/logbook/index/';
+ $config['total_rows'] = $this->db->count_all($this->config->item('table_name'));
+ $config['per_page'] = '25';
+ $config['num_links'] = 6;
+ $config['full_tag_open'] = '';
+ $config['full_tag_close'] = '';
+ $config['cur_tag_open'] = '';
+ $config['cur_tag_close'] = '';
- $this->pagination->initialize($config);
+ $this->pagination->initialize($config);
- //load the model and get results
- $this->load->model('logbook_model');
- $data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3));
+ //load the model and get results
+ $this->load->model('logbook_model');
+ $data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3));
- // Calculate Lat/Lng from Locator to use on Maps
- if($this->session->userdata('user_locator')) {
- $this->load->library('qra');
- $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
- $data['qra'] = "set";
- $data['qra_lat'] = $qra_position[0];
- $data['qra_lng'] = $qra_position[1];
- } else {
- $data['qra'] = "none";
- }
+ // Calculate Lat/Lng from Locator to use on Maps
+ if($this->session->userdata('user_locator')) {
+ $this->load->library('qra');
+ $qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
+ $data['qra'] = "set";
+ $data['qra_lat'] = $qra_position[0];
+ $data['qra_lng'] = $qra_position[1];
+ } else {
+ $data['qra'] = "none";
+ }
- // load the view
- $data['page_title'] = "Logbook";
+ // load the view
+ $data['page_title'] = "Logbook";
- $this->load->view('layout/header', $data);
- $this->load->view('view_log/index');
- $this->load->view('layout/footer');
+ $this->load->view('layout/header', $data);
+ $this->load->view('view_log/index');
+ $this->load->view('layout/footer');
- }
+ }
- function json($callsign)
- {
- $this->load->model('user_model');
- if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
+ function json($callsign)
+ {
+ $this->load->model('user_model');
+ if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
- $this->load->model('logbook_model');
+ $this->load->model('logbook_model');
- $return = [
- "dxcc" => false,
- "callsign_name" => "",
- "callsign_qra" => "",
- "callsign_qth" => "",
- "callsign_iota" => "",
- "bearing" => "",
- "workedBefore" => false
- ];
+ $return = [
+ "dxcc" => false,
+ "callsign_name" => "",
+ "callsign_qra" => "",
+ "callsign_qth" => "",
+ "callsign_iota" => "",
+ "bearing" => "",
+ "workedBefore" => false
+ ];
- $return['dxcc'] = $this->find_dxcc($callsign);
- $return['partial'] = $this->partial($callsign);
+ $return['dxcc'] = $this->find_dxcc($callsign);
+ $return['partial'] = $this->partial($callsign);
// Do we have local data for the Callsign?
if($this->logbook_model->call_name($callsign) != null)
@@ -81,7 +81,7 @@ class Logbook extends CI_Controller {
$return['callsign_qth'] = $this->logbook_model->call_qth($callsign);
$return['callsign_iota'] = $this->logbook_model->call_iota($callsign);
$return['bearing'] = $this->bearing($return['callsign_qra']);
- $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
+ $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
echo json_encode($return, JSON_PRETTY_PRINT);
return;
}
@@ -105,8 +105,8 @@ class Logbook extends CI_Controller {
$this->load->library('hamqth');
if(!$this->session->userdata('hamqth_session_key')) {
- $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
- $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
+ $hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
+ $this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
}
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
@@ -118,244 +118,244 @@ class Logbook extends CI_Controller {
$return['callsign_qra'] = $callbook['gridsquare'];
$return['callsign_qth'] = $callbook['city'];
$return['callsign_iota'] = $callbook['iota'];
- $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
+ $return['workedBefore'] = $this->worked_grid_before($return['callsign_qra']);
}
$return['bearing'] = $this->bearing($return['callsign_qra']);
echo json_encode($return, JSON_PRETTY_PRINT);
return;
- }
+ }
- function worked_grid_before($gridsquare)
- {
- if (strlen($gridsquare) < 4)
- return false;
+ function worked_grid_before($gridsquare)
+ {
+ if (strlen($gridsquare) < 4)
+ return false;
- $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
- $query = $this->db->get($this->config->item('table_name'), 1, 0);
- foreach ($query->result() as $workedBeforeRow)
- {
- return true;
- }
- return false;
- }
+ $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4));
+ $query = $this->db->get($this->config->item('table_name'), 1, 0);
+ foreach ($query->result() as $workedBeforeRow)
+ {
+ return true;
+ }
+ return false;
+ }
- /* Used to generate maps for displaying on /logbook/ */
- function qso_map() {
- $this->load->model('logbook_model');
+ /* Used to generate maps for displaying on /logbook/ */
+ function qso_map() {
+ $this->load->model('logbook_model');
- $this->load->library('qra');
+ $this->load->library('qra');
- $data['qsos'] = $this->logbook_model->get_qsos($this->uri->segment(3),$this->uri->segment(4));
+ $data['qsos'] = $this->logbook_model->get_qsos($this->uri->segment(3),$this->uri->segment(4));
- echo "{\"markers\": [";
- $count = 1;
- foreach ($data['qsos']->result() as $row) {
- //print_r($row);
- if($row->COL_GRIDSQUARE != null) {
- $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
- if($count != 1) {
- echo ",";
- }
+ echo "{\"markers\": [";
+ $count = 1;
+ foreach ($data['qsos']->result() as $row) {
+ //print_r($row);
+ if($row->COL_GRIDSQUARE != null) {
+ $stn_loc = $this->qra->qra2latlong($row->COL_GRIDSQUARE);
+ if($count != 1) {
+ echo ",";
+ }
- if($row->COL_SAT_NAME != null) {
- echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
- } else {
- echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
- }
+ if($row->COL_SAT_NAME != null) {
+ echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
SAT: ".$row->COL_SAT_NAME."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
+ } else {
+ echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
+ }
- $count++;
+ $count++;
- } else {
- $query = $this->db->query('
- SELECT *
- FROM dxcc
- WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
- ORDER BY LENGTH( prefix ) DESC
- LIMIT 1
- ');
+ } else {
+ $query = $this->db->query('
+ SELECT *
+ FROM dxcc
+ WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
+ ORDER BY LENGTH( prefix ) DESC
+ LIMIT 1
+ ');
- foreach ($query->result() as $dxcc) {
- if($count != 1) {
- echo ",";
- }
- echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
- $count++;
- }
- }
+ foreach ($query->result() as $dxcc) {
+ if($count != 1) {
+ echo ",";
+ }
+ echo "{\"lat\":\"".$dxcc->lat."\",\"lng\":\"".$dxcc->long."\", \"html\":\"Callsign: ".$row->COL_CALL."
Date/Time: ".$row->COL_TIME_ON."
Band: ".$row->COL_BAND."
Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
+ $count++;
+ }
+ }
- }
- echo "]";
- echo "}";
- }
+ }
+ echo "]";
+ echo "}";
+ }
- function view($id) {
- $this->load->model('user_model');
- if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
+ function view($id) {
+ $this->load->model('user_model');
+ if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
- $this->load->library('qra');
+ $this->load->library('qra');
- $this->db->where('COL_PRIMARY_KEY', $id);
- $data['query'] = $this->db->get($this->config->item('table_name'));
+ $this->db->where('COL_PRIMARY_KEY', $id);
+ $data['query'] = $this->db->get($this->config->item('table_name'));
- $this->load->view('view_log/qso', $data);
- }
+ $this->load->view('view_log/qso', $data);
+ }
- function partial($id) {
- $this->load->model('user_model');
- if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
-
- $html = "";
- $this->db->like('COL_CALL', $id);
- $this->db->order_by("COL_TIME_ON", "desc");
- $this->db->limit(16);
- $query = $this->db->get($this->config->item('table_name'));
+ function partial($id) {
+ $this->load->model('user_model');
+ if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
+
+ $html = "";
+ $this->db->like('COL_CALL', $id);
+ $this->db->order_by("COL_TIME_ON", "desc");
+ $this->db->limit(16);
+ $query = $this->db->get($this->config->item('table_name'));
- if ($query->num_rows() > 0)
- {
- $html .= "
| Date | "; - $html .= "Callsign | "; - $html .= "RST Sent | "; - $html .= "RST Recv | "; - $html .= "Band | "; - $html .= "Mode | "; - $html .= "|
| ".$row->COL_TIME_ON." | "; - $html .= "".$row->COL_CALL." | "; - $html .= "".$row->COL_RST_SENT." | "; - $html .= "".$row->COL_RST_RCVD." | "; - if($row->COL_SAT_NAME != null) { - $html .= "".$row->COL_SAT_NAME." | "; - } else { - $html .= "".$row->COL_BAND." | "; - } - $html .= "".$row->COL_MODE." | "; - $html .= "
| Date | "; + $html .= "Callsign | "; + $html .= "RST Sent | "; + $html .= "RST Recv | "; + $html .= "Band | "; + $html .= "Mode | "; + $html .= "|
| ".$row->COL_TIME_ON." | "; + $html .= "".$row->COL_CALL." | "; + $html .= "".$row->COL_RST_SENT." | "; + $html .= "".$row->COL_RST_RCVD." | "; + if($row->COL_SAT_NAME != null) { + $html .= "".$row->COL_SAT_NAME." | "; + } else { + $html .= "".$row->COL_BAND." | "; + } + $html .= "".$row->COL_MODE." | "; + $html .= "