| 1 |
<?php |
| 2 |
|
| 3 |
// Exit if accessed directly. |
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
/** |
| 9 |
* Format this page for PDF or print. |
| 10 |
* |
| 11 |
* Override this template by copying it to yourtheme/charitable/charitable-pdf-receipts/pdf.php |
| 12 |
* |
| 13 |
* @package Charitable-PDF-Receipts |
| 14 |
* @author WPCharitable |
| 15 |
* @since 1.8.1 |
| 16 |
* @version 1.8.8.6 |
| 17 |
*/ |
| 18 |
|
| 19 |
$charitable_action = $view_args['action'] === 'print' ? 'print' : 'download'; |
| 20 |
|
| 21 |
$charitable_admin_2_0_css = $view_args['charitable_admin_2_0_css']; |
| 22 |
|
| 23 |
$charitable_donations = $view_args['donations']; |
| 24 |
$charitable_donation_total = $view_args['donation_total']; |
| 25 |
$charitable_donation_average = $view_args['donation_average']; |
| 26 |
$charitable_total_count_donors = $view_args['total_count_donors']; |
| 27 |
$charitable_total_amount_refunds = $view_args['total_amount_refunds']; |
| 28 |
$charitable_total_count_refunds = $view_args['total_count_refunds']; |
| 29 |
$charitable_donation_breakdown_html = $view_args['donation_breakdown_html']; |
| 30 |
$charitable_activity_list = $view_args['activity_list']; |
| 31 |
$charitable_top_donors = $view_args['top_donors']; |
| 32 |
$charitable_top_campaigns = $view_args['top_campaigns']; |
| 33 |
$charitable_payment_methods_list = $view_args['payment_methods_list']; |
| 34 |
$charitable_headline_chart_options = $view_args['headline_chart_options']; |
| 35 |
$charitable_payment_methods_chart_options = $view_args['payment_methods_chart_options']; |
| 36 |
|
| 37 |
$charitable_campaign_id = $view_args['campaign_id']; |
| 38 |
$charitable_campaign = $view_args['campaign']; |
| 39 |
|
| 40 |
$charitable_category_id = $view_args['category_id']; |
| 41 |
$charitable_category_term_name = $view_args['category_term_name']; |
| 42 |
|
| 43 |
$charitable_chart_js = $view_args['charitable_chart_js']; |
| 44 |
|
| 45 |
// convert php array values into a javascript array. |
| 46 |
$charitable_headline_chart_options_donation_axis = wp_json_encode( $charitable_headline_chart_options['donation_axis'] ); |
| 47 |
$charitable_headline_chart_options_date_axis = wp_json_encode( $charitable_headline_chart_options['date_axis'] ); |
| 48 |
|
| 49 |
$charitable_payment_methods_chart_options_payment_percentages = wp_json_encode( $charitable_payment_methods_chart_options['payment_percentages'] ); |
| 50 |
$charitable_payment_methods_chart_options_payment_labels = wp_json_encode( $charitable_payment_methods_chart_options['payment_labels'] ); |
| 51 |
|
| 52 |
$charitable_currency_symbol = $view_args['currency_symbol']; |
| 53 |
$charitable_currency_symbol = ( false !== $charitable_currency_symbol ) ? html_entity_decode( $charitable_currency_symbol ) : '$'; |
| 54 |
|
| 55 |
$charitable_start_date = ! empty( $view_args['start_date'] ) ? $view_args['start_date'] : false; |
| 56 |
$charitable_end_date = ! empty( $view_args['end_date'] ) ? $view_args['end_date'] : false; |
| 57 |
|
| 58 |
?> |
| 59 |
<!DOCTYPE html> |
| 60 |
<html> |
| 61 |
<head> |
| 62 |
<title><?php echo esc_html__( 'Overview Report', 'charitable' ); ?></title> |
| 63 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 64 |
<style> |
| 65 |
<?php |
| 66 |
echo file_get_contents( $charitable_admin_2_0_css ); // phpcs:ignore |
| 67 |
|
| 68 |
/** |
| 69 |
* Add any custom styles to the PDF. |
| 70 |
* |
| 71 |
* @since 1.8.1 |
| 72 |
* |
| 73 |
* @param array $view_args The view arguments. |
| 74 |
*/ |
| 75 |
do_action( 'charitable_pdf_receipts_pdf_styles', $view_args ); |
| 76 |
?> |
| 77 |
</style> |
| 78 |
</head> |
| 79 |
|
| 80 |
<body id="charitable-pdf" style="margin: 0p; padding: 0; width: 100%; border: 0;"> |
| 81 |
|
| 82 |
<div class="charitable-overview-report" |
| 83 |
<?php |
| 84 |
if ( $charitable_action === 'download' ) : |
| 85 |
?> |
| 86 |
style="width: 100%; background-color: white; margin: 0; padding: 0;"<?php endif; ?>> |
| 87 |
|
| 88 |
<div class="charitable-headline-reports" |
| 89 |
<?php |
| 90 |
if ( $charitable_action === 'download' ) : |
| 91 |
?> |
| 92 |
style="margin: 0 auto; padding: 0;"<?php endif; ?>> |
| 93 |
|
| 94 |
<div class="charitable-print-header"> |
| 95 |
<h1><?php echo esc_html__( 'Overview Report', 'charitable' ); ?></h1> |
| 96 |
<?php if ( $charitable_start_date && $charitable_end_date ) : ?> |
| 97 |
<p><?php echo esc_html( $charitable_start_date ); ?> - <?php echo esc_html( $charitable_end_date ); ?></p> |
| 98 |
<?php endif; ?> |
| 99 |
<?php if ( isset( $charitable_campaign->post_title ) && $charitable_campaign->post_title ) : ?> |
| 100 |
<p><?php echo esc_html__( 'Campaign', 'charitable' ); ?>: <?php echo esc_html( $charitable_campaign->post_title ); ?></p> |
| 101 |
<?php endif; ?> |
| 102 |
<?php if ( $charitable_category_term_name ) : ?> |
| 103 |
<p><?php echo esc_html__( 'Campaign Category:', 'charitable' ); ?>: <?php echo esc_html( $charitable_category_term_name ); ?></p> |
| 104 |
<?php endif; ?> |
| 105 |
</div> |
| 106 |
|
| 107 |
|
| 108 |
<div class="charitable-cards"> |
| 109 |
<div class="charitable-container charitable-report-ui charitable-card" |
| 110 |
<?php |
| 111 |
if ( $charitable_action === 'download' ) : |
| 112 |
?> |
| 113 |
style="width: 24.5%; display:inline-block;"<?php endif; ?>> |
| 114 |
<strong><span id="charitable-top-donation-total-amount"><?php echo $charitable_donation_total; // phpcs:ignore ?></span></strong> |
| 115 |
<p><span id="charitable-top-donation-total-count"><?php echo count( $charitable_donations ); ?></span> <?php echo esc_html__( 'Total Donations (Net)', 'charitable' ); ?></p> |
| 116 |
</div> |
| 117 |
<div class="charitable-container charitable-report-ui charitable-card" |
| 118 |
<?php |
| 119 |
if ( $charitable_action === 'download' ) : |
| 120 |
?> |
| 121 |
style="width: 24.5%; display:inline-block;"<?php endif; ?>> |
| 122 |
<strong><span id="charitable-top-donation-average"><?php echo $charitable_donation_average; // phpcs:ignore ?></span></strong> |
| 123 |
<p><?php echo esc_html__( 'Average Donation', 'charitable' ); ?></p> |
| 124 |
</div> |
| 125 |
<div class="charitable-container charitable-report-ui charitable-card" |
| 126 |
<?php |
| 127 |
if ( $charitable_action === 'download' ) : |
| 128 |
?> |
| 129 |
style="width: 24.5%; display:inline-block;"<?php endif; ?>> |
| 130 |
<strong><span id="charitable-top-donor-count"><?php echo intval( $charitable_total_count_donors ); // phpcs:ignore ?></span></strong> |
| 131 |
<p><?php echo esc_html__( 'Donors', 'charitable' ); ?></p> |
| 132 |
</div> |
| 133 |
<div class="charitable-container charitable-report-ui charitable-card" |
| 134 |
<?php |
| 135 |
if ( $charitable_action === 'download' ) : |
| 136 |
?> |
| 137 |
style="width: 24.5%; display:inline-block;"<?php endif; ?>> |
| 138 |
<strong><span id="charitable-top-refund-total-amount"><?php echo charitable_format_money( $charitable_total_amount_refunds ); // phpcs:ignore ?></span></strong> |
| 139 |
<p><span id="charitable-top-refund-count"><?php echo intval( $charitable_total_count_refunds ); ?></span> <?php echo esc_html__( 'Refunds', 'charitable' ); ?></p> |
| 140 |
</div> |
| 141 |
</div> |
| 142 |
|
| 143 |
<?php if ( $charitable_action === 'print' ) : ?> |
| 144 |
<div class="charitable-container charitable-report-ui charitable-headline-graph-container"> |
| 145 |
<div id="charitable-headline-graph" class="charitable-headline-graph"> |
| 146 |
</div> |
| 147 |
</div> |
| 148 |
<?php endif; ?> |
| 149 |
|
| 150 |
</div> |
| 151 |
|
| 152 |
</div> |
| 153 |
|
| 154 |
<div class=" |
| 155 |
<?php |
| 156 |
if ( $charitable_action === 'print' ) : |
| 157 |
?> |
| 158 |
tablenav charitable-section<?php endif; ?>" |
| 159 |
<?php |
| 160 |
if ( $charitable_action === 'download' ) : |
| 161 |
?> |
| 162 |
style="width: 100%; background-color: white; margin: 0px 0 0 0;"<?php endif; ?>> |
| 163 |
|
| 164 |
<div class="alignleft actions"> |
| 165 |
<h4><?php echo esc_html__( 'Donations Breakdown', 'charitable' ); ?></h4> |
| 166 |
</div> |
| 167 |
|
| 168 |
<br class="clear"> |
| 169 |
|
| 170 |
<table class="wp-list-table widefat fixed striped table-view-list donations-breakdown charitable-report-ui"> |
| 171 |
<thead> |
| 172 |
<tr> |
| 173 |
<th scope="col" id="date" class="manage-column column-date"><span><?php echo esc_html__( 'Date', 'charitable' ); ?></span></a></th> |
| 174 |
<th scope="col" id="donations" class="manage-column column-donations"><?php echo esc_html__( 'Donations', 'charitable' ); ?></th> |
| 175 |
<th scope="col" id="no-of-donors" class="manage-column column-donors"><?php echo esc_html__( 'No. of Donors', 'charitable' ); ?></th> |
| 176 |
<th scope="col" id="refunds" class="manage-column column-refunds"><?php echo esc_html__( 'Refunds', 'charitable' ); ?></th> |
| 177 |
<th scope="col" id="net" class="manage-column column-net"><?php echo esc_html__( 'Net', 'charitable' ); ?></th> |
| 178 |
</tr> |
| 179 |
</thead> |
| 180 |
<tbody id="donations-breakdown-list"> |
| 181 |
<?php echo $charitable_donation_breakdown_html; // phpcs:ignore ?> |
| 182 |
</tbody> |
| 183 |
</table> |
| 184 |
|
| 185 |
<br class="clear"> |
| 186 |
|
| 187 |
</div> |
| 188 |
|
| 189 |
<div class=" |
| 190 |
<?php |
| 191 |
if ( $charitable_action === 'print' ) : |
| 192 |
?> |
| 193 |
charitable-section-grid charitable-section-grid-column-flexible<?php endif; ?>"> |
| 194 |
|
| 195 |
<div class="charitable-container charitable-report-card charitable-activity-report" data-section-name="activity"> |
| 196 |
<div class="header"> |
| 197 |
<h4><?php echo esc_html__( 'Activity', 'charitable' ); ?></h4> |
| 198 |
</div> |
| 199 |
<div class="charitable-toggle-container charitable-report-ui"> |
| 200 |
<div class="the-list"> |
| 201 |
<?php echo $charitable_activity_list; // phpcs:ignore ?> |
| 202 |
</div> |
| 203 |
</div> |
| 204 |
</div> |
| 205 |
|
| 206 |
<div class="charitable-container charitable-report-card charitable-top-donors-report"> |
| 207 |
<div class="header"> |
| 208 |
<h4><?php echo esc_html__( 'Top Donors', 'charitable' ); ?></h4> |
| 209 |
</div> |
| 210 |
<div class="charitable-toggle-container charitable-report-ui"> |
| 211 |
<?php echo $charitable_top_donors; // phpcs:ignore ?> |
| 212 |
</div> |
| 213 |
</div> |
| 214 |
|
| 215 |
</div> |
| 216 |
|
| 217 |
<div class="charitable-section-grid one-third charitable-section-grid-column-flexible"> |
| 218 |
|
| 219 |
<div class="charitable-container charitable-report-card charitable-top-campaigns-report"> |
| 220 |
<div class="header"> |
| 221 |
<h4><?php echo esc_html__( 'Top Campaigns', 'charitable' ); ?></h4> |
| 222 |
</div> |
| 223 |
<div class="charitable-toggle-container charitable-report-ui"> |
| 224 |
<?php if ( ! empty( $charitable_top_campaigns ) ) : ?> |
| 225 |
<div class="the-list"> |
| 226 |
<ul id="charitable-top-campaigns-list"> |
| 227 |
<?php echo $charitable_top_campaigns; // phpcs:ignore ?> |
| 228 |
</ul> |
| 229 |
</div> |
| 230 |
<?php else : ?> |
| 231 |
<?php endif; ?> |
| 232 |
</div> |
| 233 |
</div> |
| 234 |
|
| 235 |
<div class="charitable-container charitable-report-card charitable-payment-methods-report"> |
| 236 |
<div class="header"> |
| 237 |
<h4><?php echo esc_html__( 'Payment Methods', 'charitable' ); ?></h4> |
| 238 |
</div> |
| 239 |
<div class="charitable-toggle-container charitable-report-ui"> |
| 240 |
<div class="the-graph"> |
| 241 |
<div id="charitable-payment-methods-graph" class="charitable-payment-methods-graph"> |
| 242 |
</div> |
| 243 |
<div class="the-legend"> |
| 244 |
<ul id="charitable-payment-methods-list"> |
| 245 |
<?php echo $charitable_payment_methods_list; // phpcs:ignore ?> |
| 246 |
</ul> |
| 247 |
</div> <!-- the legend --> |
| 248 |
</div> |
| 249 |
</div> |
| 250 |
</div> |
| 251 |
|
| 252 |
</div> |
| 253 |
|
| 254 |
<?php if ( $charitable_action === 'print' ) : ?> |
| 255 |
|
| 256 |
<script src="<?php echo esc_url( $charitable_chart_js ); // phpcs:ignore ?>" id="charitable-apex-charts-js"></script> |
| 257 |
|
| 258 |
<script id="charitable-report-data-js"> |
| 259 |
var charitable_reporting = { |
| 260 |
'currency_symbol' : "<?php echo $charitable_currency_symbol; // phpcs:ignore ?>", |
| 261 |
"headline_chart_options": |
| 262 |
{"donation_axis":<?php echo $charitable_headline_chart_options_donation_axis; // phpcs:ignore ?>, |
| 263 |
"date_axis":<?php echo $charitable_headline_chart_options_date_axis; // phpcs:ignore ?> |
| 264 |
}, |
| 265 |
"payment_methods_chart_options":{ |
| 266 |
"payment_percentages":<?php echo $charitable_payment_methods_chart_options_payment_percentages; // phpcs:ignore ?>, |
| 267 |
"payment_labels":<?php echo $charitable_payment_methods_chart_options_payment_labels; // phpcs:ignore ?> |
| 268 |
} |
| 269 |
}; |
| 270 |
</script> |
| 271 |
|
| 272 |
<script type="text/javascript" id="charitable-report-headline-chart-js"> |
| 273 |
var charitable_headline_chart = new ApexCharts( document.querySelector("#charitable-headline-graph"), { |
| 274 |
chart: { |
| 275 |
animations: { |
| 276 |
enabled: false |
| 277 |
}, |
| 278 |
background: '#fff', |
| 279 |
foreColor: "#757781", |
| 280 |
type: 'area', |
| 281 |
width: '900px', |
| 282 |
stacked: true, |
| 283 |
toolbar: { |
| 284 |
show: false |
| 285 |
}, |
| 286 |
zoom: { |
| 287 |
enabled: false |
| 288 |
} |
| 289 |
}, |
| 290 |
colors: ["#5AA15226"], |
| 291 |
grid: { |
| 292 |
borderColor: "#C9D4CA", |
| 293 |
clipMarkers: false, |
| 294 |
yaxis: { |
| 295 |
lines: { |
| 296 |
show: true |
| 297 |
} |
| 298 |
} |
| 299 |
}, |
| 300 |
dataLabels: { |
| 301 |
enabled: false |
| 302 |
}, |
| 303 |
series: [{ |
| 304 |
name: '<?php echo esc_html__( 'Donations', 'charitable' ); ?>', |
| 305 |
data: charitable_reporting.headline_chart_options.donation_axis |
| 306 |
}], |
| 307 |
stroke: { |
| 308 |
width: 3, |
| 309 |
colors: ["#5AA152"] |
| 310 |
}, |
| 311 |
fill: { |
| 312 |
type: "solid" |
| 313 |
}, |
| 314 |
markers: { |
| 315 |
size: 5, |
| 316 |
colors: ["#FFFFFF"], |
| 317 |
strokeColor: "#5AA152", |
| 318 |
strokeWidth: 4 |
| 319 |
}, |
| 320 |
legend: { |
| 321 |
show: false |
| 322 |
}, |
| 323 |
xaxis: { |
| 324 |
categories: charitable_reporting.headline_chart_options.date_axis, |
| 325 |
}, |
| 326 |
yaxis: { |
| 327 |
labels: { |
| 328 |
formatter: function (val) { |
| 329 |
return charitable_decodeHtml(charitable_reporting.currency_symbol) + val.toFixed(2) |
| 330 |
} |
| 331 |
} |
| 332 |
} |
| 333 |
}); |
| 334 |
|
| 335 |
/* utils */ |
| 336 |
|
| 337 |
/** |
| 338 |
* Util function that decodes HTML entities. |
| 339 |
* |
| 340 |
* @since 1.8.1 |
| 341 |
* |
| 342 |
*/ |
| 343 |
function charitable_decodeHtml( html ) { |
| 344 |
var txt = document.createElement("textarea"); |
| 345 |
txt.innerHTML = html; |
| 346 |
return txt.value; |
| 347 |
} |
| 348 |
|
| 349 |
charitable_headline_chart.render(); |
| 350 |
|
| 351 |
var charitable_payment_chart = new ApexCharts( document.querySelector("#charitable-payment-methods-graph"), { |
| 352 |
series: charitable_reporting.payment_methods_chart_options.payment_percentages, |
| 353 |
labels: charitable_reporting.payment_methods_chart_options.payment_labels, |
| 354 |
colors: [ |
| 355 |
'#d21561', '#9e36f9', '#F99E36', '#2B66D1', '#5AA152' |
| 356 |
], |
| 357 |
chart: { |
| 358 |
type: 'donut', |
| 359 |
width: '75%', |
| 360 |
toolbar: { |
| 361 |
autoSelected: "pan", |
| 362 |
show: false |
| 363 |
} |
| 364 |
}, |
| 365 |
dataLabels: { |
| 366 |
enabled: false |
| 367 |
}, |
| 368 |
yaxis: { |
| 369 |
labels: { |
| 370 |
formatter: (value) => { |
| 371 |
return value + '%' |
| 372 |
} |
| 373 |
} |
| 374 |
}, |
| 375 |
plotOptions: { |
| 376 |
pie: { |
| 377 |
donut: { |
| 378 |
size: '80%' |
| 379 |
} |
| 380 |
} |
| 381 |
}, |
| 382 |
total: { |
| 383 |
show: true, |
| 384 |
showAlways: true, |
| 385 |
label: 'Total', |
| 386 |
fontSize: '22px', |
| 387 |
fontFamily: 'Helvetica, Arial, sans-serif', |
| 388 |
fontWeight: 600, |
| 389 |
color: '#373d3f', |
| 390 |
formatter: function (w) { |
| 391 |
return w.globals.seriesTotals.reduce((a, b) => { |
| 392 |
return a + b |
| 393 |
}, 0) |
| 394 |
} |
| 395 |
}, |
| 396 |
legend: { |
| 397 |
show: false, |
| 398 |
showForSingleSeries: true, |
| 399 |
showForNullSeries: true, |
| 400 |
showForZeroSeries: true, |
| 401 |
position: 'bottom', |
| 402 |
horizontalAlign: 'center', |
| 403 |
floating: false, |
| 404 |
fontSize: '14px', |
| 405 |
fontFamily: 'Helvetica, Arial', |
| 406 |
fontWeight: 400, |
| 407 |
inverseOrder: true, |
| 408 |
customLegendItems: [], |
| 409 |
offsetX: 0, |
| 410 |
offsetY: 0, |
| 411 |
labels: { |
| 412 |
useSeriesColors: false |
| 413 |
}, |
| 414 |
markers: { |
| 415 |
width: 12, |
| 416 |
height: 12, |
| 417 |
strokeWidth: 0, |
| 418 |
strokeColor: '#fff', |
| 419 |
radius: 12, |
| 420 |
offsetX: 0, |
| 421 |
offsetY: 0, |
| 422 |
customHTML: function () { |
| 423 |
return '<span class="custom-marker">test</span>' |
| 424 |
} |
| 425 |
}, |
| 426 |
itemMargin: { |
| 427 |
horizontal: 5, |
| 428 |
vertical: 0 |
| 429 |
} |
| 430 |
} |
| 431 |
}); |
| 432 |
|
| 433 |
charitable_payment_chart.render(); |
| 434 |
|
| 435 |
window.onload = function() { window.print(); } |
| 436 |
|
| 437 |
</script> |
| 438 |
|
| 439 |
<?php endif; ?> |
| 440 |
|
| 441 |
</body> |
| 442 |
|
| 443 |
</html> |
| 444 |
|