@@ -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