Skip to content

Commit ae494dd

Browse files
authored
Merge pull request wavelog#268 from AndreasK79/dxcc_orbit
[DXCC Award] Added orbit and sat to the selection
2 parents 997018e + 40e779a commit ae494dd

File tree

21 files changed

+189
-45
lines changed

21 files changed

+189
-45
lines changed

application/controllers/Awards.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public function dxcc () {
103103
$this->load->model('modes');
104104
$this->load->model('bands');
105105

106+
$data['orbits'] = $this->bands->get_worked_orbits();
107+
$data['sats_available'] = $this->bands->get_worked_sats();
108+
$data['user_default_band'] = $this->session->userdata('user_default_band');
109+
106110
$data['worked_bands'] = $this->bands->get_worked_bands('dxcc'); // Used in the view for band select
107111
$data['modes'] = $this->modes->active(); // Used in the view for mode select
108112

@@ -138,6 +142,8 @@ public function dxcc () {
138142
$postdata['Antarctica'] = $this->security->xss_clean($this->input->post('Antarctica'));
139143
$postdata['band'] = $this->security->xss_clean($this->input->post('band'));
140144
$postdata['mode'] = $this->security->xss_clean($this->input->post('mode'));
145+
$postdata['sat'] = $this->security->xss_clean($this->input->post('sats'));
146+
$postdata['orbit'] = $this->security->xss_clean($this->input->post('orbits'));
141147
}
142148
else { // Setting default values at first load of page
143149
$postdata['qsl'] = 1;
@@ -157,6 +163,8 @@ public function dxcc () {
157163
$postdata['Antarctica'] = 1;
158164
$postdata['band'] = 'All';
159165
$postdata['mode'] = 'All';
166+
$postdata['sat'] = 'All';
167+
$postdata['orbit'] = 'All';
160168
}
161169

162170
$dxcclist = $this->dxcc->fetchdxcc($postdata);
@@ -1405,6 +1413,8 @@ public function dxcc_map() {
14051413
$postdata['SouthAmerica'] = $this->input->post('SouthAmerica') == 0 ? NULL: 1;
14061414
$postdata['Oceania'] = $this->input->post('Oceania') == 0 ? NULL: 1;
14071415
$postdata['Antarctica'] = $this->input->post('Antarctica') == 0 ? NULL: 1;
1416+
$postdata['sat'] = $this->security->xss_clean($this->input->post('sat'));
1417+
$postdata['orbit'] = $this->security->xss_clean($this->input->post('orbit'));
14081418

14091419
$dxcclist = $this->dxcc->fetchdxcc($postdata);
14101420

application/models/Cq.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ function get_cq_array($bands, $postdata, $location_list) {
2323
if ($postdata['worked'] != NULL) {
2424
$cqBand = $this->getCQWorked($location_list, $band, $postdata);
2525
foreach ($cqBand as $line) {
26-
$bandCq[$line->col_cqz][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cqz) . '","' . $band . '","'. $postdata['mode'] . '","CQZone","")\'>W</a></div>';
26+
$bandCq[$line->col_cqz][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cqz) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","CQZone","")\'>W</a></div>';
2727
$cqZ[$line->col_cqz]['count']++;
2828
}
2929
}
3030
if ($postdata['confirmed'] != NULL) {
3131
$cqBand = $this->getCQConfirmed($location_list, $band, $postdata);
3232
foreach ($cqBand as $line) {
33-
$bandCq[$line->col_cqz][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cqz) . '","' . $band . '","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>C</a></div>';
33+
$bandCq[$line->col_cqz][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . str_replace("&", "%26", $line->col_cqz) . '","' . $band . '","All", "All","'. $postdata['mode'] . '","CQZone","'.$qsl.'")\'>C</a></div>';
3434
$cqZ[$line->col_cqz]['count']++;
3535
}
3636
}

application/models/Dok.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ function get_dok_array($bands, $postdata, $location_list) {
2828
$dokBand = $this->getDokWorked($location_list, $band, $postdata);
2929
foreach ($dokBand as $line) {
3030
if (array_key_exists($line->COL_DARC_DOK, $bandDok)) { /* For now ignore DOKs which are logged but not existing in the official lists any more */
31-
$bandDok[$line->COL_DARC_DOK][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . $line->COL_DARC_DOK . '","' . $band . '","' . $postdata['mode'] . '","DOK", "")\'>W</a></div>';
31+
$bandDok[$line->COL_DARC_DOK][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . $line->COL_DARC_DOK . '","' . $band . '","All","All","' . $postdata['mode'] . '","DOK", "")\'>W</a></div>';
3232
$doks[$line->COL_DARC_DOK]['count']++;
3333
}
3434
}
@@ -38,7 +38,7 @@ function get_dok_array($bands, $postdata, $location_list) {
3838
$dokBand = $this->getDokConfirmed($location_list, $band, $postdata);
3939
foreach ($dokBand as $line) {
4040
if (array_key_exists($line->COL_DARC_DOK, $bandDok)) { /* For now ignore DOKs which are logged but not existing in the official lists any more */
41-
$bandDok[$line->COL_DARC_DOK][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $line->COL_DARC_DOK . '","' . $band . '","' . $postdata['mode'] . '","DOK", "'.$qsl.'")\'>C</a></div>';
41+
$bandDok[$line->COL_DARC_DOK][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $line->COL_DARC_DOK . '","' . $band . '","All","All","' . $postdata['mode'] . '","DOK", "'.$qsl.'")\'>C</a></div>';
4242
$doks[$line->COL_DARC_DOK]['count']++;
4343
}
4444
}

application/models/Dxcc.php

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ function info($callsign) {
3333
}
3434
}
3535

36-
function search(){
37-
print_r($this->input->get());
38-
return;
39-
}
40-
41-
function empty_table($table) {
42-
$this->db->empty_table($table);
43-
}
44-
4536
/*
4637
* Fetches a list of all dxcc's, both current and deleted
4738
*/
@@ -89,15 +80,15 @@ function get_dxcc_array($dxccArray, $bands, $postdata) {
8980
if ($postdata['worked'] != NULL) {
9081
$workedDXCC = $this->getDxccBandWorked($location_list, $band, $postdata);
9182
foreach ($workedDXCC as $wdxcc) {
92-
$dxccMatrix[$wdxcc->dxcc][$band] = '<div class="bg-danger awardsBgDanger" ><a href=\'javascript:displayContacts("'.str_replace("&", "%26", $wdxcc->name).'","'. $band . '","'. $postdata['mode'] . '","DXCC", "")\'>W</a></div>';
83+
$dxccMatrix[$wdxcc->dxcc][$band] = '<div class="bg-danger awardsBgDanger" ><a href=\'javascript:displayContacts("'.str_replace("&", "%26", $wdxcc->name).'","'. $band . '","'. $postdata['sat'] . '","' . $postdata['orbit'] . '","'. $postdata['mode'] . '","DXCC", "")\'>W</a></div>';
9384
}
9485
}
9586

9687
// If confirmed is checked, we add confirmed entities to the array
9788
if ($postdata['confirmed'] != NULL) {
9889
$confirmedDXCC = $this->getDxccBandConfirmed($location_list, $band, $postdata);
9990
foreach ($confirmedDXCC as $cdxcc) {
100-
$dxccMatrix[$cdxcc->dxcc][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("'.str_replace("&", "%26", $cdxcc->name).'","'. $band . '","'. $postdata['mode'] . '","DXCC","'.$qsl.'")\'>C</a></div>';
91+
$dxccMatrix[$cdxcc->dxcc][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("'.str_replace("&", "%26", $cdxcc->name).'","'. $band . '","'. $postdata['sat'] . '","'. $postdata['orbit'] . '","' . $postdata['mode'] . '","DXCC","'.$qsl.'")\'>C</a></div>';
10192
}
10293
}
10394
}
@@ -133,15 +124,23 @@ function getDxccBandConfirmed($location_list, $band, $postdata) {
133124
$sql = "select adif as dxcc, name from dxcc_entities
134125
join (
135126
select col_dxcc from ".$this->config->item('table_name')." thcv
127+
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
136128
where station_id in (" . $location_list .
137129
") and col_dxcc > 0";
138130

139131
$sql .= $this->genfunctions->addBandToQuery($band);
132+
if ($band == 'SAT') {
133+
if ($postdata['sat'] != 'All') {
134+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
135+
}
136+
}
140137

141138
if ($postdata['mode'] != 'All') {
142139
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
143140
}
144141

142+
$sql .= $this->addOrbitToQuery($postdata);
143+
145144
$sql .= $this->genfunctions->addQslToQuery($postdata);
146145

147146
$sql .= " group by col_dxcc
@@ -162,18 +161,27 @@ function getDxccBandWorked($location_list, $band, $postdata) {
162161
$sql = "select adif as dxcc, name from dxcc_entities
163162
join (
164163
select col_dxcc from ".$this->config->item('table_name')." thcv
164+
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
165165
where station_id in (" . $location_list .
166166
") and col_dxcc > 0";
167167
$sql .= $this->genfunctions->addBandToQuery($band);
168+
if ($band == 'SAT') {
169+
if ($postdata['sat'] != 'All') {
170+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
171+
}
172+
}
168173
if ($postdata['mode'] != 'All') {
169174
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
170175
}
176+
$sql .= $this->addOrbitToQuery($postdata);
177+
171178
$sql .= " group by col_dxcc
172179
) x on dxcc_entities.adif = x.col_dxcc";;
173180
if ($postdata['includedeleted'] == NULL) {
174181
$sql .= " and dxcc_entities.end is null";
175182
}
176183
$sql .= $this->addContinentsToQuery($postdata);
184+
177185
$query = $this->db->query($sql);
178186
return $query->result();
179187
}
@@ -193,11 +201,16 @@ function fetchDxcc($postdata) {
193201
from dxcc_entities";
194202

195203
if ($postdata['notworked'] == NULL) {
196-
$sql .= " join (select col_dxcc from " . $this->config->item('table_name') . " where station_id in (" . $location_list . ") and col_dxcc > 0";
204+
$sql .= " join (select col_dxcc from " . $this->config->item('table_name') . " thcv
205+
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
206+
where station_id in (" . $location_list . ") and col_dxcc > 0";
197207

198208
if ($postdata['band'] != 'All') {
199209
if ($postdata['band'] == 'SAT') {
200210
$sql .= " and col_prop_mode ='" . $postdata['band'] . "'";
211+
if ($postdata['sat'] != 'All') {
212+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
213+
}
201214
} else {
202215
$sql .= " and col_prop_mode !='SAT'";
203216
$sql .= " and col_band ='" . $postdata['band'] . "'";
@@ -208,6 +221,8 @@ function fetchDxcc($postdata) {
208221
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
209222
}
210223

224+
$sql .= $this->addOrbitToQuery($postdata);
225+
211226
$sql .= ' group by col_dxcc) x on dxcc_entities.adif = x.col_dxcc';
212227
}
213228

@@ -230,16 +245,30 @@ function getDxccWorked($location_list, $postdata) {
230245
join (
231246
select col_dxcc
232247
from ".$this->config->item('table_name')." thcv
248+
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
233249
where station_id in (" . $location_list .
234250
") and col_dxcc > 0";
235251
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
252+
if ($postdata['band'] == 'SAT') {
253+
if ($postdata['sat'] != 'All') {
254+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
255+
}
256+
}
257+
258+
$sql .= $this->addOrbitToQuery($postdata);
236259

237260
if ($postdata['mode'] != 'All') {
238261
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
239262
}
240263

241264
$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";
242265
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
266+
if ($postdata['band'] == 'SAT') {
267+
if ($postdata['sat'] != 'All') {
268+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
269+
}
270+
}
271+
$sql .= $this->addOrbitToQuery($postdata);
243272

244273
if ($postdata['mode'] != 'All') {
245274
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
@@ -256,6 +285,7 @@ function getDxccWorked($location_list, $postdata) {
256285
}
257286

258287
$sql .= $this->addContinentsToQuery($postdata);
288+
259289
$query = $this->db->query($sql);
260290
return $query->result();
261291
}
@@ -265,15 +295,23 @@ function getDxccConfirmed($location_list, $postdata) {
265295
join (
266296
select col_dxcc
267297
from ".$this->config->item('table_name')." thcv
298+
LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name
268299
where station_id in (". $location_list .
269300
") and col_dxcc > 0";
270301

271302
$sql .= $this->genfunctions->addBandToQuery($postdata['band']);
303+
if ($postdata['band'] == 'SAT') {
304+
if ($postdata['sat'] != 'All') {
305+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
306+
}
307+
}
272308

273309
if ($postdata['mode'] != 'All') {
274310
$sql .= " and (col_mode = '" . $postdata['mode'] . "' or col_submode = '" . $postdata['mode'] . "')";
275311
}
276312

313+
$sql .= $this->addOrbitToQuery($postdata);
314+
277315
$sql .= $this->genfunctions->addQslToQuery($postdata);
278316

279317
$sql .= " group by col_dxcc
@@ -286,6 +324,7 @@ function getDxccConfirmed($location_list, $postdata) {
286324

287325
$sql .= $this->addContinentsToQuery($postdata);
288326

327+
289328
$query = $this->db->query($sql);
290329

291330
return $query->result();
@@ -356,12 +395,16 @@ function get_dxcc_summary($bands, $postdata) {
356395

357396
function getSummaryByBand($band, $postdata, $location_list) {
358397
$sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv";
398+
$sql .= " LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name";
359399
$sql .= " join dxcc_entities d on thcv.col_dxcc = d.adif";
360400

361401
$sql .= " where station_id in (" . $location_list . ") and col_dxcc > 0";
362402

363403
if ($band == 'SAT') {
364404
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
405+
if ($band != 'All') {
406+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
407+
}
365408
} else if ($band == 'All') {
366409
$this->load->model('bands');
367410

@@ -386,19 +429,35 @@ function getSummaryByBand($band, $postdata, $location_list) {
386429

387430
$sql .= $this->addContinentsToQuery($postdata);
388431

432+
$sql .= $this->addOrbitToQuery($postdata);
433+
389434
$query = $this->db->query($sql);
390435

391436
return $query->result();
392437
}
393438

439+
// Adds orbit type to query
440+
function addOrbitToQuery($postdata) {
441+
$sql = '';
442+
if ($postdata['orbit'] != 'All') {
443+
$sql .= ' AND satellite.orbit = \''.$postdata['orbit'].'\'';
444+
}
445+
446+
return $sql;
447+
}
448+
394449
function getSummaryByBandConfirmed($band, $postdata, $location_list) {
395450
$sql = "SELECT count(distinct thcv.col_dxcc) as count FROM " . $this->config->item('table_name') . " thcv";
451+
$sql .= " LEFT JOIN satellite on thcv.COL_SAT_NAME = satellite.name";
396452
$sql .= " join dxcc_entities d on thcv.col_dxcc = d.adif";
397453

398454
$sql .= " where station_id in (" . $location_list . ")";
399455

400456
if ($band == 'SAT') {
401457
$sql .= " and thcv.col_prop_mode ='" . $band . "'";
458+
if ($postdata['sat'] != 'All') {
459+
$sql .= " and col_sat_name ='" . $postdata['sat'] . "'";
460+
}
402461
} else if ($band == 'All') {
403462
$this->load->model('bands');
404463

@@ -419,6 +478,8 @@ function getSummaryByBandConfirmed($band, $postdata, $location_list) {
419478

420479
$sql .= $this->genfunctions->addQslToQuery($postdata);
421480

481+
$sql .= $this->addOrbitToQuery($postdata);
482+
422483

423484
if ($postdata['includedeleted'] == NULL) {
424485
$sql .= " and d.end is null";

application/models/Helvetia_model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ function get_helvetia_array($bands, $postdata) {
3838
if ($postdata['worked'] != NULL) {
3939
$helvetiaBand = $this->gethelvetiaWorked($location_list, $band, $postdata);
4040
foreach ($helvetiaBand as $line) {
41-
$bandhelvetia[$line->col_state][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . $line->col_state . '","' . $band . '","'. $postdata['mode'] . '","helvetia", "")\'>W</a></div>';
41+
$bandhelvetia[$line->col_state][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . $line->col_state . '","' . $band . '","All","All","'. $postdata['mode'] . '","helvetia", "")\'>W</a></div>';
4242
$states[$line->col_state]['count']++;
4343
}
4444
}
4545
if ($postdata['confirmed'] != NULL) {
4646
$helvetiaBand = $this->gethelvetiaConfirmed($location_list, $band, $postdata);
4747
foreach ($helvetiaBand as $line) {
48-
$bandhelvetia[$line->col_state][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $line->col_state . '","' . $band . '","'. $postdata['mode'] . '","helvetia", "'.$qsl.'")\'>C</a></div>';
48+
$bandhelvetia[$line->col_state][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $line->col_state . '","' . $band . '","All","All","'. $postdata['mode'] . '","helvetia", "'.$qsl.'")\'>C</a></div>';
4949
$states[$line->col_state]['count']++;
5050
}
5151
}

application/models/Iota.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ function get_iota_array($iotaArray, $bands, $postdata) {
2929
if ($postdata['worked'] != NULL) {
3030
$workedIota = $this->getIotaBandWorked($location_list, $band, $postdata);
3131
foreach ($workedIota as $wiota) {
32-
$iotaMatrix[$wiota->tag][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("'.$wiota->tag.'","'. $band . '","'. $postdata['mode'] . '","IOTA")\'>W</a></div>';
32+
$iotaMatrix[$wiota->tag][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("'.$wiota->tag.'","'. $band . '","All","All","'. $postdata['mode'] . '","IOTA")\'>W</a></div>';
3333
}
3434
}
3535

3636
// If confirmed is checked, we add confirmed iotas to the array
3737
if ($postdata['confirmed'] != NULL) {
3838
$confirmedIota = $this->getIotaBandConfirmed($location_list, $band, $postdata);
3939
foreach ($confirmedIota as $ciota) {
40-
$iotaMatrix[$ciota->tag][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("'.$ciota->tag.'","'. $band . '","'. $postdata['mode'] . '","IOTA")\'>C</a></div>';
40+
$iotaMatrix[$ciota->tag][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("'.$ciota->tag.'","'. $band . '","All","All","'. $postdata['mode'] . '","IOTA")\'>C</a></div>';
4141
}
4242
}
4343
}

application/models/Jcc_model.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -855,14 +855,14 @@ function get_jcc_array($bands, $postdata) {
855855
if ($postdata['worked'] != NULL) {
856856
$jccBand = $this->getJccWorked($location_list, $band, $postdata);
857857
foreach ($jccBand as $line) {
858-
$bandJcc[$line->col_cnty][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . $line->col_cnty . '","' . $band . '","'. $postdata['mode'] . '","JCC", "")\'>W</a></div>';
858+
$bandJcc[$line->col_cnty][$band] = '<div class="bg-danger awardsBgDanger"><a href=\'javascript:displayContacts("' . $line->col_cnty . '","' . $band . '","All","All","'. $postdata['mode'] . '","JCC", "")\'>W</a></div>';
859859
$cities[$line->col_cnty]['count']++;
860860
}
861861
}
862862
if ($postdata['confirmed'] != NULL) {
863863
$jccBand = $this->getJccConfirmed($location_list, $band, $postdata);
864864
foreach ($jccBand as $line) {
865-
$bandJcc[$line->col_cnty][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $line->col_cnty . '","' . $band . '","'. $postdata['mode'] . '","JCC", "'.$qsl.'")\'>C</a></div>';
865+
$bandJcc[$line->col_cnty][$band] = '<div class="bg-success awardsBgSuccess"><a href=\'javascript:displayContacts("' . $line->col_cnty . '","' . $band . '","All","All","'. $postdata['mode'] . '","JCC", "'.$qsl.'")\'>C</a></div>';
866866
$cities[$line->col_cnty]['count']++;
867867
}
868868
}

0 commit comments

Comments
 (0)