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

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

262 lines 11.7 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 $charitable_report_overview_defaults = apply_filters(
60 'charitable_report_activity_defaults',
61 array(
62 'start_date' => gmdate( 'Y/m/d', strtotime( '-7 days' ) ),
63 'end_date' => gmdate( 'Y/m/d' ),
64 'campaign_id' => -1,
65 'activity_type' => '',
66 'limit' => false,
67 )
68 );
69
70 $charitable_start_date = $charitable_report_overview_defaults['start_date'];
71 $charitable_end_date = $charitable_report_overview_defaults['end_date'];
72 $charitable_campaign_id = $charitable_report_overview_defaults['campaign_id'];
73 $charitable_activity_type = $charitable_report_overview_defaults['activity_type'];
74
75 }
76
77 $charitable_args = array(
78 'start_date' => $charitable_start_date,
79 'end_date' => $charitable_end_date,
80 'campaign_id' => $charitable_campaign_id,
81 );
82 $charitable_reports->init_with_array( 'activity', $charitable_args );
83
84 // activity (filter and action) types.
85
86 // Activity types is a filter from the dropdown on the activity page.
87 // Empty means no filter. Example: 'campaigns-created'.
88 // $activity_filter_types = array( 'campaigns-created' );.
89 $charitable_activity_filter_types = array();
90
91 // Activity action types are actions found in the database for filtering.
92 // For example this is filtering for donation and campaign activities...
93 // $activity_action_types = array(
94 // 'donation' => array( 'charitable-completed' ),
95 // 'campaign' => array( 'charitable-campaign-created', 'charitable-campaign-ended', 'charitable-campaign-goal-reached' ),
96 // );.
97 $charitable_activity_action_types = array();
98
99 // cammpaigns.
100 $charitable_campaign_args = false;
101 $charitable_available_campaigns = Charitable_Campaigns::get_campaign_title_id( $charitable_campaign_args );
102 $charitable_campaign_dropdown = array();
103 if ( ! empty( $charitable_available_campaigns ) ) :
104 $charitable_campaign_dropdown = wp_list_pluck( $charitable_available_campaigns, 'title', 'id' );
105 // sort by title (array value) alphabetically.
106 asort( $charitable_campaign_dropdown );
107 endif;
108
109 $charitable_activity_args = array(
110 'campaign_id' => $charitable_campaign_id,
111 'activity_filter_types' => $charitable_activity_filter_types,
112 'activity_action_types' => $charitable_activity_action_types,
113 );
114 $charitable_report_activity = $charitable_reports->get_activity( $charitable_activity_args );
115
116 }
117
118 if ( $charitable_db_tables_installed ) :
119
120 ?>
121
122 <?php if ( charitable_is_pro() ) : ?>
123 <div class="tablenav top with-margin">
124 <div class="alignleft actions">
125
126 <label for="report-campaign-filter" class="screen-reader-text"><?php echo esc_html__( 'Show Activity', 'charitable' ); ?></label>
127 <select name="category_id" id="report-campaign-filter">
128 <option value="-1"><?php echo esc_html__( 'Showing activity for', 'charitable' ); ?> <?php echo esc_html__( 'All Campaigns', 'charitable' ); ?></option>
129 <?php if ( is_array( $charitable_campaign_dropdown ) && ! empty( $charitable_campaign_dropdown ) ) : ?>
130 <?php foreach ( $charitable_campaign_dropdown as $charitable_campaign_dropdown_id => $charitable_campaign_title ) : ?>
131 <option value="<?php echo intval( $charitable_campaign_dropdown_id ); ?>"><?php echo esc_html( $charitable_campaign_title ); ?></option>
132 <?php endforeach; ?>
133 <?php endif; ?>
134 </select>
135
136 </div>
137 <div class="alignright">
138
139 <?php echo $charitable_reports->get_activity_report_filter_dropdown( $charitable_activity_filter_types ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
140
141 <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 ); ?>" />
142
143 <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>
144
145 </div>
146 <br class="clear">
147 </div>
148 <?php endif; ?>
149 <?php endif; ?>
150
151 <div class="charitable-activity-report">
152
153 <div class="charitable-container charitable-title-card">
154
155 <div class="charitable-title-card-content">
156
157 <h1><?php echo esc_html__( 'Campaign Activity', 'charitable' ); ?></h1>
158
159 <p><?php echo esc_html__( 'This report shows what donations and events are happening on the various Charitable campaigns on your site.', 'charitable' ); ?></p>
160
161 <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>
162
163 <?php do_action( 'charitable_after_activity_report_description' ); ?>
164
165 </div>
166
167 </div>
168
169 <?php if ( ! $charitable_db_tables_installed ) : ?>
170
171 <div class="charitable-reports-notice">
172 <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>
173 <p><a href="<?php echo esc_url( $charitable_install_link ); ?>" class="button button-primary"><?php echo esc_html__( 'Install Database Tables', 'charitable' ); ?></a></p>
174 </div>
175
176 <?php else : ?>
177
178 <div class="tablenav charitable-section charitable-tablenav-activity">
179
180 <div class="alignleft actions">
181 <h2><?php echo esc_html__( 'Activities', 'charitable' ); ?></h2>
182 </div>
183 <div class="alignright">
184
185 <?php if ( ! charitable_is_pro() ) : ?>
186
187 <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>
188
189 <?php else : ?>
190
191 <form action="" method="post" class="charitable-report-download-form" id="charitable-activity-download-form">
192 <input name="charitable_report_action" type="hidden" value="charitable_report_download_activity">
193 <input name="start_date" type="hidden" value="<?php echo esc_html( $charitable_start_date ); ?>" />
194 <input name="end_date" type="hidden" value="<?php echo esc_html( $charitable_end_date ); ?>" />
195 <input name="campaign_id" type="hidden" value="<?php echo intval( $charitable_campaign_id ); ?>" />
196 <input name="activity_type" type="hidden" value="<?php echo esc_attr( $charitable_activity_type ); ?>">
197 <?php wp_nonce_field( 'charitable_export_report', 'charitable_export_report_nonce' ); ?>
198 <button
199 <?php
200 if ( empty( $charitable_report_activity ) ) :
201 ?>
202 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>
203 </form>
204
205 <?php endif; ?>
206
207 </div>
208
209 <br class="clear">
210
211 <div class="charitable-activity-list-container">
212
213 <div class="charitable-report-table-container">
214
215 <?php do_action( 'charitable_report_before_activity_table' ); ?>
216
217 <?php
218 if ( ! charitable_is_pro() ) :
219 ?>
220 <div class="charitable-restricted"><div class="restricted-access-overlay"></div><?php endif; ?>
221
222 <?php
223
224 if ( ! empty( $charitable_report_activity ) ) :
225
226 ?>
227
228 <div class="the-list charitable-the-list-container charitable-no-scroll">
229 <?php
230
231 echo $charitable_reports->generate_activity_list( $charitable_report_activity ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
232
233 ?>
234 </div>
235
236 <?php else : ?>
237
238 <div class="charitable-no-results">
239 <p><?php echo esc_html__( 'No activity found.', 'charitable' ); ?></p>
240 </div>
241
242 <?php endif; ?>
243
244 <?php
245 if ( ! charitable_is_pro() ) :
246 ?>
247 </div><?php endif; ?>
248
249 <?php do_action( 'charitable_report_after_activity_table' ); ?>
250
251 </div>
252
253 </div>
254
255 </div> <!-- .charitable-section -->
256
257 <?php endif; ?>
258
259 </div> <!-- .charitable-activity-report -->
260
261 <?php
262