1
+ <?php
2
+
3
+ if ( ! defined ('BASEPATH ' )) exit ('No direct script access allowed ' );
4
+
5
+
6
+ /*
7
+ This controller contains features for Cabrillo
8
+ */
9
+
10
+ class Cabrillo extends CI_Controller {
11
+
12
+ function __construct () {
13
+ parent ::__construct ();
14
+
15
+ $ this ->load ->model ('user_model ' );
16
+ if (!$ this ->user_model ->authorize (2 )) { $ this ->session ->set_flashdata ('notice ' , 'You \'re not allowed to do that! ' ); redirect ('dashboard ' ); }
17
+ }
18
+
19
+ public function index () {
20
+ $ data ['page_title ' ] = "Export Cabrillo " ;
21
+
22
+ $ this ->load ->model ('Contesting_model ' );
23
+ $ this ->load ->model ('stations ' );
24
+
25
+ $ data ['station_profile ' ] = $ this ->stations ->all_of_user ();
26
+ $ active_station_id = $ this ->stations ->find_active ();
27
+ $ station_profile = $ this ->stations ->profile ($ active_station_id );
28
+
29
+ $ data ['active_station_info ' ] = $ station_profile ->row ();
30
+
31
+ $ footerData = [];
32
+ $ footerData ['scripts ' ] = [
33
+ 'assets/js/sections/cabrillo.js '
34
+ ];
35
+
36
+ $ this ->load ->view ('interface_assets/header ' , $ data );
37
+ $ this ->load ->view ('cabrillo/index ' );
38
+ $ this ->load ->view ('interface_assets/footer ' , $ footerData );
39
+ }
40
+
41
+ public function getContests () {
42
+ $ this ->load ->model ('Contesting_model ' );
43
+
44
+ $ station_id = $ this ->security ->xss_clean ($ this ->input ->post ('station_id ' ));
45
+ $ year = $ this ->security ->xss_clean ($ this ->input ->post ('year ' ));
46
+ $ result = $ this ->Contesting_model ->get_logged_contests ($ station_id , $ year );
47
+
48
+ header ('Content-Type: application/json ' );
49
+ echo json_encode ($ result );
50
+ }
51
+
52
+ public function getYears () {
53
+ $ this ->load ->model ('Contesting_model ' );
54
+ $ station_id = $ this ->security ->xss_clean ($ this ->input ->post ('station_id ' ));
55
+
56
+ $ result = $ this ->Contesting_model ->get_logged_years ($ station_id );
57
+
58
+ header ('Content-Type: application/json ' );
59
+ echo json_encode ($ result );
60
+ }
61
+
62
+ public function getContestDates () {
63
+ $ this ->load ->model ('Contesting_model ' );
64
+ $ station_id = $ this ->security ->xss_clean ($ this ->input ->post ('station_id ' ));
65
+ $ year = $ this ->security ->xss_clean ($ this ->input ->post ('year ' ));
66
+ $ contestid = $ this ->security ->xss_clean ($ this ->input ->post ('contestid ' ));
67
+
68
+ $ result = $ this ->Contesting_model ->get_contest_dates ($ station_id , $ year , $ contestid );
69
+
70
+ header ('Content-Type: application/json ' );
71
+ echo json_encode ($ result );
72
+ }
73
+
74
+ public function export () {
75
+ // Set memory limit to unlimited to allow heavy usage
76
+ ini_set ('memory_limit ' , '-1 ' );
77
+ $ this ->load ->model ('Contesting_model ' );
78
+
79
+ $ this ->load ->model ('stations ' );
80
+
81
+ $ this ->load ->model ('user_model ' );
82
+
83
+ $ station_id = $ this ->security ->xss_clean ($ this ->input ->post ('station_id ' ));
84
+ $ contest_id = $ this ->security ->xss_clean ($ this ->input ->post ('contestid ' ));
85
+
86
+ $ from = $ this ->security ->xss_clean ($ this ->input ->post ('contestdatesfrom ' ));
87
+ $ to = $ this ->security ->xss_clean ($ this ->input ->post ('contestdatesto ' ));
88
+
89
+ $ station = $ this ->stations ->profile ($ station_id );
90
+
91
+ $ station = $ station ->row ();
92
+
93
+ $ userinfo = $ this ->user_model ->get_by_id ($ this ->session ->userdata ('user_id ' ));
94
+
95
+ $ userinfo = $ userinfo ->row ();
96
+
97
+ $ data ['qsos ' ] = $ this ->Contesting_model ->export_custom ($ from , $ to , $ contest_id , $ station_id );
98
+
99
+ $ data ['contest_id ' ] = $ contest_id ;
100
+ $ data ['callsign ' ] = $ station ->station_callsign ;
101
+ $ data ['claimed_score ' ] = '' ;
102
+ $ data ['categoryoperator ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categoryoperator ' ));
103
+ $ data ['categoryassisted ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categoryassisted ' ));
104
+ $ data ['categoryband ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categoryband ' ));
105
+ $ data ['categorymode ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categorymode ' ));
106
+ $ data ['categorypower ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categorypower ' ));
107
+ $ data ['categorystation ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categorystation ' ));
108
+ $ data ['categorytransmitter ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categorytransmitter ' ));
109
+ $ data ['categoryoverlay ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('categoryoverlay ' ));
110
+ $ data ['operators ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('operators ' ));
111
+ $ data ['club ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('club ' ));
112
+ $ data ['name ' ] = $ userinfo ->user_firstname . ' ' . $ userinfo ->user_lastname ;
113
+ $ data ['email ' ] = $ userinfo ->user_email ;
114
+ $ data ['address ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('address ' ));
115
+ $ data ['addresscity ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('addresscity ' ));
116
+ $ data ['addressstateprovince ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('addressstateprovince ' ));
117
+ $ data ['addresspostalcode ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('addresspostalcode ' ));
118
+ $ data ['addresscountry ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('addresscountry ' ));
119
+ $ data ['soapbox ' ] = $ this ->security ->xss_clean ($ this ->input ->post ('soapbox ' ));
120
+ $ data ['gridlocator ' ] = $ station ->station_gridsquare ;
121
+
122
+ $ this ->load ->view ('cabrillo/export ' , $ data );
123
+ }
124
+ }
0 commit comments