| 1 |
<?php |
| 2 |
/** |
| 3 |
* Admin View: Exports |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; |
| 8 |
} ?> |
| 9 |
|
| 10 |
<div id="poststuff"> |
| 11 |
<div id="give-dashboard-widgets-wrap"> |
| 12 |
<div id="post-body"> |
| 13 |
<div id="post-body-content"> |
| 14 |
|
| 15 |
<?php |
| 16 |
/** |
| 17 |
* Fires before the reports export tab. |
| 18 |
* |
| 19 |
* @since 1.0 |
| 20 |
*/ |
| 21 |
do_action( 'give_tools_tab_export_content_top' ); |
| 22 |
?> |
| 23 |
|
| 24 |
<table class="widefat export-options-table give-table striped"> |
| 25 |
<thead> |
| 26 |
<tr> |
| 27 |
<th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th> |
| 28 |
<th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th> |
| 29 |
</tr> |
| 30 |
</thead> |
| 31 |
<tbody> |
| 32 |
<?php |
| 33 |
/** |
| 34 |
* Fires in the reports export tab. |
| 35 |
* |
| 36 |
* Allows you to add new TR elements to the table before |
| 37 |
* other elements. |
| 38 |
* |
| 39 |
* @since 1.0 |
| 40 |
*/ |
| 41 |
do_action( 'give_tools_tab_export_table_top' ); |
| 42 |
?> |
| 43 |
|
| 44 |
<tr class="give-export-donations-history"> |
| 45 |
<td scope="row" class="row-title"> |
| 46 |
<h3> |
| 47 |
<span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span> |
| 48 |
</h3> |
| 49 |
<p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
| 50 |
</td> |
| 51 |
<td> |
| 52 |
<a class="button" href="<?php echo esc_url( add_query_arg( [ 'type' => 'export_donations' ] ) ); ?>"> |
| 53 |
<?php esc_html_e( 'Generate CSV', 'give' ); ?> |
| 54 |
</a> |
| 55 |
</td> |
| 56 |
</tr> |
| 57 |
|
| 58 |
<tr class="give-export-pdf-sales-earnings"> |
| 59 |
<td scope="row" class="row-title"> |
| 60 |
<h3> |
| 61 |
<span><?php esc_html_e( 'Export PDF of Donations and Revenue', 'give' ); ?></span> |
| 62 |
</h3> |
| 63 |
<p><?php esc_html_e( 'Download a PDF of Donations and Revenue reports for all forms for the current year.', 'give' ); ?></p> |
| 64 |
</td> |
| 65 |
<td> |
| 66 |
<a class="button" href="<?php echo esc_url( wp_nonce_url( add_query_arg( [ 'give-action' => 'generate_pdf' ] ), 'give_generate_pdf' ) ); ?>"> |
| 67 |
<?php esc_html_e( 'Generate PDF', 'give' ); ?> |
| 68 |
</a> |
| 69 |
</td> |
| 70 |
</tr> |
| 71 |
<tr class="give-export-sales-earnings"> |
| 72 |
<td scope="row" class="row-title"> |
| 73 |
<h3> |
| 74 |
<span><?php esc_html_e( 'Export Revenue and Donation Stats', 'give' ); ?></span> |
| 75 |
</h3> |
| 76 |
<p><?php esc_html_e( 'Download a CSV of revenue and donations over time.', 'give' ); ?></p> |
| 77 |
</td> |
| 78 |
<td> |
| 79 |
<form method="post"> |
| 80 |
<?php |
| 81 |
// @since 2.21.2 |
| 82 |
// Year in year dropdown should begin from first donation year instead of only display first five recent year. |
| 83 |
$firstDonation = give()->donations->getFirstDonation(); |
| 84 |
$firstDonationDate = $firstDonation->createdAt ?? null; |
| 85 |
$currentYear = date('Y', current_time('timestamp')); |
| 86 |
|
| 87 |
$start_year_dropdown = Give()->html->year_dropdown( |
| 88 |
'start_year', |
| 89 |
0, |
| 90 |
$firstDonationDate ? ($currentYear - $firstDonationDate->format('Y')) : 0 |
| 91 |
); |
| 92 |
|
| 93 |
$end_year_dropdown = Give()->html->year_dropdown( |
| 94 |
'end_year', |
| 95 |
0, |
| 96 |
$firstDonationDate ? ($currentYear - $firstDonationDate->format('Y')) : 0 |
| 97 |
); |
| 98 |
printf( |
| 99 |
esc_html__('%1$s to %2$s', 'give'), |
| 100 |
$start_year_dropdown . ' ' . Give()->html->month_dropdown('start_month'), |
| 101 |
$end_year_dropdown . ' ' . Give()->html->month_dropdown('end_month') |
| 102 |
); |
| 103 |
?> |
| 104 |
<input type="hidden" name="give-action" value="earnings_export"/> |
| 105 |
<input type="hidden" name="give-nonce" value="<?= wp_create_nonce('give_earnings_export') ?>"/> |
| 106 |
<input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
| 107 |
</form> |
| 108 |
</td> |
| 109 |
</tr> |
| 110 |
|
| 111 |
<?php |
| 112 |
/** |
| 113 |
* @since 2.21.2 |
| 114 |
*/ |
| 115 |
do_action( 'give_tools_tab_export_after_donation_history' ); |
| 116 |
?> |
| 117 |
|
| 118 |
<?php |
| 119 |
/** |
| 120 |
* @since 2.21.2 |
| 121 |
*/ |
| 122 |
do_action( 'give_tools_tab_export_before_core_settings' ); |
| 123 |
?> |
| 124 |
|
| 125 |
<tr class="give-export-core-settings"> |
| 126 |
<td scope="row" class="row-title"> |
| 127 |
<h3> |
| 128 |
<span><?php esc_html_e( 'Export GiveWP Settings', 'give' ); ?></span> |
| 129 |
</h3> |
| 130 |
<p><?php esc_html_e( 'Download an export of Give\'s settings and import it in a new WordPress installation.', 'give' ); ?></p> |
| 131 |
</td> |
| 132 |
<td> |
| 133 |
<form method="post"> |
| 134 |
<?php |
| 135 |
$export_excludes = apply_filters( 'give_settings_export_excludes', [] ); |
| 136 |
if ( ! empty( $export_excludes ) ) { |
| 137 |
?> |
| 138 |
<i class="settings-excludes-title"><?php esc_html_e( 'Checked options from the list will not be exported.', 'give' ); ?></i> |
| 139 |
<ul class="settings-excludes-list"> |
| 140 |
<?php foreach ( $export_excludes as $option_key => $option_label ) { ?> |
| 141 |
<li> |
| 142 |
<label for="settings_export_excludes[<?php echo $option_key; ?>]"> |
| 143 |
<input |
| 144 |
type="checkbox" |
| 145 |
checked |
| 146 |
name="settings_export_excludes[<?php echo $option_key; ?>]" |
| 147 |
id="settings_export_excludes[<?php echo $option_key; ?>]" |
| 148 |
/> |
| 149 |
<?php echo esc_html( $option_label ); ?> |
| 150 |
</label> |
| 151 |
</li> |
| 152 |
<?php } ?> |
| 153 |
</ul> |
| 154 |
<?php } ?> |
| 155 |
<input type="hidden" name="give-action" value="core_settings_export"/> |
| 156 |
<input type="submit" value="<?php esc_attr_e( 'Export JSON', 'give' ); ?>" class="button-secondary"/> |
| 157 |
</form> |
| 158 |
</td> |
| 159 |
</tr> |
| 160 |
<?php |
| 161 |
/** |
| 162 |
* Fires in the reports export tab. |
| 163 |
* |
| 164 |
* Allows you to add new TR elements to the table after |
| 165 |
* other elements. |
| 166 |
* |
| 167 |
* @since 1.0 |
| 168 |
*/ |
| 169 |
do_action( 'give_tools_tab_export_table_bottom' ); |
| 170 |
?> |
| 171 |
</tbody> |
| 172 |
</table> |
| 173 |
|
| 174 |
<?php |
| 175 |
/** |
| 176 |
* Fires after the reports export tab. |
| 177 |
* |
| 178 |
* @since 1.0 |
| 179 |
*/ |
| 180 |
do_action( 'give_tools_tab_export_content_bottom' ); |
| 181 |
?> |
| 182 |
|
| 183 |
</div> |
| 184 |
<!-- .post-body-content --> |
| 185 |
</div> |
| 186 |
<!-- .post-body --> |
| 187 |
</div><!-- #give-dashboard-widgets-wrap --> |
| 188 |
</div><!-- #poststuff --> |
| 189 |
|