| 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/print/dashboard.php |
| 12 |
* |
| 13 |
* @package charitable |
| 14 |
* @author WPCharitable |
| 15 |
* @since 1.8.1 |
| 16 |
* @version 1.8.1.6 |
| 17 |
* @version 1.8.8.6 |
| 18 |
*/ |
| 19 |
|
| 20 |
$charitable_action = $view_args['action'] === 'print' ? 'print' : 'download'; |
| 21 |
|
| 22 |
$charitable_cards = $view_args['charitable_cards']; |
| 23 |
$charitable_reports = $view_args['charitable_reports']; |
| 24 |
$charitable_admin_2_0_css = $view_args['charitable_admin_2_0_css']; |
| 25 |
$charitable_chart_js = $view_args['charitable_chart_js']; |
| 26 |
|
| 27 |
$charitable_start_date = ! empty( $view_args['start_date'] ) ? $view_args['start_date'] : false; |
| 28 |
$charitable_end_date = ! empty( $view_args['end_date'] ) ? $view_args['end_date'] : false; |
| 29 |
|
| 30 |
$charitable_headline_chart_options = $view_args['headline_chart_options']; |
| 31 |
|
| 32 |
// Regarding the donation and data axis for the headline chart: convert php array values into a javascript array. |
| 33 |
$charitable_headline_chart_options_donation_axis = wp_json_encode( $charitable_headline_chart_options['donation_axis'] ); |
| 34 |
$charitable_headline_chart_options_date_axis = wp_json_encode( $charitable_headline_chart_options['date_axis'] ); |
| 35 |
|
| 36 |
$charitable_payment_methods_chart_options_payment_percentages = wp_json_encode( array() ); |
| 37 |
$charitable_payment_methods_chart_options_payment_labels = wp_json_encode( array() ); |
| 38 |
|
| 39 |
$charitable_currency_symbol = $view_args['currency_symbol']; |
| 40 |
$charitable_currency_symbol = ( false !== $charitable_currency_symbol ) ? html_entity_decode( $charitable_currency_symbol ) : '$'; |
| 41 |
|
| 42 |
?> |
| 43 |
<!DOCTYPE html> |
| 44 |
<html> |
| 45 |
<head> |
| 46 |
<title><?php echo esc_html__( 'Dashboard Report', 'charitable' ); ?></title> |
| 47 |
<meta name="viewport" content="width=device-width, initial-scale=1"> |
| 48 |
<style> |
| 49 |
<?php |
| 50 |
echo file_get_contents( $charitable_admin_2_0_css ); // phpcs:ignore |
| 51 |
|
| 52 |
/** |
| 53 |
* Add any custom styles to the PDF. |
| 54 |
* |
| 55 |
* @since 1.8.1 |
| 56 |
* |
| 57 |
* @param array $view_args The view arguments. |
| 58 |
*/ |
| 59 |
do_action( 'charitable_pdf_dashboard_styles', $view_args ); |
| 60 |
?> |
| 61 |
|
| 62 |
/* Print-specific styles for full-width chart */ |
| 63 |
.charitable-headline-graph-container { |
| 64 |
width: 100% !important; |
| 65 |
max-width: 100% !important; |
| 66 |
padding: 20px 0 !important; |
| 67 |
margin: 0 !important; |
| 68 |
} |
| 69 |
|
| 70 |
.charitable-headline-graph { |
| 71 |
width: 100% !important; |
| 72 |
max-width: 100% !important; |
| 73 |
} |
| 74 |
|
| 75 |
.apexcharts-canvas { |
| 76 |
width: 100% !important; |
| 77 |
max-width: 100% !important; |
| 78 |
} |
| 79 |
|
| 80 |
/* Hide any notifications that might appear */ |
| 81 |
.charitable-notification, |
| 82 |
.notice, |
| 83 |
.update-nag, |
| 84 |
.charitable-admin-notice { |
| 85 |
display: none !important; |
| 86 |
} |
| 87 |
</style> |
| 88 |
</head> |
| 89 |
|
| 90 |
<body id="charitable-pdf" class="charitable-pdf-<?php echo esc_attr( $charitable_action ); ?> charitable-pdf-dashboard-<?php echo esc_attr( $charitable_action ); ?>" style="margin: 0px; padding: 0; width: 100%; border: 0; overflow-x: hidden;"> |
| 91 |
|
| 92 |
<div class="charitable-dashboard-report" |
| 93 |
<?php |
| 94 |
if ( $charitable_action === 'download' ) : |
| 95 |
?> |
| 96 |
style="width: 100%; background-color: white; margin: 0; padding: 0;"<?php endif; ?>> |
| 97 |
|
| 98 |
<div class="charitable-headline-reports" |
| 99 |
<?php |
| 100 |
if ( $charitable_action === 'download' ) : |
| 101 |
?> |
| 102 |
style="margin: 0 auto; padding: 0;"<?php endif; ?>> |
| 103 |
|
| 104 |
<div class="charitable-print-header"> |
| 105 |
<h1><?php echo esc_html__( 'Dashboard Report', 'charitable' ); ?></h1> |
| 106 |
<?php if ( $charitable_start_date && $charitable_end_date ) : ?> |
| 107 |
<p><?php echo esc_html( $charitable_start_date ); ?> - <?php echo esc_html( $charitable_end_date ); ?></p> |
| 108 |
<?php endif; ?> |
| 109 |
</div> |
| 110 |
|
| 111 |
<div id="charitable-dashboard-report-cards"> |
| 112 |
<?php echo $charitable_cards; // phpcs:ignore ?> |
| 113 |
</div> |
| 114 |
|
| 115 |
<div class="charitable-container charitable-report-ui charitable-headline-graph-container" style="width: 100%; max-width: 100%; padding: 20px 0;"> |
| 116 |
<div id="charitable-headline-graph" class="charitable-headline-graph" style="width: 100%;"></div> |
| 117 |
</div> |
| 118 |
|
| 119 |
</div> |
| 120 |
|
| 121 |
<div class="charitable-section charitable-section-flexible"> |
| 122 |
|
| 123 |
<div id="charitable-dashboard-report-sections"> |
| 124 |
<?php echo $charitable_reports; // phpcs:ignore ?> |
| 125 |
</div> |
| 126 |
|
| 127 |
</div> |
| 128 |
|
| 129 |
</div> |
| 130 |
|
| 131 |
<?php if ( $charitable_action === 'print' ) : ?> |
| 132 |
|
| 133 |
<script src="<?php echo esc_url( $charitable_chart_js ); // phpcs:ignore ?>" id="charitable-apex-charts-js"></script> |
| 134 |
|
| 135 |
<script id="charitable-report-data-js"> |
| 136 |
|
| 137 |
var charitable_reporting = { |
| 138 |
'currency_symbol' : "<?php echo $charitable_currency_symbol; // phpcs:ignore ?>", |
| 139 |
"headline_chart_options":{ |
| 140 |
"donation_axis":<?php echo $charitable_headline_chart_options_donation_axis; // phpcs:ignore ?>, |
| 141 |
"date_axis":<?php echo $charitable_headline_chart_options_date_axis; // phpcs:ignore ?>}, |
| 142 |
"payment_methods_chart_options":{ |
| 143 |
"payment_percentages":<?php echo $charitable_payment_methods_chart_options_payment_percentages; // phpcs:ignore ?>, |
| 144 |
"payment_labels":<?php echo $charitable_payment_methods_chart_options_payment_labels; // phpcs:ignore ?> |
| 145 |
} |
| 146 |
}; |
| 147 |
|
| 148 |
</script> |
| 149 |
|
| 150 |
<script type="text/javascript" id="charitable-report-headline-chart-js"> |
| 151 |
var charitable_headline_chart = new ApexCharts( document.querySelector("#charitable-headline-graph"), { |
| 152 |
chart: { |
| 153 |
animations: { |
| 154 |
enabled: false |
| 155 |
}, |
| 156 |
background: '#fff', |
| 157 |
foreColor: "#757781", |
| 158 |
type: 'area', |
| 159 |
width: '100%', |
| 160 |
stacked: true, |
| 161 |
toolbar: { |
| 162 |
show: false |
| 163 |
}, |
| 164 |
zoom: { |
| 165 |
enabled: false |
| 166 |
} |
| 167 |
}, |
| 168 |
colors: ["#5AA15226"], |
| 169 |
grid: { |
| 170 |
borderColor: "#C9D4CA", |
| 171 |
clipMarkers: false, |
| 172 |
yaxis: { |
| 173 |
lines: { |
| 174 |
show: true |
| 175 |
} |
| 176 |
}, |
| 177 |
padding: { |
| 178 |
right: 28, |
| 179 |
left: 8, |
| 180 |
top: 0, |
| 181 |
bottom: 0 |
| 182 |
} |
| 183 |
}, |
| 184 |
dataLabels: { |
| 185 |
enabled: false |
| 186 |
}, |
| 187 |
series: [{ |
| 188 |
name: 'Donations', |
| 189 |
data: charitable_reporting.headline_chart_options.donation_axis |
| 190 |
}], |
| 191 |
stroke: { |
| 192 |
width: 3, |
| 193 |
colors: ["#5AA152"] |
| 194 |
}, |
| 195 |
fill: { |
| 196 |
type: "solid" |
| 197 |
}, |
| 198 |
markers: { |
| 199 |
size: 5, |
| 200 |
colors: ["#FFFFFF"], |
| 201 |
strokeColor: "#5AA152", |
| 202 |
strokeWidth: 4 |
| 203 |
}, |
| 204 |
legend: { |
| 205 |
show: false |
| 206 |
}, |
| 207 |
xaxis: { |
| 208 |
categories: charitable_reporting.headline_chart_options.date_axis, |
| 209 |
}, |
| 210 |
yaxis: { |
| 211 |
labels: { |
| 212 |
formatter: function (val) { |
| 213 |
return charitable_decodeHtml(charitable_reporting.currency_symbol) + val.toFixed(2) |
| 214 |
} |
| 215 |
} |
| 216 |
} |
| 217 |
}); |
| 218 |
|
| 219 |
charitable_headline_chart.render(); |
| 220 |
|
| 221 |
/* utils */ |
| 222 |
|
| 223 |
/** |
| 224 |
* Util function that decodes HTML entities. |
| 225 |
* |
| 226 |
* @since 1.8.1 |
| 227 |
* |
| 228 |
*/ |
| 229 |
function charitable_decodeHtml( html ) { |
| 230 |
var txt = document.createElement("textarea"); |
| 231 |
txt.innerHTML = html; |
| 232 |
return txt.value; |
| 233 |
} |
| 234 |
|
| 235 |
window.onload = function() { window.print(); } |
| 236 |
|
| 237 |
</script> |
| 238 |
|
| 239 |
<?php endif; ?> |
| 240 |
|
| 241 |
</body> |
| 242 |
|
| 243 |
</html> |
| 244 |
|