-
Notifications
You must be signed in to change notification settings - Fork 0
/
SRBC.php
327 lines (299 loc) · 8.69 KB
/
SRBC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
<?php
/*
Plugin Name: SRBC
Description: Solid Rock Bible Camp Plugin for Registration and Displaying Users
Version: 0.8.12
*/
//Require
require_once "admin/shortcodes.php";
require_once "admin/menus.php";
require_once "functions.php";
//Initial install code, setting up database
function srbc_install() {
//Create a table for campers
$sql = "CREATE TABLE IF NOT EXISTS srbc_campers (
camper_id INT AUTO_INCREMENT,
camper_first_name TINYTEXT NOT NULL,
camper_last_name TINYTEXT NOT NULL,
parent_first_name TINYTEXT NOT NULL,
parent_last_name TINYTEXT NOT NULL,
email TEXT NOT NULL,
birthday DATE,
address TEXT NOT NULL,
city TINYTEXT NOT NULL,
state TINYTEXT NOT NULL,
zipcode MEDIUMINT NOT NULL,
phone TINYTEXT NOT NULL,
phone2 TINYTEXT,
grade TINYTEXT NOT NULL,
gender TINYTEXT NOT NULL,
age TINYINT NOT NULL,
notes TEXT,
tshirt_size TINYTEXT,
PRIMARY KEY (camper_id)
) ENGINE=INNODB;";
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta( $sql );
//Create a table for Camps
$sql = "CREATE TABLE IF NOT EXISTS srbc_camps (
camp_id INT AUTO_INCREMENT,
area TINYTEXT NOT NULL,
name TINYTEXT NOT NULL,
description TEXT NOT NULL,
start_date DATE,
end_date DATE,
dropoff_time TINYTEXT NOT NULL,
pickup_time TINYTEXT NOT NULL,
cost SMALLINT NOT NULL,
horse_cost SMALLINT,
horse_opt_cost TINYINT NOT NULL,
horse_list_size TINYINT NOT NULL,
horse_waiting_list_size TINYINT NOT NULL,
waiting_list_size SMALLINT NOT NULL,
boy_registration_size SMALLINT NOT NULL,
girl_registration_size SMALLINT NOT NULL,
overall_size SMALLINT NOT NULL,
grade_range TINYTEXT NOT NULL,
closed_to_registrations TINYINT,
day_camp TINYINT,
hidden TINYINT,
PRIMARY KEY (camp_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Create a registration database that keeps track of individual registrations.
//Waitlist is 0 if they are not on the waitlist and a 1 if they are on the waitlist
//Horse_waiting list is the same as above ^
$sql = "CREATE TABLE IF NOT EXISTS srbc_registration (
registration_id INT AUTO_INCREMENT,
camp_id INT NOT NULL,
camper_id INT NOT NULL,
date TINYTEXT NOT NULL,
counselor TINYTEXT,
assistant_counselor TINYTEXT,
lodging TINYTEXT,
horse_opt TINYINT NOT NULL,
busride TINYTEXT NOT NULL,
discount_type TINYTEXT,
discount FLOAT(6,2),
scholarship_amt FLOAT(6,2) ,
scholarship_type TINYTEXT,
waitlist TINYINT NOT NULL,
horse_waitlist TINYINT NOT NULL,
checked_in TINYINT NOT NULL,
health_form TINYINT NOT NULL,
packing_list_sent TINYINT NOT NULL,
registration_notes TEXT,
PRIMARY KEY (registration_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Inactive registrations table
$sql = "CREATE TABLE IF NOT EXISTS srbc_registration_inactive (
registration_id INT AUTO_INCREMENT,
camp_id INT NOT NULL,
camper_id INT NOT NULL,
date TINYTEXT NOT NULL,
counselor TINYTEXT,
assistant_counselor TINYTEXT,
lodging TINYTEXT,
horse_opt TINYINT NOT NULL,
busride TINYTEXT NOT NULL,
discount_type TINYTEXT,
discount FLOAT(6,2),
scholarship_amt FLOAT(6,2) ,
scholarship_type TINYTEXT,
waitlist TINYINT NOT NULL,
horse_waitlist TINYINT NOT NULL,
checked_in TINYINT NOT NULL,
health_form TINYINT NOT NULL,
packing_list_sent TINYINT NOT NULL,
registration_notes TEXT,
PRIMARY KEY (registration_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Database keeping track of payments
$sql = "CREATE TABLE IF NOT EXISTS srbc_payments (
payment_id INT AUTO_INCREMENT,
registration_id INT NOT NULL,
payment_type TINYTEXT NOT NULL,
payment_amt FLOAT(6,2) NOT NULL,
payment_date TINYTEXT,
note TINYTEXT,
fee_type TINYTEXT,
registration_day TINYINT,
entered_by TINYTEXT,
PRIMARY KEY (payment_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Create application database for staff applications
$sql = "CREATE TABLE IF NOT EXISTS srbc_staff_app (
staff_app_id INT AUTO_INCREMENT,
Firstname TINYTEXT,
Middlename TINYTEXT,
Lastname TINYTEXT,
ssn TEXT NOT NULL,
PRIMARY KEY (staff_app_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Create health form database
$sql = "CREATE TABLE IF NOT EXISTS srbc_health_form (
health_form_id INT AUTO_INCREMENT,
camper_id INT,
IV TEXT,
aesKey TEXT,
data TEXT,
PRIMARY KEY (health_form_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Create parental_agreements_versions database
//This is for storing different versions of the parental agreements so that the parent's
//signature is on the correct one if the agreement gets updated
$sql = "CREATE TABLE IF NOT EXISTS srbc_parental_agreements_versions (
agreement_id INT AUTO_INCREMENT,
agreement_text MEDIUMTEXT,
PRIMARY KEY (agreement_id)
) ENGINE=INNODB;";
dbDelta( $sql );
//Create database for parental_agreement_signatures
$sql = "CREATE TABLE IF NOT EXISTS srbc_parental_agreements_sig (
agreement_sig_id INT AUTO_INCREMENT,
camper_id INT,
signature_img MEDIUMTEXT,
agreement_id INT,
PRIMARY KEY (agreement_sig_id)
) ENGINE=INNODB;";
dbDelta( $sql );
}
register_activation_hook( __FILE__, 'srbc_install' );
//Debugging stuff
/*register_activation_hook( __FILE__, 'my_activation_func' );
function my_activation_func() {
file_put_contents( __DIR__ . '/my_loggg.txt', ob_get_contents() );
}*/
//Remove any things we have setup
function pluginprefix_deactivation() {
}
register_deactivation_hook( __FILE__, 'pluginprefix_deactivation' );
/*----------------------------------------------------------------------
MENU HOOKS
*/
//Master page
function srbc_overview()
{
add_menu_page(
'SRBC',
'SRBC',
'manage_options',
'srbc_overview',
'srbc_overview_page',
plugin_dir_url(__FILE__) . 'images\SRBC-logo.png',
50
);
}
add_action('admin_menu', 'srbc_overview');
//Submenus
function srbc_campers()
{
add_submenu_page(
'srbc_overview',
'Camper Management',
'Camper Management',
'manage_options',
'camper_management',
'srbc_camper_management'
);
}
add_action('admin_menu', 'srbc_campers');
//Submenu Camps
function camps_list()
{
add_submenu_page(
'srbc_overview',
'Camps Management',
'Camps Management',
'manage_options',
'camp_management',
'srbc_camps_management'
);
}
add_action('admin_menu', 'camps_list');
function camps_reports()
{
add_submenu_page(
'srbc_overview',
'Reports',
'Reports',
'manage_options',
'camp_reports',
'srbc_camp_reports'
);
}
add_action('admin_menu', 'camps_reports');
function program_menu()
{
add_submenu_page(
'srbc_overview',
'Camper Lodging',
'Camper Lodging',
'manage_options',
'srbc_program_access',
'srbc_program_access'
);
}
add_action('admin_menu', 'program_menu');
function staff_app_setup()
{
add_submenu_page(
'srbc_overview',
'Staff Applications',
'Staff Applications',
'manage_options',
'staff_application_menu',
'staff_application_menu'
);
}
add_action('admin_menu', 'staff_app_setup');
function settings()
{
add_submenu_page(
'srbc_overview',
'Settings',
'Settings',
'manage_options',
'srbc_settings',
'srbc_settings'
);
}
add_action('admin_menu', 'settings');
//END MENUS
//Settings
function register_my_setting() {
$args = array(
'type' => 'string',
'default' => NULL,
);
register_setting( 'srbc_options_group', 'srbc_database_year', $args );
register_setting( 'srbc_options_group', 'srbc_summer_camps_disable', $args );
}
add_action( 'admin_init', 'register_my_setting');
//Notice for if they are currently in a different database year
function database_notice(){
if (get_option("srbc_database_year") != "")
{
echo '<div class="notice notice-warning is-dismissible">
<p>Notice you are currently using the '. get_option("srbc_database_year") .' database.</p>
</div>';
}
}
add_action('admin_notices', 'database_notice');
//Shortcodes
add_shortcode( 'srbc_registration', 'srbc_registration' );
add_shortcode( 'srbc_registration_complete', 'srbc_registration_complete' );
add_shortcode( 'srbc_camps', 'srbc_camps' );
add_shortcode( 'srbc_application', 'srbc_application' );
add_shortcode( 'srbc_application_complete', 'srbc_application_complete' );
add_shortcode( 'srbc_camp_search', 'srbc_camp_search' );
add_shortcode( 'srbc_contact_form_email', 'srbc_contact_form_email' );
add_shortcode( 'srbc_volunteer_contact_form_email', 'srbc_volunteer_contact_form_email' );
add_shortcode( 'srbc_health_form_generate', 'srbc_health_form_generate' );
add_shortcode( 'srbc_make_payment_on_camper', 'srbc_make_payment_on_camper' );
add_shortcode( 'srbc_make_donation', 'srbc_make_donation' );