PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11
1.8.13.1 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 All 212 releases
charitable / includes / admin / views / reports / overview.php

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

322 lines 17.2 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 $charitable_start_date = gmdate( 'Y/m/d', strtotime( '-7 days' ) );
54 $charitable_end_date = gmdate( 'Y/m/d' );
55 $charitable_filter = 7;
56 $charitable_campaign_id = -1; // cannot be zero because that would be false.
57 $charitable_category_id = 0;
58 }
59
60 $charitable_report_overview_args = apply_filters(
61 'charitable_report_overview_args',
62 array(
63 'start_date' => $charitable_start_date,
64 'end_date' => $charitable_end_date,
65 'filter' => $charitable_filter,
66 'campaign_id' => $charitable_campaign_id,
67 'category_id' => $charitable_category_id,
68 )
69 );
70
71 $charitable_reports->init_with_array( 'overview', $charitable_report_overview_args );
72
73 // main activity.
74 $charitable_report_activity = $charitable_reports->get_activity();
75
76 // donations.
77 $charitable_donations = $charitable_reports->get_donations();
78 $charitable_total_count_donations = count( $charitable_donations );
79 $charitable_total_amount_donations = $charitable_reports->get_donations_total();
80 $charitable_donation_breakdown = $charitable_reports->get_donations_by_day();
81 $charitable_payment_breakdown = $charitable_reports->get_donations_by_payment();
82 $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 );
83 $charitable_donation_total = charitable_format_money( $charitable_total_amount_donations );
84
85 // donors.
86 $charitable_top_donors = $charitable_reports->get_top_donors_overview();
87 $charitable_total_count_donors = $charitable_reports->get_donors_count();
88 $charitable_total_donors_label = ( 1 === $charitable_total_count_donors ) ? esc_html__( 'Donor', 'charitable' ) : esc_html__( 'Donors', 'charitable' );
89
90 // refunds.
91 $charitable_refunds_data = $charitable_reports->get_refunds();
92 $charitable_total_amount_refunds = $charitable_refunds_data['total_amount'];
93 $charitable_total_count_refunds = $charitable_refunds_data['total_count'];
94
95 // campaigns.
96 $charitable_args = array( 'posts_per_page' => apply_filters( 'charitable_overview_top_campaigns_amount', 20 ) );
97 $charitable_top_campaigns = Charitable_Campaigns::ordered_by_amount( $charitable_args );
98 $charitable_campaign_dropdown = array();
99 if ( ! empty( $charitable_top_campaigns->posts ) ) :
100 $charitable_campaign_dropdown = wp_list_pluck( $charitable_top_campaigns->posts, 'post_title', 'ID' );
101 $charitable_campaign_dropdown = array_map( 'esc_html', $charitable_campaign_dropdown );
102 // sort by title.
103 asort( $charitable_campaign_dropdown );
104 endif;
105
106 $charitable_campaign_categories = $charitable_reports->get_campaign_categories();
107 $charitable_campaign_category_id = 0;
108
109 ?>
110
111 <div class="tablenav top">
112 <div class="alignleft actions">
113 <label for="report-campaign-filter" class="screen-reader-text"><?php echo esc_html__( 'Select Campaign', 'charitable' ); ?></label>
114 <select name="action" id="report-campaign-filter">
115 <option value="-1"><?php echo esc_html__( 'Showing Results for', 'charitable' ); ?> <strong><?php echo esc_html__( 'All Campaigns', 'charitable' ); ?></strong></option>
116 <?php if ( ! empty( $charitable_campaign_dropdown ) ) : ?>
117 <?php foreach ( $charitable_campaign_dropdown as $charitable_campaign_dropdown_id => $charitable_campaign_title ) : ?>
118 <option value="<?php echo intval( $charitable_campaign_dropdown_id ); ?>"><?php echo esc_html( $charitable_campaign_title ); ?></option>
119 <?php endforeach; ?>
120 <?php endif; ?>
121 </select>
122 <?php if ( ! empty( $charitable_campaign_categories ) ) : ?>
123 <label for="report-category-filter" class="screen-reader-text"><?php echo esc_html__( 'Select Category', 'charitable' ); ?></label>
124 <?php
125
126 // create a dropdown of WordPress csategories hierarchically.
127 wp_dropdown_categories(
128 array(
129 'show_option_all' => esc_html__( 'All Categories', 'charitable' ),
130 'show_option_none' => '',
131 'option_none_value' => '-1',
132 'orderby' => 'name',
133 'order' => 'ASC',
134 'show_count' => 1,
135 'hide_empty' => 0,
136 'child_of' => 0,
137 'exclude' => '',
138 'echo' => 1,
139 'selected' => $charitable_campaign_category_id,
140 'hierarchical' => 1,
141 'name' => 'action',
142 'id' => 'report-category-filter',
143 'class' => '',
144 'depth' => 0,
145 'tab_index' => 0,
146 'taxonomy' => 'campaign_category',
147 )
148 );
149
150 ?>
151 <?php endif; ?>
152 </div>
153 <div class="alignright">
154
155 <form action="" method="post" target="_blank" class="charitable-report-print" id="charitable-overview-print">
156 <input name="charitable_report_action" type="hidden" value="charitable_report_print_overview" />
157 <input name="start_date" type="hidden" value="<?php echo esc_attr( $charitable_start_date ); ?>" />
158 <input name="end_date" type="hidden" value="<?php echo esc_attr( $charitable_end_date ); ?>" />
159 <input name="campaign_id" type="hidden" value="<?php echo intval( $charitable_campaign_id ); ?>" />
160 <input name="category_id" type="hidden" value="<?php echo intval( $charitable_category_id ); ?>" />
161 <?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?>
162 <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>
163 </form>
164
165 <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 ); ?>" />
166
167 <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>
168
169 </div>
170 <br class="clear">
171 </div>
172
173 <div class="charitable-overview-report">
174
175 <div class="charitable-headline-reports">
176
177 <div class="charitable-cards">
178 <div class="charitable-container charitable-report-ui charitable-card">
179 <strong><span id="charitable-top-donation-total-amount"><?php echo esc_html( $charitable_donation_total ); ?></span></strong>
180 <p><span id="charitable-top-donation-total-count"><?php echo count( $charitable_donations ); ?></span> <?php echo esc_html__( 'Total Donations (Net)', 'charitable' ); ?></p>
181 </div>
182 <div class="charitable-container charitable-report-ui charitable-card">
183 <strong><span id="charitable-top-donation-average"><?php echo esc_html( $charitable_donation_average ); ?></span></strong>
184 <p><?php echo esc_html__( 'Average Donation', 'charitable' ); ?></p>
185 </div>
186 <div class="charitable-container charitable-report-ui charitable-card">
187 <strong><span id="charitable-top-donor-count"><?php echo intval( $charitable_total_count_donors ); ?></span></strong>
188 <p><?php echo esc_html( $charitable_total_donors_label ); ?></p>
189 </div>
190 <div class="charitable-container charitable-report-ui charitable-card">
191 <strong><span id="charitable-top-refund-total-amount"><?php echo charitable_format_money( $charitable_total_amount_refunds ); // phpcs:ignore ?></span></strong>
192 <p><span id="charitable-top-refund-count"><?php echo intval( $charitable_total_count_refunds ); ?></span> <?php echo esc_html__( 'Refunds', 'charitable' ); ?></p>
193 </div>
194 </div>
195
196 <div class="charitable-container charitable-report-ui charitable-headline-graph-container">
197 <div id="charitable-headline-graph" class="charitable-headline-graph">
198 </div>
199 </div>
200
201 </div>
202
203 <div class="tablenav charitable-section">
204
205 <div class="alignleft actions">
206 <h2><?php echo esc_html__( 'Donations Breakdown', 'charitable' ); ?></h2>
207 </div>
208 <div class="alignright">
209
210 <form target="_blank" action="" method="post" class="charitable-report-download-form" id="charitable-donations-breakdown-download-form">
211 <input name="charitable_report_action" type="hidden" value="charitable_report_download_donation_breakdown" />
212 <input name="start_date" type="hidden" value="<?php echo esc_attr( $charitable_start_date ); ?>" />
213 <input name="end_date" type="hidden" value="<?php echo esc_attr( $charitable_end_date ); ?>" />
214 <input name="campaign_id" type="hidden" value="<?php echo intval( $charitable_campaign_id ); ?>" />
215 <input name="category_id" type="hidden" value="<?php echo intval( $charitable_category_id ); ?>" />
216 <?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?>
217 <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>
218 </form>
219
220 </div>
221 <br class="clear">
222
223 <table class="wp-list-table widefat fixed striped table-view-list donations-breakdown charitable-report-ui">
224 <thead>
225 <tr>
226 <th scope="col" id="date" class="manage-column column-date"><span><?php echo esc_html__( 'Date', 'charitable' ); ?></span></a></th>
227 <th scope="col" id="donations" class="manage-column column-donations"><?php echo esc_html__( 'Donations', 'charitable' ); ?></th>
228 <th scope="col" id="no-of-donors" class="manage-column column-donors"><?php echo esc_html__( 'No. of Donors', 'charitable' ); ?></th>
229 <th scope="col" id="refunds" class="manage-column column-refunds"><?php echo esc_html__( 'Refunds', 'charitable' ); ?></th>
230 <th scope="col" id="net" class="manage-column column-net"><?php echo esc_html__( 'Net', 'charitable' ); ?></th>
231 </tr>
232 </thead>
233 <tbody id="donations-breakdown-list">
234 <?php echo $charitable_reports->generate_donations_breakdown_rows( $charitable_donation_breakdown, $charitable_refunds_data ); // phpcs:ignore ?>
235 </tbody>
236 <tfoot>
237 <tr>
238 <th scope="col" id="title" class="manage-column column-titl"><span><?php echo esc_html__( 'Date', 'charitable' ); ?></span></a></th>
239 <th scope="col" id="creator" class="manage-column column-creator"><?php echo esc_html__( 'Donations', 'charitable' ); ?></th>
240 <th scope="col" id="donated" class="manage-column column-donated"><?php echo esc_html__( 'No. of Donors', 'charitable' ); ?></th>
241 <th scope="col" id="status" class="manage-column column-status"><?php echo esc_html__( 'Refunds', 'charitable' ); ?></th>
242 <th scope="col" id="end_date" class="manage-column column-end_date"><?php echo esc_html__( 'Net', 'charitable' ); ?></th>
243 </tr>
244 </tfoot>
245 </table>
246
247 <br class="clear">
248
249 </div>
250
251 <div class="charitable-section-grid charitable-section-grid-column-flexible">
252
253 <div class="charitable-container charitable-report-card charitable-activity-report" data-section-name="activity">
254 <div class="header">
255 <h4><?php echo esc_html__( 'Activity', 'charitable' ); ?></h4>
256 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
257 </div>
258 <div class="charitable-toggle-container charitable-report-ui">
259 <div class="the-list">
260 <?php echo $charitable_reports->generate_activity_list( $charitable_report_activity ); // phpcs:ignore ?>
261 </div>
262 </div>
263 </div>
264
265 <div class="charitable-container charitable-report-card charitable-top-donors-report">
266 <div class="header">
267 <h4><?php echo esc_html__( 'Top Donors', 'charitable' ); ?></h4>
268 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
269 </div>
270 <div class="charitable-toggle-container charitable-report-ui">
271 <?php echo $charitable_reports->generate_top_donors( $charitable_top_donors ); // phpcs:ignore ?>
272 </div>
273 </div>
274
275 </div>
276
277 <div class="charitable-section-grid one-third charitable-section-grid-column-flexible">
278
279 <div class="charitable-container charitable-report-card charitable-top-campaigns-report">
280 <div class="header">
281 <h4><?php echo esc_html__( 'Top Campaigns', 'charitable' ); ?></h4>
282 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
283 </div>
284 <div class="charitable-toggle-container charitable-report-ui">
285 <?php if ( ! empty( $charitable_top_campaigns->posts ) ) : ?>
286 <div class="the-list">
287 <ul id="charitable-top-campaigns-list">
288 <?php echo $charitable_reports->generate_top_campaigns( $charitable_top_campaigns ); // phpcs:ignore ?>
289 </ul>
290 </div>
291 <?php else : ?>
292 <div class="no-items">
293 <div class="the-list">
294 <p><strong><?php echo esc_html__( 'There are no campaigns at the moment.', 'charitable' ); ?></strong></p>
295 <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>
296 </div>
297 </div>
298 <?php endif; ?>
299 </div>
300 </div>
301
302 <div class="charitable-container charitable-report-card charitable-payment-methods-report">
303 <div class="header">
304 <h4><?php echo esc_html__( 'Payment Methods', 'charitable' ); ?></h4>
305 <a href="#" class="charitable-toggle"><i class="fa fa-angle-down charitable-angle-down"></i></a>
306 </div>
307 <div class="charitable-toggle-container charitable-report-ui">
308 <div class="the-graph">
309 <div id="charitable-payment-methods-graph" class="charitable-payment-methods-graph">
310 </div>
311 <div class="the-legend">
312 <ul id="charitable-payment-methods-list">
313 <?php echo $charitable_reports->generate_payment_methods_list( $charitable_payment_breakdown ); // phpcs:ignore ?>
314 </ul>
315 </div> <!-- the legend -->
316 </div>
317 </div>
318 </div>
319
320 </div>
321
322 </div>