-
Notifications
You must be signed in to change notification settings - Fork 3
/
tm-online-application.php
1814 lines (841 loc) · 42.6 KB
/
tm-online-application.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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
//do_action('rsvpmaker_paypal_record_payment',$response,$_REQUEST);
add_action('rsvpmaker_paypal_record_payment',10,2);
function wp4t_paypal_application_payment($response,$get) {
rsvpmaker_debug_log($response,'wp4t_paypal_application_payment');
rsvpmaker_debug_log($get,'wp4t_paypal_application_payment http request');
global $wpdb;
}
function tm_member_application( $atts ) {
global $rsvp_options;
rsvpmaker_fix_timezone();
if ( isset( $_GET['rsvpstripeconfirm'] ) ) {
return; // let rsvpmaker show payment message
}
if ( isset( $_GET['paydues'] ) ) {
return paydues_later();
}
global $post;
if ( empty( $_POST['user_email'] ) ) {
return tm_application_form_start( $atts );
}
$notifications = get_option( 'tm_application_notifications' );
$titles = get_option('tm_application_titles');
if(!empty($titles))
{
foreach($titles as $title)
{
$officer_email = toastmasters_officer_email_by_title($title);
if(!empty($notifications) && !empty($officer_email))
$notifications .= ", ";
if(!empty($officer_email))
$notifications .= $officer_email;
}
}
if ( empty( $notifications ) ) {
$notifications = get_option( 'admin_email' );
}
// add code to buffer output, write to file on post
ob_start();
if ( ! is_admin() ) {
?>
<style>
label {
display: inline-block;
width: 150px;
}
</style>
<?php
}
include 'application-form.php';
$output = ob_get_clean();
$payprompt = '';
if(isset( $_POST['applicant_signature'] ) && empty( $_POST['applicant_signature'] ))
{
echo '<h2>Missing signature error</h2>';
return;//should have been caught with client side validation
}
if ( ! empty( $_POST['applicant_signature'] ) ) {
if(!wp_verify_nonce(rsvpmaker_nonce_data('data'),rsvpmaker_nonce_data('key')) )
wp_die('security error');
$content = preg_replace( '/(<(style)\b[^>]*>).*?(<\/\2>)/is', '$1$3', $output );
$newpost['post_type'] = 'tmapplication';
$newpost['post_status'] = 'private';
$newpost['post_content'] = wp_kses_post($content);
$newpost['post_title'] = 'Membership Application: ' . sanitize_text_field($_POST['first_name'] . ' ' . $_POST['last_name']);
$post_id = wp_insert_post( $newpost );
foreach ( $_POST as $slug => $value ) {
update_post_meta( $post_id, $slug, sanitize_text_field($value) );
}
$chosen_gateway = get_rsvpmaker_payment_gateway ();
$payprompt = '';
$vars['amount'] = get_post_meta( $post->ID, 'tm_application_fee', true );// fetch from page for form
if(empty($vars['amount']) && !empty($_POST['tm_application_fee']))
$vars['amount'] = sanitize_text_input($_POST['tm_application_fee']);
if(empty($vars['amount']))
$payprompt .= '<p style="color:red">Error recording dues amount.</p>';
update_post_meta( $post_id, 'tm_application_fee', $vars['amount'] );// record to app document
$until = get_post_meta( $post->ID, 'tm_application_until', true );// fetch from page for form
update_post_meta( $post_id, 'tm_application_until', $until );// record to app document
$vars['name'] = sanitize_text_field($_POST['first_name'] . ' ' . $_POST['last_name']);
$vars['email'] = sanitize_text_field($_POST['user_email']);
$vars['tracking'] = 'tmapplication' . $post_id;
$vars['description'] = 'Toastmasters Application '.$post_id.' '.$vars['name'];
$vars['name'] = sanitize_text_field($_POST['first_name'] . ' ' . $_POST['last_name']);
$vars['email'] = sanitize_text_field($_POST['user_email']);
$vars['tracking'] = 'tmapplication' . $post_id;
if ( ('Stripe' == $chosen_gateway ) || strpos($chosen_gateway,'Stripe') !== false ) {
$payprompt .= rsvpmaker_stripe_form( $vars );
}
if ( ('PayPal' == $chosen_gateway ) || strpos($chosen_gateway,'PayPal') !== false ) {
if(!empty($payprompt))
$payprompt .= '<p>Or pay with PayPal</p>';
$payprompt .= rsvpmaker_paypal_button( $vars['amount'], $rsvp_options['paypal_currency'], $vars['description'], array('tracking_key' => 'tm_application', 'tracking_value' => $post_id) );
}
$mail['subject'] = 'PENDING ' . $newpost['post_title'];
$mail['html'] = '<p>Verify with officer signature <a href="';
$mail['html'] .= admin_url( 'admin.php?page=member_application_approval&app=' . $post_id );
$mail['html'] .= '">' . admin_url( 'admin.php?page=member_application_approval&app=' . $post_id ) . '</a></p>' . "\n\n";
$mail['html'] .= $output;
$mail['fromname'] = $vars['name'];
$mail['from'] = $vars['email'];
$duesmessage = get_option('tm_application_dues_message');
$payprompt .= sprintf('<p>%s: %s</p>',__('Dues amount','rsvpmaker-for-toastmasters'),number_format($vars['amount'],2));
$payprompt .= wp_kses_post($duesmessage);
$n = explode( ',', $notifications );
foreach ( $n as $to ) {
$mail['to'] = $to;
rsvpmailer( $mail );
$payprompt .= sprintf( '<p>Pending application emailed to %s</p>', $to );
}
}
return $payprompt . $output;
}
function paydues_later() {
$id = (int) $_GET['paydues'];
$vars['amount'] = get_post_meta( $id, 'tm_application_fee', true );
$vars['description'] = 'Toastmasters Dues Payment';
$vars['name'] = get_post_meta( $id, 'first_name', true ) . ' ' . get_post_meta( $id, 'last_name', true );
$vars['email'] = get_post_meta( $id, 'user_email', true );
$vars['tracking'] = 'tmapplication' . $id;
$payprompt = rsvpmaker_stripe_form( $vars );
return sprintf( '<h2>Pay dues for %s</h2>', $vars['name'] ) . $payprompt;
}
add_shortcode( 'club_fee_schedule', 'club_fee_schedule' );
function club_fee_schedule() {
$ti_dues = get_option( 'ti_dues' );
$club_dues = get_option( 'club_dues' );
$club_new_member_fee = (int) get_option( 'club_new_member_fee' );
$new_member_fee = 20 + $club_new_member_fee;
$output = '';
$months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
if ( empty( $ti_dues ) ) {
return 'not set';
} else {
$output .= '<style>.feeschedule th {text-align: center;} .feeschedule td {text-align: center; min-width: 100px;}</style>';
$output .= sprintf( '<table class="feeschedule"><tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th>%s</th></tr>', __( 'Month', 'rsvpmaker-for-toastmasters' ), __( 'TI Dues', 'rsvpmaker-for-toastmasters' ), __( 'Club Dues', 'rsvpmaker-for-toastmasters' ), __( 'Club New Member', 'rsvpmaker-for-toastmasters' ), __( 'Total', 'rsvpmaker-for-toastmasters' ), __( '+ New Member Fee', 'rsvpmaker-for-toastmasters' ) );
foreach ( $months as $index => $month ) {
$total = number_format( $ti_dues[ $index ] + $club_dues[ $index ] + $club_new_member_fee, 2 );
$new = number_format( $total + 20, 2 );
$output .= sprintf( '<tr><th>%s</th><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $month, number_format( $ti_dues[ $index ], 2 ), number_format( $club_dues[ $index ], 2 ), $club_new_member_fee, $total, $new );
}
$output .= '</table>';
}
return $output;
}
function tm_application_fee() {
global $post;
if ( isset( $_POST['membership_type'] ) && wp_verify_nonce(rsvpmaker_nonce_data('data'),rsvpmaker_nonce_data('key')) ) {
$new = ( $_POST['membership_type'] == 'New' ) ? 20 : 0;
$ti_dues = get_option( 'ti_dues' );
if ( empty( $ti_dues ) || $ti_dues[3] == '45.00' ) {
$ti_dues = array( 30.00, 20.00, 10.00, 60.00, 50.00, 40.00, 30.00, 20.00, 10.00, 60.00, 50.00, 40.00 );
}
$club_dues = get_option( 'club_dues' );
if ( empty( $club_dues ) ) {
$club_dues = array( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );
}
$monthindex = (isset($_POST['monthindex'])) ? $_POST['monthindex'] : rsvpmaker_date( 'n' ) - 1;
$t = mktime(12,0,0,$monthindex + 1);
$club_new = (int) get_option( 'club_new_member_fee' );
$ti_dues_calc = ( $_POST['membership_type'] == 'Transfer' ) ? 0 : $ti_dues[ $monthindex ];
$club_dues_calc = $club_dues[ $monthindex ];
$fee = $ti_dues_calc + $club_dues_calc + $new + $club_new;
$feetext = sprintf( '<p>Membership Starting: %s</p>', rsvpmaker_date( 'F 1, Y',$t ));
$feetext .= sprintf(
'<p>Toastmasters International Dues: <strong>%s</strong><br>
<em>Paid twice a year by all members, membership dues are pro-rated from the member’s start month.</em></p>',
number_format( $ti_dues_calc, 2 )
);
if ( $ti_dues_calc == 0 ) {
$feetext .= '<p>(Paid member of another club requesting transfer.)</p>';
}
$feetext .= sprintf( '<p>New member fee (US$20): <strong>%s</strong><br /><em>Paid only by new members, this fee covers the cost of the first education path, online copy of The Navigator and processing</em></p>', number_format( $new, 2 ) );
$renewal_dates = wpt_renewal_dates();
if($ti_dues_calc > 60)
array_shift($renewal_dates);
$renew = array_shift($renewal_dates);
//printf('<p>Pay Until: %s</p>',$renew);
update_post_meta($post->ID,'tm_application_until',$renew);
$feetext .= sprintf( '<p>Total Payment to Toastmasters International: %s</p>', number_format( $ti_dues_calc + $new, 2 ) );
$feetext .= sprintf( '<p>Club Dues: <strong>%s</strong></p>', number_format( $club_dues_calc, 2 ) );
$feetext .= sprintf( '<p>Club New Member Fee: <strong>%s</strong></p>', number_format( $club_new, 2 ) );
$feetext .= sprintf( '<p>Total Payment to Club: <strong>%s</strong></p>', number_format( $club_dues_calc + $club_new, 2 ) );
$feetext .= sprintf( '<p>Total: <strong>%s</strong></p>', number_format( $fee, 2 ) );
echo wp_kses_post($feetext);
echo '<input type="hidden" name="monthindex" value="'.$monthindex.'">';
echo '<input type="hidden" name="tm_application_fee" value="'.$fee.'">';
update_post_meta( $post->ID, 'tm_application_fee', $fee );
update_post_meta( $post->ID, 'tm_application_feetext', $feetext );
} else {
echo get_post_meta( $post->ID, 'tm_application_feetext', true );
}
}
function tm_application_form_start( $atts ) {
$pdf = ( isset( $atts['pdf'] ) ) ? $atts['pdf'] : 'https://toastmasterscdn.azureedge.net/medias/files/membership-files/membership-applications/800-membership-application.pdf';
if ( isset( $_POST['user_email'] ) && empty( $_POST['user_email'] ) ) {
return 'Email address is required <a href="' . get_permalink() . '">Try again</a>';
}
ob_start();
?>
<style>
label {
display: inline-block;
width: 150px;
}
</style>
<p>By submitting this online membership application, you agree to treat it as the legally binding equivalent of the standard Toastmasters International membership application, and you will be prompted to agree to all the same terms and conditions. If you prefer, you can download and sign the <a href="<?php echo esc_attr($pdf); ?>" target="_blank">PDF version</a>.</p>
<form method="post" action="<?php echo get_permalink(); ?>">
<p>Step 1: We need a little data to set up the application form and calculate the pro-rated dues (based on the month that you are joining). On the next screen, you will enter your personal data and electronically sign the application.</p>
<p>Email address <?php tm_application_form_field( 'user_email' ); ?> (required)</p>
<p>Application Type <?php tm_application_form_choice( 'membership_type', array( 'New', 'Dual', 'Transfer', 'Reinstated (break in membership)', 'Renewing (no break in membership)' ) ); ?></p>
<?php
$monthindex = date('n') - 1;
$monthtext = date('F');
$o = '<option value="'.$monthindex.'">'.$monthtext.' 1</option>';
$t = strtotime('Next month');
$monthindex = date('n',$t) - 1;
$monthtext = date('F',$t);
$o .= '<option value="'.$monthindex.'">'.$monthtext.' 1</option>';
?>
<p>Start membership: <select name="monthindex"><?php echo $o ?></select></p>
<p><em>"New" means the member is new to Toastmasters (not just new to this club).</em></p>
<p><em>"Transfer" means you are currently enrolled as a paying member of another club, which you wish to withdraw from and apply credit for your dues to our club.</em></p>
<p id="transferprompt">If you are transferring from another club, please provide as much information as possible so we can look up your records. The <a href="https://www.toastmasters.org/Find-a-Club">Find a Club</a> feature of the toastmasters.org website can help you look up club numbers.</p>
<p id="formerclubinfo"><label>Previous club name</label> <?php tm_application_form_field( 'previous_club_name' ); ?><br ><label>Previous club number</label><?php tm_application_form_field( 'previous_club_number' ); ?><br /> <label>Member number</label><?php tm_application_form_field( 'toastmasters_id' ); ?><br /><em>Appears above your name on the mailing label for Toastmaster magazine.</em></p>
<?php wp_nonce_field('application_email'); ?>
<button>Next Screen</button>
<?php rsvpmaker_nonce(); ?>
</form>
<p> </p>
<script>
jQuery(document).ready(function($) {
$('#transferprompt').hide();
$('#formerclubinfo').hide();
var membership_type = 'New';
$('#membership_type').change(function(){
membership_type = $( "select#membership_type option:selected" ).val();
if(membership_type != 'New')
$('#formerclubinfo').show();
if(membership_type == 'Transfer')
$('#transferprompt').show();
else
$('#transferprompt').hide();
});
});
</script>
<?php
return ob_get_clean();
}
function tm_application_form_hidden( $slug ) {
echo ' <strong>' . esc_html(stripslashes( $_POST[ $slug ] )) . '</strong>';
printf( '<input type="hidden" name="%s" id="%s" value="%s" />', $slug, $slug, sanitize_text_field(stripslashes( $_POST[ $slug ]) ) );
}
function tm_application_form_field( $slug ) {
global $post;
$defaults = array(
'club_name' => get_option( 'club_name' ),
'club_number' => get_option( 'club_number' ),
'club_city' => get_option( 'club_city' ),
'date' => rsvpmaker_date( 'F j, Y' ),
);
if ( isset( $_POST[ $slug ] ) ) {
echo ' <strong>' . esc_html(stripslashes( sanitize_text_field($_POST[ $slug ]) )) . '</strong>';
} else {
$value = '';
if ( ! empty( $defaults[ $slug ] ) ) {
$value = $defaults[ $slug ];
} elseif ( strpos( $slug, 'date' ) ) {
$value = $defaults['date'];
}
if ( empty( $value ) ) {
printf( ' <input type="text" name="%s" id="%s" value="" />', $slug, $slug );
} else {
printf( ' <input type="hidden" name="%s" id="%s" value="%s" /> <strong>%s</strong>', $slug, $slug, esc_attr($value), esc_html($value) );
}
}
}
function tm_application_form_choice( $slug, $choices ) {
global $post;
if ( isset( $_POST['first_name'] ) ) {
echo ' <strong>' . $_POST[ $slug ] . '</strong>';
} else {
printf( '<select name="%s" id="%s">', $slug, $slug );
foreach ( $choices as $choice ) {
printf( '<option value="%s">%s</option>', $choice, $choice );
}
echo '</select>';
}
}
function member_application_settings( $action = '' ) {
rsvpmaker_admin_heading('Toastmasters Dues Schedule and Application Form',__FUNCTION__);
wpt_dues_navigation();
global $wpdb;
if ( empty( $action ) ) {
$action = admin_url( 'options-general.php?page=member_application_settings' );
}
$sql = "SELECT ID FROM $wpdb->posts WHERE post_content LIKE '%tm_member_application%' AND post_status='publish'";
$apppage = $wpdb->get_var( $sql );
if ( isset( $_POST['ti_dues'] ) && wp_verify_nonce(rsvpmaker_nonce_data('data'),rsvpmaker_nonce_data('key')) ) {
update_option( 'club_name', sanitize_text_field(stripslashes( $_POST['club_name'] ) ));
update_option( 'club_number', sanitize_text_field($_POST['club_number']) );
update_option( 'club_city', sanitize_text_field(stripslashes( $_POST['club_city'] ) ) );
update_option( 'ti_dues', array_map('sanitize_text_field',$_POST['ti_dues']) );
update_option( 'club_dues', array_map('sanitize_text_field',$_POST['club_dues']) );
update_option( 'club_new_member_fee', sanitize_text_field($_POST['club_new_member_fee']) );
update_option( 'tm_application_notifications', sanitize_text_field($_POST['tm_application_notifications']) );
update_option( 'tm_application_titles', $_POST['tm_application_titles'] );
if ( isset( $_POST['rsvpmaker_stripe_pk'] ) ) {
update_option( 'rsvpmaker_stripe_pk', sanitize_text_field($_POST['rsvpmaker_stripe_pk']) );
update_option( 'rsvpmaker_stripe_sk', sanitize_text_field($_POST['rsvpmaker_stripe_sk']) );
update_option( 'rsvpmaker_stripe_notify', sanitize_text_field($_POST['tm_application_notifications']) );
}
if ( isset( $_POST['addpage'] ) ) {
$page['post_title'] = 'Application';
$page['post_content'] = '<!-- wp:shortcode -->
[tm_member_application]
<!-- /wp:shortcode -->';
$page['post_status'] = 'publish';
$page['post_type'] = 'page';
$apppage = wp_insert_post( $page );
}
}
$ti_dues = get_option( 'ti_dues' );
if ( empty( $ti_dues ) || $ti_dues[3] == '45.00' ) {
$ti_dues = array( '30.00', '20.00', '10.00', '60.00', '50.00', '40.00', '30.00', '20.00', '10.00', '60.00', '50.00', '40.00' );
update_option( 'ti_dues',$ti_dues );
}
$club_dues = get_option( 'club_dues' );
if ( empty( $club_dues ) ) {
$club_dues = array( '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' );
}
if ( isset( $_GET['reset_renewal_page'] ) ) {
delete_option( 'ti_dues_renewal_page' );
}
if ( isset( $_POST['ti_dues_renewal_page'] ) && wp_verify_nonce(rsvpmaker_nonce_data('data'),rsvpmaker_nonce_data('key')) ) {
if ( is_numeric( $_POST['ti_dues_renewal_page'] ) ) {
update_option( 'ti_dues_renewal_page', $_POST['ti_dues_renewal_page'] );
} elseif ( $_POST['ti_dues_renewal_page'] == 'create' ) {
$renew = $ti_dues[3] + $club_dues[3];
$page['post_title'] = 'Dues Renewal';
$page['post_name'] = 'renew';
$page['post_content'] = '<!-- wp:wp4toastmasters/duesrenewal /-->';
$page['post_status'] = 'publish';
$page['post_type'] = 'page';
$stripepage = wp_insert_post( $page );
update_option( 'ti_dues_renewal_page', $stripepage );
printf( '<div class="notice notice-success"><p>Dues Renewal page added: <a href="%s">Edit</a></p></div>', admin_url( 'post.php?post=' . $stripepage . '&action=edit' ) );
}
}
$notifications = get_option( 'tm_application_notifications' );
$titles = get_option( 'tm_application_titles' );
if(empty($titles))
$titles = array();
if ( empty( $notifications ) ) {
$notifications = get_option( 'admin_email' );
}
$months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' );
?>
<form action="<?php echo esc_attr($action); ?>" method="post">
<input type="hidden" name="active" value="settings" />
<p><strong>Club Name:</strong><br /><input type="text" name="club_name" value="<?php echo esc_attr(get_option( 'club_name' )); ?>" /> </p>
<p><strong>Club Number:</strong><br /><input type="text" name="club_number" value="<?php echo esc_attr(get_option( 'club_number' )); ?>" /> </p>
<p><strong>Club City:</strong><br /><input type="text" name="club_city" value="<?php echo esc_attr(get_option( 'club_city' )); ?>" /> </p>
<table>
<tr><th>Month</th><th>TI Dues</th><th>Club Dues</th></tr>
<?php
foreach ( $months as $i => $month ) {
?>
<tr><td><?php echo esc_attr($month); ?></td><td><input type="text" name="ti_dues[<?php echo $i; ?>]" id="ti_dues<?php echo $i; ?>" value="<?php echo esc_attr($ti_dues[ $i ]); ?>" /></td><td><input type="text" name="club_dues[<?php echo $i; ?>]" id="club_dues<?php echo $i; ?>"" value="<?php echo esc_attr($club_dues[ $i ]); ?>" /></td></tr>
<?php
}
?>
</table>
<p><strong>Club New Member Fee:</strong><br /><input type="text" name="club_new_member_fee" value="<?php echo esc_attr(get_option( 'club_new_member_fee' )); ?>" /> </p>
<p><strong>Renewal Fee:</strong><br>
<?php
if(isset($_POST['tm_renew6_type'])) {
$type = sanitize_text_field($_POST['tm_renew6_type']);
if($type == 'auto')
$tm_6momthfee = sanitize_text_field($_POST['tm_renew6_auto']);
else
$tm_6momthfee = sanitize_text_field($_POST['tm_6monthfee']);
update_option('tm_renew6_type',$type);
update_option('tm_6monthfee',$tm_6momthfee);
update_option("tm_renew12",sanitize_text_field($_POST["tm_renew12"]));
}
$tm_renew6_type = get_option('tm_renew6_type') ?>
<input type="radio" name="tm_renew6_type" value="auto" <?php if(empty($tm_renew6_type) || ($tm_renew6_type == 'auto') ) echo ' checked="checked" ' ?> ><input type="hidden" name="tm_renew6_auto" id="tm_renew6_auto" value=""> Set the six month renewal fee to <strong><span id="renew6"></span></strong>, based on the schedule above.<br>
<input type="radio" name="tm_renew6_type" value="manual" <?php if($tm_renew6_type == 'manual') echo ' checked="checked" ' ?>> Set the six month renewal fee to <input type="text" name="tm_6monthfee" value="<?php echo esc_attr(get_option("tm_6monthfee")) ?>" ><br>
Optional: Offer a one-year renewal with a fee of <input type="text" name="tm_renew12" value="<?php echo esc_attr(get_option("tm_renew12")); ?>" >
</p>
<p><strong>Email Approval Notifications To:</strong><br /><input style="width: 90%" type="text" name="tm_application_notifications" value="<?php echo esc_attr($notifications); ?>" /><br />
Multiple email addresses may be entered, separated by a comma.</p>
<?php
$wp4toastmasters_officer_titles = get_option( 'wp4toastmasters_officer_titles' );
if($wp4toastmasters_officer_titles)
{
echo '<p>'.__('Notification by Title','rsvpmaker-for-toastmasters').'</p>';
foreach($wp4toastmasters_officer_titles as $title) {
if(empty($title))
continue;
$checked = '';
$email = toastmasters_officer_email_by_title( $title );
if(!empty($titles)) {
if(in_array($title,$titles))
$checked = ' checked="checked" ';
}
elseif(('Treasurer' == $title) || strpos($title,'Membership') || (__('Treasurer','rsvpmaker-for-toastmasters') == $title) || strpos($title,__('Membership','rsvpmaker-for-toastmasters')) )
$checked = ' checked="checked" ';//defaults if this has not been set
printf('<div><input type="checkbox" name="tm_application_titles[]" value="%s" %s>%s (%s)</div>',$title,$checked,$title,$email);
}
}
if(isset($_POST['tm_application_dues_message']))
{
$tm_application_dues_message = wp_kses_post(stripslashes($_POST['tm_application_dues_message']));
update_option('tm_application_dues_message',$tm_application_dues_message);
}
else
$tm_application_dues_message = wp_kses_post(get_option('tm_application_dues_message'));
printf('<p>%s<br><textarea name="tm_application_dues_message" class="mce">%s</textarea></p>',__('Message to applicant about dues payment (for example, instructions for paying by check)','rsvpmaker-for-toastmasters'),$tm_application_dues_message);
printf('<h2>%s</h2>',__('Online Payments Services','rsvpmaker-for-toastmasters'));
$chosen_gateway = get_rsvpmaker_payment_gateway ();
if(empty($chosen_gateway) || ('Cash or Custom' == $chosen_gateway))
printf('<p>%s</p>',__('Not configured'));
else
printf('<p>%s %s</p>',__('Configured to use','rsvpmaker-for-toastmasters'),$chosen_gateway);
printf('<p><a href="%s">%s</a></p>',admin_url('options-general.php?page=rsvpmaker_settings'),__('Configure online payment service (Stripe or PayPal)','rsvpmaker-for-toastmasters'));
$renew_page = get_option( 'ti_dues_renewal_page' );
if ( $renew_page ) {
printf( '<p><a href="%s">Edit page</a> with dues renewal button.</p>', admin_url( 'post.php?post=' . esc_attr($renew_page) . '&action=edit' ) );
} else {
$sql = "SELECT * FROM $wpdb->posts WHERE post_status='publish' AND post_content LIKE '%wp:wp4toastmasters/duesrenewal%' ORDER BY ID DESC";
$pages = $wpdb->get_results( $sql );
$create = '<p><input type="radio" name="ti_dues_renewal_page" value="create" ';
$create .= ( empty( $pages ) ) ? ' checked="checked" >' : '>';
echo $create;
echo ' Create dues renewal page</p>';
echo '<p><input type="radio" name="ti_dues_renewal_page" value="" > No thanks</p>';
if ( $pages ) {
foreach ( $pages as $index => $page ) {
$checked = ( $index == 0 ) ? ' checked="checked" ' : '';
printf( '<p><input type="radio" name="ti_dues_renewal_page" value="%d" %s > Existing page: %s</p>', intval($page->ID), $checked, esc_html($page->post_title) );
}
}
}
if ( empty( $apppage ) ) {
printf( '<p><input type="checkbox" name="addpage" value="1" checked="checked"> Create a page where the application will be displayed.</p>' );
} else {
printf( '<p>Application page: <a target="_blank" href="%s">View</a> or <a target="_blank" href="%s">Edit</a>', get_permalink( $apppage ), admin_url( 'post.php?action=edit&post=' . $apppage ) );
}
submit_button();
rsvpmaker_nonce();
?>
</form>
<?php echo club_fee_schedule(); ?>
<p>To display this table on the website, use the shortcode [club_fee_schedule] as a placeholder in the text of a page or blog post.</p>
<script>
jQuery( document ).ready(
function($) {
var formatter = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
});