diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 97d4a3756..ebf2cb56d 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -153,6 +153,10 @@ class Awards extends CI_Controller { $postdata['mode'] = $this->security->xss_clean($this->input->post('mode')); $postdata['sat'] = $this->security->xss_clean($this->input->post('sats')); $postdata['orbit'] = $this->security->xss_clean($this->input->post('orbits')); + + $postdata['dateFrom'] = $this->security->xss_clean($this->input->post('dateFrom')); + $postdata['dateTo'] = $this->security->xss_clean($this->input->post('dateTo')); + } else { // Setting default values at first load of page $postdata['qsl'] = 1; $postdata['lotw'] = 1; @@ -174,10 +178,13 @@ class Awards extends CI_Controller { $postdata['mode'] = 'All'; $postdata['sat'] = 'All'; $postdata['orbit'] = 'All'; + + $postdata['dateFrom'] = null; + $postdata['dateTo'] = null; } $dxcclist = $this->dxcc->fetchdxcc($postdata); - if ($dxcclist[0]->adif == "0") { + if ($dxcclist && $dxcclist[0]->adif == "0") { unset($dxcclist[0]); } $data['dxcc_array'] = $this->dxcc->get_dxcc_array($dxcclist, $bands, $postdata); @@ -520,7 +527,9 @@ class Awards extends CI_Controller { $type = $this->security->xss_clean($this->input->post('Type')); $qsl = $this->input->post('QSL') == null ? '' : $this->security->xss_clean($this->input->post('QSL')); $searchmode = $this->input->post('searchmode') == null ? '' : $this->security->xss_clean($this->input->post('searchmode')); - $data['results'] = $this->logbook_model->qso_details($searchphrase, $band, $mode, $type, $qsl, $sat, $orbit, $searchmode, $propagation); + $dateFrom = $this->security->xss_clean($this->input->post('dateFrom')); + $dateTo = $this->security->xss_clean($this->input->post('dateTo')); + $data['results'] = $this->logbook_model->qso_details($searchphrase, $band, $mode, $type, $qsl, $sat, $orbit, $searchmode, $propagation, $dateFrom, $dateTo); // This is done because we have two different ways to get dxcc info in Wavelog. Once is using the name (in awards), and the other one is using the ADIF DXCC. // We replace the values to make it look a bit nicer @@ -1723,6 +1732,8 @@ class Awards extends CI_Controller { $postdata['sat'] = $this->security->xss_clean($this->input->post('sat')); $postdata['orbit'] = $this->security->xss_clean($this->input->post('orbit')); + $postdata['dateFrom'] = $this->security->xss_clean($this->input->post('dateFrom')); + $postdata['dateTo'] = $this->security->xss_clean($this->input->post('dateTo')); $dxcclist = $this->dxcc->fetchdxcc($postdata); if ($dxcclist[0]->adif == "0") { diff --git a/application/models/Dxcc.php b/application/models/Dxcc.php index 8b5520552..20225cc8b 100644 --- a/application/models/Dxcc.php +++ b/application/models/Dxcc.php @@ -90,7 +90,7 @@ class DXCC extends CI_Model { if ($postdata['worked'] != NULL) { $workedDXCC = $this->getDxccBandWorked($location_list, $band, $postdata); foreach ($workedDXCC as $wdxcc) { - $dxccMatrix[$wdxcc->dxcc][$band] = '
dxcc.'","'. $band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "")\'>W
'; + $dxccMatrix[$wdxcc->dxcc][$band] = '
dxcc.'","'. $band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC2", "", "'.$postdata['dateFrom'].'", "'.$postdata['dateTo'].'")\'>W
'; } } @@ -98,7 +98,7 @@ class DXCC extends CI_Model { if ($postdata['confirmed'] != NULL) { $confirmedDXCC = $this->getDxccBandConfirmed($location_list, $band, $postdata); foreach ($confirmedDXCC as $cdxcc) { - $dxccMatrix[$cdxcc->dxcc][$band] = '
dxcc.'","'. $band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC2","'.$qsl.'")\'>'.$this->cf_type($postdata, $cdxcc->qsl,$cdxcc->lotw, $cdxcc->eqsl, $cdxcc->qrz, $cdxcc->clublog).'
'; + $dxccMatrix[$cdxcc->dxcc][$band] = '
dxcc.'","'. $band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC2","'.$qsl.'","'.$postdata['dateFrom'].'","'.$postdata['dateTo'].'")\'>'.$this->cf_type($postdata, $cdxcc->qsl,$cdxcc->lotw, $cdxcc->eqsl, $cdxcc->qrz, $cdxcc->clublog).'
'; } } } @@ -171,6 +171,16 @@ class DXCC extends CI_Model { $sql .= $this->genfunctions->addQslToQuery($postdata); + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + $sql .= " group by col_dxcc ) x on dxcc_entities.adif = x.col_dxcc"; @@ -209,6 +219,17 @@ class DXCC extends CI_Model { $bindings[]=$postdata['mode']; $bindings[]=$postdata['mode']; } + + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + $sql .= $this->addOrbitToQuery($postdata,$bindings); $sql .= " group by col_dxcc @@ -258,10 +279,20 @@ class DXCC extends CI_Model { $sql.=" and (col_prop_mode != 'SAT' or col_prop_mode is null)"; } + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + if ($postdata['mode'] != 'All') { - $sql .= " and (col_mode = ? or col_submode = ?)"; - $bindings[]=$postdata['mode']; - $bindings[]=$postdata['mode']; + $sql .= " and (col_mode = ? or col_submode = ?)"; + $bindings[]=$postdata['mode']; + $bindings[]=$postdata['mode']; } $sql .= $this->addOrbitToQuery($postdata, $bindings); @@ -311,6 +342,16 @@ class DXCC extends CI_Model { $bindings[]=$postdata['mode']; } + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + $sql .= " and not exists (select 1 from ".$this->config->item('table_name')." where station_id in (". $location_list .") and col_dxcc = thcv.col_dxcc and col_dxcc > 0"; $sql .= $this->genfunctions->addBandToQuery($postdata['band'],$bindings); if ($postdata['band'] == 'SAT') { @@ -324,6 +365,16 @@ class DXCC extends CI_Model { $sql.=" and (col_prop_mode != 'SAT' or col_prop_mode is null)"; } + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = ? or col_submode = ?)"; @@ -356,6 +407,16 @@ class DXCC extends CI_Model { where station_id in (". $location_list . ") and col_dxcc > 0"; + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + $sql .= $this->genfunctions->addBandToQuery($postdata['band'],$bindings); if ($postdata['band'] == 'SAT') { $sql .= " and col_prop_mode = 'SAT'"; @@ -486,6 +547,16 @@ class DXCC extends CI_Model { $bindings[]=$band; } + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = ? or col_submode = ?)"; $bindings[]=$postdata['mode']; @@ -546,6 +617,16 @@ class DXCC extends CI_Model { $bindings[]=$band; } + if ($postdata['dateFrom'] != NULL) { + $sql .= " and date(col_time_on) >= ?"; + $bindings[]=$postdata['dateFrom']; + } + + if ($postdata['dateTo'] != NULL) { + $sql .= " and date(col_time_on) <= ?"; + $bindings[]=$postdata['dateTo']; + } + if ($postdata['mode'] != 'All') { $sql .= " and (col_mode = ? or col_submode = ?)"; $bindings[]=$postdata['mode']; diff --git a/application/models/Logbook_model.php b/application/models/Logbook_model.php index 3301100c8..622a0c192 100644 --- a/application/models/Logbook_model.php +++ b/application/models/Logbook_model.php @@ -533,7 +533,7 @@ class Logbook_model extends CI_Model { /* * Used to fetch QSOs from the logbook in the awards */ - public function qso_details($searchphrase, $band, $mode, $type, $qsl, $sat = null, $orbit = null, $searchmode = null, $propagation = null) { + public function qso_details($searchphrase, $band, $mode, $type, $qsl, $sat = null, $orbit = null, $searchmode = null, $propagation = null, $datefrom = null, $dateto = null) { $this->load->model('logbooks_model'); $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook')); @@ -744,6 +744,13 @@ class Logbook_model extends CI_Model { $this->db->or_where("COL_SUBMODE", $mode); $this->db->group_end(); } + + if ($datefrom != null) { + $this->db->where('date(COL_TIME_ON) >=', $datefrom); + } + if ($dateto != null) { + $this->db->where('date(COL_TIME_ON) <=', $dateto); + } $this->db->order_by("COL_TIME_ON", "desc"); $this->db->order_by("COL_PRIMARY_KEY", "desc"); diff --git a/application/views/awards/dxcc/index.php b/application/views/awards/dxcc/index.php index 3b2182271..a05ec39b1 100644 --- a/application/views/awards/dxcc/index.php +++ b/application/views/awards/dxcc/index.php @@ -36,6 +36,24 @@ '; } else { - echo ''; + echo ''; } ?> diff --git a/application/views/interface_assets/footer.php b/application/views/interface_assets/footer.php index 57b77c2cc..bae43f49c 100644 --- a/application/views/interface_assets/footer.php +++ b/application/views/interface_assets/footer.php @@ -2568,7 +2568,7 @@ function viewEqsl(picture, callsign) { /* * Used to fetch QSOs from the logbook in the awards */ - function displayContacts(searchphrase, band, sat, orbit, mode, type, qsl) { + function displayContacts(searchphrase, band, sat, orbit, mode, type, qsl, datefrom, dateto) { $.ajax({ url: base_url + 'index.php/awards/qso_details_ajax', type: 'post', @@ -2579,7 +2579,9 @@ function viewEqsl(picture, callsign) { 'Orbit': orbit, 'Mode': mode, 'Type': type, - 'QSL' : qsl + 'QSL' : qsl, + 'dateFrom': datefrom, + 'dateTo': dateto }, success: function (html) { BootstrapDialog.show({ @@ -2640,7 +2642,7 @@ function viewEqsl(picture, callsign) { }); } - function displayContactsOnMap(target, searchphrase, band, sat, orbit, mode, type, qsl) { + function displayContactsOnMap(target, searchphrase, band, sat, orbit, mode, type, qsl, datefrom, dateto) { $.ajax({ url: base_url + 'index.php/awards/qso_details_ajax', type: 'post', @@ -2651,7 +2653,9 @@ function viewEqsl(picture, callsign) { 'Orbit': orbit, 'Mode': mode, 'Type': type, - 'QSL' : qsl + 'QSL' : qsl, + 'dateFrom': datefrom, + 'dateTo': dateto }, success: function (html) { var dialog = new BootstrapDialog({ diff --git a/assets/js/sections/dxccmap.js b/assets/js/sections/dxccmap.js index 875d39457..5cbdd2fc8 100644 --- a/assets/js/sections/dxccmap.js +++ b/assets/js/sections/dxccmap.js @@ -73,6 +73,8 @@ function load_dxcc_map() { Antarctica: +$('#Antarctica').prop('checked'), sat: $("#sats").val(), orbit: $("#orbits").val(), + dateFrom: $('#dateFrom').val(), + dateTo: $('#dateTo').val(), }, success: function(data) { load_dxcc_map2(data, worked, confirmed, notworked); @@ -204,5 +206,5 @@ function addMarker(L, D, mapColor, map) { function onClick(e) { var marker = e.target; - displayContactsOnMap($("#dxccmap"),marker.options.adif, $('#band2').val(), $('#sats').val(), $('#orbits').val(), $('#mode').val(), 'DXCC2'); + displayContactsOnMap($("#dxccmap"),marker.options.adif, $('#band2').val(), $('#sats').val(), $('#orbits').val(), $('#mode').val(), 'DXCC2', '', $('#dateFrom').val(), $('#dateTo').val()); }