diff --git a/application/controllers/Cabrillo.php b/application/controllers/Cabrillo.php index eb921baf..d23e5a87 100644 --- a/application/controllers/Cabrillo.php +++ b/application/controllers/Cabrillo.php @@ -78,16 +78,11 @@ class Cabrillo extends CI_Controller { $this->load->model('stations'); - - $station_id = $this->security->xss_clean($this->input->post('station_id')); $contest_id = $this->security->xss_clean($this->input->post('contestid')); - $fromto = $this->security->xss_clean($this->input->post('contestdates')); - $fromto = explode(',', $fromto); - - $from = $fromto[0]; - $to = $fromto[1]; + $from = $this->security->xss_clean($this->input->post('contestdatesfrom')); + $to = $this->security->xss_clean($this->input->post('contestdatesto')); $station = $this->stations->profile($station_id); diff --git a/application/models/Contesting_model.php b/application/models/Contesting_model.php index e139d919..2a615a7f 100644 --- a/application/models/Contesting_model.php +++ b/application/models/Contesting_model.php @@ -233,7 +233,7 @@ class Contesting_model extends CI_Model { } function get_contest_dates($station_id, $year, $contestid) { - $sql = "select min(date(col_time_on)) mindate, max(date(col_time_on)) maxdate + $sql = "select distinct (date(col_time_on)) date from " . $this->config->item('table_name') . " where coalesce(COL_CONTEST_ID, '') <> '' and station_id =" . $station_id . diff --git a/assets/js/sections/cabrillo.js b/assets/js/sections/cabrillo.js index b2daec13..f428cdf0 100644 --- a/assets/js/sections/cabrillo.js +++ b/assets/js/sections/cabrillo.js @@ -7,6 +7,7 @@ function loadYears() { type: 'post', data: {'station_id': $("#station_id").val()}, success: function (data) { + if (data.length > 0) { $(".contestyear").append('
Select year:
' + '' + @@ -18,6 +19,9 @@ function loadYears() { .attr("value",value.year) .text(value.year)); }); + } else { + $(".contestyear").append("No contests were found for this station location!"); + } } }); } @@ -56,16 +60,26 @@ function loadContestDates() { 'contestid': $("#contestid").val(), 'station_id': $("#station_id").val()}, success: function (data) { - $(".contestdates").append('
Select daterange:
' + - '' + + '' + + '' + ' '); $.each(data, function(key, value) { - $('#contestdates') + $('#contestdatesfrom') .append($("") - .attr("value", value.mindate + ',' + value.maxdate) - .text(value.mindate + ' - ' + value.maxdate)); + .attr("value", value.date) + .text(value.date)); + }); + + + $.each(data, function(key, value) { + $('#contestdatesto') + .append($("") + .attr("value", value.date) + .text(value.date)); }); } });