diff --git a/application/controllers/Awards.php b/application/controllers/Awards.php index 4e04544b0..eb19bef06 100644 --- a/application/controllers/Awards.php +++ b/application/controllers/Awards.php @@ -1472,7 +1472,7 @@ class Awards extends CI_Controller { This displays the DXCC map */ public function jcc_map() { - $this->load->model('dxcc'); + $this->load->model('jcc_model'); $this->load->model('bands'); $bands[] = $this->security->xss_clean($this->input->post('band')); @@ -1487,24 +1487,19 @@ class Awards extends CI_Controller { $postdata['band'] = $this->security->xss_clean($this->input->post('band')); $postdata['mode'] = $this->security->xss_clean($this->input->post('mode')); - $i = 0; - echo json_encode(null); - return; + $jcc_wkd = $this->jcc_model->fetch_jcc_wkd($postdata); + $jcc_cnfm = $this->jcc_model->fetch_jcc_cnfm($postdata); - foreach ($dxcclist as $dxcc) { - $newdxcc[$i]['adif'] = $dxcc->adif; - $newdxcc[$i]['prefix'] = $dxcc->prefix; - $newdxcc[$i]['name'] = ucwords(strtolower($dxcc->name), "- (/"); - if ($dxcc->Enddate!=null) { - $newdxcc[$i]['name'] .= ' (deleted)'; - } - $newdxcc[$i]['lat'] = $dxcc->lat; - $newdxcc[$i]['long'] = $dxcc->long; - $newdxcc[$i++]['status'] = isset($dxcc_array[$dxcc->adif]) ? $this->returnStatus($dxcc_array[$dxcc->adif]) : 'x'; + $jccs = []; + foreach ($jcc_wkd as $jcc) { + $jccs[$jcc->COL_CNTY] = array(1, 0); + } + foreach ($jcc_cnfm as $jcc) { + $jccs[$jcc->COL_CNTY][1] = 1; } header('Content-Type: application/json'); - echo json_encode($newdxcc); + echo json_encode($jccs); } /* diff --git a/application/models/Jcc_model.php b/application/models/Jcc_model.php index 93e887647..22768b10f 100644 --- a/application/models/Jcc_model.php +++ b/application/models/Jcc_model.php @@ -1183,5 +1183,31 @@ class Jcc_model extends CI_Model { $query = $this->db->query($sql); return $query->result(); } + + function fetch_jcc_wkd($postdata) { + $sql = 'SELECT DISTINCT `COL_CNTY` FROM '.$this->config->item('table_name').' WHERE 1'; + $sql .= $this->addStateToQuery(); + $sql .= $this->genfunctions->addBandToQuery($postdata['band']); + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $sql .= ' ORDER BY COL_CNTY ASC'; + $query = $this->db->query($sql); + return $query->result(); + } + + function fetch_jcc_cnfm($postdata) { + $sql = 'SELECT DISTINCT `COL_CNTY` FROM '.$this->config->item('table_name').' WHERE 1'; + $sql .= $this->addStateToQuery(); + $sql .= $this->genfunctions->addBandToQuery($postdata['band']); + if ($postdata['mode'] != 'All') { + $sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')"; + } + $sql .= $this->genfunctions->addQslToQuery($postdata); + $sql .= ' ORDER BY COL_CNTY ASC'; + $query = $this->db->query($sql); + return $query->result(); + } + } ?> diff --git a/assets/js/sections/jccmap.js b/assets/js/sections/jccmap.js index 50e9270ea..48d9b0f7e 100644 --- a/assets/js/sections/jccmap.js +++ b/assets/js/sections/jccmap.js @@ -54,51 +54,44 @@ function load_jcc_map2(data, worked, confirmed, notworked) { var notworkedcount = 0; var confirmedcount = 0; var workednotconfirmedcount = 0; + jccstuff.forEach((jcc) => { - console.log(jcc[0]); var D = []; - D['prefix'] = jcc[0]; - D['lat'] = jcc[2]; - D['long'] = jcc[3]; - addMarker(L, D, 'blue', map); - }); - - for (var i = 0; i < data.length; i++) { - var D = data[i]; - if (D['status'] != 'x') { - var mapColor = 'red'; - - if (D['status'] == 'C') { + if (jcc[0] in data) { + if (confirmed.checked == true) { + if (data[jcc[0]][1] == 1) { mapColor = 'green'; - if (confirmed != '0') { - addMarker(L, D, mapColor, map); - confirmedcount++; - } - } - if (D['status'] == 'W') { - mapColor = 'orange'; - if (worked != '0') { - addMarker(L, D, mapColor, map); - workednotconfirmedcount++; - } - } - if (D['status'] == '-') { - mapColor = 'red'; - if (notworked != '0') { - addMarker(L, D, mapColor, map); - notworkedcount++; - } - } - } - } + D['prefix'] = jcc[0]; + D['lat'] = jcc[2]; + D['long'] = jcc[3]; + addMarker(L, D, mapColor, map); + confirmedcount++; + return; + } + } + if (worked.checked == true) { + mapColor = 'orange'; + D['prefix'] = jcc[0]; + D['lat'] = jcc[2]; + D['long'] = jcc[3]; + addMarker(L, D, mapColor, map); + workednotconfirmedcount++; + } + } else { + if (notworked.checked == true) { + mapColor = 'red'; + D['prefix'] = jcc[0]; + D['lat'] = jcc[2]; + D['long'] = jcc[3]; + addMarker(L, D, mapColor, map); + notworkedcount++; + } + } + }); /*Legend specific*/ var legend = L.control({ position: "topright" }); - if (notworked.checked == false) { - notworkedcount = 0; - } - legend.onAdd = function(map) { var div = L.DomUtil.create("div", "legend"); div.innerHTML += "

Colors

";