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 / activity.php

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

270 lines 12.0 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_campaign_id = false;
23 $charitable_activity_type = false;
24
25 // first check and see if the database tables for activity exist.
26 $charitable_donation_activities_db = Charitable_Donation_Activities_DB::get_instance();
27 $charitable_campaign_activities_db = Charitable_Campaign_Activities_DB::get_instance();
28 $charitable_db_tables_installed = false;
29 $charitable_install_link = admin_url( 'index.php?page=charitable-upgrades&charitable-upgrade=create_activity_tables&nonce=' . wp_create_nonce( 'charitable-upgrade' ) );
30
31 // check to see if db tables exist.
32 if ( $charitable_donation_activities_db->table_exists() && $charitable_campaign_activities_db->table_exists() ) {
33
34 $charitable_db_tables_installed = true;
35
36 $charitable_reports = Charitable_Reports::get_instance();
37
38 // Check the transients via charitable_report_overview_args.
39 $charitable_report_data_args = false; // get_transient( 'charitable-report-activity-args' );
40
41 if ( false !== $charitable_report_data_args ) {
42
43 $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;
44 $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;
45 $charitable_campaign_id = ( false === $charitable_campaign_id && ! empty( $charitable_report_data_args['campaign_id'] ) ) ? intval( $charitable_report_data_args['campaign_id'] ) : false;
46 $charitable_activity_type = ( false === $charitable_activity_type && ! empty( $charitable_report_data_args['activity_type'] ) ) ? esc_attr( $charitable_report_data_args['activity_type'] ) : false;
47 }
48
49 if ( false === $charitable_start_date || false === $charitable_end_date || false === $charitable_campaign_id ) {
50 // so nothing from the transient, so check the $_GET.
51 $charitable_start_date = isset( $_GET['start_date'] ) ? $charitable_reports->get_valid_date_string( sanitize_text_field( $_GET['start_date'] ) ) : false; // phpcs:ignore
52 $charitable_end_date = isset( $_GET['end_date'] ) ? $charitable_reports->get_valid_date_string( sanitize_text_field( $_GET['end_date'] ) ) : false; // phpcs:ignore
53 $charitable_campaign_id = isset( $_GET['campaign_id'] ) ? intval( $_GET['campaign_id'] ) : false; // phpcs:ignore
54 $charitable_activity_type = isset( $_GET['activity_type'] ) ? esc_attr( $_GET['activity_type'] ) : false; // phpcs:ignore
55 }
56
57 if ( false === $charitable_start_date || false === $charitable_end_date || false === $charitable_campaign_id ) {
58 // If still nothing assign defaults.
59 /*
60 * Site-local, not UTC: this feeds Charitable_Reports::get_data(), which
61 * filters on p.post_date (site-local time), so a bound built from bare
62 * UTC excludes part of today's activity on any site whose timezone is
63 * ahead of UTC.
64 *
65 * @since 1.8.13
66 */
67 $charitable_report_overview_defaults = apply_filters(
68 'charitable_report_activity_defaults',
69 array(
70 'start_date' => gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) - ( 7 * DAY_IN_SECONDS ) ),
71 'end_date' => gmdate( 'Y/m/d', current_time( 'timestamp', 0 ) ),
72 'campaign_id' => -1,
73 'activity_type' => '',
74 'limit' => false,
75 )
76 );
77
78 $charitable_start_date = $charitable_report_overview_defaults['start_date'];
79 $charitable_end_date = $charitable_report_overview_defaults['end_date'];
80 $charitable_campaign_id = $charitable_report_overview_defaults['campaign_id'];
81 $charitable_activity_type = $charitable_report_overview_defaults['activity_type'];
82
83 }
84
85 $charitable_args = array(
86 'start_date' => $charitable_start_date,
87 'end_date' => $charitable_end_date,
88 'campaign_id' => $charitable_campaign_id,
89 );
90 $charitable_reports->init_with_array( 'activity', $charitable_args );
91
92 // activity (filter and action) types.
93
94 // Activity types is a filter from the dropdown on the activity page.
95 // Empty means no filter. Example: 'campaigns-created'.
96 // $activity_filter_types = array( 'campaigns-created' );.
97 $charitable_activity_filter_types = array();
98
99 // Activity action types are actions found in the database for filtering.
100 // For example this is filtering for donation and campaign activities...
101 // $activity_action_types = array(
102 // 'donation' => array( 'charitable-completed' ),
103 // 'campaign' => array( 'charitable-campaign-created', 'charitable-campaign-ended', 'charitable-campaign-goal-reached' ),
104 // );.
105 $charitable_activity_action_types = array();
106
107 // cammpaigns.
108 $charitable_campaign_args = false;
109 $charitable_available_campaigns = Charitable_Campaigns::get_campaign_title_id( $charitable_campaign_args );
110 $charitable_campaign_dropdown = array();
111 if ( ! empty( $charitable_available_campaigns ) ) :
112 $charitable_campaign_dropdown = wp_list_pluck( $charitable_available_campaigns, 'title', 'id' );
113 // sort by title (array value) alphabetically.
114 asort( $charitable_campaign_dropdown );
115 endif;
116
117 $charitable_activity_args = array(
118 'campaign_id' => $charitable_campaign_id,
119 'activity_filter_types' => $charitable_activity_filter_types,
120 'activity_action_types' => $charitable_activity_action_types,
121 );
122 $charitable_report_activity = $charitable_reports->get_activity( $charitable_activity_args );
123
124 }
125
126 if ( $charitable_db_tables_installed ) :
127
128 ?>
129
130 <?php if ( charitable_is_pro() ) : ?>
131 <div class="tablenav top with-margin">
132 <div class="alignleft actions">
133
134 <label for="report-campaign-filter" class="screen-reader-text"><?php echo esc_html__( 'Show Activity', 'charitable' ); ?></label>
135 <select name="category_id" id="report-campaign-filter">
136 <option value="-1"><?php echo esc_html__( 'Showing activity for', 'charitable' ); ?> <?php echo esc_html__( 'All Campaigns', 'charitable' ); ?></option>
137 <?php if ( is_array( $charitable_campaign_dropdown ) && ! empty( $charitable_campaign_dropdown ) ) : ?>
138 <?php foreach ( $charitable_campaign_dropdown as $charitable_campaign_dropdown_id => $charitable_campaign_title ) : ?>
139 <option value="<?php echo intval( $charitable_campaign_dropdown_id ); ?>"><?php echo esc_html( $charitable_campaign_title ); ?></option>
140 <?php endforeach; ?>
141 <?php endif; ?>
142 </select>
143
144 </div>
145 <div class="alignright">
146
147 <?php echo $charitable_reports->get_activity_report_filter_dropdown( $charitable_activity_filter_types ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
148
149 <input type="text" id="charitable-reports-topnav-datepicker" class="charitable-reports-datepicker charitable-datepicker-ranged" data-start-date="<?php echo esc_html( $charitable_start_date ); ?>" data-end-date="<?php echo esc_html( $charitable_end_date ); ?>" value="<?php echo esc_html( $charitable_start_date ); ?> - <?php echo esc_html( $charitable_end_date ); ?>" />
150
151 <div class="charitable-datepicker-container"><a href="#" class="button button-primary" id="charitable-reports-filter-button" data-filter-type="activity"><?php echo esc_html__( 'Filter', 'charitable' ); ?></a></div>
152
153 </div>
154 <br class="clear">
155 </div>
156 <?php endif; ?>
157 <?php endif; ?>
158
159 <div class="charitable-activity-report">
160
161 <div class="charitable-container charitable-title-card">
162
163 <div class="charitable-title-card-content">
164
165 <h1><?php echo esc_html__( 'Campaign Activity', 'charitable' ); ?></h1>
166
167 <p><?php echo esc_html__( 'This report shows what donations and events are happening on the various Charitable campaigns on your site.', 'charitable' ); ?></p>
168
169 <p><strong><?php echo esc_html__( 'Why This Is Important', 'charitable' ); ?>:</strong> <?php echo esc_html__( 'This gives you a "heads up" timeline in chronological order of what is happening on your site, allowing you to quickly see if a particular campaign is suddenly receiving donations or is getting popular - allowing you to act accordingly.', 'charitable' ); ?> </p>
170
171 <?php do_action( 'charitable_after_activity_report_description' ); ?>
172
173 </div>
174
175 </div>
176
177 <?php if ( ! $charitable_db_tables_installed ) : ?>
178
179 <div class="charitable-reports-notice">
180 <p><?php echo esc_html__( 'The database tables for the activity report have not been installed. Please click the button below to install them.', 'charitable' ); ?></p>
181 <p><a href="<?php echo esc_url( $charitable_install_link ); ?>" class="button button-primary"><?php echo esc_html__( 'Install Database Tables', 'charitable' ); ?></a></p>
182 </div>
183
184 <?php else : ?>
185
186 <div class="tablenav charitable-section charitable-tablenav-activity">
187
188 <div class="alignleft actions">
189 <h2><?php echo esc_html__( 'Activities', 'charitable' ); ?></h2>
190 </div>
191 <div class="alignright">
192
193 <?php if ( ! charitable_is_pro() ) : ?>
194
195 <button disabled="disabled" value="<?php echo esc_html__( 'Download CSV', 'charitable' ); ?>" class="button with-icon charitable-report-download-button" title="<?php echo esc_html__( 'Download CSV', 'charitable' ); ?>" data-nonce=""><label><?php echo esc_html__( 'Download CSV', 'charitable' ); ?></label><img src="<?php echo charitable()->get_path( 'assets', false ) . 'images/icons/download.svg'; // phpcs:ignore ?>" alt=""></button>
196
197 <?php else : ?>
198
199 <form action="" method="post" class="charitable-report-download-form" id="charitable-activity-download-form">
200 <input name="charitable_report_action" type="hidden" value="charitable_report_download_activity">
201 <input name="start_date" type="hidden" value="<?php echo esc_html( $charitable_start_date ); ?>" />
202 <input name="end_date" type="hidden" value="<?php echo esc_html( $charitable_end_date ); ?>" />
203 <input name="campaign_id" type="hidden" value="<?php echo intval( $charitable_campaign_id ); ?>" />
204 <input name="activity_type" type="hidden" value="<?php echo esc_attr( $charitable_activity_type ); ?>">
205 <?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?>
206 <button
207 <?php
208 if ( empty( $charitable_report_activity ) ) :
209 ?>
210 disabled="true"<?php endif; ?> value="<?php echo esc_html__( 'Download CSV', 'charitable' ); ?>" type="submit" class="button with-icon charitable-report-download-button" title="<?php echo esc_html__( 'Download CSV', 'charitable' ); ?>" data-nonce=""><label><?php echo esc_html__( 'Download CSV', 'charitable' ); ?></label><img src="<?php echo charitable()->get_path( 'assets', false ) . 'images/icons/download.svg'; // phpcs:ignore ?>" alt=""></button>
211 </form>
212
213 <?php endif; ?>
214
215 </div>
216
217 <br class="clear">
218
219 <div class="charitable-activity-list-container">
220
221 <div class="charitable-report-table-container">
222
223 <?php do_action( 'charitable_report_before_activity_table' ); ?>
224
225 <?php
226 if ( ! charitable_is_pro() ) :
227 ?>
228 <div class="charitable-restricted"><div class="restricted-access-overlay"></div><?php endif; ?>
229
230 <?php
231
232 if ( ! empty( $charitable_report_activity ) ) :
233
234 ?>
235
236 <div class="the-list charitable-the-list-container charitable-no-scroll">
237 <?php
238
239 echo $charitable_reports->generate_activity_list( $charitable_report_activity ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
240
241 ?>
242 </div>
243
244 <?php else : ?>
245
246 <div class="charitable-no-results">
247 <p><?php echo esc_html__( 'No activity found.', 'charitable' ); ?></p>
248 </div>
249
250 <?php endif; ?>
251
252 <?php
253 if ( ! charitable_is_pro() ) :
254 ?>
255 </div><?php endif; ?>
256
257 <?php do_action( 'charitable_report_after_activity_table' ); ?>
258
259 </div>
260
261 </div>
262
263 </div> <!-- .charitable-section -->
264
265 <?php endif; ?>
266
267 </div> <!-- .charitable-activity-report -->
268
269 <?php
270