@@ -58,9 +58,13 @@ function index()
58
58
if ($ this ->session ->userdata ('user_locator ' )) {
59
59
$ this ->load ->library ('qra ' );
60
60
$ qra_position = $ this ->qra ->qra2latlong ($ this ->session ->userdata ('user_locator ' ));
61
- $ data ['qra ' ] = "set " ;
62
- $ data ['qra_lat ' ] = $ qra_position [0 ];
63
- $ data ['qra_lng ' ] = $ qra_position [1 ];
61
+ if (isset ($ qra_position [0 ]) and isset ($ qra_position [1 ])) {
62
+ $ data ['qra ' ] = "set " ;
63
+ $ data ['qra_lat ' ] = $ qra_position [0 ];
64
+ $ data ['qra_lng ' ] = $ qra_position [1 ];
65
+ } else {
66
+ $ data ['qra ' ] = "none " ;
67
+ }
64
68
} else {
65
69
$ data ['qra ' ] = "none " ;
66
70
}
@@ -638,13 +642,65 @@ function partial($id) {
638
642
}
639
643
}
640
644
641
- function search_result ($ id ="" ) {
645
+ function search_result ($ id ="" , $ id2 = "" ) {
642
646
$ this ->load ->model ('user_model ' );
643
-
647
+
644
648
if (!$ this ->user_model ->authorize ($ this ->config ->item ('auth_mode ' ))) { return ; }
649
+
650
+ $ fixedid = $ id ;
651
+
652
+ if ($ id2 != "" ) {
653
+ $ fixedid = $ id . '/ ' . $ id2 ;
654
+ }
655
+
656
+ $ query = $ this ->querydb ($ fixedid );
657
+
658
+ if ($ query ->num_rows () == 0 ) {
659
+ $ query = $ this ->querydb ($ id );
660
+
661
+ if ($ query ->num_rows () > 0 ) {
662
+ $ data ['results ' ] = $ query ;
663
+ $ this ->load ->view ('view_log/partial/log_ajax.php ' , $ data );
664
+ }
665
+ else {
666
+ $ this ->load ->model ('search ' );
667
+
668
+ $ iota_search = $ this ->search ->callsign_iota ($ id );
669
+
670
+ if ($ iota_search ->num_rows () > 0 )
671
+ {
672
+ $ data ['results ' ] = $ iota_search ;
673
+ $ this ->load ->view ('view_log/partial/log_ajax.php ' , $ data );
674
+ } else {
675
+ if ($ this ->config ->item ('callbook ' ) == "qrz " && $ this ->config ->item ('qrz_username ' ) != null && $ this ->config ->item ('qrz_password ' ) != null ) {
676
+ // Lookup using QRZ
677
+ $ this ->load ->library ('qrz ' );
645
678
646
- //$this->db->select(''.$this->config->item('table_name').'.COL_CALL, '.$this->config->item('table_name').'.COL_BAND, '.$this->config->item('table_name').'.COL_TIME_ON, '.$this->config->item('table_name').'.COL_RST_RCVD, '.$this->config->item('table_name').'.COL_RST_SENT, '.$this->config->item('table_name').'.COL_MODE, '.$this->config->item('table_name').'.COL_SUBMODE, '.$this->config->item('table_name').'.COL_NAME, '.$this->config->item('table_name').'.COL_COUNTRY, '.$this->config->item('table_name').'.COL_PRIMARY_KEY, '.$this->config->item('table_name').'.COL_SAT_NAME, '.$this->config->item('table_name').'.COL_GRIDSQUARE, '.$this->config->item('table_name').'.COL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_RCVD, '.$this->config->item('table_name').'.COL_EQSL_QSL_SENT, '.$this->config->item('table_name').'.COL_QSL_SENT, '.$this->config->item('table_name').'.COL_STX, '.$this->config->item('table_name').'.COL_STX_STRING, '.$this->config->item('table_name').'.COL_SRX, '.$this->config->item('table_name').'.COL_SRX_STRING, '.$this->config->item('table_name').'.COL_LOTW_QSL_SENT, '.$this->config->item('table_name').'.COL_LOTW_QSL_RCVD, '.$this->config->item('table_name').'.COL_VUCC_GRIDS, station_profile.*');
679
+ if (!$ this ->session ->userdata ('qrz_session_key ' )) {
680
+ $ qrz_session_key = $ this ->qrz ->session ($ this ->config ->item ('qrz_username ' ), $ this ->config ->item ('qrz_password ' ));
681
+ $ this ->session ->set_userdata ('qrz_session_key ' , $ qrz_session_key );
682
+ }
647
683
684
+ $ data ['callsign ' ] = $ this ->qrz ->search ($ id , $ this ->session ->userdata ('qrz_session_key ' ), $ this ->config ->item ('use_fullname ' ));
685
+ } /*else {
686
+ // Lookup using hamli
687
+ $this->load->library('hamli');
688
+
689
+ $data['callsign'] = $this->hamli->callsign($id);
690
+ }*/
691
+
692
+ $ data ['id ' ] = strtoupper ($ id );
693
+
694
+ $ this ->load ->view ('search/result ' , $ data );
695
+ }
696
+ }
697
+ } else {
698
+ $ data ['results ' ] = $ query ;
699
+ $ this ->load ->view ('view_log/partial/log_ajax.php ' , $ data );
700
+ }
701
+ }
702
+
703
+ function querydb ($ id ) {
648
704
$ this ->db ->from ($ this ->config ->item ('table_name ' ));
649
705
$ this ->db ->join ('station_profile ' , 'station_profile.station_id = ' .$ this ->config ->item ('table_name ' ).'.station_id ' );
650
706
$ this ->db ->group_start ();
@@ -654,47 +710,75 @@ function search_result($id="") {
654
710
$ this ->db ->group_end ();
655
711
$ this ->db ->where ('station_profile.user_id ' , $ this ->session ->userdata ('user_id ' ));
656
712
$ this ->db ->order_by ('' .$ this ->config ->item ('table_name ' ).'.COL_TIME_ON ' , 'desc ' );
657
- $ query = $ this ->db ->get ();
713
+ return $ this ->db ->get ();
714
+ }
658
715
659
- if ($ query ->num_rows () > 0 )
660
- {
661
- $ data ['results ' ] = $ query ;
662
- $ this ->load ->view ('view_log/partial/log_ajax.php ' , $ data );
663
- } else {
664
- $ this ->load ->model ('search ' );
716
+ function search_duplicates ($ station_id ) {
717
+ $ station_id = $ this ->security ->xss_clean ($ station_id );
665
718
666
- $ iota_search = $ this ->search -> callsign_iota ( $ id );
719
+ $ this ->load -> model ( ' user_model ' );
667
720
668
- if ($ iota_search ->num_rows () > 0 )
669
- {
670
- $ data ['results ' ] = $ iota_search ;
671
- $ this ->load ->view ('view_log/partial/log_ajax.php ' , $ data );
672
- } else {
673
- if ($ this ->config ->item ('callbook ' ) == "qrz " && $ this ->config ->item ('qrz_username ' ) != null && $ this ->config ->item ('qrz_password ' ) != null ) {
674
- // Lookup using QRZ
675
- $ this ->load ->library ('qrz ' );
721
+ if (!$ this ->user_model ->authorize ($ this ->config ->item ('auth_mode ' ))) { return ; }
722
+
723
+ $ CI =& get_instance ();
724
+ $ CI ->load ->model ('logbooks_model ' );
725
+ $ logbooks_locations_array = $ CI ->logbooks_model ->list_logbook_relationships ($ this ->session ->userdata ('active_station_logbook ' ));
726
+
727
+ if (!$ logbooks_locations_array ) {
728
+ return null ;
729
+ }
676
730
677
- if (!$ this ->session ->userdata ('qrz_session_key ' )) {
678
- $ qrz_session_key = $ this ->qrz ->session ($ this ->config ->item ('qrz_username ' ), $ this ->config ->item ('qrz_password ' ));
679
- $ this ->session ->set_userdata ('qrz_session_key ' , $ qrz_session_key );
680
- }
731
+ $ location_list = "' " .implode ("',' " ,$ logbooks_locations_array )."' " ;
732
+
733
+ $ sql = 'select count(*) as occurence, COL_CALL, COL_MODE, COL_SUBMODE, station_callsign, COL_SAT_NAME, COL_BAND, min(col_time_on) Mintime, max(col_time_on) Maxtime from ' . $ this ->config ->item ('table_name ' ) .
734
+ ' join station_profile on ' . $ this ->config ->item ('table_name ' ) . '.station_id = station_profile.station_id where ' . $ this ->config ->item ('table_name ' ) .'.station_id in ( ' . $ location_list . ') ' ;
735
+
736
+ if ($ station_id != 'All ' ) {
737
+ $ sql .= ' and station_profile.station_id = ' . $ station_id ;
738
+ }
739
+
740
+ $ sql .= ' group by col_call, col_mode, COL_SUBMODE, STATION_CALLSIGN, col_band, COL_SAT_NAME having count(*) > 1 and timediff(maxtime, mintime) < 3000 ' ;
681
741
682
- $ data ['callsign ' ] = $ this ->qrz ->search ($ id , $ this ->session ->userdata ('qrz_session_key ' ), $ this ->config ->item ('use_fullname ' ));
683
- } /*else {
684
- // Lookup using hamli
685
- $this->load->library('hamli');
742
+ $ query = $ this ->db ->query ($ sql );
686
743
687
- $data['callsign'] = $this->hamli->callsign($id);
688
- }*/
744
+ $ data ['qsos ' ] = $ query ;
689
745
690
- $ data [ ' id ' ] = strtoupper ( $ id );
746
+ $ this -> load -> view ( ' search/duplicates_result.php ' , $ data );
691
747
692
- $ this ->load ->view ('search/result ' , $ data );
693
- }
694
- }
695
748
}
696
749
750
+ function search_incorrect_cq_zones ($ station_id ) {
751
+ $ station_id = $ this ->security ->xss_clean ($ station_id );
697
752
753
+ $ this ->load ->model ('user_model ' );
754
+
755
+ if (!$ this ->user_model ->authorize ($ this ->config ->item ('auth_mode ' ))) { return ; }
756
+
757
+ $ CI =& get_instance ();
758
+ $ CI ->load ->model ('logbooks_model ' );
759
+ $ logbooks_locations_array = $ CI ->logbooks_model ->list_logbook_relationships ($ this ->session ->userdata ('active_station_logbook ' ));
760
+
761
+ if (!$ logbooks_locations_array ) {
762
+ return null ;
763
+ }
764
+
765
+ $ location_list = "' " .implode ("',' " ,$ logbooks_locations_array )."' " ;
766
+
767
+ $ sql = 'select *, (select group_concat(distinct cqzone order by cqzone) from dxcc_master where countrycode = thcv.col_dxcc and cqzone <> \'\' order by cqzone asc) as correctcqzone from ' . $ this ->config ->item ('table_name ' ) .
768
+ ' thcv join station_profile on thcv.station_id = station_profile.station_id where thcv.station_id in ( ' . $ location_list . ')
769
+ and not exists (select 1 from dxcc_master where countrycode = thcv.col_dxcc and cqzone = col_cqz) and col_dxcc > 0
770
+ ' ;
771
+
772
+ if ($ station_id != 'All ' ) {
773
+ $ sql .= ' and station_profile.station_id = ' . $ station_id ;
774
+ }
775
+
776
+ $ query = $ this ->db ->query ($ sql );
777
+
778
+ $ data ['qsos ' ] = $ query ;
779
+
780
+ $ this ->load ->view ('search/cqzones_result.php ' , $ data );
781
+ }
698
782
699
783
/*
700
784
* Provide a dxcc search, returning results json encoded
0 commit comments