@@ -645,7 +645,6 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
645
645
$ applicant_votes = ccgn_application_votes_counts ($ applicant_id );
646
646
$ asked_class = '' ;
647
647
$ who_asked = '' ;
648
- //print_r($voucher);
649
648
if (empty ($ asked_info ['user_id ' ])) {
650
649
$ log_user = ccgn_ask_clarification_log_get_id ($ applicant_id );
651
650
foreach ($ log_user as $ entry ) {
@@ -667,7 +666,6 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
667
666
$ user_is_asked_for_clarification = $ asked_info ['status ' ];
668
667
}
669
668
echo '<div class="ccgn-box applicant ' .$ asked_class .'"> ' ;
670
- //echo '<div class="icon"><span class="dashicons dashicons-admin-users"></span></div>';
671
669
echo '<h3 class="applicant-name"> ' .$ voucher ['name ' ].'</h3> ' ;
672
670
echo '<span class="date"> ' .$ voucher ['date ' ].'</span> ' ;
673
671
if ($ user_is_asked_for_clarification ) {
@@ -687,28 +685,33 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
687
685
if (($ voucher ['vouched ' ] == 'Yes ' ) && (ccgn_current_user_is_final_approver ($ applicant_id ) || ccgn_current_user_is_membership_council ($ applicant_id )) ) {
688
686
echo '<a href="#" onClick="$.askVoucher( ' .$ voucher ['id ' ].', \'' .$ voucher ['name ' ].'\', ' .$ applicant_id .')" class="button">Ask for clarification</a> ' ;
689
687
}
688
+ if (current_user_can ( 'administrator ' ) && ($ voucher ['vouched ' ] == 'No ' )) {
689
+ echo '<br><a href="#" class="button-primary" style="background-color: #dc3232;" onClick="$.removeVoucher( ' .$ voucher ['id ' ].', \'' .$ voucher ['name ' ].'\', ' .$ applicant_id .')" class="button">Remove this voucher</a> ' ;
690
+ }
690
691
691
692
echo '</div> ' ;
692
693
}
693
694
echo '</div> ' ;
694
- // echo cgn_application_users_page_vouch_responses (
695
- // $applicant_id,
696
- // true
697
- // );
698
695
add_thickbox ();
696
+ echo '<div id="remove-voucher-modal" style="display:none;"> ' ;
697
+ echo '<h2>You are about to remove this voucher: <span class="name-display"></span></h2> ' ;
698
+ echo '<p>That means that you think the vouch is not correct and the applicant needs to choose another voucher</p> ' ;
699
+ echo '<p>this process will send an email to the applicant in order to choose a new voucher the status will be updated to "update-vouchers" </p> ' ;
700
+ echo '<p>Are you sure you want to do this? </p> ' ;
701
+ echo '<br> ' ;
702
+ echo wp_nonce_field ('remove_voucher ' , 'remove_voucher_nonce ' , true , false );
703
+ echo '<div class="buttons"> ' ;
704
+ echo '<button id="close-remove-voucher" class="button close-window">Close</button> ' ;
705
+ echo "<button id= \"remove-voucher-for-sure \" class= \"button button-primary ask-voucher-for-sure \">Yes, I'm sure</button> " ;
706
+ echo '</div> ' ;
707
+ echo '</div> ' ;
699
708
echo '<div id="ask-clarification-modal" style="display:none;"> ' ;
700
709
echo '<h2>You are about to ask for clarification to the voucher: <span class="name-display"></span></h2> ' ;
701
710
echo '<p>That means you think the text supporting this application is not enough, is not clear or is not helpful for you to approve this application. If that is the case, you can ask the voucher to clarify.</p> ' ;
702
-
703
-
704
711
echo '<div class="log-content" id="log-content-ask-voucher"> ' ;
705
712
echo '<p>This already was requested by: </p> ' ;
706
713
echo '<div class="inner-scroll medium"> ' ;
707
714
echo '<ol class="log-entries" id="log-entry-ask-voucher"> ' ;
708
-
709
- //foreach ($log as $entry) {
710
- // echo '<li><div class="log-entry"><strong>'.$entry['ask_user_name'].'</strong> asked on <span class="date">'.$entry['date'].'</span></div></li>';
711
- //}
712
715
echo '</ol> ' ;
713
716
echo '</div> ' ;
714
717
echo '<p>There is no need to send this email again to the voucher. In case you consider that necessary, you can do it again.</p> ' ;
@@ -721,7 +724,6 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
721
724
echo '<button id="close-ask-voucher" class="button close-window">Close</button> ' ;
722
725
echo "<button id= \"ask-voucher-for-sure \" class= \"button button-primary ask-voucher-for-sure \">Yes, I'm sure</button> " ;
723
726
echo '</div> ' ;
724
- //echo '</p>';
725
727
echo '</div> ' ;
726
728
echo '<div id="change-voucher-modal" style="display:none;"> ' ;
727
729
echo '<h2>You are about to change the current voucher: <span class="name-display"></span></h2> ' ;
@@ -886,6 +888,40 @@ function ccgn_ajax_ask_voucher()
886
888
add_action ('wp_ajax_nopriv_ask_voucher ' , 'ccgn_ajax_ask_voucher ' );
887
889
add_action ('wp_ajax_ask_voucher ' , 'ccgn_ajax_ask_voucher ' );
888
890
891
+ function ccgn_ajax_remove_voucher ()
892
+ {
893
+ $ user_id = $ _POST ['user_id ' ];
894
+ $ applicant_id = $ _POST ['applicant_id ' ];
895
+ if (check_ajax_referer ('remove_voucher ' , 'sec ' ) && (!empty ($ user_id ))) {
896
+ $ entries = ccgn_entries_referring_to_user ($ applicant_id ,'Vouch For Applicant ' );
897
+ $ entry_id = null ;
898
+ foreach ($ entries as $ entry ) {
899
+ if ($ entry ['form_id ' ] == 44 ) {
900
+ $ entry_id = $ entry ['id ' ];
901
+ break ;
902
+ }
903
+ }
904
+ $ created_by_applicant = ccgn_entries_created_by_user ($ applicant_id ,41 );
905
+ foreach ($ created_by_applicant as $ form_entry ) {
906
+ if ($ form_entry ['form_id ' ] == 41 ) {
907
+ if ($ form_entry ['1 ' ] == $ user_id ) {
908
+ GFAPI ::update_entry_field ($ form_entry ['id ' ], '1 ' , '' );
909
+ } elseif ($ form_entry ['2 ' ] == $ user_id ) {
910
+ GFAPI ::update_entry_field ($ form_entry ['id ' ], '2 ' , '' );
911
+ }
912
+ }
913
+ }
914
+ GFAPI ::delete_entry ( $ entry_id );
915
+ _ccgn_registration_user_set_stage ( $ applicant_id , 'update-vouchers ' );
916
+ ccgn_registration_email_voucher_cannot ( $ applicant_id , $ user_id );
917
+ echo 'ok ' ;
918
+ }
919
+ exit (0 );
920
+ }
921
+
922
+ add_action ('wp_ajax_nopriv_remove_voucher ' , 'ccgn_ajax_remove_voucher ' );
923
+ add_action ('wp_ajax_remove_voucher ' , 'ccgn_ajax_remove_voucher ' );
924
+
889
925
function ccgn_ajax_change_voucher ()
890
926
{
891
927
$ voucher_id = esc_attr ($ _POST ['voucher_id ' ]);
0 commit comments