From fc425da77f8ac3ea76c8e5ded84d678f183f1926 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 24 Apr 2024 09:34:30 +0200 Subject: [PATCH 01/11] Export button ... --- application/controllers/Awards.php | 4 +++ application/views/awards/jcc/index.php | 1 + assets/js/sections/jcc.js | 47 +++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index ac3a0d618..42bad44a3 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -329,6 +329,10 @@ class Awards extends CI_Controller { $this->load->view('interface_assets/footer', $footerData); } + public function jcc_export() { + return json_encode(array('test' => 'abcd')); + } + public function vucc() { $this->load->model('vucc'); $this->load->model('bands'); diff --git a/application/views/awards/jcc/index.php b/application/views/awards/jcc/index.php index 776b5199f..0e4c464f4 100644 --- a/application/views/awards/jcc/index.php +++ b/application/views/awards/jcc/index.php @@ -98,6 +98,7 @@
+
diff --git a/assets/js/sections/jcc.js b/assets/js/sections/jcc.js index 464f1d2fd..4e3ea8602 100644 --- a/assets/js/sections/jcc.js +++ b/assets/js/sections/jcc.js @@ -15,4 +15,49 @@ $(document).ready(function () { 'csv' ] }); -}); \ No newline at end of file +}); + +function export_qsos() { + console.log("TEST"); + $.ajax({ + url: base_url + 'index.php/awards/jcc_export', + type: 'post', + xhrFields: { + responseType: 'blob', + }, + data: { + band: $('#band2').val(), + mode: $('#mode').val(), + worked: +$('#worked').prop('checked'), + confirmed: +$('#confirmed').prop('checked'), + notworked: +$('#notworked').prop('checked'), + qsl: +$('#qsl').prop('checked'), + lotw: +$('#lotw').prop('checked'), + qrz: +$('#qrz').prop('checked'), + eqsl: +$('#eqsl').prop('checked'), + includedeleted: +$('#includedeleted').prop('checked'), + Africa: +$('#Africa').prop('checked'), + Asia: +$('#Asia').prop('checked'), + Europe: +$('#Europe').prop('checked'), + NorthAmerica: +$('#NorthAmerica').prop('checked'), + SouthAmerica: +$('#SouthAmerica').prop('checked'), + Oceania: +$('#Oceania').prop('checked'), + Antarctica: +$('#Antarctica').prop('checked'), + sat: $("#sats").val(), + orbit: $("#orbits").val(), + }, + success: function(data) { + var a = document.createElement('a'); + var url = window.URL.createObjectURL(data); + a.href = url; + a.download = 'report.csv'; + document.body.append(a); + a.click(); + a.remove(); + window.URL.revokeObjectURL(url); + }, + error: function() { + console.log("error"); + }, + }); +} From af6b1bae867191d323e635c6d5cb436a61269501 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 24 Apr 2024 19:20:41 +0200 Subject: [PATCH 02/11] Download function works --- application/controllers/Awards.php | 5 ++++- assets/js/sections/jcc.js | 18 +++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 42bad44a3..19f6dbc5b 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -330,7 +330,10 @@ class Awards extends CI_Controller { } public function jcc_export() { - return json_encode(array('test' => 'abcd')); + $fp = fopen( 'php://output', 'w' ); + fputcsv($fp, array('Car', 'Year', 'Miles' )); + fclose($fp); + return; } public function vucc() { diff --git a/assets/js/sections/jcc.js b/assets/js/sections/jcc.js index 4e3ea8602..89bec3c2c 100644 --- a/assets/js/sections/jcc.js +++ b/assets/js/sections/jcc.js @@ -18,12 +18,11 @@ $(document).ready(function () { }); function export_qsos() { - console.log("TEST"); $.ajax({ url: base_url + 'index.php/awards/jcc_export', type: 'post', xhrFields: { - responseType: 'blob', + responseType: 'text/csv;charset=utf8', }, data: { band: $('#band2').val(), @@ -48,13 +47,18 @@ function export_qsos() { }, success: function(data) { var a = document.createElement('a'); - var url = window.URL.createObjectURL(data); + var fileData = ['\ufeff'+data]; + console.log(fileData); + var blob = new Blob(fileData,{ + type: "text/csv;charset=utf-8;" + }); + var url = URL.createObjectURL(blob); a.href = url; - a.download = 'report.csv'; - document.body.append(a); + a.download = 'qso_export.csv'; + + document.body.appendChild(a); a.click(); - a.remove(); - window.URL.revokeObjectURL(url); + document.body.removeChild(a); }, error: function() { console.log("error"); From 9e91f6f9c6bc88d44d2472bc72a6012936dfa1f9 Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 24 Apr 2024 22:42:11 +0200 Subject: [PATCH 03/11] Raw function body in model --- application/controllers/Awards.php | 29 +++++++++++++++++++++++++---- application/models/Jcc_model.php | 3 +++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 19f6dbc5b..9ccf79265 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -330,10 +330,31 @@ class Awards extends CI_Controller { } public function jcc_export() { - $fp = fopen( 'php://output', 'w' ); - fputcsv($fp, array('Car', 'Year', 'Miles' )); - fclose($fp); - return; + $this->load->model('Jcc_model'); + $qsl = $this->security->xss_clean($this->input->post('qsl')); + $lotw = $this->security->xss_clean($this->input->post('lotw')); + $eqsl = $this->security->xss_clean($this->input->post('eqsl')); + $qrz = $this->security->xss_clean($this->input->post('qrz')); + $worked = $this->security->xss_clean($this->input->post('worked')); + $confirmed = $this->security->xss_clean($this->input->post('confirmed')); + $notworked = $this->security->xss_clean($this->input->post('notworked')); + $includedeleted = $this->security->xss_clean($this->input->post('includedeleted')); + $Africa = $this->security->xss_clean($this->input->post('Africa')); + $Asia = $this->security->xss_clean($this->input->post('Asia')); + $Europe = $this->security->xss_clean($this->input->post('Europe')); + $NorthAmerica = $this->security->xss_clean($this->input->post('NorthAmerica')); + $SouthAmerica = $this->security->xss_clean($this->input->post('SouthAmerica')); + $Oceania = $this->security->xss_clean($this->input->post('Oceania')); + $Antarctica = $this->security->xss_clean($this->input->post('Antarctica')); + $band = $this->security->xss_clean($this->input->post('band')); + $mode = $this->security->xss_clean($this->input->post('mode')); + + $qsos = $this->Jcc_model->exportJcc(); + + $fp = fopen( 'php://output', 'w' ); + fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode'), ';'); + fclose($fp); + return; } public function vucc() { diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index f972eee40..cdaadd558 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -1131,5 +1131,8 @@ class Jcc_model extends CI_Model { $sql .= " and COL_CNTY in (".implode(',', array_keys($this->jaCities)).")"; return $sql; } + + function exportJcc() { + } } ?> From 9f4f5810b96d57b9f3d693cd92b950dcae168fb5 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 00:27:49 +0200 Subject: [PATCH 04/11] Bassic export function working --- application/controllers/Awards.php | 31 ++++++--------- application/models/Jcc_model.php | 63 +++++++++++++++++++++++++++++- 2 files changed, 75 insertions(+), 19 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 9ccf79265..e33ae1fdb 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -331,28 +331,23 @@ class Awards extends CI_Controller { public function jcc_export() { $this->load->model('Jcc_model'); - $qsl = $this->security->xss_clean($this->input->post('qsl')); - $lotw = $this->security->xss_clean($this->input->post('lotw')); - $eqsl = $this->security->xss_clean($this->input->post('eqsl')); - $qrz = $this->security->xss_clean($this->input->post('qrz')); - $worked = $this->security->xss_clean($this->input->post('worked')); - $confirmed = $this->security->xss_clean($this->input->post('confirmed')); - $notworked = $this->security->xss_clean($this->input->post('notworked')); - $includedeleted = $this->security->xss_clean($this->input->post('includedeleted')); - $Africa = $this->security->xss_clean($this->input->post('Africa')); - $Asia = $this->security->xss_clean($this->input->post('Asia')); - $Europe = $this->security->xss_clean($this->input->post('Europe')); - $NorthAmerica = $this->security->xss_clean($this->input->post('NorthAmerica')); - $SouthAmerica = $this->security->xss_clean($this->input->post('SouthAmerica')); - $Oceania = $this->security->xss_clean($this->input->post('Oceania')); - $Antarctica = $this->security->xss_clean($this->input->post('Antarctica')); - $band = $this->security->xss_clean($this->input->post('band')); - $mode = $this->security->xss_clean($this->input->post('mode')); + $postdata['qsl'] = $this->security->xss_clean($this->input->post('qsl')); + $postdata['lotw'] = $this->security->xss_clean($this->input->post('lotw')); + $postdata['eqsl'] = $this->security->xss_clean($this->input->post('eqsl')); + $postdata['qrz'] = $this->security->xss_clean($this->input->post('qrz')); + $postdata['worked'] = $this->security->xss_clean($this->input->post('worked')); + $postdata['confirmed'] = $this->security->xss_clean($this->input->post('confirmed')); + $postdata['notworked'] = $this->security->xss_clean($this->input->post('notworked')); + $postdata['band'] = $this->security->xss_clean($this->input->post('band')); + $postdata['mode'] = $this->security->xss_clean($this->input->post('mode')); - $qsos = $this->Jcc_model->exportJcc(); + $qsos = $this->Jcc_model->exportJcc($postdata); $fp = fopen( 'php://output', 'w' ); fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode'), ';'); + foreach ($qsos as $qso) { + fputcsv($fp, array($qso['cnty'], $qso['call'], $qso['date'], $qso['band'], $qso['mode']), ';'); + } fclose($fp); return; } diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index cdaadd558..882108224 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -1132,7 +1132,68 @@ class Jcc_model extends CI_Model { return $sql; } - function exportJcc() { + function exportJcc($postdata) { + $CI =& get_instance(); + $CI->load->model('logbooks_model'); + $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + + if (!$logbooks_locations_array) { + return null; + } + + $location_list = "'".implode("','",$logbooks_locations_array)."'"; + + $jccArray = array_keys($this->jaCities); + + $sql = "SELECT distinct col_cnty FROM " . $this->config->item('table_name') . " thcv + where station_id in (" . $location_list . ")"; + + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + + $sql .= $this->addStateToQuery(); + + $sql .= $this->genfunctions->addBandToQuery($postdata['band']); + + $sql .= " and not exists (select 1 from ". $this->config->item('table_name') . + " where station_id in (". $location_list . ")" . + " and col_cnty = thcv.col_cnty"; + + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + + $sql .= $this->genfunctions->addBandToQuery($postdata['band']); + + $sql .= $this->genfunctions->addQslToQuery($postdata); + + $sql .= $this->addStateToQuery(); + + $sql .= ")"; + + $query = $this->db->query($sql); + + $jccs = array(); + foreach($query->result() as $line) { + $jccs[] = $line->col_cnty; + } + $qsos = array(); + foreach($jccs as $jcc) { + $qso = $this->getFirstQso($location_list, $jcc); + $qsos[] = array('cnty' => $qso[0]->COL_CNTY, 'call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE); + } + + return $qsos; + } + + function getFirstQso($location_list, $jcc) { + $sql = 'SELECT COL_CNTY, COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE FROM '.$this->config->item('table_name').' t1 + WHERE station_id in ('.$location_list.')'; + $sql .= ' AND COL_CNTY = \''.$jcc.'\''; + $sql .= ' ORDER BY COL_TIME_ON ASC LIMIT 1'; + $query = $this->db->query($sql); + return $query->result(); } } ?> From 5bdbf46d7d8940435fdcd847eee37d3fdba3f9ea Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 07:28:44 +0200 Subject: [PATCH 05/11] Add number and mv cnty to remarks --- application/controllers/Awards.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index e33ae1fdb..ae8440ddf 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -344,9 +344,11 @@ class Awards extends CI_Controller { $qsos = $this->Jcc_model->exportJcc($postdata); $fp = fopen( 'php://output', 'w' ); - fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode'), ';'); + $i=1; + fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode', 'Remarks'), ';'); foreach ($qsos as $qso) { - fputcsv($fp, array($qso['cnty'], $qso['call'], $qso['date'], $qso['band'], $qso['mode']), ';'); + fputcsv($fp, array($i, $qso['call'], $qso['date'], $qso['band'], $qso['mode'], $qso['cnty']), ';'); + $i++; } fclose($fp); return; From 4761b935ee43713a49e3b185c830acb2c1cfde8e Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 07:34:56 +0200 Subject: [PATCH 06/11] Add JCC names to export --- application/controllers/Awards.php | 2 +- application/models/Jcc_model.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index ae8440ddf..b4c1db86f 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -347,7 +347,7 @@ class Awards extends CI_Controller { $i=1; fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode', 'Remarks'), ';'); foreach ($qsos as $qso) { - fputcsv($fp, array($i, $qso['call'], $qso['date'], $qso['band'], $qso['mode'], $qso['cnty']), ';'); + fputcsv($fp, array($i, $qso['call'], $qso['date'], $qso['band'], $qso['mode'], $qso['cnty'].' - '.$qso['jcc']), ';'); $i++; } fclose($fp); diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index 882108224..caaeeb0ac 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -1181,7 +1181,7 @@ class Jcc_model extends CI_Model { $qsos = array(); foreach($jccs as $jcc) { $qso = $this->getFirstQso($location_list, $jcc); - $qsos[] = array('cnty' => $qso[0]->COL_CNTY, 'call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE); + $qsos[] = array('call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE, 'cnty' => $qso[0]->COL_CNTY, 'jcc' => $this->jaCities[$qso[0]->COL_CNTY]); } return $qsos; From 0ace9a48d1e5c7d72bfec60d3139f03df66bb9e9 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 07:37:18 +0200 Subject: [PATCH 07/11] Refactor model loading --- application/models/Jcc_model.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index caaeeb0ac..157a637d9 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -825,8 +825,7 @@ class Jcc_model extends CI_Model { ); function get_jcc_array($bands, $postdata) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); + $this->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { From d30e782083a9c697bcefc9eb4f1043c850edff67 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 07:39:07 +0200 Subject: [PATCH 08/11] Revert "Refactor model loading" This reverts commit 0ace9a48d1e5c7d72bfec60d3139f03df66bb9e9. --- application/models/Jcc_model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index 157a637d9..caaeeb0ac 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -825,7 +825,8 @@ class Jcc_model extends CI_Model { ); function get_jcc_array($bands, $postdata) { - $this->load->model('logbooks_model'); + $CI =& get_instance(); + $CI->load->model('logbooks_model'); $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { From 1146beabf055536c306bad5b3d377270100001a1 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 07:41:50 +0200 Subject: [PATCH 09/11] Refactor model loading --- application/models/Jcc_model.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index caaeeb0ac..a876f28f7 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -825,9 +825,8 @@ class Jcc_model extends CI_Model { ); function get_jcc_array($bands, $postdata) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { return null; @@ -1020,9 +1019,8 @@ class Jcc_model extends CI_Model { */ function get_jcc_summary($bands, $postdata) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { return null; @@ -1133,9 +1131,8 @@ class Jcc_model extends CI_Model { } function exportJcc($postdata) { - $CI =& get_instance(); - $CI->load->model('logbooks_model'); - $logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); + $this->load->model('logbooks_model'); + $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); if (!$logbooks_locations_array) { return null; From adbfaab3615446865554a994a9ba4258eb6b382b Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 07:46:31 +0200 Subject: [PATCH 10/11] Add prop_mode if set --- application/controllers/Awards.php | 2 +- application/models/Jcc_model.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index b4c1db86f..251c85763 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -347,7 +347,7 @@ class Awards extends CI_Controller { $i=1; fputcsv($fp, array('No', 'Callsign', 'Date', 'Band', 'Mode', 'Remarks'), ';'); foreach ($qsos as $qso) { - fputcsv($fp, array($i, $qso['call'], $qso['date'], $qso['band'], $qso['mode'], $qso['cnty'].' - '.$qso['jcc']), ';'); + fputcsv($fp, array($i, $qso['call'], $qso['date'], ($qso['prop_mode'] != null ? $qso['band'].' / '.$qso['prop_mode'] : $qso['band']), $qso['mode'], $qso['cnty'].' - '.$qso['jcc']), ';'); $i++; } fclose($fp); diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index a876f28f7..2862126bd 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -1178,14 +1178,14 @@ class Jcc_model extends CI_Model { $qsos = array(); foreach($jccs as $jcc) { $qso = $this->getFirstQso($location_list, $jcc); - $qsos[] = array('call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE, 'cnty' => $qso[0]->COL_CNTY, 'jcc' => $this->jaCities[$qso[0]->COL_CNTY]); + $qsos[] = array('call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE, 'prop_mode' => $qso[0]->COL_PROP_MODE, 'cnty' => $qso[0]->COL_CNTY, 'jcc' => $this->jaCities[$qso[0]->COL_CNTY]); } return $qsos; } function getFirstQso($location_list, $jcc) { - $sql = 'SELECT COL_CNTY, COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE FROM '.$this->config->item('table_name').' t1 + $sql = 'SELECT COL_CNTY, COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_PROP_MODE FROM '.$this->config->item('table_name').' t1 WHERE station_id in ('.$location_list.')'; $sql .= ' AND COL_CNTY = \''.$jcc.'\''; $sql .= ' ORDER BY COL_TIME_ON ASC LIMIT 1'; From 91904cb9d475a3289482a825ddea20b85d6bed90 Mon Sep 17 00:00:00 2001 From: phl0 Date: Thu, 25 Apr 2024 13:51:25 +0200 Subject: [PATCH 11/11] Add sort order any also make it filterable by band/mode --- application/models/Jcc_model.php | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index 2862126bd..93e887647 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -1150,24 +1150,9 @@ class Jcc_model extends CI_Model { } $sql .= $this->addStateToQuery(); - $sql .= $this->genfunctions->addBandToQuery($postdata['band']); - - $sql .= " and not exists (select 1 from ". $this->config->item('table_name') . - " where station_id in (". $location_list . ")" . - " and col_cnty = thcv.col_cnty"; - - if ($postdata['mode'] != 'All') { - $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; - } - - $sql .= $this->genfunctions->addBandToQuery($postdata['band']); - $sql .= $this->genfunctions->addQslToQuery($postdata); - - $sql .= $this->addStateToQuery(); - - $sql .= ")"; + $sql .= ' ORDER BY COL_CNTY ASC'; $query = $this->db->query($sql); @@ -1177,16 +1162,22 @@ class Jcc_model extends CI_Model { } $qsos = array(); foreach($jccs as $jcc) { - $qso = $this->getFirstQso($location_list, $jcc); + $qso = $this->getFirstQso($location_list, $jcc, $postdata); $qsos[] = array('call' => $qso[0]->COL_CALL, 'date' => $qso[0]->COL_TIME_ON, 'band' => $qso[0]->COL_BAND, 'mode' => $qso[0]->COL_MODE, 'prop_mode' => $qso[0]->COL_PROP_MODE, 'cnty' => $qso[0]->COL_CNTY, 'jcc' => $this->jaCities[$qso[0]->COL_CNTY]); } return $qsos; } - function getFirstQso($location_list, $jcc) { + function getFirstQso($location_list, $jcc, $postdata) { $sql = 'SELECT COL_CNTY, COL_CALL, COL_TIME_ON, COL_BAND, COL_MODE, COL_PROP_MODE FROM '.$this->config->item('table_name').' t1 WHERE station_id in ('.$location_list.')'; + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $sql .= $this->addStateToQuery(); + $sql .= $this->genfunctions->addBandToQuery($postdata['band']); + $sql .= $this->genfunctions->addQslToQuery($postdata); $sql .= ' AND COL_CNTY = \''.$jcc.'\''; $sql .= ' ORDER BY COL_TIME_ON ASC LIMIT 1'; $query = $this->db->query($sql);