| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the export button in the donation filters box. |
| 4 |
* |
| 5 |
* @author Studio 164a |
| 6 |
* @package Charitable/Admin View/Donations Page |
| 7 |
* @since 1.0.0 |
| 8 |
*/ |
| 9 |
|
| 10 |
$modal_class = apply_filters( 'charitable_modal_window_class', 'charitable-modal' ); |
| 11 |
$start_date = isset( $_GET['start_date'] ) ? sanitize_text_field( $_GET['start_date'] ) : null; |
| 12 |
$end_date = isset( $_GET['end_date'] ) ? sanitize_text_field( $_GET['end_date'] ) : null; |
| 13 |
$post_status = isset( $_GET['post_status'] ) ? $_GET['post_status'] : 'all'; |
| 14 |
$report_type = isset( $_GET['report_type'] ) ? $_GET['report_type'] : 'donations'; |
| 15 |
$report_types = apply_filters( 'charitable_donation_export_report_types', array( |
| 16 |
'donations' => __( 'Donations', 'charitable' ), |
| 17 |
) ); |
| 18 |
|
| 19 |
?> |
| 20 |
<div id="charitable-donations-export-modal" style="display: none;" class="charitable-donations-modal <?php echo esc_attr( $modal_class ); ?>" tabindex="0"> |
| 21 |
<a class="modal-close"></a> |
| 22 |
<h3><?php _e( 'Export Donations', 'charitable' ); ?></h3> |
| 23 |
<form class="charitable-donations-modal-form charitable-modal-form" method="get" action="<?php echo admin_url( 'admin.php' ); ?>"> |
| 24 |
<?php wp_nonce_field( 'charitable_export_donations', '_charitable_export_nonce' ); ?> |
| 25 |
<input type="hidden" name="charitable_action" value="export_donations" /> |
| 26 |
<input type="hidden" name="page" value="charitable-donations-table" /> |
| 27 |
<fieldset> |
| 28 |
<legend><?php _e( 'Filter by Date', 'charitable' ); ?></legend> |
| 29 |
<input type="text" id="charitable-export-start_date" name="start_date" class="charitable-datepicker" value="<?php echo $start_date; ?>" placeholder="<?php esc_attr_e( 'From:', 'charitable' ); ?>" /> |
| 30 |
<input type="text" id="charitable-export-end_date" name="end_date" class="charitable-datepicker" value="<?php echo $end_date; ?>" placeholder="<?php esc_attr_e( 'To:', 'charitable' ); ?>" /> |
| 31 |
</fieldset> |
| 32 |
<label for="charitable-donations-export-status"><?php _e( 'Filter by Status', 'charitable' ); ?></label> |
| 33 |
<select id="charitable-donations-export-status" name="post_status"> |
| 34 |
<option value="all" <?php selected( $post_status, 'all' ); ?>><?php _e( 'All', 'charitable' ); ?></option> |
| 35 |
<?php foreach ( charitable_get_valid_donation_statuses() as $key => $status ) : ?> |
| 36 |
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $post_status, $key ); ?>><?php echo $status; ?></option> |
| 37 |
<?php endforeach ?> |
| 38 |
</select> |
| 39 |
<label for="charitable-donations-export-campaign"><?php _e( 'Filter by Campaign', 'charitable' ); ?></label> |
| 40 |
<select id="charitable-donations-export-campaign" name="campaign_id"> |
| 41 |
<option value="all"><?php _e( 'All Campaigns', 'charitable' ); ?></option> |
| 42 |
<?php |
| 43 |
foreach ( get_posts( array( |
| 44 |
'post_type' => 'campaign', |
| 45 |
'post_status' => 'any', |
| 46 |
'posts_per_page' => -1, |
| 47 |
) ) as $campaign ) : |
| 48 |
?> |
| 49 |
<option value="<?php echo $campaign->ID; ?>"><?php echo get_the_title( $campaign->ID ); ?></option> |
| 50 |
<?php endforeach ?> |
| 51 |
</select> |
| 52 |
<?php if ( count( $report_types ) > 1 ) : ?> |
| 53 |
<label for="charitable-donations-export-report-type"><?php _e( 'Type of Report', 'charitable' ); ?></label> |
| 54 |
<select id="charitable-donations-export-report-type" name="report_type"> |
| 55 |
<?php foreach ( $report_types as $key => $report_label ) : ?> |
| 56 |
<option value="<?php echo esc_attr( $key ); ?>"><?php echo $report_label; ?></option> |
| 57 |
<?php endforeach; ?> |
| 58 |
</select> |
| 59 |
<?php else : ?> |
| 60 |
<input type="hidden" name="report_type" value="<?php echo esc_attr( key( $report_types ) ); ?>" /> |
| 61 |
<?php endif ?> |
| 62 |
<?php do_action( 'charitable_export_donations_form' ); ?> |
| 63 |
<button name="charitable-export-donations" class="button button-primary"><?php _e( 'Export', 'charitable' ); ?></button> |
| 64 |
</form> |
| 65 |
</div> |
| 66 |
|