Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/1847 #1863

Merged
merged 30 commits into from
Jul 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
d775d4c
Merge pull request #57 from WordImpress/release/1.8.12
mehul0810 Jul 13, 2017
b98bdf9
Added Pagination using jump to page number for Reports > Form
mehul0810 Jul 13, 2017
8cbda0b
updated pagination for donation logs
mehul0810 Jul 13, 2017
684b0bb
Updated JS for confirmation popup issue when jumping to page number u…
mehul0810 Jul 13, 2017
4973f10
ran gulp
mehul0810 Jul 13, 2017
ae1c15a
fixed logs pagination issue
mehul0810 Jul 14, 2017
34aa72e
Merge pull request #58 from WordImpress/release/1.8.12
mehul0810 Jul 14, 2017
e8983f8
Restricted unnecessary elements in url
mehul0810 Jul 14, 2017
1cbe27d
script label changes
mehul0810 Jul 14, 2017
df6de77
script changes
mehul0810 Jul 14, 2017
bab7d34
Refactor: change resend_receipt to resend-receipt
ravinderk Jul 14, 2017
2217929
refactor: optimize script for bulk action
ravinderk Jul 14, 2017
c68f55b
code formatting
mehul0810 Jul 14, 2017
cce1028
code formatting and comment improvement
mehul0810 Jul 14, 2017
799c015
resolved merge conflict
mehul0810 Jul 15, 2017
7643ef3
Merge branch 'WordImpress-release/1.8.12' into issue/1847
mehul0810 Jul 15, 2017
dabc47b
improved forms under reports by removed form tag usage directly
mehul0810 Jul 15, 2017
54a288d
Added Comments
mehul0810 Jul 15, 2017
ed1ee37
added support for donors tab under reporting section
mehul0810 Jul 15, 2017
0c9ff5f
removed a block of code due to which main form is not generated for f…
mehul0810 Jul 15, 2017
5d2ffa2
minor fix and proper commenting
mehul0810 Jul 15, 2017
19fecd8
logs improvement with dynamic forms tag
mehul0810 Jul 15, 2017
daa7284
Set Form method for logs
mehul0810 Jul 17, 2017
669fe20
minor fn name change
mehul0810 Jul 17, 2017
b8eef92
removed inclusion of logs.php from here as its not working
mehul0810 Jul 17, 2017
0e0e418
Included logs.php here for better callback
mehul0810 Jul 17, 2017
f513d26
remove unnecesary direct call of form tags
mehul0810 Jul 17, 2017
26929b4
removed restriction of not using main form tags
mehul0810 Jul 17, 2017
f4f2fd4
minor comment change
mehul0810 Jul 17, 2017
aa37034
reverted changes to give_vars
mehul0810 Jul 17, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 ) ?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

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