From 0f25c574ac3c6cdab7c3ea5689c653d9b7952c70 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Wed, 24 Oct 2018 23:21:28 -0300
Subject: [PATCH 01/12] datatable field correction
---
.../admin/assets/js/script.js | 2 +-
.../includes/gravityforms-interaction.php | 21 +++++++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/plugins/cc-global-network/admin/assets/js/script.js b/plugins/cc-global-network/admin/assets/js/script.js
index a1a8b7b..7344c38 100644
--- a/plugins/cc-global-network/admin/assets/js/script.js
+++ b/plugins/cc-global-network/admin/assets/js/script.js
@@ -44,7 +44,7 @@ function format(d) {
'' + d.vouches_for + ' ' +
'Votes against ' +
- '' + d.votes_for + ' ' +
+ '' + d.votes_against + ' ' +
'' +
'' +
'Vouchers against ' +
diff --git a/plugins/cc-global-network/includes/gravityforms-interaction.php b/plugins/cc-global-network/includes/gravityforms-interaction.php
index f415068..3c33603 100644
--- a/plugins/cc-global-network/includes/gravityforms-interaction.php
+++ b/plugins/cc-global-network/includes/gravityforms-interaction.php
@@ -547,6 +547,8 @@ function ccgn_reopen_application_auto_closed_because_cannots (
'RE-OPENING APPLICATION AUTO-CLOSED DUE TO "CANNOT" VOUCHES: Setting update date to '
. $update_date
);
+ // Delete votes from user if there are
+ 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
@@ -555,7 +557,15 @@ function ccgn_reopen_application_auto_closed_because_cannots (
ccgn_registration_email_voucher_cannot_reminder( $applicant_id );
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);
+ if ( count( $entries ) > 0 ) {
+ foreach ($entries as $entry) {
+ GFAPI::delete_entry($entry['id']);
+ }
+ }
+}
// Remove a mistaken vouching response and reset the applicant's vouching
// timescale. This should only be called extraordinarily, in response to a
// support request.
@@ -830,7 +840,14 @@ function ccgn_application_vouches_counts ( $applicant_id ) {
'cannot' => $cannot
);
}
-
+function ccgn_application_can_vote($applicant_id) {
+ $vouches = ccgn_application_vouches_counts($applicant_id);
+ if ($vouches[ 'yes' ] >= 2) {
+ return true;
+ } else {
+ return false;
+ }
+}
// A predicate function for sorting. Is this Vouching result a 'Cannot' rather
// than a 'Yes' or a 'No'?
From 18f1f38467b6ee38602e5d18d111cb879c979a01 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Thu, 1 Nov 2018 07:57:47 -0300
Subject: [PATCH 02/12] improve user profile screen on admin section
---
.../admin/assets/css/admin_styles.css | 110 +++++++++++
.../admin/assets/js/script.js | 187 ++++++++++++------
.../admin/user-application-page.php | 113 ++++++++---
.../includes/format-applicant-profile.php | 112 +++++++++--
.../includes/gravityforms-interaction.php | 32 ++-
5 files changed, 443 insertions(+), 111 deletions(-)
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..85682d1 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,114 @@
}
.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.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 {
+ vertical-align: top;
+}
+.preview-details td h6 {
+ margin: 1rem 0;
+ font-size: 1.3rem;
+ font-weight: bold;
}
\ 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 7344c38..4eaba66 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,36 @@ 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 + ' ' +
+ 'Votes against ' +
+ '' + d.votes_against + ' ' +
' ' +
'' +
- 'Vouchers against ' +
- ''+ d.vouches_against +' ' +
+ 'Vouchers against ' +
+ '' + d.vouches_against + ' ' +
' ' +
'
';
}
-jQuery(document).ready(function($){
- $.resetVouchers = function(id) {
+jQuery(document).ready(function ($) {
+ $.resetVouchers = function (id) {
$('#reset-vouchers-for-sure').off('click');
tb_show("Reset Vouchers", "#TB_inline?width=600&height=250&inlineId=resetvouchers-modal");
- $('#close-reset-vouchers').on('click', function(e){
+ $('#close-reset-vouchers').on('click', function (e) {
e.preventDefault();
tb_remove();
return false;
});
- $('#reset-vouchers-for-sure').on('click', function(e){
+ $('#reset-vouchers-for-sure').on('click', function (e) {
var sec = $('#reset_vouchers_nonce').val(),
this_button = $(this);
$.ajax({
@@ -92,13 +92,53 @@ jQuery(document).ready(function($){
});
});
}
+ $.askVoucher = function (id, name) {
+ $('#ask-voucher-for-sure').off('click');
+ $('#ask-clarification-modal').find('.name-display').html(name);
+ tb_show("Ask for clarification to voucher", "#TB_inline?width=600&height=300&inlineId=ask-clarification-modal");
+ $('#close-ask-voucher').on('click', function (e) {
+ e.preventDefault();
+ tb_remove();
+ return false;
+ });
+ console.log(id);
+ $('#ask-voucher-for-sure').on('click', function (e) {
+ var sec = $('#ask_voucher_nonce').val(),
+ this_button = $(this);
+ $.ajax({
+ url: wpApiSettings.ajax_url,
+ type: 'POST',
+ data: {
+ action: 'ask_voucher',
+ user_id: id,
+ sec: sec
+ },
+ beforeSend: function () {
+ this_button.text('Working...');
+ },
+ success: function (data) {
+ this_button.text("Yes, I'm sure");
+ $('#alert-messages').html('');
+ if (data == 'ok') {
+ tb_remove();
+ $('#alert-messages').append('The request was sended to the user
').find('.notice').delay(3200).fadeOut(300);
+ $('#search-all-members').trigger('click');
+ }
+ if (data == 'error') {
+ $('#alert-messages').append('There was an error sending your request
').find('.notice').delay(3200).fadeOut(300);
+ tb_remove();
+ }
+ }
+ });
+ });
+ }
var table1 = $('#ccgn-table-applications-approval').DataTable({
- 'columns': [
+ 'columns': [
{
- "className": 'details-control',
- "orderable": false,
- "data": null,
- "defaultContent": ' '
+ "className": 'details-control',
+ "orderable": false,
+ "data": null,
+ "defaultContent": ' '
},
{ 'data': 'applicant' },
{ 'data': 'applicant_type' },
@@ -106,29 +146,29 @@ jQuery(document).ready(function($){
{ 'data': 'vouching_status' },
{ 'data': 'voting_status' },
{ 'data': 'application_date' }
- ],
- 'columnDefs': [
- {
- targets: 1,
- 'render': function (data, type, row, meta) {
- return '' + data+' ';
- }
- }
- ],
- 'ajax': {
- 'url': wpApiSettings.root + 'commoners/v2/application-approval/list',
- 'type': 'POST',
- 'beforeSend': function (xhr) {
- xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
- },
- 'data': { 'current_user': wpApiSettings.current_user }
- },
- rowCallback: function(row, data) {
- if (data.already_voted_by_me == 'yes') {
- $(row).addClass('green-mark');
- }
- }
- });
+ ],
+ 'columnDefs': [
+ {
+ targets: 1,
+ 'render': function (data, type, row, meta) {
+ return '' + data + ' ';
+ }
+ }
+ ],
+ 'ajax': {
+ 'url': wpApiSettings.root + 'commoners/v2/application-approval/list',
+ 'type': 'POST',
+ 'beforeSend': function (xhr) {
+ xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
+ },
+ 'data': { 'current_user': wpApiSettings.current_user }
+ },
+ rowCallback: function (row, data) {
+ if (data.already_voted_by_me == 'yes') {
+ $(row).addClass('green-mark');
+ }
+ }
+ });
var table_members = $('#ccgn-list-new-individuals').DataTable({
'columns': [
{ 'data': 'display_name' },
@@ -140,13 +180,21 @@ jQuery(document).ready(function($){
{ 'data': 'member_vouchers' },
{ 'data': 'member_approval_date' }
],
+ 'columnDefs': [
+ {
+ targets: 0,
+ 'render': function (data, type, row, meta) {
+ return '' + data + ' ';
+ }
+ }
+ ],
'ajax': {
'url': wpApiSettings.root + 'commoners/v2/list-members',
'type': 'POST',
'beforeSend': function (xhr) {
xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
},
- 'data': {
+ 'data': {
'current_user': wpApiSettings.current_user,
'start_date': wpApiSettings.site_epoch,
'end_date': wpApiSettings.date_now
@@ -205,14 +253,20 @@ jQuery(document).ready(function($){
}
],
'columnDefs': [
+ {
+ targets: 1,
+ 'render': function (data, type, row, meta) {
+ return '' + data + ' ';
+ }
+ },
{
'targets': 7,
- 'render' : function(data, type, row, meta) {
+ 'render': function (data, type, row, meta) {
var output = '';
if (wpApiSettings.is_sub_admin != 'yes') {
output += '';
- output += ' ';
- output += ' ';
+ output += ' ';
+ output += ' ';
output += ' ';
} else {
output += 'No actions';
@@ -220,9 +274,9 @@ jQuery(document).ready(function($){
return output;
}
}
- ]
+ ]
});
- $('#search-all-members').on('click', function(e){
+ $('#search-all-members').on('click', function (e) {
e.preventDefault;
var obj = $(this);
$.ajax({
@@ -232,11 +286,11 @@ jQuery(document).ready(function($){
obj.text('Loading...');
xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
},
- 'data': {
+ 'data': {
'current_user': wpApiSettings.current_user,
'search_user': $('#user_id').val()
},
- success: function(data) {
+ success: function (data) {
table_search_users.clear();
table_search_users.rows.add(data);
table_search_users.draw();
@@ -260,14 +314,14 @@ jQuery(document).ready(function($){
tr.addClass('shown');
}
});
- $('#member_type').on('change',function () {
+ $('#member_type').on('change', function () {
table1.draw();
table_members.draw();
});
$('.ui-datepicker-input').on('change', function () {
table_members.draw();
});
- $('.email-list').on('click', function(e){
+ $('.email-list').on('click', function (e) {
$('#emails-modal').find('p').html(
table_members
.columns(1, { search: 'applied' })
@@ -281,5 +335,12 @@ jQuery(document).ready(function($){
$('.ui-datepicker-input').datepicker({
dateFormat: 'yy-mm-dd'
});
-
+ $('.display-details').on('click', function (e) {
+ e.preventDefault();
+ var obj = $(this),
+ target = obj.data('target');
+ obj.toggleClass('opened');
+ $(target).slideToggle('fast');
+ return false;
+ });
});
\ No newline at end of file
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index 2183419..6608e10 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -53,14 +53,15 @@ function ccgn_application_users_page_vote_responses ( $applicant_id ) {
$votes = ccgn_application_votes ( $applicant_id );
foreach ($votes as $vote) {
$voter = get_user_by('ID', $vote['created_by']);
- $result .=
- 'From: '
- . $voter->display_name
- . ' Voted: '
+ $result .= '
';
+ $result .= '
'
+ . '
'. $voter->display_name . ' '
+ .'
Voted: '
. $vote[
CCGN_GF_VOTE_APPROVE_MEMBERSHIP_APPLICATION
]
. '
';
+ $result .= '
';
}
return $result;
}
@@ -418,11 +419,10 @@ function ccgn_application_format_legal_approval ( $applicant_id, $state ) {
function ccgn_application_user_page_render_change_vouchers ( $applicant_id,
$state ) {
if ( current_user_can( 'ccgn_pre_approve' ) ) {
- echo _('Change Vouch Requests ');
if ( $state == CCGN_APPLICATION_STATE_VOUCHING ) {
echo '';
+ . '" class="button">';
echo _('Change vouch requests for applicant.');
echo '
';
} else {
@@ -463,35 +463,90 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo _('Membership Application Details ');
echo _('Details Provided By Applicant ');
echo ccgn_user_page_applicant_profile_text( $applicant_id );
- echo _('Vouchers Requested ');
- $voucher_choices = ccgn_application_vouchers ( $applicant_id );
- 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 'Vouchers information ';
+ echo '';
+ echo '
';
+ echo _('
Vouchers Requested ');
+ $voucher_choices = ccgn_application_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 '
';
+
if ( $state != CCGN_APPLICATION_STATE_RECEIVED ) {
- ccgn_application_user_page_render_change_vouchers (
- $applicant_id,
- $state
- );
- echo _('
Vouches Received ');
- echo ccgn_application_users_page_vouch_counts ( $applicant_id );
- echo _('
Vouches ');
- echo ccgn_application_users_page_vouch_responses (
+ echo '
';
+ echo _('
Vouches Received ');
+ echo ccgn_application_users_page_vouch_counts ( $applicant_id );
+ ccgn_application_user_page_render_change_vouchers(
+ $applicant_id,
+ $state
+ );
+ echo '';
+ echo '
';
+ echo _('Vouches list ');
+ echo '';
+ $vouchers = ccgn_application_users_page_vouch_responses_data(
$applicant_id,
true
);
+ foreach ($vouchers as $voucher) {
+ echo '
';
+ echo '
';
+ echo '
'.$voucher['name'].' ';
+ echo '
'.$voucher['date'].' ';
+ 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 '
';
+ }
+ echo '
';
+ // echo cgn_application_users_page_vouch_responses (
+ // $applicant_id,
+ // true
+ // );
+ add_thickbox();
+ echo '';
+ echo '
You are about to ask for clarification to the voucher: ';
+ $log = ccgn_ask_clarification_log_get_id($applicant_id);
+ if (!empty($log)) {
+ echo '
This operation have been perfomed some times:
';
+ echo '
';
+ }
+ echo '
Are you sure you want to do this?
';
+ echo '
';
+ echo wp_nonce_field('ask_voucher', 'ask_voucher_nonce', true, false);
+ echo '
';
+ echo 'Close ';
+ echo "Yes, I'm sure ";
+ echo '
';
+ //echo '';
+ echo '
';
}
- echo _('Global Council Approval ');
- echo _('Votes Received ');
- echo ccgn_application_users_page_vote_counts ( $applicant_id );
+ echo _('Global Council Approval');
+ echo '';
+ echo '
';
+ echo _('
Votes Received ');
+ echo ccgn_application_users_page_vote_counts ( $applicant_id );
+ echo '';
+ echo '
';
echo _('Votes ');
- echo ccgn_application_users_page_vote_responses ( $applicant_id );
+ echo ' ';
+ echo ccgn_application_users_page_vote_responses ( $applicant_id );
+ echo '
';
}
function ccgn_application_users_page () {
diff --git a/plugins/cc-global-network/includes/format-applicant-profile.php b/plugins/cc-global-network/includes/format-applicant-profile.php
index f33d0ff..52594a2 100644
--- a/plugins/cc-global-network/includes/format-applicant-profile.php
+++ b/plugins/cc-global-network/includes/format-applicant-profile.php
@@ -83,9 +83,9 @@ function ccgn_vp_format_field ( $entry, $item ) {
);
// Make sure the entry has a value for this item
if( $value ) {
- $html = ''
- . $item[ 0 ] . ' '
- . $value
+ $html = '
'
+ . ''. $item[ 0 ] . ' '
+ . ''.$value.' '
. '';
}
return $html;
@@ -113,11 +113,39 @@ function ccgn_vp_format_avatar ( $entry ) {
// Format the relevant fields from the Applicant Details form as html.
-function ccgn_vouching_form_profile_format( $entry, $map ) {
+function ccgn_vouching_form_profile_format( $entry, $map, $applicant_id ) {
+ $is_individual = ccgn_user_is_individual_applicant($entry['created_by']);
+ $statement = ($is_individual) ? $entry[3] : $entry[6];
+ $bio = $entry[2];
$html = '';
+ $html .= '
';
+ $html .= '';
+ $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 .= ' ';
+ $html .= '
';
+ $html .= '
View more applicant details ';
+ $html .= '
';
+ if ($is_individual) {
+ unset($map[2]);
+ unset($map[3]);
+ } else {
+ unset($map[4]);
+ }
+ unset ($statement);
+ unset ($bio);
foreach( $map as $item ) {
$html .= ccgn_vp_format_field( $entry, $item );
}
+ $html .= '
';
$html .= '
';
return $html;
}
@@ -131,7 +159,8 @@ function ccgn_vouching_form_individual_profile_text ( $applicant_id ) {
//. ccgn_vp_format_avatar( $entry )
. ccgn_vouching_form_profile_format(
$entry,
- CCGN_GF_DETAILS_VOUCH_MAP
+ CCGN_GF_DETAILS_VOUCH_MAP,
+ $applicant_id
);
}
@@ -139,7 +168,8 @@ function ccgn_vouching_form_institution_profile_text ( $applicant_id ) {
return 'Institutional Applicant '
. ccgn_vouching_form_profile_format(
ccgn_details_institution_form_entry ( $applicant_id ),
- CCGN_GF_INSTITUTION_DETAILS_VOUCH_MAP
+ CCGN_GF_INSTITUTION_DETAILS_VOUCH_MAP,
+ $applicant_id
);
}
@@ -157,9 +187,9 @@ function ccgn_vouching_form_applicant_profile_text ( $applicant_id ) {
function ccgn_user_page_individual_profile_text ( $applicant_id ) {
$entry = ccgn_details_individual_form_entry( $applicant_id );
- return 'Individual Applicant '
- //. ccgn_vp_format_avatar ( $entry )
- . ccgn_applicant_display_name_formatted ( $applicant_id )
+
+ return //. ccgn_vp_format_avatar ( $entry )
+ ccgn_applicant_display_name_formatted ( $applicant_id )
. ccgn_vouching_form_profile_format(
$entry,
CCGN_GF_DETAILS_USER_PAGE_MAP
@@ -167,8 +197,7 @@ function ccgn_user_page_individual_profile_text ( $applicant_id ) {
}
function ccgn_user_page_institution_profile_text ( $applicant_id ) {
- return 'Institutional Applicant '
- . ccgn_applicant_display_name_formatted ( $applicant_id )
+ return ccgn_applicant_display_name_formatted ( $applicant_id )
.ccgn_vouching_form_profile_format(
ccgn_details_institution_form_entry ( $applicant_id ),
CCGN_GF_INSTITUTION_DETAILS_USER_PAGE_MAP
@@ -195,12 +224,65 @@ function ccgn_applicant_display_name ( $applicant_id ) {
function ccgn_applicant_display_name_formatted ( $applicant_id ) {
if ( ccgn_user_is_individual_applicant ( $applicant_id ) ) {
- return '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_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
+) {
+ $today = date('Y-m-d');
+ $log = ccgn_ask_clarification_log_get();
+ $log[$applicant_id][] = array(
+ 'applicant_id' => $applicant_id,
+ 'date' => $today,
+ '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 3c33603..946e94f 100644
--- a/plugins/cc-global-network/includes/gravityforms-interaction.php
+++ b/plugins/cc-global-network/includes/gravityforms-interaction.php
@@ -1799,16 +1799,40 @@ function ccgn_application_users_page_vouch_responses (
}
return $result;
}
+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']
. '
';
}
@@ -1819,7 +1843,7 @@ function ccgn_application_users_page_vouchers ( $applicant_id ) {
$result = '';
$vouchers = ccgn_application_vouchers_users ( $applicant_id );
foreach ( $vouchers as $voucher ) {
- $result .= '' . $voucher->display_name . '
';
+ $result .= ' ' . $voucher->display_name . '
';
}
return $result;
}
From ec49fadb0452957aaf5dff16a2f4d8a918def086 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Thu, 1 Nov 2018 08:17:42 -0300
Subject: [PATCH 03/12] add new entry to global network emails to ask a voucher
for clarification
---
.../admin/options-emails.php | 53 +++++++++++++++++++
1 file changed, 53 insertions(+)
diff --git a/plugins/cc-global-network/admin/options-emails.php b/plugins/cc-global-network/admin/options-emails.php
index 5f7d469..48cd9fc 100644
--- a/plugins/cc-global-network/admin/options-emails.php
+++ b/plugins/cc-global-network/admin/options-emails.php
@@ -311,6 +311,27 @@ function ccgn_settings_emails_chapter_contact_wrapper () {
>
+
+
+
+
Date: Thu, 1 Nov 2018 08:59:13 -0300
Subject: [PATCH 04/12] added ajax action to ask voucher for clarification
---
.../admin/assets/js/script.js | 8 +++----
.../admin/user-application-page.php | 19 ++++++++++++++-
.../includes/registration-form-emails.php | 23 +++++++++++++++++++
3 files changed, 45 insertions(+), 5 deletions(-)
diff --git a/plugins/cc-global-network/admin/assets/js/script.js b/plugins/cc-global-network/admin/assets/js/script.js
index 4eaba66..e521d5c 100644
--- a/plugins/cc-global-network/admin/assets/js/script.js
+++ b/plugins/cc-global-network/admin/assets/js/script.js
@@ -85,14 +85,14 @@ jQuery(document).ready(function ($) {
$('#search-all-members').trigger('click');
}
if (data == 'error') {
- $('#alert-messages').append('There was an error restoring the vouching state
').find('.notice').delay(3200).fadeOut(300);
+ $('#alert-messages').append('There was an error restoring the vouching state
').find('.notice').delay(3200).fadeOut(300);
tb_remove();
}
}
});
});
}
- $.askVoucher = function (id, name) {
+ $.askVoucher = function (id, name, applicant_id) {
$('#ask-voucher-for-sure').off('click');
$('#ask-clarification-modal').find('.name-display').html(name);
tb_show("Ask for clarification to voucher", "#TB_inline?width=600&height=300&inlineId=ask-clarification-modal");
@@ -101,7 +101,6 @@ jQuery(document).ready(function ($) {
tb_remove();
return false;
});
- console.log(id);
$('#ask-voucher-for-sure').on('click', function (e) {
var sec = $('#ask_voucher_nonce').val(),
this_button = $(this);
@@ -111,6 +110,7 @@ jQuery(document).ready(function ($) {
data: {
action: 'ask_voucher',
user_id: id,
+ applicant_id: applicant_id,
sec: sec
},
beforeSend: function () {
@@ -125,7 +125,7 @@ jQuery(document).ready(function ($) {
$('#search-all-members').trigger('click');
}
if (data == 'error') {
- $('#alert-messages').append('There was an error sending your request
').find('.notice').delay(3200).fadeOut(300);
+ $('#alert-messages').append('There was an error sending your request
').find('.notice').delay(3200).fadeOut(300);
tb_remove();
}
}
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index 6608e10..afe31dc 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -461,6 +461,7 @@ function ccgn_application_users_page_render_state ( $applicant_id, $state ) {
function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo _('Membership Application Details ');
+ echo '
';
echo _('Details Provided By Applicant ');
echo ccgn_user_page_applicant_profile_text( $applicant_id );
echo 'Vouchers information ';
@@ -503,7 +504,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
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 'Ask for clarification ';
}
echo '';
}
@@ -610,3 +611,19 @@ function ccgn_application_user_link( $actions, $user_object ) {
}
return $actions;
}
+
+// Ajax function
+// Executed in the UI when a MC member ask to a voucher for clarification
+function ccgn_ajax_ask_voucher()
+{
+ $user_id = $_POST['user_id'];
+ $applicant_id = $_POST['applicant_id'];
+ if (check_ajax_referer('ask_voucher', 'sec') && (!empty($user_id))) {
+ ccgn_ask_email_vouching_request($applicant_id,$user_id);
+ ccgn_ask_clarification_log_append($applicant_id);
+ echo 'ok';
+ }
+ exit(0);
+}
+add_action('wp_ajax_nopriv_ask_voucher', 'ccgn_ajax_ask_voucher');
+add_action('wp_ajax_ask_voucher', 'ccgn_ajax_ask_voucher');
\ 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
From 04669d5a871edd69677aef08382535016dced918 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Sun, 4 Nov 2018 10:13:32 -0300
Subject: [PATCH 05/12] style fix on profile screen
---
plugins/cc-global-network/admin/assets/css/admin_styles.css | 1 +
1 file changed, 1 insertion(+)
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 85682d1..8b5ef43 100644
--- a/plugins/cc-global-network/admin/assets/css/admin_styles.css
+++ b/plugins/cc-global-network/admin/assets/css/admin_styles.css
@@ -192,6 +192,7 @@ table.ccgn-profile tr td.title {
margin-bottom: 2rem;
}
.preview-details td {
+ width: 50%;
vertical-align: top;
}
.preview-details td h6 {
From ef0bb377df23d30328e0626aa1d5cac05c575cfa Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Tue, 6 Nov 2018 01:09:54 -0300
Subject: [PATCH 06/12] change vouchers and fix ask for clarification update
---
.../admin/assets/css/admin_styles.css | 16 ++
.../admin/assets/js/script.js | 83 ++++++++++
.../admin/user-application-page.php | 152 +++++++++++++++++-
.../includes/gravityforms-interaction.php | 18 ++-
4 files changed, 267 insertions(+), 2 deletions(-)
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 8b5ef43..e6eecd4 100644
--- a/plugins/cc-global-network/admin/assets/css/admin_styles.css
+++ b/plugins/cc-global-network/admin/assets/css/admin_styles.css
@@ -199,4 +199,20 @@ table.ccgn-profile tr td.title {
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: 2rem;
+}
+#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 e521d5c..a9d5e62 100644
--- a/plugins/cc-global-network/admin/assets/js/script.js
+++ b/plugins/cc-global-network/admin/assets/js/script.js
@@ -92,6 +92,56 @@ jQuery(document).ready(function ($) {
});
});
}
+ $.changeVoucher = function (applicantId, voucherName, currentVoucher,theOtherVoucher,position) {
+ $('#change-voucher-for-sure').off('click');
+ $('#input_changeVoucher option[disabled="disabled"]').removeAttr('disabled');
+ $('#change-voucher-modal').find('.name-display').html(voucherName); //Display the voucher name that will be changed
+ $('#change-voucher-modal').find('#input_changeVoucher').val(currentVoucher);
+ $('#input_changeVoucher option[value="'+theOtherVoucher+'"]').attr('disabled','disabled');
+ $("#input_changeVoucher").trigger("chosen:updated");
+ tb_show("Change current voucher", "#TB_inline?width=600&height=300&inlineId=change-voucher-modal");
+ $('#close-change-voucher').on('click', function (e) {
+ e.preventDefault();
+ tb_remove();
+ return false;
+ });
+ $('#change-voucher-for-sure').on('click', function (e) {
+ var sec = $('#change_voucher_nonce').val(),
+ this_button = $(this),
+ new_voucher = $("#input_changeVoucher").val();
+ $.ajax({
+ url: wpApiSettings.ajax_url,
+ type: 'POST',
+ data: {
+ action: 'change_voucher',
+ voucher_id: currentVoucher,
+ applicant_id: applicantId,
+ position: position,
+ new_voucher: new_voucher,
+ sec: sec
+ },
+ beforeSend: function () {
+ this_button.text('Working...');
+ },
+ success: function (data) {
+ this_button.text("Yes, I'm sure");
+ $('#alert-messages').html('');
+ if (data == 'ok') {
+ tb_remove();
+ //$('#alert-messages').append('The request was sended to the user
').find('.notice').delay(3200).fadeOut(300);
+ console.log('ok');
+ location.reload();
+
+ }
+ if (data == 'error') {
+ console.log('error');
+ $('#alert-messages').append('There was an error sending your request
').find('.notice').delay(3200).fadeOut(300);
+ tb_remove();
+ }
+ }
+ });
+ });
+ }
$.askVoucher = function (id, name, applicant_id) {
$('#ask-voucher-for-sure').off('click');
$('#ask-clarification-modal').find('.name-display').html(name);
@@ -343,4 +393,37 @@ jQuery(document).ready(function ($) {
$(target).slideToggle('fast');
return false;
});
+ $('#input_changeVoucher').chosen({});
+
+ $('#set-new-vouch-reason').on('click', function(e) {
+ e.preventDefault();
+ var obj = $(this),
+ new_reason = $('#clarification_voucher').val(),
+ entry_id = obj.data('entry-id'),
+ sec = $('#clarification_voucher_nonce').val();
+ $.ajax({
+ url: wpApiSettings.ajax_url,
+ type: 'POST',
+ data: {
+ action: 'reason_voucher',
+ entry_id: entry_id,
+ new_reason: new_reason,
+ sec: sec
+ },
+ beforeSend: function () {
+ obj.text('Working...');
+ },
+ success: function (data) {
+ obj.text("Set new reason");
+ $('#change-voucher-messages').html('');
+ if (data == 'ok') {
+ location.reload();
+ }
+ if (data == 'error') {
+ $('#change-voucher-messages').append('There was an error sending your request
').find('.notice').delay(3200).fadeOut(300);
+ }
+ }
+ });
+ return false;
+ });
});
\ No newline at end of file
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index afe31dc..a434e4b 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -469,6 +469,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo '';
echo _('
Vouchers Requested ');
$voucher_choices = ccgn_application_vouchers ( $applicant_id );
+ echo '
'; print_r($voucher_choices); echo ' ';
echo '
Original request date: '
. date('Y-m-d', strtotime($voucher_choices['date_created']))
. '
';
@@ -490,6 +491,44 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
);
echo '
';
echo ' ';
+ $clarification_mode = get_user_meta(get_current_user_id(), 'ccgn_need_to_clarify_vouch_reason', true);
+ if ( isset($_GET['clarification']) && $clarification_mode ) {
+ echo '';
+ echo '
';
+ echo '
Clarification of your voucher ';
+ echo '
';
+ $form_id = RGFormsModel::get_form_id(CCGN_GF_VOUCH);
+
+ $search_criteria = array();
+ $search_criteria['field_filters'][]
+ = array(
+ 'key' => 'created_by',
+ 'value' => get_current_user_id(),
+ );
+ $search_criteria['field_filters'][]
+ = array(
+ 'key' => CCGN_GF_VOUCH_APPLICANT_ID_FIELD,
+ 'value' => $applicant_id,
+ );
+ $get_the_entries = GFAPI::get_entries(
+ $form_id,
+ $search_criteria,
+ array(
+ array(
+ 'key' => 'date_created',
+ 'direction' => 'ASC',
+ 'is_numeric' => false
+ )
+ )
+ );
+ //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 '
Set new reason ';
+ echo '
';
+ }
echo _('Vouches list ');
echo '';
$vouchers = ccgn_application_users_page_vouch_responses_data(
@@ -536,6 +575,38 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo '
';
//echo '';
echo '';
+ echo '';
+ echo '
You are about to change the current voucher: ';
+ echo '
';
+ gravity_form_enqueue_scripts( 41, false );
+ $choices = array();
+ $members = ccgn_registration_form_list_members(get_current_user_id());
+ foreach ($members as $member) {
+ $choices[] = array(
+ 'text' => $member[1].' ('.$member[2].')',
+ 'value' => $member[0],
+ 'is_selected' => false
+ );
+ }
+ $field_properties = array(
+ 'type' => 'select',
+ 'enableEnhancedUI' => true,
+ 'id' => 'changeVoucher',
+ 'cssClass' => 'custom-select-changer',
+ 'choices' => $choices
+ );
+ $field = GF_Fields::create($field_properties);
+ echo $field->get_field_input();
+ echo '
';
+ echo '
';
+ echo wp_nonce_field('change_voucher', 'change_voucher_nonce', true, false);
+ echo '
';
+ echo 'Close ';
+ echo "Change ";
+ echo '
';
+ //echo '';
+ echo '
';
+
}
echo _('Global Council Approval');
echo '';
@@ -614,16 +685,95 @@ function ccgn_application_user_link( $actions, $user_object ) {
// Ajax function
// Executed in the UI when a MC member ask to a voucher for clarification
+// @user_id : user to be notified
function ccgn_ajax_ask_voucher()
{
$user_id = $_POST['user_id'];
$applicant_id = $_POST['applicant_id'];
if (check_ajax_referer('ask_voucher', 'sec') && (!empty($user_id))) {
ccgn_ask_email_vouching_request($applicant_id,$user_id);
+ //set user state to clarification of the reason to vouch applicant
+ update_user_meta($user_id,'ccgn_need_to_clarify_vouch_reason',1);
ccgn_ask_clarification_log_append($applicant_id);
echo 'ok';
}
exit(0);
}
add_action('wp_ajax_nopriv_ask_voucher', 'ccgn_ajax_ask_voucher');
-add_action('wp_ajax_ask_voucher', 'ccgn_ajax_ask_voucher');
\ No newline at end of file
+add_action('wp_ajax_ask_voucher', 'ccgn_ajax_ask_voucher');
+
+function ccgn_ajax_change_voucher()
+{
+ $voucher_id = esc_attr($_POST['voucher_id']);
+ $applicant_id = esc_attr($_POST['applicant_id']);
+ $position = esc_attr($_POST['position']);
+ $new_voucher = esc_attr( $_POST['new_voucher'] );
+
+ if (check_ajax_referer('change_voucher', 'sec') && (!empty($new_voucher))) {
+
+ $form_id = RGFormsModel::get_form_id(CCGN_GF_CHOOSE_VOUCHERS);
+
+ $search_criteria = array();
+ $search_criteria['field_filters'][]
+ = array(
+ 'key' => 'created_by',
+ 'value' => $applicant_id,
+ );
+
+ $get_the_entries = GFAPI::get_entries(
+ $form_id,
+ $search_criteria,
+ array(
+ array(
+ 'key' => 'date_created',
+ 'direction' => 'ASC',
+ 'is_numeric' => false
+ )
+ )
+ );
+ //echo '
'; print_r($get_the_entries); echo ' ';
+ $entry_id = $get_the_entries[0]['id'];
+ $update_date = GFAPI::update_entry_field($entry_id, 'date_updated', date('Y-m-d H:m:s'));
+ $change_voucher_result = GFAPI::update_entry_field($entry_id, $position, $new_voucher);
+ if ($change_voucher_result) {
+ //send email to the new voucher
+ ccgn_registration_email_vouching_request(
+ $applicant_id,
+ $voucher_id
+ );
+ echo 'ok';
+ } else {
+ echo 'error';
+ }
+ } else {
+ echo 'error';
+ }
+ exit(0);
+}
+add_action('wp_ajax_nopriv_change_voucher', 'ccgn_ajax_change_voucher');
+add_action('wp_ajax_change_voucher', 'ccgn_ajax_change_voucher');
+
+// Save new reason to vouch in order to clarify the reason of the vouched user
+function ccgn_ajax_modify_reason_voucher()
+{
+ $user_id = get_current_user_id();
+ $applicant_id = esc_attr($_POST['applicant_id']);
+ $new_reason = esc_attr($_POST['new_reason']);
+ $entry_id = esc_attr($_POST['entry_id']);
+ if (check_ajax_referer('clarification_voucher', 'sec') && (!empty($user_id)) && (!empty($entry_id)) && (!empty($new_reason)) ) {
+ //ccgn_ask_email_vouching_request($applicant_id, $user_id);
+ $update_date = GFAPI::update_entry_field($entry_id, 'date_updated', date('Y-m-d H:m:s'));
+ $reasonchange_result = GFAPI::update_entry_field($entry_id, CCGN_GF_VOUCH_REASON,$new_reason);
+ if ($reasonchange_result) {
+ echo 'ok';
+ update_user_meta($user_id, 'ccgn_need_to_clarify_vouch_reason', 0);
+ } else {
+ echo 'error';
+ }
+ } else {
+ echo 'error';
+ }
+ exit(0);
+}
+add_action('wp_ajax_nopriv_reason_voucher', 'ccgn_ajax_modify_reason_voucher');
+add_action('wp_ajax_reason_voucher', 'ccgn_ajax_modify_reason_voucher');
\ 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 946e94f..3a18ca9 100644
--- a/plugins/cc-global-network/includes/gravityforms-interaction.php
+++ b/plugins/cc-global-network/includes/gravityforms-interaction.php
@@ -1842,8 +1842,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') ) ? '
Change ' : '';
+ $result .= '
' . $voucher->display_name . $action_button .'
';
+ $position++;
}
return $result;
}
From b3ec02800317aef64c63ac7d1451e25c22132609 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Tue, 6 Nov 2018 08:57:18 -0300
Subject: [PATCH 07/12] style improvement on vouching profile && vouching
requests list
---
.../admin/assets/css/admin_styles.css | 1 +
.../admin/user-application-page.php | 7 +-
.../includes/format-applicant-profile.php | 24 ++++--
.../public/vouching-form-shortcode.php | 8 +-
themes/cc-commoners/assets/css/extra.css | 79 +++++++++++++++++++
themes/cc-commoners/assets/js/cc-commoners.js | 9 ++-
6 files changed, 117 insertions(+), 11 deletions(-)
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 e6eecd4..42dc8db 100644
--- a/plugins/cc-global-network/admin/assets/css/admin_styles.css
+++ b/plugins/cc-global-network/admin/assets/css/admin_styles.css
@@ -192,6 +192,7 @@ table.ccgn-profile tr td.title {
margin-bottom: 2rem;
}
.preview-details td {
+ padding: .5rem;
width: 50%;
vertical-align: top;
}
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index a434e4b..c819be9 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -469,7 +469,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo '';
echo _('
Vouchers Requested ');
$voucher_choices = ccgn_application_vouchers ( $applicant_id );
- echo '
'; print_r($voucher_choices); echo ' ';
+
echo '
Original request date: '
. date('Y-m-d', strtotime($voucher_choices['date_created']))
. '
';
@@ -490,7 +490,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
$state
);
echo '
';
- echo ' ';
+
$clarification_mode = get_user_meta(get_current_user_id(), 'ccgn_need_to_clarify_vouch_reason', true);
if ( isset($_GET['clarification']) && $clarification_mode ) {
echo ' ';
@@ -529,6 +529,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo 'Set new reason ';
echo '
';
}
+ echo ' ';
echo _('Vouches list ');
echo '';
$vouchers = ccgn_application_users_page_vouch_responses_data(
@@ -607,6 +608,8 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
//echo '';
echo '
';
+ } else {
+ echo ' ';
}
echo _('Global Council Approval');
echo '';
diff --git a/plugins/cc-global-network/includes/format-applicant-profile.php b/plugins/cc-global-network/includes/format-applicant-profile.php
index 52594a2..66b40e0 100644
--- a/plugins/cc-global-network/includes/format-applicant-profile.php
+++ b/plugins/cc-global-network/includes/format-applicant-profile.php
@@ -117,7 +117,12 @@ function ccgn_vouching_form_profile_format( $entry, $map, $applicant_id ) {
$is_individual = ccgn_user_is_individual_applicant($entry['created_by']);
$statement = ($is_individual) ? $entry[3] : $entry[6];
$bio = $entry[2];
- $html = '
';
+ $html = '';
+ if (!is_admin()){
+ $the_user = get_user_by('ID', $applicant_id);
+ $html .= '
'.$the_user->display_name.' ';
+ }
+ $html .= '
';
$html .= '
';
$html .= '';
$html .= '';
@@ -134,11 +139,20 @@ function ccgn_vouching_form_profile_format( $entry, $map, $applicant_id ) {
$html .= '
';
$html .= '
View more applicant details ';
$html .= '
';
- if ($is_individual) {
- unset($map[2]);
- unset($map[3]);
+ if (is_admin()) {
+ if ($is_individual) {
+ unset($map[2]);
+ unset($map[3]);
+ } else {
+ unset($map[4]);
+ }
} else {
- unset($map[4]);
+ if ($is_individual) {
+ unset($map[0]);
+ unset($map[1]);
+ } else {
+ unset($map[2]);
+ }
}
unset ($statement);
unset ($bio);
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 _( "Current Vouching Requests " );
+ echo _( "Current Vouching Requests " );
foreach ( $requests as $request ) {
$applicant_id = $request[ 'created_by' ];
// Make sure the user has been Spam Checked, otherwise people
@@ -64,12 +64,14 @@ function ccgn_vouching_requests_render ( $voucher_id ) {
if ( ! ccgn_registration_user_is_vouchable ( $applicant_id ) ) {
continue;
}
+ $icon = (ccgn_user_is_individual_applicant($applicant_id)) ? '' : ' ';
$applicant = get_user_by( 'ID', $applicant_id );
- $request_html = '';
+ $request_html .= ' '
+ . '"> '.$icon.' '
. ccgn_applicant_display_name (
$applicant_id
);
diff --git a/themes/cc-commoners/assets/css/extra.css b/themes/cc-commoners/assets/css/extra.css
index 2fa5fa5..912a687 100644
--- a/themes/cc-commoners/assets/css/extra.css
+++ b/themes/cc-commoners/assets/css/extra.css
@@ -73,6 +73,9 @@
right: 0;
top: 28%;
}
+/*///////////////////////////////////////
+ USER APPLICATION STATUS
+////////////////////////////////////////*/
/*
ENTRY STATUS
*/
@@ -163,4 +166,80 @@
}
.entry-status.on-hold .icon .dashicons {
color: #ff7300;
+}
+
+/*///////////////////////////////////////
+ APPLICANT PUBLIC PROFILE
+////////////////////////////////////////*/
+
+table.ccgn-profile {
+ display: none;
+ width: 100%;
+ 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: flex;
+ padding: .5rem;
+ align-items: center;
+ background-color: #cea500;
+ color: #FFF;
+ transition: all .5s ease;
+}
+.display-details:hover {
+ background-color: #e6b800;
+}
+.display-details .dashicons {
+ transition: all .5s ease;
+}
+.display-details.opened .dashicons {
+ transform: rotate(-180deg);
+}
+.preview-details td {
+ padding: .5rem;
+ width: 50%;
+ vertical-align: top;
+ font-size: .9rem;
+}
+.preview-details td h6 {
+ margin: 1rem 0;
+ font-size: 1.1rem;
+ font-weight: bold;
+}
+.signup-form-body .applicant-title {
+ padding: .5rem 0;
+ border-bottom: 1px solid #cea500;
+ border-top: 1px solid #cea500;
+}
+.signup-form-body h3 {
+ font-size: 1.2rem;
+}
+/* VOUCH LIST */
+.vouch-list {
+ list-style-type: none;
+}
+.vouch-list .vouch-item a {
+ display: flex;
+ padding: .5rem;
+ margin-bottom: 1rem;
+ align-items: center;
+ background-color: #efaf01;
+ text-decoration: none;
+ color: #5D5D5D;
+}
+.vouch-list .vouch-item a .dashicons {
+ margin-right: .5rem;
+}
+.vouch-list .vouch-item a:hover {
+ background-color: #ef9c01;
+ color: white;
}
\ No newline at end of file
diff --git a/themes/cc-commoners/assets/js/cc-commoners.js b/themes/cc-commoners/assets/js/cc-commoners.js
index 0c13224..b616308 100644
--- a/themes/cc-commoners/assets/js/cc-commoners.js
+++ b/themes/cc-commoners/assets/js/cc-commoners.js
@@ -67,6 +67,13 @@ jQuery(document).ready(function($){
$(this).removeClass("titulo-activo");
});
-
+ $('.display-details').on('click', function (e) {
+ e.preventDefault();
+ var obj = $(this),
+ target = obj.data('target');
+ obj.toggleClass('opened');
+ $(target).slideToggle('fast');
+ return false;
+ });
});
\ No newline at end of file
From c059628d4bfea1c47f481bf9e6f52da9e5d42fcc Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Tue, 6 Nov 2018 09:49:30 -0300
Subject: [PATCH 08/12] fix condition for MC member voting
---
plugins/cc-global-network/admin/user-application-page.php | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index c819be9..a58ccf6 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -436,11 +436,13 @@ function ccgn_application_users_page_render_state ( $applicant_id, $state ) {
echo _('Pre-Approve ');
ccgn_application_users_page_pre_form ( $applicant_id );
} elseif ( $state == CCGN_APPLICATION_STATE_VOUCHING ) {
- if (ccgn_current_user_is_final_approver()) {
+ if (ccgn_current_user_is_final_approver() || ccgn_current_user_is_membership_council()) {
echo _('Vote ');
ccgn_application_users_page_vote_form ( $applicant_id );
- echo _('Final Approval ');
- ccgn_application_users_page_final_approval_form( $applicant_id );
+ if (ccgn_current_user_is_final_approver()) {
+ echo _('Final Approval ');
+ ccgn_application_users_page_final_approval_form( $applicant_id );
+ }
}
} elseif ( ccgn_membership_council_voting_disabled_for ( $applicant_id ) ) {
echo _('Voted Against ');
From c4b881e94525489d943cd910ea7ee33572a45b06 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Tue, 6 Nov 2018 12:22:36 -0300
Subject: [PATCH 09/12] fix log display on ask voucher for clarification window
---
.../admin/assets/css/admin_styles.css | 2 +-
.../admin/assets/js/script.js | 27 ++++++++++++++++-
.../admin/user-application-page.php | 30 +++++++++++--------
.../includes/format-applicant-profile.php | 20 ++++++++++++-
4 files changed, 63 insertions(+), 16 deletions(-)
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 42dc8db..facf830 100644
--- a/plugins/cc-global-network/admin/assets/css/admin_styles.css
+++ b/plugins/cc-global-network/admin/assets/css/admin_styles.css
@@ -210,7 +210,7 @@ table.ccgn-profile tr td.title {
}
#TB_ajaxContent {
position: relative;
- padding-bottom: 2rem;
+ padding-bottom: 4rem !important;
}
#TB_ajaxContent .buttons {
position: absolute;
diff --git a/plugins/cc-global-network/admin/assets/js/script.js b/plugins/cc-global-network/admin/assets/js/script.js
index a9d5e62..b8e4a8b 100644
--- a/plugins/cc-global-network/admin/assets/js/script.js
+++ b/plugins/cc-global-network/admin/assets/js/script.js
@@ -145,7 +145,32 @@ jQuery(document).ready(function ($) {
$.askVoucher = function (id, name, applicant_id) {
$('#ask-voucher-for-sure').off('click');
$('#ask-clarification-modal').find('.name-display').html(name);
- tb_show("Ask for clarification to voucher", "#TB_inline?width=600&height=300&inlineId=ask-clarification-modal");
+ tb_show("Ask for clarification to voucher", "#TB_inline?width=600&height=350&inlineId=ask-clarification-modal");
+ $('#log-content-ask-voucher').hide();
+ var logList = $('#log-entry-ask-voucher');
+ logList.html('');
+ $.ajax({
+ url: wpApiSettings.ajax_url,
+ type: 'POST',
+ data: {
+ action: 'ask_voucher_log',
+ applicant_id: applicant_id,
+ voucher_id: id
+ },
+ success: function (data) {
+ converted_data = JSON.parse(data);
+ console.log(logList);
+ if (converted_data.length > 0) {
+ converted_data.forEach(function(element){
+ console.log(element);
+ logList.append('' + element.ask_user_name + ' on ' + element.date + '
');
+ });
+ $('#log-content-ask-voucher').show();
+ } else {
+ $('#log-content-ask-voucher').hide();
+ }
+ }
+ });
$('#close-ask-voucher').on('click', function (e) {
e.preventDefault();
tb_remove();
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index a58ccf6..4e6c242 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -54,8 +54,7 @@ function ccgn_application_users_page_vote_responses ( $applicant_id ) {
foreach ($votes as $vote) {
$voter = get_user_by('ID', $vote['created_by']);
$result .= '';
- $result .= '
'
- . '
'. $voter->display_name . ' '
+ $result .= '
'. $voter->display_name . ' '
.'
Voted: '
. $vote[
CCGN_GF_VOTE_APPROVE_MEMBERSHIP_APPLICATION
@@ -532,7 +531,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
echo '
';
}
echo ' ';
- echo _('Vouches list ');
+ echo _('Vouchers list ');
echo '';
$vouchers = ccgn_application_users_page_vouch_responses_data(
$applicant_id,
@@ -540,7 +539,7 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
);
foreach ($vouchers as $voucher) {
echo '
';
- echo '
';
+ //echo '
';
echo '
'.$voucher['name'].' ';
echo '
'.$voucher['date'].' ';
echo '
' . $voucher['reason'] . '
';
@@ -558,17 +557,22 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
add_thickbox();
echo '
';
echo '
You are about to ask for clarification to the voucher: ';
- $log = ccgn_ask_clarification_log_get_id($applicant_id);
- if (!empty($log)) {
- echo '
This operation have been perfomed some times:
';
+ echo '
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.
';
+
+
+ echo '
';
+ echo '
This already was requested by:
';
echo '
';
- }
+ echo '
There is no need to send this email again to the voucher. In case you consider that necessary, you can do it again.
';
+ echo '
';
+
echo '
Are you sure you want to do this?
';
echo '
';
echo wp_nonce_field('ask_voucher', 'ask_voucher_nonce', true, false);
@@ -699,7 +703,7 @@ function ccgn_ajax_ask_voucher()
ccgn_ask_email_vouching_request($applicant_id,$user_id);
//set user state to clarification of the reason to vouch applicant
update_user_meta($user_id,'ccgn_need_to_clarify_vouch_reason',1);
- ccgn_ask_clarification_log_append($applicant_id);
+ ccgn_ask_clarification_log_append($applicant_id,$user_id);
echo 'ok';
}
exit(0);
diff --git a/plugins/cc-global-network/includes/format-applicant-profile.php b/plugins/cc-global-network/includes/format-applicant-profile.php
index 66b40e0..c9cb3c6 100644
--- a/plugins/cc-global-network/includes/format-applicant-profile.php
+++ b/plugins/cc-global-network/includes/format-applicant-profile.php
@@ -264,6 +264,22 @@ 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();
@@ -287,13 +303,15 @@ function ccgn_ask_clarification_log_set($log_structure)
}
function ccgn_ask_clarification_log_append(
- $applicant_id
+ $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,
From c70bf30546b04412d95a7f74cb8de6a33ca49289 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Tue, 6 Nov 2018 15:11:13 -0300
Subject: [PATCH 10/12] fix email send id on voucher change
---
plugins/cc-global-network/admin/user-application-page.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index 4e6c242..27ec80d 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -748,7 +748,7 @@ function ccgn_ajax_change_voucher()
//send email to the new voucher
ccgn_registration_email_vouching_request(
$applicant_id,
- $voucher_id
+ $new_voucher
);
echo 'ok';
} else {
From ac20a3d8f5eef9b7188390c242b9da703a8899b3 Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Thu, 8 Nov 2018 09:22:20 -0300
Subject: [PATCH 11/12] function to wipe users with a certain state and
registered a certain amount of months ago
---
.../admin/user-application-page.php | 3 +-
.../includes/application-state.php | 53 +++++++++++++++++++
.../includes/gravityforms-interaction.php | 4 +-
3 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index 27ec80d..6de2e9e 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -740,13 +740,12 @@ function ccgn_ajax_change_voucher()
)
)
);
- //echo ''; print_r($get_the_entries); echo ' ';
$entry_id = $get_the_entries[0]['id'];
$update_date = GFAPI::update_entry_field($entry_id, 'date_updated', date('Y-m-d H:m:s'));
$change_voucher_result = GFAPI::update_entry_field($entry_id, $position, $new_voucher);
if ($change_voucher_result) {
//send email to the new voucher
- ccgn_registration_email_vouching_request(
+ $send_mail = ccgn_registration_email_vouching_request(
$applicant_id,
$new_voucher
);
diff --git a/plugins/cc-global-network/includes/application-state.php b/plugins/cc-global-network/includes/application-state.php
index a9f30bf..ebc413e 100644
--- a/plugins/cc-global-network/includes/application-state.php
+++ b/plugins/cc-global-network/includes/application-state.php
@@ -457,4 +457,57 @@ function ccgn_show_current_application_status($user_id) {
$current_state['step'] = $steps[$current_status['stage']];
$current_state['date'] = $current_status['date'];
return $current_state;
+}
+
+//Remove old applications left in custom state
+//The main reason is to wipe old applications considered abandoned
+function ccgn_get_old_applications_with_state($state, $months_ago)
+{
+ $args = array(
+ 'role' => 'new-user',
+ 'posts_per_page' => -1,
+ 'date_query' => array(
+ array(
+ 'column' => 'user_registered',
+ 'before' => $months_ago . ' months ago'
+ )
+ ),
+ 'meta_query' => array(
+ array(
+ 'key' => 'ccgn-application-state',
+ 'value' => $state
+ )
+ )
+ );
+ $query = new WP_User_Query($args);
+ return $query;
+}
+function ccgn_list_old_applications_with_state($state, $months_ago)
+{
+ $query = ccgn_get_old_applications_with_state($state, $months_ago);
+ echo '-------------------------------------------------------------------------------------' . "\n";
+ echo 'LISTING USERS WITH THE STATE "' . $state . '" AND REGISTERED ' . $months_ago . ' MONTHS AGO' . "\n";
+ echo '-------------------------------------------------------------------------------------' . "\n";
+ foreach ($query->get_results() as $user) {
+ $user_id = $user->data->ID;
+ echo $user_id . ' - ' . $user->data->display_name . '( ' . $user->data->user_login . ' ) - registered on: ' . $user->data->user_registered . "\n";
+ }
+}
+function ccgn_remove_old_applications_with_state($state, $months_ago)
+{
+ $query = ccgn_get_old_applications_with_state($state, $months_ago);
+ foreach ($query->get_results() as $user) {
+ $user_id = $user->data->ID;
+ $user_name = $user->data->display_name;
+ $user_login = $user->data->user_login;
+ _ccgn_application_delete_entries_created_by($user_id);
+ delete_user_meta($user_id, CCGN_APPLICATION_TYPE);
+ delete_user_meta($user_id, CCGN_APPLICATION_STATE);
+ delete_user_meta($user_id, CCGN_USER_IS_AUTOVOUCHED);
+
+ $delete = wp_delete_user($user_id);
+ if ($delete) {
+ echo 'DELETED USER: ' . $user_id . ' - ' . $user_name . '( ' . $user_login . ' )' . "\n";
+ }
+ }
}
\ 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 6e71530..cfadcb0 100644
--- a/plugins/cc-global-network/includes/gravityforms-interaction.php
+++ b/plugins/cc-global-network/includes/gravityforms-interaction.php
@@ -1806,6 +1806,8 @@ 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
@@ -1984,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
From 395e2db27567a0a14f2793308a1433631f2e589a Mon Sep 17 00:00:00 2001
From: hugosolar
Date: Thu, 8 Nov 2018 09:58:47 -0300
Subject: [PATCH 12/12] highlight voucher box if has been asked for
clarification
---
.../cc-global-network/admin/assets/css/admin_styles.css | 3 +++
.../cc-global-network/admin/user-application-page.php | 9 ++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
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 facf830..a154f63 100644
--- a/plugins/cc-global-network/admin/assets/css/admin_styles.css
+++ b/plugins/cc-global-network/admin/assets/css/admin_styles.css
@@ -172,6 +172,9 @@ table.ccgn-profile tr td.title {
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;
}
diff --git a/plugins/cc-global-network/admin/user-application-page.php b/plugins/cc-global-network/admin/user-application-page.php
index 6de2e9e..c5b2716 100644
--- a/plugins/cc-global-network/admin/user-application-page.php
+++ b/plugins/cc-global-network/admin/user-application-page.php
@@ -494,6 +494,8 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
$clarification_mode = get_user_meta(get_current_user_id(), 'ccgn_need_to_clarify_vouch_reason', true);
if ( isset($_GET['clarification']) && $clarification_mode ) {
+ echo ' ';
+ echo '
';
echo '
';
echo '
';
echo '
Clarification of your voucher ';
@@ -538,10 +540,15 @@ function ccgn_application_users_page_render_details ( $applicant_id, $state ) {
true
);
foreach ($vouchers as $voucher) {
- echo '
';
+ $asked = get_user_meta($voucher['id'], 'ccgn_need_to_clarify_vouch_reason', true);
+ $asked_class = ($asked) ? ' asked-box' : '';
+ echo '
';
//echo '
';
echo '
'.$voucher['name'].' ';
echo '
'.$voucher['date'].' ';
+ if ($asked) {
+ echo '
Asked for clarification ';
+ }
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)) ) {