diff --git a/application/controllers/Logbookadvanced.php b/application/controllers/Logbookadvanced.php index 8b963fefa..3b62e4942 100644 --- a/application/controllers/Logbookadvanced.php +++ b/application/controllers/Logbookadvanced.php @@ -154,7 +154,7 @@ class Logbookadvanced extends CI_Controller { 'dok' => xss_clean($this->input->post('dok')), 'qrzSent' => xss_clean($this->input->post('qrzSent')), 'qrzReceived' => xss_clean($this->input->post('qrzReceived')), - 'distance' => xss_clean($this->input->post('distance')), + 'distance' => xss_clean($this->input->post('distanceinput')), ); } diff --git a/application/models/Logbookadvanced_model.php b/application/models/Logbookadvanced_model.php index bf1e660b5..f283af058 100644 --- a/application/models/Logbookadvanced_model.php +++ b/application/models/Logbookadvanced_model.php @@ -472,14 +472,16 @@ class Logbookadvanced_model extends CI_Model { $where = "AND $where"; } - $limit = $searchCriteria['qsoresults']; - // Ensure limit has a valid value, default to 250 if empty or invalid - if (empty($limit) || !is_numeric($limit) || $limit <= 0) { - $limit = 250; + $where = trim(implode(" AND ", $conditions)); + if ($where != "") { + $where = "AND $where"; } - // Create a version of $where for the inner subquery with proper table alias - $whereInner = str_replace('qsos.', 'qsos_inner.', $where); + $limit = ''; + + if ($searchCriteria['qsoresults'] != 'All') { + $limit = 'limit ' . $searchCriteria['qsoresults']; + } $where2 = ''; @@ -494,25 +496,18 @@ class Logbookadvanced_model extends CI_Model { $sql = " SELECT qsos.*, dxcc_entities.*, lotw_users.*, station_profile.*, satellite.*, dxcc_entities.name as dxccname, mydxcc.name AS station_country, exists(select 1 from qsl_images where qsoid = qsos.COL_PRIMARY_KEY) as qslcount, coalesce(contest.name, qsos.col_contest_id) as contestname - FROM ( - SELECT qsos_inner.COL_PRIMARY_KEY - FROM " . $this->config->item('table_name') . " qsos_inner - INNER JOIN station_profile sp_inner ON qsos_inner.station_id = sp_inner.station_id - WHERE sp_inner.user_id = ? - $whereInner - ORDER BY qsos_inner.COL_TIME_ON desc, qsos_inner.COL_PRIMARY_KEY desc - LIMIT $limit - ) AS FilteredIDs - INNER JOIN " . $this->config->item('table_name') . " qsos ON qsos.COL_PRIMARY_KEY = FilteredIDs.COL_PRIMARY_KEY + FROM " . $this->config->item('table_name') . " qsos INNER JOIN station_profile ON qsos.station_id=station_profile.station_id LEFT OUTER JOIN satellite ON qsos.col_prop_mode='SAT' and qsos.COL_SAT_NAME = COALESCE(NULLIF(satellite.name, ''), NULLIF(satellite.displayname, '')) LEFT OUTER JOIN dxcc_entities ON qsos.col_dxcc = dxcc_entities.adif left outer join dxcc_entities mydxcc on qsos.col_my_dxcc = mydxcc.adif LEFT OUTER JOIN lotw_users ON qsos.col_call = lotw_users.callsign LEFT OUTER JOIN contest ON qsos.col_contest_id = contest.adifname - where 1 = 1 + WHERE station_profile.user_id = ? + $where $where2 ORDER BY qsos.COL_TIME_ON desc, qsos.COL_PRIMARY_KEY desc + $limit "; return $this->db->query($sql, $binding); diff --git a/application/views/logbookadvanced/index.php b/application/views/logbookadvanced/index.php index 8043ff50d..45f948bdc 100644 --- a/application/views/logbookadvanced/index.php +++ b/application/views/logbookadvanced/index.php @@ -290,11 +290,11 @@ $options = json_decode($options);