diff --git a/application/controllers/Logbook.php b/application/controllers/Logbook.php index 6c38c2d1..7e5f630f 100755 --- a/application/controllers/Logbook.php +++ b/application/controllers/Logbook.php @@ -198,26 +198,28 @@ class Logbook extends CI_Controller { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if($type == "SAT") { - $this->db->where('COL_PROP_MODE', 'SAT'); - } else { - $this->db->where('COL_MODE', $mode); - $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); + if(!empty($logbooks_locations_array)) { + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + } else { + $this->db->where('COL_MODE', $mode); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); - } - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); - $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); - $this->db->limit(1); + } + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->like('SUBSTRING(COL_GRIDSQUARE, 1, 4)', substr($gridsquare, 0, 4)); + $this->db->order_by($this->config->item('table_name').".COL_TIME_ON", "desc"); + $this->db->limit(1); - $query = $this->db->get($this->config->item('table_name')); + $query = $this->db->get($this->config->item('table_name')); - foreach ($query->result() as $workedBeforeRow) - { - return true; + foreach ($query->result() as $workedBeforeRow) + { + return true; + } } return false; } @@ -272,28 +274,36 @@ class Logbook extends CI_Controller { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if($type == "SAT") { - $this->db->where('COL_PROP_MODE', 'SAT'); + if(!empty($logbooks_locations_array)) { + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + } else { + $this->db->where('COL_MODE', $mode); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + + } + + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_COUNTRY', urldecode($country)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) + { + $return['workedBefore'] = true; + } + + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + + return; } else { - $this->db->where('COL_MODE', $mode); - $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); + $return['workedBefore'] = false; + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + return; } - - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_COUNTRY', urldecode($country)); - - $query = $this->db->get($this->config->item('table_name'), 1, 0); - foreach ($query->result() as $workedBeforeRow) - { - $return['workedBefore'] = true; - } - - header('Content-Type: application/json'); - echo json_encode($return, JSON_PRETTY_PRINT); - - return; } function jsonlookupcallsign($callsign, $type, $band, $mode) { @@ -309,28 +319,34 @@ class Logbook extends CI_Controller { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - if($type == "SAT") { - $this->db->where('COL_PROP_MODE', 'SAT'); + if(!empty($logbooks_locations_array)) { + if($type == "SAT") { + $this->db->where('COL_PROP_MODE', 'SAT'); + } else { + $this->db->where('COL_MODE', $mode); + $this->db->where('COL_BAND', $band); + $this->db->where('COL_PROP_MODE !=','SAT'); + + } + + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->where('COL_CALL', strtoupper($callsign)); + + $query = $this->db->get($this->config->item('table_name'), 1, 0); + foreach ($query->result() as $workedBeforeRow) + { + $return['workedBefore'] = true; + } + + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + return; } else { - $this->db->where('COL_MODE', $mode); - $this->db->where('COL_BAND', $band); - $this->db->where('COL_PROP_MODE !=','SAT'); - + $return['workedBefore'] = false; + header('Content-Type: application/json'); + echo json_encode($return, JSON_PRETTY_PRINT); + return; } - - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->where('COL_CALL', strtoupper($callsign)); - - $query = $this->db->get($this->config->item('table_name'), 1, 0); - foreach ($query->result() as $workedBeforeRow) - { - $return['workedBefore'] = true; - } - - header('Content-Type: application/json'); - echo json_encode($return, JSON_PRETTY_PRINT); - - return; } @@ -416,6 +432,7 @@ class Logbook extends CI_Controller { $html = ""; + if(!empty($logbooks_locations_array)) { $this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*'); $this->db->from($this->config->item('table_name')); @@ -428,8 +445,9 @@ class Logbook extends CI_Controller { $this->db->limit(5); $query = $this->db->get(); + } - if ($query->num_rows() > 0) + if (!empty($logbooks_locations_array) && $query->num_rows() > 0) { $html .= "
"; $html .= ""; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 2913d98f..94961fbc 100755 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -595,12 +595,16 @@ class Logbook_model extends CI_Model { $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); - $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME'); - $this->db->where_in('station_id', $logbooks_locations_array); - $this->db->order_by("COL_TIME_ON", "desc"); - $this->db->limit($num); + if(!empty($logbooks_locations_array)) { + $this->db->select('COL_CALL, COL_BAND, COL_TIME_ON, COL_RST_RCVD, COL_RST_SENT, COL_MODE, COL_SUBMODE, COL_NAME, COL_COUNTRY, COL_PRIMARY_KEY, COL_SAT_NAME'); + $this->db->where_in('station_id', $logbooks_locations_array); + $this->db->order_by("COL_TIME_ON", "desc"); + $this->db->limit($num); - return $this->db->get($this->config->item('table_name')); + return $this->db->get($this->config->item('table_name')); + } else { + return false; + } } /* diff --git a/application/views/dashboard/index.php b/application/views/dashboard/index.php index 45bc6f4a..a6c1e386 100644 --- a/application/views/dashboard/index.php +++ b/application/views/dashboard/index.php @@ -82,6 +82,7 @@ function echo_table_col($row, $name) { 0) { foreach ($last_five_qsos->result() as $row) { ?> '; ?> @@ -113,7 +114,7 @@ function echo_table_col($row, $name) { echo_table_col($row, $this->session->userdata('user_column4')==""?'Band':$this->session->userdata('user_column4')); ?> - +
diff --git a/application/views/qso/index.php b/application/views/qso/index.php index 3a2fa808..84df359e 100755 --- a/application/views/qso/index.php +++ b/application/views/qso/index.php @@ -525,7 +525,8 @@ } $i = 0; - foreach ($query->result() as $row) { + if($query != false) { + foreach ($query->result() as $row) { echo ''; echo ''; $timestamp = strtotime($row->COL_TIME_ON); @@ -545,7 +546,7 @@ COL_BAND; ?> - +