Skip to content

Commit

Permalink
Merge pull request #1863 from mehul0810/issue/1847
Browse files Browse the repository at this point in the history
Issue/1847
  • Loading branch information
Devin Walker committed Jul 17, 2017
2 parents 3fcacf0 + aa37034 commit 234c378
Show file tree
Hide file tree
Showing 10 changed files with 168 additions and 146 deletions.
111 changes: 35 additions & 76 deletions assets/js/admin/admin-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -1715,85 +1715,44 @@ jQuery.noConflict();
*/
$payment_filters.on( 'submit', function( e ) {
var current_action = $( 'select[name="action"]', $( this ) ).val(),
$payments = [],
confirm_action_notice = '';

$( 'input[name="payment[]"]:checked', $( this ) ).each( function( index, item ) {
$payments.push( $( this ).val() );
} );

// Total payment count.
$payments = $payments.length.toString();

switch ( current_action ) {
case 'delete':
// Check if admin did not select any payment.
if ( ! parseInt( $payments ) ) {
alert( give_vars.bulk_action.delete.zero_payment_selected );
return false;
}

// Ask admin before processing.
confirm_action_notice = ( 1 < $payments ) ? give_vars.bulk_action.delete.delete_payments : give_vars.bulk_action.delete.delete_payment;
if ( ! window.confirm( confirm_action_notice.replace( '{payment_count}', $payments ) ) ) {
return false;
}

break;

case 'resend-receipt':
// Check if admin did not select any payment.
if ( ! parseInt( $payments ) ) {
alert( give_vars.bulk_action.resend_receipt.zero_recipient_selected );
return false;
}

// Ask admin before processing.
confirm_action_notice = ( 1 < $payments ) ? give_vars.bulk_action.resend_receipt.resend_receipts : give_vars.bulk_action.resend_receipt.resend_receipt;
if ( ! window.confirm( confirm_action_notice.replace( '{payment_count}', $payments ) ) ) {
return false;
}

break;

default:
current_action_label = $( 'select[name="action"]', $( this ) ).find(':selected').text(),
$payments = $( 'input[name="payment[]"]:checked' ).length,
is_status_type_action = ( -1 !== current_action.indexOf( 'set-status-' ) ),
confirm_action_notice = '',
status = '';

// Set common action, if action type is status.
current_action = is_status_type_action ?
'set-to-status' :
current_action;


if( Object.keys( give_vars.bulk_action ).length ) {
for ( status in give_vars.bulk_action ) {
if( status === current_action ) {
// Get status text if current action types is status.
confirm_action_notice = is_status_type_action ?
give_vars.bulk_action[current_action].zero.replace( '{status}', current_action_label.replace( 'Set To ', '' ) ) :
give_vars.bulk_action[current_action].zero;

// Check if admin selected any donations or not.
if ( ! parseInt( $payments ) ) {
alert( confirm_action_notice );
return false;
}

var status = '';

if ( 'set-status-publish' === current_action ) {
status = 'completed';
} else if ( 'set-status-pending' === current_action ) {
status = 'pending';
} else if ( 'set-status-processing' === current_action ) {
status = 'processing';
} else if ( 'set-status-refunded' === current_action ) {
status = 'refunded';
} else if ( 'set-status-revoked' === current_action ) {
status = 'revoked';
} else if ( 'set-status-failed' === current_action ) {
status = 'failed';
} else if ( 'set-status-cancelled' === current_action ) {
status = 'cancelled';
} else if ( 'set-status-abandoned' === current_action ) {
status = 'abandoned';
} else if ( 'set-status-preapproval' === current_action ) {
status = 'preapproval';
}
// Get message on basis of payment count.
confirm_action_notice = ( 1 < $payments ) ?
give_vars.bulk_action[current_action].multiple :
give_vars.bulk_action[current_action].single;

// Check if admin did not select any payment.
if ( ! parseInt( $payments ) ) {
alert( give_vars.bulk_action.set_to_status.zero.replace( '{status}', status ) );
return false;
// Trigger Admin Confirmation PopUp.
return window.confirm( confirm_action_notice
.replace( '{payment_count}', $payments )
.replace( '{status}', current_action_label.replace( 'Set To ', '' ) )
);
}

// Ask admin before processing.
confirm_action_notice = ( 1 < $payments ) ? give_vars.bulk_action.set_to_status.multiple : give_vars.bulk_action.set_to_status.single;
if ( ! window.confirm( confirm_action_notice.replace( '{payment_count}', $payments ).replace( '{status}', status ) ) ) {
return false;
}

break;

}
}

return true;
Expand Down
2 changes: 2 additions & 0 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ private function includes() {
require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/class-give-graph.php';
require_once GIVE_PLUGIN_DIR . 'includes/admin/reporting/graphing.php';

require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';

require_once GIVE_PLUGIN_DIR . 'includes/admin/tools/data/tools-actions.php';

require_once GIVE_PLUGIN_DIR . 'includes/admin/shortcodes/abstract-shortcode-generator.php';
Expand Down
3 changes: 2 additions & 1 deletion includes/admin/admin-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ function give_redirect_to_clean_url_admin_pages() {
$give_pages = array(
'give-payment-history',
'give-donors',
'give-reports'
'give-reports',
'give-tools'
);

// Get current page.
Expand Down
4 changes: 1 addition & 3 deletions includes/admin/class-admin-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,13 +724,11 @@ class="give-input-field<?php echo( empty( $value['class'] ) ? '' : ' ' . esc_att
// Custom: Log field.
case 'logs' :

include GIVE_PLUGIN_DIR . 'includes/admin/tools/logs/logs.php';

// Get current section.
$current_section = $_GET['section'] = give_get_current_setting_section();

/**
* Fires the in report page logs view.
* Fires for each tab of logs view.
*
* @since 1.0
*/
Expand Down
7 changes: 1 addition & 6 deletions includes/admin/reporting/class-settings-donors.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,13 @@ public function __construct() {
add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) );
add_action( 'give_admin_field_report_donors', array( $this, 'render_report_donors_field' ), 10, 2 );

// Do not use main donor for this tab.
if( give_get_current_setting_tab() === $this->id ) {
add_action( 'give-reports_open_form', '__return_empty_string' );
add_action( 'give-reports_close_form', '__return_empty_string' );
}
}

/**
* Add this page to settings.
*
* @since 1.8
* @param array $pages Lst of pages.
* @param array $pages List of pages.
* @return array
*/
public function add_settings_page( $pages ) {
Expand Down
7 changes: 1 addition & 6 deletions includes/admin/reporting/class-settings-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,13 @@ public function __construct() {
add_action( "give-reports_settings_{$this->id}_page", array( $this, 'output' ) );
add_action( 'give_admin_field_report_forms', array( $this, 'render_report_forms_field' ), 10, 2 );

// Do not use main form for this tab.
if( give_get_current_setting_tab() === $this->id ) {
add_action( 'give-reports_open_form', '__return_empty_string' );
add_action( 'give-reports_close_form', '__return_empty_string' );
}
}

/**
* Add this page to settings.
*
* @since 1.8
* @param array $pages Lst of pages.
* @param array $pages List of pages.
* @return array
*/
public function add_settings_page( $pages ) {
Expand Down
36 changes: 25 additions & 11 deletions includes/admin/reporting/reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ function give_reports_forms_table() {
$give_table = new Give_Form_Reports_Table();
$give_table->prepare_items();
$give_table->display();
?>
<input type="hidden" name="post_type" value="give_forms"/>
<input type="hidden" name="page" value="give-reports"/>
<input type="hidden" name="tab" value="forms"/>
<?php
}

add_action( 'give_reports_view_forms', 'give_reports_forms_table' );
Expand Down Expand Up @@ -271,16 +276,14 @@ function give_reports_donors_table() {
* @since 1.0
*/
do_action( 'give_logs_donors_table_top' );

$give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' );
$give_table->display();
?>
<form id="give-donors-filter" method="get">
<?php
$give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' );
$give_table->display();
?>
<input type="hidden" name="post_type" value="give_forms"/>
<input type="hidden" name="page" value="give-reports"/>
<input type="hidden" name="tab" value="donors"/>
</form>
<input type="hidden" name="post_type" value="give_forms"/>
<input type="hidden" name="page" value="give-reports"/>
<input type="hidden" name="tab" value="donors"/>

<?php
/**
* Fires after the donors log actions form.
Expand All @@ -295,7 +298,6 @@ function give_reports_donors_table() {

add_action( 'give_reports_view_donors', 'give_reports_donors_table' );


/**
* Renders the Gateways Table
*
Expand All @@ -314,7 +316,6 @@ function give_reports_gateways_table() {

add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' );


/**
* Renders the Reports Earnings Graphs
*
Expand Down Expand Up @@ -370,4 +371,17 @@ function give_estimated_monthly_stats() {
return maybe_unserialize( $estimated );
}

/**
* Assign Get form method for reporting tabs
*
* @since 1.8.12
*
* @return string
*/
function give_reports_set_form_method() {
return 'get';
}
add_filter( 'give-reports_form_method_tab_forms', 'give_reports_set_form_method', 10 );
add_filter( 'give-reports_form_method_tab_donors', 'give_reports_set_form_method', 10 );

// @TODO: After release 1.8 Donations -> Reports generates with new setting api, so we can remove some old code from this file.
7 changes: 1 addition & 6 deletions includes/admin/tools/class-settings-logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,14 @@ public function __construct() {

parent::__construct();

// Do not use main form for this tab.
if ( give_get_current_setting_tab() === $this->id ) {
add_action( 'give-tools_open_form', '__return_empty_string' );
add_action( 'give-tools_close_form', '__return_empty_string' );
}
}

/**
* Add this page to settings.
*
* @since 1.8
*
* @param array $pages Lst of pages.
* @param array $pages List of pages.
*
* @return array
*/
Expand Down
Loading

0 comments on commit 234c378

Please sign in to comment.