Skip to content

Commit c556a42

Browse files
committed
Add advanced filtering and stats to WWFF awards page
Enhanced the WWFF awards page with band, mode, and QSL type filters, quick preset buttons, and a summary section showing worked/confirmed parks and milestone progress. Updated the controller to handle filter input and summary data, and extended the model with methods for filtered queries and statistics.
1 parent e85e180 commit c556a42

3 files changed

Lines changed: 446 additions & 4 deletions

File tree

application/controllers/Awards.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,30 @@ private function build_sota_options($meta, $field) {
547547
*/
548548
public function wwff()
549549
{
550-
551-
// Grab all worked wwff stations
552550
$this->load->model('wwff');
553-
$data['wwff_all'] = $this->wwff->get_all();
551+
$this->load->model('modes');
552+
$this->load->model('bands');
553+
554+
$data['worked_bands'] = $this->bands->get_worked_bands('wwff');
555+
$data['modes'] = $this->modes->active();
556+
557+
if ($this->input->method() === 'post') {
558+
$postdata['band'] = $this->security->xss_clean($this->input->post('band'));
559+
$postdata['mode'] = $this->security->xss_clean($this->input->post('mode'));
560+
$postdata['qsl'] = $this->security->xss_clean($this->input->post('qsl'));
561+
$postdata['lotw'] = $this->security->xss_clean($this->input->post('lotw'));
562+
$postdata['eqsl'] = $this->security->xss_clean($this->input->post('eqsl'));
563+
} else {
564+
$postdata['band'] = 'All';
565+
$postdata['mode'] = 'All';
566+
$postdata['qsl'] = 1;
567+
$postdata['lotw'] = 1;
568+
$postdata['eqsl'] = 0;
569+
}
570+
571+
$data['postdata'] = $postdata;
572+
$data['wwff_all'] = $this->wwff->get_all_filtered($postdata);
573+
$data['wwff_summary'] = $this->wwff->get_wwff_summary($postdata);
554574

555575
// Render page
556576
$data['page_title'] = "Awards - WWFF";

application/models/Wwff.php

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,143 @@ function get_all() {
2424

2525
return $this->db->get($this->config->item('table_name'));
2626
}
27+
28+
function get_all_filtered($postdata = array()) {
29+
$CI =& get_instance();
30+
$CI->load->model('logbooks_model');
31+
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
32+
33+
if (!$logbooks_locations_array) {
34+
return null;
35+
}
36+
37+
$this->load->model('bands');
38+
$bandslots = $this->bands->get_worked_bands('wwff');
39+
40+
if(!$bandslots) return null;
41+
42+
$this->db->where_in("station_id", $logbooks_locations_array);
43+
$this->db->where('COL_WWFF_REF !=', '');
44+
45+
// Apply band filter
46+
if (isset($postdata['band']) && $postdata['band'] != 'All') {
47+
if ($postdata['band'] == 'SAT') {
48+
$this->db->where('col_prop_mode', 'SAT');
49+
} else {
50+
$this->db->where('col_band', $postdata['band']);
51+
$this->db->where('col_prop_mode !=', 'SAT');
52+
}
53+
} else {
54+
$this->db->where_in("col_band", $bandslots);
55+
}
56+
57+
// Apply mode filter
58+
if (isset($postdata['mode']) && $postdata['mode'] != 'All') {
59+
$this->db->where("(col_mode = '" . $this->db->escape_str($postdata['mode']) . "' or col_submode = '" . $this->db->escape_str($postdata['mode']) . "')", NULL, FALSE);
60+
}
61+
62+
// Apply QSL filter
63+
if (isset($postdata['qsl']) || isset($postdata['lotw']) || isset($postdata['eqsl'])) {
64+
$qsl_conditions = array();
65+
if (isset($postdata['qsl']) && $postdata['qsl']) {
66+
$qsl_conditions[] = "col_qsl_rcvd = 'Y'";
67+
}
68+
if (isset($postdata['lotw']) && $postdata['lotw']) {
69+
$qsl_conditions[] = "col_lotw_qsl_rcvd = 'Y'";
70+
}
71+
if (isset($postdata['eqsl']) && $postdata['eqsl']) {
72+
$qsl_conditions[] = "col_eqsl_qsl_rcvd = 'Y'";
73+
}
74+
if (!empty($qsl_conditions)) {
75+
$this->db->where("(" . implode(" or ", $qsl_conditions) . ")", NULL, FALSE);
76+
}
77+
}
78+
79+
$this->db->order_by("COL_WWFF_REF", "ASC");
80+
$this->db->order_by("COL_TIME_ON", "DESC");
81+
82+
return $this->db->get($this->config->item('table_name'));
83+
}
84+
85+
function get_wwff_summary($postdata = array()) {
86+
$CI =& get_instance();
87+
$CI->load->model('logbooks_model');
88+
$logbooks_locations_array = $CI->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
89+
90+
if (!$logbooks_locations_array) {
91+
return null;
92+
}
93+
94+
$this->load->model('bands');
95+
$bandslots = $this->bands->get_worked_bands('wwff');
96+
97+
if(!$bandslots) return null;
98+
99+
// Count unique parks worked
100+
$this->db->select('count(distinct COL_WWFF_REF) as count');
101+
$this->db->where_in("station_id", $logbooks_locations_array);
102+
$this->db->where('COL_WWFF_REF !=', '');
103+
104+
if (isset($postdata['band']) && $postdata['band'] != 'All') {
105+
if ($postdata['band'] == 'SAT') {
106+
$this->db->where('col_prop_mode', 'SAT');
107+
} else {
108+
$this->db->where('col_band', $postdata['band']);
109+
$this->db->where('col_prop_mode !=', 'SAT');
110+
}
111+
} else {
112+
$this->db->where_in("col_band", $bandslots);
113+
}
114+
115+
if (isset($postdata['mode']) && $postdata['mode'] != 'All') {
116+
$this->db->where("(col_mode = '" . $this->db->escape_str($postdata['mode']) . "' or col_submode = '" . $this->db->escape_str($postdata['mode']) . "')", NULL, FALSE);
117+
}
118+
119+
$result = $this->db->get($this->config->item('table_name'));
120+
$total_parks = ($result->num_rows() > 0) ? $result->row()->count : 0;
121+
122+
// Count confirmed parks (with QSL)
123+
$this->db->select('count(distinct COL_WWFF_REF) as count');
124+
$this->db->where_in("station_id", $logbooks_locations_array);
125+
$this->db->where('COL_WWFF_REF !=', '');
126+
127+
if (isset($postdata['band']) && $postdata['band'] != 'All') {
128+
if ($postdata['band'] == 'SAT') {
129+
$this->db->where('col_prop_mode', 'SAT');
130+
} else {
131+
$this->db->where('col_band', $postdata['band']);
132+
$this->db->where('col_prop_mode !=', 'SAT');
133+
}
134+
} else {
135+
$this->db->where_in("col_band", $bandslots);
136+
}
137+
138+
if (isset($postdata['mode']) && $postdata['mode'] != 'All') {
139+
$this->db->where("(col_mode = '" . $this->db->escape_str($postdata['mode']) . "' or col_submode = '" . $this->db->escape_str($postdata['mode']) . "')", NULL, FALSE);
140+
}
141+
142+
$qsl_conditions = array();
143+
if (isset($postdata['qsl']) && $postdata['qsl']) {
144+
$qsl_conditions[] = "col_qsl_rcvd = 'Y'";
145+
}
146+
if (isset($postdata['lotw']) && $postdata['lotw']) {
147+
$qsl_conditions[] = "col_lotw_qsl_rcvd = 'Y'";
148+
}
149+
if (isset($postdata['eqsl']) && $postdata['eqsl']) {
150+
$qsl_conditions[] = "col_eqsl_qsl_rcvd = 'Y'";
151+
}
152+
if (!empty($qsl_conditions)) {
153+
$this->db->where("(" . implode(" or ", $qsl_conditions) . ")", NULL, FALSE);
154+
}
155+
156+
$result = $this->db->get($this->config->item('table_name'));
157+
$confirmed_parks = ($result->num_rows() > 0) ? $result->row()->count : 0;
158+
159+
return array(
160+
'total_parks' => $total_parks,
161+
'confirmed_parks' => $confirmed_parks
162+
);
163+
}
27164
}
28165

29166
?>

0 commit comments

Comments
 (0)