PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
charitable / includes / admin / views / reports / overview.php

overview.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/admin/views/reports/overview.php

329 lines 17.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Display the main reports "overview" page.
10 *
11 * @author David Bisset
12 * @package Charitable/Admin View/Settings
13 * @copyright Copyright (c) 2023, WP Charitable LLC
14 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
15 * @since 1.8,1
16 * @version 1.8.1
17 * @version 1.8.8.6
18 */
19
20 $charitable_start_date = false;
21 $charitable_end_date = false;
22 $charitable_filter = false;
23 $charitable_campaign_id = false;
24 $charitable_category_id = false;
25 $status = false; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
26
27 $charitable_reports = Charitable_Reports::get_instance();
28
29 // Check the transients via charitable_report_overview_args.
30 $charitable_report_data_args = false; // get_transient( 'charitable-report-overview-args' );
31
32 if ( false !== $charitable_report_data_args ) {
33
34 $charitable_start_date = ( false === $charitable_start_date && ! empty( $charitable_report_data_args['start_date'] ) ) ? $charitable_reports->get_valid_date_string( $charitable_report_data_args['start_date'] ) : false;
35 $charitable_end_date = ( false === $charitable_end_date && ! empty( $charitable_report_data_args['end_date'] ) ) ? $charitable_reports->get_valid_date_string( $charitable_report_data_args['end_date'] ) : false;
36 $charitable_filter = ( false === $charitable_filter && ! empty( $charitable_report_data_args['filter'] ) ) ? intval( $charitable_report_data_args['filter'] ) : 'test';
37 $charitable_campaign_id = ( false === $charitable_campaign_id && ! empty( $charitable_report_data_args['campaign_id'] ) ) ? intval( $charitable_report_data_args['campaign_id'] ) : false;
38 $charitable_category_id = ( false === $charitable_category_id && ! empty( $charitable_report_data_args['category_id'] ) ) ? intval( $charitable_report_data_args['category_id'] ) : false;
39
40 }
41
42 if ( false === $charitable_start_date || false === $charitable_end_date || false === $charitable_filter ) {
43 // so nothing from the transient, so check the $_GET.
44 $charitable_start_date = isset( $_GET['start_date'] ) ? $charitable_reports->get_valid_date_string( sanitize_text_field( $_GET['start_date'] ) ) : false; // phpcs:ignore
45 $charitable_end_date = isset( $_GET['end_date'] ) ? $charitable_reports->get_valid_date_string( sanitize_text_field( $_GET['end_date'] ) ) : false; // phpcs:ignore
46 $charitable_filter = isset( $_GET['filter'] ) ? intval( $_GET['filter'] ) : false; // phpcs:ignore
47 $charitable_campaign_id = isset( $_GET['campaign_id'] ) ? intval( $_GET['campaign_id'] ) : false; // phpcs:ignore
48 $charitable_category_id = isset( $_GET['category_id'] ) ? intval( $_GET['category_id'] ) : false; // phpcs:ignore
49 }
50
51 if ( false === $charitable_start_date || false === $charitable_end_date || false === $charitable_filter ) {
52 // If still nothing assign defaults.
53 /*
54 * Site-local, not UTC: post_date is stored in site-local time, so a bound
55 * built from bare UTC excludes part of today's donations on any site whose
56 * timezone is ahead of UTC.
57 *
58 * @since 1.8.13
59 */
60 $charitable_start_date = gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) - ( 7 * DAY_IN_SECONDS ) );
61 $charitable_end_date = gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) );
62 $charitable_filter = 7;
63 $charitable_campaign_id = -1; // cannot be zero because that would be false.
64 $charitable_category_id = 0;
65 }
66
67 $charitable_report_overview_args = apply_filters(
68 'charitable_report_overview_args',
69 array(
70 'start_date' => $charitable_start_date,
71 'end_date' => $charitable_end_date,
72 'filter' => $charitable_filter,
73 'campaign_id' => $charitable_campaign_id,
74 'category_id' => $charitable_category_id,
75 )
76 );
77
78 $charitable_reports->init_with_array( 'overview', $charitable_report_overview_args );
79
80 // main activity.
81 $charitable_report_activity = $charitable_reports->get_activity();
82
83 // donations.
84 $charitable_donations = $charitable_reports->get_donations();
85 $charitable_total_count_donations = count( $charitable_donations );
86 $charitable_total_amount_donations = $charitable_reports->get_donations_total();
87 $charitable_donation_breakdown = $charitable_reports->get_donations_by_day();
88 $charitable_payment_breakdown = $charitable_reports->get_donations_by_payment();
89 $charitable_donation_average = ( $charitable_total_amount_donations > 0 && $charitable_total_amount_donations > 0 ) ? ( charitable_format_money( $charitable_total_amount_donations / $charitable_total_count_donations, 2, true ) ) : charitable_format_money( 0 );
90 $charitable_donation_total = charitable_format_money( $charitable_total_amount_donations );
91
92 // donors.
93 $charitable_top_donors = $charitable_reports->get_top_donors_overview();
94 $charitable_total_count_donors = $charitable_reports->get_donors_count();
95 $charitable_total_donors_label = ( 1 === $charitable_total_count_donors ) ? esc_html__( 'Donor', 'charitable' ) : esc_html__( 'Donors', 'charitable' );
96
97 // refunds.
98 $charitable_refunds_data = $charitable_reports->get_refunds();
99 $charitable_total_amount_refunds = $charitable_refunds_data['total_amount'];
100 $charitable_total_count_refunds = $charitable_refunds_data['total_count'];
101
102 // campaigns.
103 $charitable_args = array( 'posts_per_page' => apply_filters( 'charitable_overview_top_campaigns_amount', 20 ) );
104 $charitable_top_campaigns = Charitable_Campaigns::ordered_by_amount( $charitable_args );
105 $charitable_campaign_dropdown = array();
106 if ( ! empty( $charitable_top_campaigns->posts ) ) :
107 $charitable_campaign_dropdown = wp_list_pluck( $charitable_top_campaigns->posts, 'post_title', 'ID' );
108 $charitable_campaign_dropdown = array_map( 'esc_html', $charitable_campaign_dropdown );
109 // sort by title.
110 asort( $charitable_campaign_dropdown );
111 endif;
112
113 $charitable_campaign_categories = $charitable_reports->get_campaign_categories();
114 $charitable_campaign_category_id = 0;
115
116 ?>
117
118 <div class="tablenav top">
119 <div class="alignleft actions">
120 <label for="report-campaign-filter" class="screen-reader-text"><?php echo esc_html__( 'Select Campaign', 'charitable' ); ?></label>
121 <select name="action" id="report-campaign-filter">
122 <option value="-1"><?php echo esc_html__( 'Showing Results for', 'charitable' ); ?> <strong><?php echo esc_html__( 'All Campaigns', 'charitable' ); ?></strong></option>
123 <?php if ( ! empty( $charitable_campaign_dropdown ) ) : ?>
124 <?php foreach ( $charitable_campaign_dropdown as $charitable_campaign_dropdown_id => $charitable_campaign_title ) : ?>
125 <option value="<?php echo intval( $charitable_campaign_dropdown_id ); ?>"><?php echo esc_html( $charitable_campaign_title ); ?></option>
126 <?php endforeach; ?>
127 <?php endif; ?>
128 </select>
129 <?php if ( ! empty( $charitable_campaign_categories ) ) : ?>
130 <label for="report-category-filter" class="screen-reader-text"><?php echo esc_html__( 'Select Category', 'charitable' ); ?></label>
131 <?php
132
133 // create a dropdown of WordPress csategories hierarchically.
134 wp_dropdown_categories(
135 array(
136 'show_option_all' => esc_html__( 'All Categories', 'charitable' ),
137 'show_option_none' => '',
138 'option_none_value' => '-1',
139 'orderby' => 'name',
140 'order' => 'ASC',
141 'show_count' => 1,
142 'hide_empty' => 0,
143 'child_of' => 0,
144 'exclude' => '',
145 'echo' => 1,
146 'selected' => $charitable_campaign_category_id,
147 'hierarchical' => 1,
148 'name' => 'action',
149 'id' => 'report-category-filter',
150 'class' => '',
151 'depth' => 0,
152 'tab_index' => 0,
153 'taxonomy' => 'campaign_category',
154 )
155 );
156
157 ?>
158 <?php endif; ?>
159 </div>
160 <div class="alignright">
161
162 <form action="" method="post" target="_blank" class="charitable-report-print" id="charitable-overview-print">
163 <input name="charitable_report_action" type="hidden" value="charitable_report_print_overview" />
164 <input name="start_date" type="hidden" value="<?php echo esc_attr( $charitable_start_date ); ?>" />
165 <input name="end_date" type="hidden" value="<?php echo esc_attr( $charitable_end_date ); ?>" />
166 <input name="campaign_id" type="hidden" value="<?php echo intval( $charitable_campaign_id ); ?>" />
167 <input name="category_id" type="hidden" value="<?php echo intval( $charitable_category_id ); ?>" />
168 <?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?>
169 <button value="Download CSV" type="submit" class="button with-icon charitable-report-print-button" title="<?php echo esc_html__( 'Print Summary', 'charitable' ); ?>" class="button with-icon charitable-report-ui" data-nonce="<?php echo wp_create_nonce( 'charitable_export_report' ); // phpcs:ignore ?>"><label><?php echo esc_html__( 'Print', 'charitable' ); ?></label><img width="15" height="15" src="<?php echo esc_url( charitable()->get_path( 'assets', false ) . 'images/icons/print.svg' ); ?>" alt=""></button>
170 </form>
171
172 <input type="text" id="charitable-reports-topnav-datepicker" class="charitable-reports-datepicker charitable-datepicker-ranged" data-start-date="<?php echo esc_attr( $charitable_start_date ); ?>" data-end-date="<?php echo esc_attr( $charitable_end_date ); ?>" value="<?php echo esc_attr( $charitable_start_date ); ?> - <?php echo esc_attr( $charitable_end_date ); ?>" />
173
174 <div class="charitable-datepicker-container"><a href="#" class="button button-primary" id="charitable-reports-filter-button" data-filter-type="overview"><?php echo esc_html__( 'Filter', 'charitable' ); ?></a></div>
175
176 </div>
177 <br class="clear">
178 </div>
179
180 <div class="charitable-overview-report">
181
182 <div class="charitable-headline-reports">
183
184 <div class="charitable-cards">
185 <div class="charitable-container charitable-report-ui charitable-card">
186 <strong><span id="charitable-top-donation-total-amount"><?php echo esc_html( $charitable_donation_total ); ?></span></strong>
187 <p><span id="charitable-top-donation-total-count"><?php echo count( $charitable_donations ); ?></span> <?php echo esc_html__( 'Total Donations (Net)', 'charitable' ); ?></p>
188 </div>
189 <div class="charitable-container charitable-report-ui charitable-card">
190 <strong><span id="charitable-top-donation-average"><?php echo esc_html( $charitable_donation_average ); ?></span></strong>
191 <p><?php echo esc_html__( 'Average Donation', 'charitable' ); ?></p>
192 </div>
193 <div class="charitable-container charitable-report-ui charitable-card">
194 <strong><span id="charitable-top-donor-count"><?php echo intval( $charitable_total_count_donors ); ?></span></strong>
195 <p><?php echo esc_html( $charitable_total_donors_label ); ?></p>
196 </div>
197 <div class="charitable-container charitable-report-ui charitable-card">
198 <strong><span id="charitable-top-refund-total-amount"><?php echo charitable_format_money( $charitable_total_amount_refunds ); // phpcs:ignore ?></span></strong>
199 <p><span id="charitable-top-refund-count"><?php echo intval( $charitable_total_count_refunds ); ?></span> <?php echo esc_html__( 'Refunds', 'charitable' ); ?></p>
200 </div>
201 </div>
202
203 <div class="charitable-container charitable-report-ui charitable-headline-graph-container">
204 <div id="charitable-headline-graph" class="charitable-headline-graph">
205 </div>
206 </div>
207
208 </div>
209
210 <div class="tablenav charitable-section">
211
212 <div class="alignleft actions">
213 <h2><?php echo esc_html__( 'Donations Breakdown', 'charitable' ); ?></h2>
214 </div>
215 <div class="alignright">
216
217 <form target="_blank" action="" method="post" class="charitable-report-download-form" id="charitable-donations-breakdown-download-form">
218 <input name="charitable_report_action" type="hidden" value="charitable_report_download_donation_breakdown" />
219 <input name="start_date" type="hidden" value="<?php echo esc_attr( $charitable_start_date ); ?>" />
220 <input name="end_date" type="hidden" value="<?php echo esc_attr( $charitable_end_date ); ?>" />
221 <input name="campaign_id" type="hidden" value="<?php echo intval( $charitable_campaign_id ); ?>" />
222 <input name="category_id" type="hidden" value="<?php echo intval( $charitable_category_id ); ?>" />
223 <?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?>
224 <button value="Download CSV" type="submit" class="button with-icon charitable-report-download-button" title="<?php echo esc_html__( 'Download CSV', 'charitable' ); ?>" class="button with-icon charitable-report-ui" data-nonce="<?php echo wp_create_nonce( 'charitable_export_report' ); // phpcs:ignore ?>"><label><?php echo esc_html__( 'Download CSV', 'charitable' ); ?></label><img src="<?php echo esc_url( charitable()->get_path( 'assets', false ) . 'images/icons/download.svg' ); ?>" alt=""></button>
225 </form>
226
227 </div>
228 <br class="clear">
229
230 <table class="wp-list-table widefat fixed striped table-view-list donations-breakdown charitable-report-ui">
231 <thead>
232 <tr>
233 <th scope="col" id="date" class="manage-column column-date"><span><?php echo esc_html__( 'Date', 'charitable' ); ?></span></a></th>
234 <th scope="col" id="donations" class="manage-column column-donations"><?php echo esc_html__( 'Donations', 'charitable' ); ?></th>
235 <th scope="col" id="no-of-donors" class="manage-column column-donors"><?php echo esc_html__( 'No. of Donors', 'charitable' ); ?></th>
236 <th scope="col" id="refunds" class="manage-column column-refunds"><?php echo esc_html__( 'Refunds', 'charitable' ); ?></th>
237 <th scope="col" id="net" class="manage-column column-net"><?php echo esc_html__( 'Net', 'charitable' ); ?></th>
238 </tr>
239 </thead>
240 <tbody id="donations-breakdown-list">
241 <?php echo $charitable_reports->generate_donations_breakdown_rows( $charitable_donation_breakdown, $charitable_refunds_data ); // phpcs:ignore ?>
242 </tbody>
243 <tfoot>
244 <tr>
245 <th scope="col" id="title" class="manage-column column-titl"><span><?php echo esc_html__( 'Date', 'charitable' ); ?></span></a></th>
246 <th scope="col" id="creator" class="manage-column column-creator"><?php echo esc_html__( 'Donations', 'charitable' ); ?></th>
247 <th scope="col" id="donated" class="manage-column column-donated"><?php echo esc_html__( 'No. of Donors', 'charitable' ); ?></th>
248 <th scope="col" id="status" class="manage-column column-status"><?php echo esc_html__( 'Refunds', 'charitable' ); ?></th>
249 <th scope="col" id="end_date" class="manage-column column-end_date"><?php echo esc_html__( 'Net', 'charitable' ); ?></th>
250 </tr>
251 </tfoot>
252 </table>
253
254 <br class="clear">
255
256 </div>
257
258 <div class="charitable-section-grid charitable-section-grid-column-flexible">
259
260 <div class="charitable-container charitable-report-card charitable-activity-report" data-section-name="activity">
261 <div class="header">
262 <h4><?php echo esc_html__( 'Activity', 'charitable' ); ?></h4>
263 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
264 </div>
265 <div class="charitable-toggle-container charitable-report-ui">
266 <div class="the-list">
267 <?php echo $charitable_reports->generate_activity_list( $charitable_report_activity ); // phpcs:ignore ?>
268 </div>
269 </div>
270 </div>
271
272 <div class="charitable-container charitable-report-card charitable-top-donors-report">
273 <div class="header">
274 <h4><?php echo esc_html__( 'Top Donors', 'charitable' ); ?></h4>
275 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
276 </div>
277 <div class="charitable-toggle-container charitable-report-ui">
278 <?php echo $charitable_reports->generate_top_donors( $charitable_top_donors ); // phpcs:ignore ?>
279 </div>
280 </div>
281
282 </div>
283
284 <div class="charitable-section-grid one-third charitable-section-grid-column-flexible">
285
286 <div class="charitable-container charitable-report-card charitable-top-campaigns-report">
287 <div class="header">
288 <h4><?php echo esc_html__( 'Top Campaigns', 'charitable' ); ?></h4>
289 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
290 </div>
291 <div class="charitable-toggle-container charitable-report-ui">
292 <?php if ( ! empty( $charitable_top_campaigns->posts ) ) : ?>
293 <div class="the-list">
294 <ul id="charitable-top-campaigns-list">
295 <?php echo $charitable_reports->generate_top_campaigns( $charitable_top_campaigns ); // phpcs:ignore ?>
296 </ul>
297 </div>
298 <?php else : ?>
299 <div class="no-items">
300 <div class="the-list">
301 <p><strong><?php echo esc_html__( 'There are no campaigns at the moment.', 'charitable' ); ?></strong></p>
302 <p class="link"><a href="<?php echo admin_url( 'edit.php?post_type=campaign&create=campaign' ); ?>"><?php echo esc_html__( 'Add New Campaign', 'charitable' ); ?><img src="<?php echo charitable()->get_path( 'assets', false ) . 'images/icons/east.svg'; // phpcs:ignore ?>" /></a></p>
303 </div>
304 </div>
305 <?php endif; ?>
306 </div>
307 </div>
308
309 <div class="charitable-container charitable-report-card charitable-payment-methods-report">
310 <div class="header">
311 <h4><?php echo esc_html__( 'Payment Methods', 'charitable' ); ?></h4>
312 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
313 </div>
314 <div class="charitable-toggle-container charitable-report-ui">
315 <div class="the-graph">
316 <div id="charitable-payment-methods-graph" class="charitable-payment-methods-graph">
317 </div>
318 <div class="the-legend">
319 <ul id="charitable-payment-methods-list">
320 <?php echo $charitable_reports->generate_payment_methods_list( $charitable_payment_breakdown ); // phpcs:ignore ?>
321 </ul>
322 </div> <!-- the legend -->
323 </div>
324 </div>
325 </div>
326
327 </div>
328
329 </div>