diff --git a/plugins/cc-global-network/admin/assets/css/admin_styles.css b/plugins/cc-global-network/admin/assets/css/admin_styles.css index a118d60..a154f63 100644 --- a/plugins/cc-global-network/admin/assets/css/admin_styles.css +++ b/plugins/cc-global-network/admin/assets/css/admin_styles.css @@ -88,4 +88,135 @@ } .dataTable tbody tr.green-mark { background-color: #cff9cf; +} + +/*USER PROFILE*/ +.title-container { + display: flex; + align-items: center; +} +.title-container.with-borders { + padding: 1rem 0; + border-top: 1px solid #e4e4e4; + border-bottom: 1px solid #e4e4e4; +} +.big-name { + font-size: 2.2rem; + display: inline-block; +} +.badge { + display: inline-block; + padding: .7rem; + margin-left: 1rem; + font-size: .8rem; + color: white; +} +.inner-scroll { + border-top: 1px solid #e4e4e4; + border-bottom: 5px solid #e4e4e4; + overflow-y: auto; +} +.inner-scroll.medium { + height: 90px; +} +.log-entry { + padding: .5rem 0; + font-size: .7rem; + border-bottom: 1px solid #f0f0f0; +} +.log-entry .date { + font-style: italic; +} +.badge.individual { + background-color: #ca4a1f; +} +.badge.institutional { + background-color: #00b9eb; +} +table.ccgn-profile { + display: none; + border-top: 5px solid #e6e6e6; +} +table.ccgn-profile tr td { + padding: .8rem 1rem; + border-bottom: 1px solid #e6e6e6; +} +table.ccgn-profile tr td.title { + font-weight: bold; + text-transform: uppercase; + text-align: right; +} +.display-details { + text-decoration: none; + display: block; + padding: .5rem; + background-color: #e6e6e6; + color: #666; + transition: all .5s ease; +} +.display-details .dashicons { + transition: all .5s ease; +} +.display-details.opened .dashicons { + transform: rotate(-180deg); +} +.applicant-columns { + display: flex; + margin-top: 2rem; + flex-wrap: wrap; +} +.applicant-columns .ccgn-box { + padding: .5rem 1.5rem 1rem 1.5rem; + margin-right: 1rem; + background-color: white; + border-radius: .2rem; + box-shadow: 0 1px 4px rgba(0,0,0,.2); +} +.applicant-columns .ccgn-box.asked-box { + background-color: #fef6e1; +} +.applicant-columns .ccgn-box.applicant { + text-align: center; +} +.applicant-columns .ccgn-box .icon .dashicons { + font-size: 3rem; + width: 3rem; + height: 3rem; +} +.applicant-columns .ccgn-box .date { + color: #999; + font-style: italic; + font-size: .7rem; +} +.applicant-columns .ccgn-box .applicant-reason { + width: 15rem; +} +.preview-details { + margin-bottom: 2rem; +} +.preview-details td { + padding: .5rem; + width: 50%; + vertical-align: top; +} +.preview-details td h6 { + margin: 1rem 0; + font-size: 1.3rem; + font-weight: bold; +} +.button.tiny { + font-size: .7rem; + padding: 0 .5rem; +} +#input_changeVoucher_chosen { + width: 100% !important; +} +#TB_ajaxContent { + position: relative; + padding-bottom: 4rem !important; +} +#TB_ajaxContent .buttons { + position: absolute; + bottom: .5rem; + padding: .5rem; } \ No newline at end of file diff --git a/plugins/cc-global-network/admin/assets/js/script.js b/plugins/cc-global-network/admin/assets/js/script.js index d364ccd..4c05b4e 100644 --- a/plugins/cc-global-network/admin/assets/js/script.js +++ b/plugins/cc-global-network/admin/assets/js/script.js @@ -8,22 +8,22 @@ $.fn.dataTable.ext.search.push( date_start = $('#date-start').val(), date_end = $('#date-end').val(), column_date = data[7]; - if ((member_type != '') && ((settings.sTableId == 'ccgn-table-applications-approval') || (settings.sTableId == 'ccgn-list-new-individuals') ) ) { + if ((member_type != '') && ((settings.sTableId == 'ccgn-table-applications-approval') || (settings.sTableId == 'ccgn-list-new-individuals'))) { if (member_type == column_member_type) { return true; } else { return false; } - } else if (((date_start != '') || (date_end != '')) && (settings.sTableId == 'ccgn-list-new-individuals' )) { + } else if (((date_start != '') || (date_end != '')) && (settings.sTableId == 'ccgn-list-new-individuals')) { var target_date = new Date(column_date), - from_date = ( date_start != '' ) ? new Date(date_start) : new Date(wpApiSettings.site_epoch), - to_date = ( date_end != '' ) ? new Date(date_end) : Date.now(); - if ( (target_date >= from_date) && (target_date <= to_date ) ) { - return true; - } else { - return false; - } - } + from_date = (date_start != '') ? new Date(date_start) : new Date(wpApiSettings.site_epoch), + to_date = (date_end != '') ? new Date(date_end) : Date.now(); + if ((target_date >= from_date) && (target_date <= to_date)) { + return true; + } else { + return false; + } + } else { return true; } @@ -33,36 +33,35 @@ function format(d) { // `d` is the original data object for the row return '
Vouchers declined | ' + - '' + d.vouches_declined + ' | ' + + 'Vouchers declined | ' + + '' + d.vouches_declined + ' | ' + - 'Votes for | ' + - '' + d.votes_for + ' | ' + + 'Votes for | ' + + '' + d.votes_for + ' | ' + '
Vouchers for | ' + - '' + d.vouches_for + ' | ' + - + 'Vouchers for | ' + + '' + d.vouches_for + ' | ' + 'Votes against | ' + '' + d.votes_against + ' | ' + '||
Vouchers against | ' + - ''+ d.vouches_against +' | ' + + 'Vouchers against | ' + + '' + d.vouches_against + ' | ' + '
There was an error restoring the vouching state
There was an error restoring the vouching state
The request was sended to the user
There was an error sending your request
The request was sended to the user
There was an error sending your request
There was an error sending your request
Voted: ' + $result .= '
Voted:' . $vote[ CCGN_GF_VOTE_APPROVE_MEMBERSHIP_APPLICATION ] . '
'; + $result .= ''; + . '" class="button">'; echo _('Change vouch requests for applicant.'); echo '
'; } else { @@ -463,37 +462,179 @@ function ccgn_application_users_page_render_state ( $applicant_id, $state ) { function ccgn_application_users_page_render_details ( $applicant_id, $state ) { echo _('Original request date: ' - . $voucher_choices['date_created'] - . '
'; - if (! is_null ( $voucher_choices[ 'date_updated' ] ) ) { - echo 'Updated request date: ' - . $voucher_choices['date_updated'] - . '
'; - } - echo ccgn_application_users_page_vouchers( $applicant_id ); + echo 'Original request date: ' + . date('Y-m-d', strtotime($voucher_choices['date_created'])) + . '
'; + if (! is_null ( $voucher_choices[ 'date_updated' ] ) ) { + echo 'Updated request date: ' + . date('Y-m-d', strtotime($voucher_choices['date_updated'])) + . '
'; + } + echo ccgn_application_users_page_vouchers( $applicant_id ); + echo ''; print_r($get_the_entries); echo ''; + $entry_id = $get_the_entries[0]['id']; + + echo wp_nonce_field('clarification_voucher', 'clarification_voucher_nonce', true, false); + echo ''; + echo ''; + echo '
' . $voucher['reason'] . '
'; + echo 'Vouched: '.$voucher['vouched'].'
'; + if (($voucher['vouched'] == 'Yes') && (ccgn_current_user_is_final_approver($applicant_id) || ccgn_current_user_is_membership_council($applicant_id)) ) { + echo 'Ask for clarification'; + } + echo ''
- . $item[ 0 ] . '
'
- . $value
+ $html = '
';
+ $html .= 'Membership Statement'; + $html .= ccgn_vp_clean_string($statement); + $html .= ' | ';
+ if ($is_individual):
+ $html .= '';
+ $html .= 'Brief Biography'; + $html .= ccgn_vp_clean_string($bio); + $html .= ' | ';
+ endif;
+ $html .= '
Applicant Name
'
- . get_user_by( 'ID', $applicant_id)->display_name
+ return '
' + . '' .get_user_by( 'ID', $applicant_id)->display_name. '' + . 'Individual Applicant' . '
'; } else { - return 'Institution Name
'
- . ccgn_institutional_applicant_name ( $applicant_id )
+ return '
' + . '' . ccgn_institutional_applicant_name ( $applicant_id ) .'' + . 'Institutional Applicant' . '
'; } } + +/////////////////////////////////////////////////////////////////////////////// +// Log ask for Clarification +/////////////////////////////////////////////////////////////////////////////// + +define('CCGN_CLARIFICATION_LOG_REG_PROP', 'ccgn-ask-clarification-log'); + +function ccgn_ask_clarification_log_get() +{ + return get_option(CCGN_CLARIFICATION_LOG_REG_PROP, array()); +} +function ccgn_ask_clarification_log_get_id($applicant_id) { + $log = ccgn_ask_clarification_log_get(); + return $log[$applicant_id]; +} +function ccgn_ask_clarification_log_get_id_ajax() +{ + $applicant_id = esc_attr($_POST['applicant_id']); + $voucher_id = esc_attr($_POST['voucher_id']); + $log = ccgn_ask_clarification_log_get(); + $return_log = array(); + foreach ($log[$applicant_id] as $entry) { + if ($entry['voucher_id'] == $voucher_id) { + $return_log[] = $entry; + } + } + echo json_encode($return_log); + exit(0); +} +add_action('wp_ajax_nopriv_ask_voucher_log', 'ccgn_ask_clarification_log_get_id_ajax'); +add_action('wp_ajax_ask_voucher_log', 'ccgn_ask_clarification_log_get_id_ajax'); +function ccgn_ask_clarification_log_ensure($today) +{ + $option = ccgn_ask_clarification_log_get(); + $days = array_keys($option); + // Oldest to newest + sort($days); + // No entry for today? Insert it + if ($days[count($days) - 1] != $today) { + $option[$today] = array(); + } + // Too many entries? Remove the oldest + if (count($option) > CCGN_CLARIFICATION_LOG_REG_TRUNCATE) { + unset($option[$days[0]]); + } + return $option; +} + +function ccgn_ask_clarification_log_set($log_structure) +{ + update_option(CCGN_CLARIFICATION_LOG_REG_PROP, $log_structure); +} + +function ccgn_ask_clarification_log_append( + $applicant_id, + $voucher_id +) { + $today = date('Y-m-d'); + $log = ccgn_ask_clarification_log_get(); + $log[$applicant_id][] = array( + 'applicant_id' => $applicant_id, + 'date' => $today, + 'voucher_id' => $voucher_id, + 'ask_user_id' => get_current_user_id(), + 'applicant_name' => get_user_by('ID', $applicant_id)->display_name, + 'ask_user_name' => get_user_by('ID', get_current_user_id())->display_name, + ); + ccgn_ask_clarification_log_set($log); +} \ No newline at end of file diff --git a/plugins/cc-global-network/includes/gravityforms-interaction.php b/plugins/cc-global-network/includes/gravityforms-interaction.php index 8e4d4df..cfadcb0 100644 --- a/plugins/cc-global-network/includes/gravityforms-interaction.php +++ b/plugins/cc-global-network/includes/gravityforms-interaction.php @@ -548,7 +548,9 @@ function ccgn_reopen_application_auto_closed_because_cannots( . $update_date ); // Delete votes from user if there are - ccgn_delete_vote_entries_from_user($applicant_id); + + ccgn_delete_vote_entries_from_user( $applicant_id ); + // Restore the user to the new-user role ccgn_user_level_set_applicant_new($applicant_id); // Set the application to be in the update vouchers stage @@ -558,6 +560,7 @@ function ccgn_reopen_application_auto_closed_because_cannots( return true; } // Delete vote entries from an applicant in order to restore the application status + function ccgn_delete_vote_entries_from_user($applicant_id) { $entries = ccgn_application_votes($applicant_id); @@ -842,6 +845,7 @@ function ccgn_application_vouches_counts ( $applicant_id ) { 'cannot' => $cannot ); } + //Return true if the applicant can be voted function ccgn_application_can_be_voted( $applicant_id ) { $vouches = ccgn_application_vouches_counts( $applicant_id ); @@ -1802,16 +1806,42 @@ function ccgn_application_users_page_vouch_responses ( } return $result; } +//The same function up here but we get the result on an array +//in order to get only the data +function ccgn_application_users_page_vouch_responses_data( + $applicant_id, + $full_date = false +) { + $result = ''; + $vouches = ccgn_application_vouches($applicant_id); + $vouches_list = array(); + foreach ($vouches as $vouch) { + $voucher = get_user_by('ID', $vouch['created_by']); + $vouch_date = ccgn_entry_created_or_updated($vouch); + if (!$full_date) { + $vouch_date = explode(' ', $vouch_date)[0]; + } + $the_vouch = array(); + $the_vouch['id'] = $vouch['created_by']; + $the_vouch['name'] = $voucher->display_name; + $the_vouch['date'] = $vouch_date; + $the_vouch['vouched'] = $vouch[CCGN_GF_VOUCH_DO_YOU_VOUCH]; + $the_vouch['reason'] = $vouch[CCGN_GF_VOUCH_REASON]; + + $vouches_list[] = $the_vouch; + } + return $vouches_list; +} // Format the count of vouches function ccgn_application_users_page_vouch_counts ( $applicant_id ) { $counts = ccgn_application_vouches_counts( $applicant_id ); - return 'Cannot: ' + return '
Cannot: ' . $counts['cannot'] - . '
Yes: ' + . '
Yes: ' . $counts['yes'] - . '
No: ' + . '
No: ' . $counts['no'] . '
'; } @@ -1821,8 +1851,24 @@ function ccgn_application_users_page_vouch_counts ( $applicant_id ) { function ccgn_application_users_page_vouchers ( $applicant_id ) { $result = ''; $vouchers = ccgn_application_vouchers_users ( $applicant_id ); + $vouch_data = ccgn_application_users_page_vouch_responses_data( + $applicant_id, + true + ); + $position = 1; foreach ( $vouchers as $voucher ) { - $result .= '' . $voucher->display_name . '
'; + $data = array(); + $other_voucher = 0; // get the other voucher ID in case if vouched is "yes". this means that we have to disable the name in the select box + foreach ($vouch_data as $vouch_item) { + if ($voucher->ID == $vouch_item['id']) { + $data = $vouch_item; + } else if ( ($voucher->ID != $vouch_item['id']) && ($vouch_item['vouched'] == 'Yes') ) { + $other_voucher = $vouch_item['id']; + } + } + $action_button = (ccgn_current_user_is_final_approver() && ($data['vouched'] != 'Yes') && ($data['vouched'] != 'No') ) ? ' ' : ''; + $result .= '' . $voucher->display_name . $action_button .'
'; + $position++; } return $result; } @@ -1940,4 +1986,4 @@ function ccgn_new_legal_approvals_declined_since ( $start_date, $end_date ) { $end_date, CCGN_GF_LEGAL_APPROVAL_APPROVED_NO ); -} +} \ No newline at end of file diff --git a/plugins/cc-global-network/includes/registration-form-emails.php b/plugins/cc-global-network/includes/registration-form-emails.php index 214e650..46faa4d 100644 --- a/plugins/cc-global-network/includes/registration-form-emails.php +++ b/plugins/cc-global-network/includes/registration-form-emails.php @@ -215,6 +215,20 @@ function ccgn_registration_email_to_voucher ( $applicant_id, ); } +function ccgn_ask_email_to_voucher ( $applicant_id, + $voucher_id, + $email_option ) { + $applicant = get_user_by( 'ID', $applicant_id ); + $voucher = get_user_by( 'ID', $voucher_id ); + ccgn_registration_email( + $applicant->user_nicename, + $applicant->ID, + $voucher->user_nicename, + $voucher->user_email, + $email_option + ); +} + function ccgn_registration_email_application_received ( $applicant_id ) { ccgn_registration_email_to_applicant( $applicant_id, @@ -283,6 +297,15 @@ function ccgn_registration_email_notify_legal_insititution_approved ( 'ccgn-email-notify-legal' ); } +function ccgn_ask_email_vouching_request ( $applicant_id, + $voucher_id ) { + ccgn_ask_email_to_voucher( + $applicant_id, + $voucher_id, + 'ccgn-email-ask-voucher' + ); +} + //////////////////////////////////////////////////////////////////////////////// // Use the name and address from our settings for emails diff --git a/plugins/cc-global-network/public/vouching-form-shortcode.php b/plugins/cc-global-network/public/vouching-form-shortcode.php index 05bbceb..673c80b 100644 --- a/plugins/cc-global-network/public/vouching-form-shortcode.php +++ b/plugins/cc-global-network/public/vouching-form-shortcode.php @@ -56,7 +56,7 @@ function ccgn_vouching_requests_for_me ( $voucher_id ) { function ccgn_vouching_requests_render ( $voucher_id ) { $requests = ccgn_vouching_requests_for_me ( $voucher_id ); if ( $requests !== [] ) { - echo _( "