@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | // Exit if accessed directly. |
| 13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 13 | +if ( ! defined('ABSPATH')) { |
|
| 14 | 14 | exit; |
| 15 | 15 | } |
| 16 | 16 | |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | $dates = give_get_report_dates(); |
| 27 | 27 | |
| 28 | 28 | // Determine graph options. |
| 29 | - switch ( $dates['range'] ) : |
|
| 29 | + switch ($dates['range']) : |
|
| 30 | 30 | case 'today': |
| 31 | 31 | case 'yesterday': |
| 32 | 32 | $day_by_day = true; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $day_by_day = false; |
| 39 | 39 | break; |
| 40 | 40 | case 'other': |
| 41 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ( $dates['m_start'] != '12' && $dates['m_end'] != '1' ) ) { |
|
| 41 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] && ($dates['m_start'] != '12' && $dates['m_end'] != '1')) { |
|
| 42 | 42 | $day_by_day = false; |
| 43 | 43 | } else { |
| 44 | 44 | $day_by_day = true; |
@@ -55,60 +55,60 @@ discard block |
||
| 55 | 55 | $earnings_data = array(); |
| 56 | 56 | $sales_data = array(); |
| 57 | 57 | |
| 58 | - if ( 'today' === $dates['range'] || 'yesterday' === $dates['range'] ) { |
|
| 58 | + if ('today' === $dates['range'] || 'yesterday' === $dates['range']) { |
|
| 59 | 59 | |
| 60 | 60 | // Hour by hour. |
| 61 | 61 | $hour = 0; |
| 62 | - $month = date( 'n', current_time( 'timestamp' ) ); |
|
| 63 | - while ( $hour <= 23 ) : |
|
| 62 | + $month = date('n', current_time('timestamp')); |
|
| 63 | + while ($hour <= 23) : |
|
| 64 | 64 | |
| 65 | - $start_date = mktime( $hour, 0, 0, $month, $dates['day'], $dates['year'] ); |
|
| 66 | - $end_date = mktime( $hour, 59, 59, $month, $dates['day'], $dates['year'] ); |
|
| 67 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
| 68 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
| 65 | + $start_date = mktime($hour, 0, 0, $month, $dates['day'], $dates['year']); |
|
| 66 | + $end_date = mktime($hour, 59, 59, $month, $dates['day'], $dates['year']); |
|
| 67 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
| 68 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
| 69 | 69 | |
| 70 | 70 | $sales_totals += $sales; |
| 71 | 71 | $earnings_totals += $earnings; |
| 72 | 72 | |
| 73 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
| 74 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
| 73 | + $sales_data[] = array($start_date * 1000, $sales); |
|
| 74 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
| 75 | 75 | |
| 76 | - $hour ++; |
|
| 76 | + $hour++; |
|
| 77 | 77 | endwhile; |
| 78 | 78 | |
| 79 | - } elseif ( 'this_week' === $dates['range'] || 'last_week' === $dates['range'] ) { |
|
| 79 | + } elseif ('this_week' === $dates['range'] || 'last_week' === $dates['range']) { |
|
| 80 | 80 | |
| 81 | 81 | // Day by day. |
| 82 | 82 | $day = $dates['day']; |
| 83 | 83 | $day_end = $dates['day_end']; |
| 84 | 84 | $month = $dates['m_start']; |
| 85 | - while ( $day <= $day_end ) : |
|
| 85 | + while ($day <= $day_end) : |
|
| 86 | 86 | |
| 87 | - $start_date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
| 88 | - $end_date = mktime( 23, 59, 59, $month, $day, $dates['year'] ); |
|
| 89 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
| 90 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
| 87 | + $start_date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
| 88 | + $end_date = mktime(23, 59, 59, $month, $day, $dates['year']); |
|
| 89 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
| 90 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
| 91 | 91 | |
| 92 | 92 | $sales_totals += $sales; |
| 93 | 93 | $earnings_totals += $earnings; |
| 94 | 94 | |
| 95 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
| 96 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
| 97 | - $day ++; |
|
| 95 | + $sales_data[] = array($start_date * 1000, $sales); |
|
| 96 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
| 97 | + $day++; |
|
| 98 | 98 | endwhile; |
| 99 | 99 | |
| 100 | 100 | } else { |
| 101 | 101 | |
| 102 | 102 | $y = $dates['year']; |
| 103 | - while ( $y <= $dates['year_end'] ) : |
|
| 103 | + while ($y <= $dates['year_end']) : |
|
| 104 | 104 | |
| 105 | - if ( $dates['year'] === $dates['year_end'] ) { |
|
| 105 | + if ($dates['year'] === $dates['year_end']) { |
|
| 106 | 106 | $month_start = $dates['m_start']; |
| 107 | 107 | $month_end = $dates['m_end']; |
| 108 | - } elseif ( $y === $dates['year'] ) { |
|
| 108 | + } elseif ($y === $dates['year']) { |
|
| 109 | 109 | $month_start = $dates['m_start']; |
| 110 | 110 | $month_end = 12; |
| 111 | - } elseif ( $y === $dates['year_end'] ) { |
|
| 111 | + } elseif ($y === $dates['year_end']) { |
|
| 112 | 112 | $month_start = 1; |
| 113 | 113 | $month_end = $dates['m_end']; |
| 114 | 114 | } else { |
@@ -117,67 +117,67 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | $i = $month_start; |
| 120 | - while ( $i <= $month_end ) : |
|
| 120 | + while ($i <= $month_end) : |
|
| 121 | 121 | |
| 122 | - if ( $day_by_day ) { |
|
| 122 | + if ($day_by_day) { |
|
| 123 | 123 | |
| 124 | - if ( $i === $month_end ) { |
|
| 124 | + if ($i === $month_end) { |
|
| 125 | 125 | |
| 126 | 126 | $num_of_days = $dates['day_end']; |
| 127 | 127 | |
| 128 | 128 | } else { |
| 129 | 129 | |
| 130 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 130 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 131 | 131 | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | $d = $dates['day']; |
| 135 | 135 | |
| 136 | - while ( $d <= $num_of_days ) : |
|
| 136 | + while ($d <= $num_of_days) : |
|
| 137 | 137 | |
| 138 | - $start_date = mktime( 0, 0, 0, $i, $d, $y ); |
|
| 139 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
| 140 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
| 141 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
| 138 | + $start_date = mktime(0, 0, 0, $i, $d, $y); |
|
| 139 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
| 140 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
| 141 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
| 142 | 142 | |
| 143 | 143 | $sales_totals += $sales; |
| 144 | 144 | $earnings_totals += $earnings; |
| 145 | 145 | |
| 146 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
| 147 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
| 146 | + $sales_data[] = array($start_date * 1000, $sales); |
|
| 147 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
| 148 | 148 | |
| 149 | - $d ++; |
|
| 149 | + $d++; |
|
| 150 | 150 | |
| 151 | 151 | endwhile; |
| 152 | 152 | |
| 153 | 153 | } else { |
| 154 | 154 | |
| 155 | 155 | // This Quarter, Last Quarter, This Year, Last Year. |
| 156 | - $start_date = mktime( 0, 0, 0, $i, 1, $y ); |
|
| 157 | - $end_date = mktime( 23, 59, 59, $i + 1, 0, $y ); |
|
| 158 | - $sales = $donation_stats->get_sales( 0, $start_date, $end_date ); |
|
| 159 | - $earnings = $donation_stats->get_earnings( 0, $start_date, $end_date ); |
|
| 156 | + $start_date = mktime(0, 0, 0, $i, 1, $y); |
|
| 157 | + $end_date = mktime(23, 59, 59, $i + 1, 0, $y); |
|
| 158 | + $sales = $donation_stats->get_sales(0, $start_date, $end_date); |
|
| 159 | + $earnings = $donation_stats->get_earnings(0, $start_date, $end_date); |
|
| 160 | 160 | |
| 161 | 161 | $sales_totals += $sales; |
| 162 | 162 | $earnings_totals += $earnings; |
| 163 | 163 | |
| 164 | - $sales_data[] = array( $start_date * 1000, $sales ); |
|
| 165 | - $earnings_data[] = array( $start_date * 1000, $earnings ); |
|
| 164 | + $sales_data[] = array($start_date * 1000, $sales); |
|
| 165 | + $earnings_data[] = array($start_date * 1000, $earnings); |
|
| 166 | 166 | |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $i ++; |
|
| 169 | + $i++; |
|
| 170 | 170 | |
| 171 | 171 | endwhile; |
| 172 | 172 | |
| 173 | - $y ++; |
|
| 173 | + $y++; |
|
| 174 | 174 | endwhile; |
| 175 | 175 | |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | $data = array( |
| 179 | - __( 'Income', 'give' ) => $earnings_data, |
|
| 180 | - __( 'Donations', 'give' ) => $sales_data, |
|
| 179 | + __('Income', 'give') => $earnings_data, |
|
| 180 | + __('Donations', 'give') => $sales_data, |
|
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | 183 | // start our own output buffer. |
@@ -190,12 +190,12 @@ discard block |
||
| 190 | 190 | <div class="inside"> |
| 191 | 191 | <?php give_reports_graph_controls(); ?> |
| 192 | 192 | <?php |
| 193 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
| 194 | - $graph->set( 'x_mode', 'time' ); |
|
| 195 | - $graph->set( 'multiple_y_axes', true ); |
|
| 193 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
| 194 | + $graph->set('x_mode', 'time'); |
|
| 195 | + $graph->set('multiple_y_axes', true); |
|
| 196 | 196 | $graph->display(); |
| 197 | 197 | |
| 198 | - if ( 'this_month' === $dates['range'] ) { |
|
| 198 | + if ('this_month' === $dates['range']) { |
|
| 199 | 199 | $estimated = give_estimated_monthly_stats(); |
| 200 | 200 | } |
| 201 | 201 | ?> |
@@ -204,21 +204,21 @@ discard block |
||
| 204 | 204 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
| 205 | 205 | <tbody> |
| 206 | 206 | <tr> |
| 207 | - <th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th> |
|
| 208 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td> |
|
| 207 | + <th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th> |
|
| 208 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td> |
|
| 209 | 209 | </tr> |
| 210 | 210 | <tr class="alternate"> |
| 211 | - <th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?><strong></th> |
|
| 211 | + <th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?><strong></th> |
|
| 212 | 212 | <td><?php echo $sales_totals; ?></td> |
| 213 | 213 | </tr> |
| 214 | - <?php if ( 'this_month' === $dates['range'] ) : ?> |
|
| 214 | + <?php if ('this_month' === $dates['range']) : ?> |
|
| 215 | 215 | <tr> |
| 216 | - <th scope="row"><strong><?php _e( 'Estimated monthly income:', 'give' ); ?></strong></th> |
|
| 217 | - <td><?php echo give_currency_filter( give_format_amount( $estimated['earnings'], array( 'sanitize' => false ) ) ); ?></td> |
|
| 216 | + <th scope="row"><strong><?php _e('Estimated monthly income:', 'give'); ?></strong></th> |
|
| 217 | + <td><?php echo give_currency_filter(give_format_amount($estimated['earnings'], array('sanitize' => false))); ?></td> |
|
| 218 | 218 | </tr> |
| 219 | 219 | <tr class="alternate"> |
| 220 | - <th scope="row"><strong><?php _e( 'Estimated monthly donations:', 'give' ); ?></strong></th> |
|
| 221 | - <td><?php echo floor( $estimated['sales'] ); ?></td> |
|
| 220 | + <th scope="row"><strong><?php _e('Estimated monthly donations:', 'give'); ?></strong></th> |
|
| 221 | + <td><?php echo floor($estimated['sales']); ?></td> |
|
| 222 | 222 | </tr> |
| 223 | 223 | <?php endif; ?> |
| 224 | 224 | </table> |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @since 1.0 |
| 233 | 233 | */ |
| 234 | - do_action( 'give_reports_graph_additional_stats' ); |
|
| 234 | + do_action('give_reports_graph_additional_stats'); |
|
| 235 | 235 | ?> |
| 236 | 236 | |
| 237 | 237 | </div> |
@@ -253,12 +253,12 @@ discard block |
||
| 253 | 253 | * |
| 254 | 254 | * @return void |
| 255 | 255 | */ |
| 256 | -function give_reports_graph_of_form( $form_id = 0 ) { |
|
| 256 | +function give_reports_graph_of_form($form_id = 0) { |
|
| 257 | 257 | // Retrieve the queried dates. |
| 258 | 258 | $dates = give_get_report_dates(); |
| 259 | 259 | |
| 260 | 260 | // Determine graph options. |
| 261 | - switch ( $dates['range'] ) : |
|
| 261 | + switch ($dates['range']) : |
|
| 262 | 262 | case 'today': |
| 263 | 263 | case 'yesterday': |
| 264 | 264 | $day_by_day = true; |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | $day_by_day = false; |
| 277 | 277 | break; |
| 278 | 278 | case 'other': |
| 279 | - if ( $dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year'] ) { |
|
| 279 | + if ($dates['m_end'] - $dates['m_start'] >= 2 || $dates['year_end'] > $dates['year']) { |
|
| 280 | 280 | $day_by_day = false; |
| 281 | 281 | } else { |
| 282 | 282 | $day_by_day = true; |
@@ -288,75 +288,75 @@ discard block |
||
| 288 | 288 | endswitch; |
| 289 | 289 | |
| 290 | 290 | $earnings_totals = (float) 0.00; // Total earnings for time period shown. |
| 291 | - $sales_totals = 0; // Total sales for time period shown. |
|
| 291 | + $sales_totals = 0; // Total sales for time period shown. |
|
| 292 | 292 | |
| 293 | 293 | $earnings_data = array(); |
| 294 | 294 | $sales_data = array(); |
| 295 | 295 | $stats = new Give_Payment_Stats(); |
| 296 | 296 | |
| 297 | - if ( $dates['range'] == 'today' || $dates['range'] == 'yesterday' ) { |
|
| 297 | + if ($dates['range'] == 'today' || $dates['range'] == 'yesterday') { |
|
| 298 | 298 | |
| 299 | 299 | // Hour by hour |
| 300 | 300 | $month = $dates['m_start']; |
| 301 | 301 | $hour = 0; |
| 302 | 302 | $minute = 0; |
| 303 | 303 | $second = 0; |
| 304 | - while ( $hour <= 23 ) : |
|
| 304 | + while ($hour <= 23) : |
|
| 305 | 305 | |
| 306 | - if ( $hour == 23 ) { |
|
| 306 | + if ($hour == 23) { |
|
| 307 | 307 | $minute = $second = 59; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $date = mktime( $hour, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
| 311 | - $date_end = mktime( $hour + 1, $minute, $second, $month, $dates['day'], $dates['year'] ); |
|
| 310 | + $date = mktime($hour, $minute, $second, $month, $dates['day'], $dates['year']); |
|
| 311 | + $date_end = mktime($hour + 1, $minute, $second, $month, $dates['day'], $dates['year']); |
|
| 312 | 312 | |
| 313 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
| 313 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
| 314 | 314 | $sales_totals += $sales; |
| 315 | 315 | |
| 316 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
| 316 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
| 317 | 317 | $earnings_totals += $earnings; |
| 318 | 318 | |
| 319 | - $sales_data[] = array( $date * 1000, $sales ); |
|
| 320 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
| 319 | + $sales_data[] = array($date * 1000, $sales); |
|
| 320 | + $earnings_data[] = array($date * 1000, $earnings); |
|
| 321 | 321 | |
| 322 | - $hour ++; |
|
| 322 | + $hour++; |
|
| 323 | 323 | endwhile; |
| 324 | 324 | |
| 325 | - } elseif ( $dates['range'] == 'this_week' || $dates['range'] == 'last_week' ) { |
|
| 325 | + } elseif ($dates['range'] == 'this_week' || $dates['range'] == 'last_week') { |
|
| 326 | 326 | |
| 327 | 327 | // Day by day. |
| 328 | 328 | $day = $dates['day']; |
| 329 | 329 | $day_end = $dates['day_end']; |
| 330 | 330 | $month = $dates['m_start']; |
| 331 | - while ( $day <= $day_end ) : |
|
| 331 | + while ($day <= $day_end) : |
|
| 332 | 332 | |
| 333 | - $date = mktime( 0, 0, 0, $month, $day, $dates['year'] ); |
|
| 334 | - $date_end = mktime( 0, 0, 0, $month, $day + 1, $dates['year'] ); |
|
| 335 | - $sales = $stats->get_sales( $form_id, $date, $date_end ); |
|
| 333 | + $date = mktime(0, 0, 0, $month, $day, $dates['year']); |
|
| 334 | + $date_end = mktime(0, 0, 0, $month, $day + 1, $dates['year']); |
|
| 335 | + $sales = $stats->get_sales($form_id, $date, $date_end); |
|
| 336 | 336 | $sales_totals += $sales; |
| 337 | 337 | |
| 338 | - $earnings = $stats->get_earnings( $form_id, $date, $date_end ); |
|
| 338 | + $earnings = $stats->get_earnings($form_id, $date, $date_end); |
|
| 339 | 339 | $earnings_totals += $earnings; |
| 340 | 340 | |
| 341 | - $sales_data[] = array( $date * 1000, $sales ); |
|
| 342 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
| 341 | + $sales_data[] = array($date * 1000, $sales); |
|
| 342 | + $earnings_data[] = array($date * 1000, $earnings); |
|
| 343 | 343 | |
| 344 | - $day ++; |
|
| 344 | + $day++; |
|
| 345 | 345 | endwhile; |
| 346 | 346 | |
| 347 | 347 | } else { |
| 348 | 348 | |
| 349 | 349 | $y = $dates['year']; |
| 350 | 350 | |
| 351 | - while ( $y <= $dates['year_end'] ) : |
|
| 351 | + while ($y <= $dates['year_end']) : |
|
| 352 | 352 | |
| 353 | 353 | $last_year = false; |
| 354 | 354 | |
| 355 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 355 | + if ($dates['year'] == $dates['year_end']) { |
|
| 356 | 356 | $month_start = $dates['m_start']; |
| 357 | 357 | $month_end = $dates['m_end']; |
| 358 | 358 | $last_year = true; |
| 359 | - } elseif ( $y == $dates['year'] ) { |
|
| 359 | + } elseif ($y == $dates['year']) { |
|
| 360 | 360 | $month_start = $dates['m_start']; |
| 361 | 361 | $month_end = 12; |
| 362 | 362 | } else { |
@@ -365,68 +365,68 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | $i = $month_start; |
| 368 | - while ( $i <= $month_end ) : |
|
| 368 | + while ($i <= $month_end) : |
|
| 369 | 369 | |
| 370 | - if ( $day_by_day ) { |
|
| 370 | + if ($day_by_day) { |
|
| 371 | 371 | |
| 372 | - if ( $i == $month_end && $last_year ) { |
|
| 372 | + if ($i == $month_end && $last_year) { |
|
| 373 | 373 | |
| 374 | 374 | $num_of_days = $dates['day_end']; |
| 375 | 375 | |
| 376 | 376 | } else { |
| 377 | 377 | |
| 378 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 378 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 379 | 379 | |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | $d = $dates['day']; |
| 383 | - while ( $d <= $num_of_days ) : |
|
| 383 | + while ($d <= $num_of_days) : |
|
| 384 | 384 | |
| 385 | - $date = mktime( 0, 0, 0, $i, $d, $y ); |
|
| 386 | - $end_date = mktime( 23, 59, 59, $i, $d, $y ); |
|
| 385 | + $date = mktime(0, 0, 0, $i, $d, $y); |
|
| 386 | + $end_date = mktime(23, 59, 59, $i, $d, $y); |
|
| 387 | 387 | |
| 388 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
| 388 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
| 389 | 389 | $sales_totals += $sales; |
| 390 | 390 | |
| 391 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
| 391 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
| 392 | 392 | $earnings_totals += $earnings; |
| 393 | 393 | |
| 394 | - $sales_data[] = array( $date * 1000, $sales ); |
|
| 395 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
| 396 | - $d ++; |
|
| 394 | + $sales_data[] = array($date * 1000, $sales); |
|
| 395 | + $earnings_data[] = array($date * 1000, $earnings); |
|
| 396 | + $d++; |
|
| 397 | 397 | |
| 398 | 398 | endwhile; |
| 399 | 399 | |
| 400 | 400 | } else { |
| 401 | 401 | |
| 402 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 402 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 403 | 403 | |
| 404 | - $date = mktime( 0, 0, 0, $i, 1, $y ); |
|
| 405 | - $end_date = mktime( 23, 59, 59, $i, $num_of_days, $y ); |
|
| 404 | + $date = mktime(0, 0, 0, $i, 1, $y); |
|
| 405 | + $end_date = mktime(23, 59, 59, $i, $num_of_days, $y); |
|
| 406 | 406 | |
| 407 | - $sales = $stats->get_sales( $form_id, $date, $end_date ); |
|
| 407 | + $sales = $stats->get_sales($form_id, $date, $end_date); |
|
| 408 | 408 | $sales_totals += $sales; |
| 409 | 409 | |
| 410 | - $earnings = $stats->get_earnings( $form_id, $date, $end_date ); |
|
| 410 | + $earnings = $stats->get_earnings($form_id, $date, $end_date); |
|
| 411 | 411 | $earnings_totals += $earnings; |
| 412 | 412 | |
| 413 | - $sales_data[] = array( $date * 1000, $sales ); |
|
| 414 | - $earnings_data[] = array( $date * 1000, $earnings ); |
|
| 413 | + $sales_data[] = array($date * 1000, $sales); |
|
| 414 | + $earnings_data[] = array($date * 1000, $earnings); |
|
| 415 | 415 | |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | - $i ++; |
|
| 418 | + $i++; |
|
| 419 | 419 | |
| 420 | 420 | endwhile; |
| 421 | 421 | |
| 422 | - $y ++; |
|
| 422 | + $y++; |
|
| 423 | 423 | endwhile; |
| 424 | 424 | |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | $data = array( |
| 428 | - __( 'Income', 'give' ) => $earnings_data, |
|
| 429 | - __( 'Donations', 'give' ) => $sales_data, |
|
| 428 | + __('Income', 'give') => $earnings_data, |
|
| 429 | + __('Donations', 'give') => $sales_data, |
|
| 430 | 430 | ); |
| 431 | 431 | |
| 432 | 432 | ?> |
@@ -434,8 +434,8 @@ discard block |
||
| 434 | 434 | <?php |
| 435 | 435 | printf( |
| 436 | 436 | /* translators: %s: form title */ |
| 437 | - esc_html__( 'Income Report for %s', 'give' ), |
|
| 438 | - get_the_title( $form_id ) |
|
| 437 | + esc_html__('Income Report for %s', 'give'), |
|
| 438 | + get_the_title($form_id) |
|
| 439 | 439 | ); |
| 440 | 440 | ?> |
| 441 | 441 | </span></h3> |
@@ -445,9 +445,9 @@ discard block |
||
| 445 | 445 | <div class="inside"> |
| 446 | 446 | <?php give_reports_graph_controls(); ?> |
| 447 | 447 | <?php |
| 448 | - $graph = new Give_Graph( $data, array( 'dataType' => array( 'amount', 'count' ) ) ); |
|
| 449 | - $graph->set( 'x_mode', 'time' ); |
|
| 450 | - $graph->set( 'multiple_y_axes', true ); |
|
| 448 | + $graph = new Give_Graph($data, array('dataType' => array('amount', 'count'))); |
|
| 449 | + $graph->set('x_mode', 'time'); |
|
| 450 | + $graph->set('multiple_y_axes', true); |
|
| 451 | 451 | $graph->display(); |
| 452 | 452 | ?> |
| 453 | 453 | </div> |
@@ -456,20 +456,20 @@ discard block |
||
| 456 | 456 | <table class="widefat reports-table alignleft" style="max-width:450px"> |
| 457 | 457 | <tbody> |
| 458 | 458 | <tr> |
| 459 | - <th scope="row"><strong><?php _e( 'Total income for period:', 'give' ); ?></strong></th> |
|
| 460 | - <td><?php echo give_currency_filter( give_format_amount( $earnings_totals, array( 'sanitize' => false ) ) ); ?></td> |
|
| 459 | + <th scope="row"><strong><?php _e('Total income for period:', 'give'); ?></strong></th> |
|
| 460 | + <td><?php echo give_currency_filter(give_format_amount($earnings_totals, array('sanitize' => false))); ?></td> |
|
| 461 | 461 | </tr> |
| 462 | 462 | <tr class="alternate"> |
| 463 | - <th scope="row"><strong><?php _e( 'Total donations for period:', 'give' ); ?></strong></th> |
|
| 463 | + <th scope="row"><strong><?php _e('Total donations for period:', 'give'); ?></strong></th> |
|
| 464 | 464 | <td><?php echo $sales_totals; ?></td> |
| 465 | 465 | </tr> |
| 466 | 466 | <tr> |
| 467 | - <th scope="row"><strong><?php _e( 'Average monthly income:', 'give' ); ?></strong></th> |
|
| 468 | - <td><?php echo give_currency_filter( give_format_amount( give_get_average_monthly_form_earnings( $form_id ), array( 'sanitize' => false ) ) ); ?></td> |
|
| 467 | + <th scope="row"><strong><?php _e('Average monthly income:', 'give'); ?></strong></th> |
|
| 468 | + <td><?php echo give_currency_filter(give_format_amount(give_get_average_monthly_form_earnings($form_id), array('sanitize' => false))); ?></td> |
|
| 469 | 469 | </tr> |
| 470 | 470 | <tr class="alternate"> |
| 471 | - <th scope="row"><strong><?php _e( 'Average monthly donations:', 'give' ); ?></strong></th> |
|
| 472 | - <td><?php echo number_format( give_get_average_monthly_form_sales( $form_id ), 0 ); ?></td> |
|
| 471 | + <th scope="row"><strong><?php _e('Average monthly donations:', 'give'); ?></strong></th> |
|
| 472 | + <td><?php echo number_format(give_get_average_monthly_form_sales($form_id), 0); ?></td> |
|
| 473 | 473 | </tr> |
| 474 | 474 | </tbody> |
| 475 | 475 | </table> |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | * |
| 483 | 483 | * @since 1.0 |
| 484 | 484 | */ |
| 485 | - do_action( 'give_reports_graph_additional_stats' ); |
|
| 485 | + do_action('give_reports_graph_additional_stats'); |
|
| 486 | 486 | ?> |
| 487 | 487 | |
| 488 | 488 | </div> |
@@ -502,26 +502,26 @@ discard block |
||
| 502 | 502 | function give_reports_graph_controls() { |
| 503 | 503 | $date_options = apply_filters( |
| 504 | 504 | 'give_report_date_options', array( |
| 505 | - 'today' => __( 'Today', 'give' ), |
|
| 506 | - 'yesterday' => __( 'Yesterday', 'give' ), |
|
| 507 | - 'this_week' => __( 'This Week', 'give' ), |
|
| 508 | - 'last_week' => __( 'Last Week', 'give' ), |
|
| 509 | - 'this_month' => __( 'This Month', 'give' ), |
|
| 510 | - 'last_month' => __( 'Last Month', 'give' ), |
|
| 511 | - 'this_quarter' => __( 'This Quarter', 'give' ), |
|
| 512 | - 'last_quarter' => __( 'Last Quarter', 'give' ), |
|
| 513 | - 'this_year' => __( 'This Year', 'give' ), |
|
| 514 | - 'last_year' => __( 'Last Year', 'give' ), |
|
| 515 | - 'other' => __( 'Custom', 'give' ), |
|
| 505 | + 'today' => __('Today', 'give'), |
|
| 506 | + 'yesterday' => __('Yesterday', 'give'), |
|
| 507 | + 'this_week' => __('This Week', 'give'), |
|
| 508 | + 'last_week' => __('Last Week', 'give'), |
|
| 509 | + 'this_month' => __('This Month', 'give'), |
|
| 510 | + 'last_month' => __('Last Month', 'give'), |
|
| 511 | + 'this_quarter' => __('This Quarter', 'give'), |
|
| 512 | + 'last_quarter' => __('Last Quarter', 'give'), |
|
| 513 | + 'this_year' => __('This Year', 'give'), |
|
| 514 | + 'last_year' => __('Last Year', 'give'), |
|
| 515 | + 'other' => __('Custom', 'give'), |
|
| 516 | 516 | ) |
| 517 | 517 | ); |
| 518 | 518 | |
| 519 | 519 | $dates = give_get_report_dates(); |
| 520 | 520 | $display = $dates['range'] == 'other' ? '' : 'display: none;'; |
| 521 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
| 521 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
| 522 | 522 | |
| 523 | - if ( empty( $dates['day_end'] ) ) { |
|
| 524 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, date( 'n' ), date( 'Y' ) ); |
|
| 523 | + if (empty($dates['day_end'])) { |
|
| 524 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, date('n'), date('Y')); |
|
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | /** |
@@ -529,7 +529,7 @@ discard block |
||
| 529 | 529 | * |
| 530 | 530 | * @since 1.0 |
| 531 | 531 | */ |
| 532 | - do_action( 'give_report_graph_controls_before' ); |
|
| 532 | + do_action('give_report_graph_controls_before'); |
|
| 533 | 533 | ?> |
| 534 | 534 | <form id="give-graphs-filter" method="get"> |
| 535 | 535 | <div class="tablenav top"> |
@@ -537,56 +537,56 @@ discard block |
||
| 537 | 537 | |
| 538 | 538 | <input type="hidden" name="post_type" value="give_forms" /> |
| 539 | 539 | <input type="hidden" name="page" value="give-reports" /> |
| 540 | - <input type="hidden" name="tab" value="<?php echo esc_attr( $tab ); ?>" /> |
|
| 540 | + <input type="hidden" name="tab" value="<?php echo esc_attr($tab); ?>" /> |
|
| 541 | 541 | |
| 542 | - <?php if ( isset( $_GET['form-id'] ) ) : ?> |
|
| 543 | - <input type="hidden" name="form-id" value="<?php echo absint( $_GET['form-id'] ); ?>" /> |
|
| 542 | + <?php if (isset($_GET['form-id'])) : ?> |
|
| 543 | + <input type="hidden" name="form-id" value="<?php echo absint($_GET['form-id']); ?>" /> |
|
| 544 | 544 | <?php endif; ?> |
| 545 | 545 | |
| 546 | 546 | <div id="give-graphs-date-options-wrap"> |
| 547 | 547 | <select id="give-graphs-date-options" name="range"> |
| 548 | - <?php foreach ( $date_options as $key => $option ) : ?> |
|
| 549 | - <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $dates['range'] ); ?>><?php echo esc_html( $option ); ?></option> |
|
| 548 | + <?php foreach ($date_options as $key => $option) : ?> |
|
| 549 | + <option value="<?php echo esc_attr($key); ?>"<?php selected($key, $dates['range']); ?>><?php echo esc_html($option); ?></option> |
|
| 550 | 550 | <?php endforeach; ?> |
| 551 | 551 | </select> |
| 552 | 552 | |
| 553 | - <div id="give-date-range-options" style="<?php echo esc_attr( $display ); ?>"> |
|
| 554 | - <span class="screen-reader-text"><?php _e( 'From', 'give' ); ?> </span> |
|
| 553 | + <div id="give-date-range-options" style="<?php echo esc_attr($display); ?>"> |
|
| 554 | + <span class="screen-reader-text"><?php _e('From', 'give'); ?> </span> |
|
| 555 | 555 | <select id="give-graphs-month-start" name="m_start" aria-label="Start Month"> |
| 556 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
| 557 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_start'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
| 556 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
| 557 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_start'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
| 558 | 558 | <?php endfor; ?> |
| 559 | 559 | </select> |
| 560 | 560 | <select id="give-graphs-day-start" name="day" aria-label="Start Day"> |
| 561 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
| 562 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
| 561 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
| 562 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day'])); ?>><?php echo esc_html($i); ?></option> |
|
| 563 | 563 | <?php endfor; ?> |
| 564 | 564 | </select> |
| 565 | 565 | <select id="give-graphs-year-start" name="year" aria-label="Start Year"> |
| 566 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
| 567 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
| 566 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
| 567 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year'])); ?>><?php echo esc_html($i); ?></option> |
|
| 568 | 568 | <?php endfor; ?> |
| 569 | 569 | </select> |
| 570 | - <span class="screen-reader-text"><?php esc_html_e( 'To', 'give' ); ?> </span> |
|
| 570 | + <span class="screen-reader-text"><?php esc_html_e('To', 'give'); ?> </span> |
|
| 571 | 571 | <span>–</span> |
| 572 | 572 | <select id="give-graphs-month-end" name="m_end" aria-label="End Month"> |
| 573 | - <?php for ( $i = 1; $i <= 12; $i ++ ) : ?> |
|
| 574 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['m_end'] ) ); ?>><?php echo esc_html( give_month_num_to_name( $i ) ); ?></option> |
|
| 573 | + <?php for ($i = 1; $i <= 12; $i++) : ?> |
|
| 574 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['m_end'])); ?>><?php echo esc_html(give_month_num_to_name($i)); ?></option> |
|
| 575 | 575 | <?php endfor; ?> |
| 576 | 576 | </select> |
| 577 | 577 | <select id="give-graphs-day-end" name="day_end" aria-label="End Day"> |
| 578 | - <?php for ( $i = 1; $i <= 31; $i ++ ) : ?> |
|
| 579 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['day_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
| 578 | + <?php for ($i = 1; $i <= 31; $i++) : ?> |
|
| 579 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['day_end'])); ?>><?php echo esc_html($i); ?></option> |
|
| 580 | 580 | <?php endfor; ?> |
| 581 | 581 | </select> |
| 582 | 582 | <select id="give-graphs-year-end" name="year_end" aria-label="End Year"> |
| 583 | - <?php for ( $i = 2007; $i <= date( 'Y' ); $i ++ ) : ?> |
|
| 584 | - <option value="<?php echo absint( $i ); ?>" <?php echo esc_attr( selected( $i, $dates['year_end'] ) ); ?>><?php echo esc_html( $i ); ?></option> |
|
| 583 | + <?php for ($i = 2007; $i <= date('Y'); $i++) : ?> |
|
| 584 | + <option value="<?php echo absint($i); ?>" <?php echo esc_attr(selected($i, $dates['year_end'])); ?>><?php echo esc_html($i); ?></option> |
|
| 585 | 585 | <?php endfor; ?> |
| 586 | 586 | </select> |
| 587 | 587 | </div> |
| 588 | 588 | |
| 589 | - <input type="submit" class="button-secondary" value="<?php _e( 'Filter', 'give' ); ?>" /> |
|
| 589 | + <input type="submit" class="button-secondary" value="<?php _e('Filter', 'give'); ?>" /> |
|
| 590 | 590 | </div> |
| 591 | 591 | |
| 592 | 592 | <input type="hidden" name="give_action" value="filter_reports" /> |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | * |
| 600 | 600 | * @since 1.0 |
| 601 | 601 | */ |
| 602 | - do_action( 'give_report_graph_controls_after' ); |
|
| 602 | + do_action('give_report_graph_controls_after'); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /** |
@@ -615,66 +615,66 @@ discard block |
||
| 615 | 615 | function give_get_report_dates() { |
| 616 | 616 | $dates = array(); |
| 617 | 617 | |
| 618 | - $current_time = current_time( 'timestamp' ); |
|
| 618 | + $current_time = current_time('timestamp'); |
|
| 619 | 619 | |
| 620 | - $dates['range'] = isset( $_GET['range'] ) ? $_GET['range'] : 'this_month'; |
|
| 621 | - $dates['year'] = isset( $_GET['year'] ) ? $_GET['year'] : date( 'Y' ); |
|
| 622 | - $dates['year_end'] = isset( $_GET['year_end'] ) ? $_GET['year_end'] : date( 'Y' ); |
|
| 623 | - $dates['m_start'] = isset( $_GET['m_start'] ) ? $_GET['m_start'] : 1; |
|
| 624 | - $dates['m_end'] = isset( $_GET['m_end'] ) ? $_GET['m_end'] : 12; |
|
| 625 | - $dates['day'] = isset( $_GET['day'] ) ? $_GET['day'] : 1; |
|
| 626 | - $dates['day_end'] = isset( $_GET['day_end'] ) ? $_GET['day_end'] : cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
| 620 | + $dates['range'] = isset($_GET['range']) ? $_GET['range'] : 'this_month'; |
|
| 621 | + $dates['year'] = isset($_GET['year']) ? $_GET['year'] : date('Y'); |
|
| 622 | + $dates['year_end'] = isset($_GET['year_end']) ? $_GET['year_end'] : date('Y'); |
|
| 623 | + $dates['m_start'] = isset($_GET['m_start']) ? $_GET['m_start'] : 1; |
|
| 624 | + $dates['m_end'] = isset($_GET['m_end']) ? $_GET['m_end'] : 12; |
|
| 625 | + $dates['day'] = isset($_GET['day']) ? $_GET['day'] : 1; |
|
| 626 | + $dates['day_end'] = isset($_GET['day_end']) ? $_GET['day_end'] : cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
| 627 | 627 | |
| 628 | 628 | // Modify dates based on predefined ranges. |
| 629 | - switch ( $dates['range'] ) : |
|
| 629 | + switch ($dates['range']) : |
|
| 630 | 630 | |
| 631 | 631 | case 'this_month': |
| 632 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 633 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 632 | + $dates['m_start'] = date('n', $current_time); |
|
| 633 | + $dates['m_end'] = date('n', $current_time); |
|
| 634 | 634 | $dates['day'] = 1; |
| 635 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
| 636 | - $dates['year'] = date( 'Y' ); |
|
| 637 | - $dates['year_end'] = date( 'Y' ); |
|
| 635 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
| 636 | + $dates['year'] = date('Y'); |
|
| 637 | + $dates['year_end'] = date('Y'); |
|
| 638 | 638 | break; |
| 639 | 639 | |
| 640 | 640 | case 'last_month': |
| 641 | - if ( date( 'n' ) == 1 ) { |
|
| 641 | + if (date('n') == 1) { |
|
| 642 | 642 | $dates['m_start'] = 12; |
| 643 | 643 | $dates['m_end'] = 12; |
| 644 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
| 645 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
| 644 | + $dates['year'] = date('Y', $current_time) - 1; |
|
| 645 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
| 646 | 646 | } else { |
| 647 | - $dates['m_start'] = date( 'n' ) - 1; |
|
| 648 | - $dates['m_end'] = date( 'n' ) - 1; |
|
| 647 | + $dates['m_start'] = date('n') - 1; |
|
| 648 | + $dates['m_end'] = date('n') - 1; |
|
| 649 | 649 | $dates['year_end'] = $dates['year']; |
| 650 | 650 | } |
| 651 | - $dates['day_end'] = cal_days_in_month( CAL_GREGORIAN, $dates['m_end'], $dates['year'] ); |
|
| 651 | + $dates['day_end'] = cal_days_in_month(CAL_GREGORIAN, $dates['m_end'], $dates['year']); |
|
| 652 | 652 | break; |
| 653 | 653 | |
| 654 | 654 | case 'today': |
| 655 | - $dates['day'] = date( 'd', $current_time ); |
|
| 656 | - $dates['day_end'] = date( 'd', $current_time ); |
|
| 657 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 658 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 659 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 660 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
| 655 | + $dates['day'] = date('d', $current_time); |
|
| 656 | + $dates['day_end'] = date('d', $current_time); |
|
| 657 | + $dates['m_start'] = date('n', $current_time); |
|
| 658 | + $dates['m_end'] = date('n', $current_time); |
|
| 659 | + $dates['year'] = date('Y', $current_time); |
|
| 660 | + $dates['year_end'] = date('Y', $current_time); |
|
| 661 | 661 | break; |
| 662 | 662 | |
| 663 | 663 | case 'yesterday': |
| 664 | - $year = date( 'Y', $current_time ); |
|
| 665 | - $month = date( 'n', $current_time ); |
|
| 666 | - $day = date( 'd', $current_time ); |
|
| 664 | + $year = date('Y', $current_time); |
|
| 665 | + $month = date('n', $current_time); |
|
| 666 | + $day = date('d', $current_time); |
|
| 667 | 667 | |
| 668 | - if ( $month == 1 && $day == 1 ) { |
|
| 668 | + if ($month == 1 && $day == 1) { |
|
| 669 | 669 | |
| 670 | 670 | $year -= 1; |
| 671 | 671 | $month = 12; |
| 672 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 672 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 673 | 673 | |
| 674 | - } elseif ( $month > 1 && $day == 1 ) { |
|
| 674 | + } elseif ($month > 1 && $day == 1) { |
|
| 675 | 675 | |
| 676 | 676 | $month -= 1; |
| 677 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 677 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 678 | 678 | |
| 679 | 679 | } else { |
| 680 | 680 | |
@@ -690,48 +690,48 @@ discard block |
||
| 690 | 690 | break; |
| 691 | 691 | |
| 692 | 692 | case 'this_week': |
| 693 | - $dates['day'] = date( 'd', $current_time - ( date( 'w', $current_time ) - 1 ) * 60 * 60 * 24 ) - 1; |
|
| 694 | - $dates['day'] += get_option( 'start_of_week' ); |
|
| 693 | + $dates['day'] = date('d', $current_time - (date('w', $current_time) - 1) * 60 * 60 * 24) - 1; |
|
| 694 | + $dates['day'] += get_option('start_of_week'); |
|
| 695 | 695 | $dates['day_end'] = $dates['day'] + 6; |
| 696 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 697 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 698 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 696 | + $dates['m_start'] = date('n', $current_time); |
|
| 697 | + $dates['m_end'] = date('n', $current_time); |
|
| 698 | + $dates['year'] = date('Y', $current_time); |
|
| 699 | 699 | break; |
| 700 | 700 | |
| 701 | 701 | case 'last_week': |
| 702 | - $dates['day'] = date( 'd', $current_time - ( date( 'w' ) - 1 ) * 60 * 60 * 24 ) - 8; |
|
| 703 | - $dates['day'] += get_option( 'start_of_week' ); |
|
| 702 | + $dates['day'] = date('d', $current_time - (date('w') - 1) * 60 * 60 * 24) - 8; |
|
| 703 | + $dates['day'] += get_option('start_of_week'); |
|
| 704 | 704 | $dates['day_end'] = $dates['day'] + 6; |
| 705 | - $dates['year'] = date( 'Y' ); |
|
| 706 | - |
|
| 707 | - if ( date( 'j', $current_time ) <= 7 ) { |
|
| 708 | - $dates['m_start'] = date( 'n', $current_time ) - 1; |
|
| 709 | - $dates['m_end'] = date( 'n', $current_time ) - 1; |
|
| 710 | - if ( $dates['m_start'] <= 1 ) { |
|
| 711 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
| 712 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
| 705 | + $dates['year'] = date('Y'); |
|
| 706 | + |
|
| 707 | + if (date('j', $current_time) <= 7) { |
|
| 708 | + $dates['m_start'] = date('n', $current_time) - 1; |
|
| 709 | + $dates['m_end'] = date('n', $current_time) - 1; |
|
| 710 | + if ($dates['m_start'] <= 1) { |
|
| 711 | + $dates['year'] = date('Y', $current_time) - 1; |
|
| 712 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
| 713 | 713 | } |
| 714 | 714 | } else { |
| 715 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 716 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 715 | + $dates['m_start'] = date('n', $current_time); |
|
| 716 | + $dates['m_end'] = date('n', $current_time); |
|
| 717 | 717 | } |
| 718 | 718 | break; |
| 719 | 719 | |
| 720 | 720 | case 'this_quarter': |
| 721 | - $month_now = date( 'n', $current_time ); |
|
| 722 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 721 | + $month_now = date('n', $current_time); |
|
| 722 | + $dates['year'] = date('Y', $current_time); |
|
| 723 | 723 | |
| 724 | - if ( $month_now <= 3 ) { |
|
| 724 | + if ($month_now <= 3) { |
|
| 725 | 725 | |
| 726 | 726 | $dates['m_start'] = 1; |
| 727 | 727 | $dates['m_end'] = 4; |
| 728 | 728 | |
| 729 | - } elseif ( $month_now <= 6 ) { |
|
| 729 | + } elseif ($month_now <= 6) { |
|
| 730 | 730 | |
| 731 | 731 | $dates['m_start'] = 4; |
| 732 | 732 | $dates['m_end'] = 7; |
| 733 | 733 | |
| 734 | - } elseif ( $month_now <= 9 ) { |
|
| 734 | + } elseif ($month_now <= 9) { |
|
| 735 | 735 | |
| 736 | 736 | $dates['m_start'] = 7; |
| 737 | 737 | $dates['m_end'] = 10; |
@@ -740,28 +740,28 @@ discard block |
||
| 740 | 740 | |
| 741 | 741 | $dates['m_start'] = 10; |
| 742 | 742 | $dates['m_end'] = 1; |
| 743 | - $dates['year_end'] = date( 'Y', $current_time ) + 1; |
|
| 743 | + $dates['year_end'] = date('Y', $current_time) + 1; |
|
| 744 | 744 | |
| 745 | 745 | } |
| 746 | 746 | break; |
| 747 | 747 | |
| 748 | 748 | case 'last_quarter': |
| 749 | - $month_now = date( 'n', $current_time ); |
|
| 750 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 751 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
| 749 | + $month_now = date('n', $current_time); |
|
| 750 | + $dates['year'] = date('Y', $current_time); |
|
| 751 | + $dates['year_end'] = date('Y', $current_time); |
|
| 752 | 752 | |
| 753 | - if ( $month_now <= 3 ) { |
|
| 753 | + if ($month_now <= 3) { |
|
| 754 | 754 | |
| 755 | 755 | $dates['m_start'] = 10; |
| 756 | 756 | $dates['m_end'] = 1; |
| 757 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year. |
|
| 757 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year. |
|
| 758 | 758 | |
| 759 | - } elseif ( $month_now <= 6 ) { |
|
| 759 | + } elseif ($month_now <= 6) { |
|
| 760 | 760 | |
| 761 | 761 | $dates['m_start'] = 1; |
| 762 | 762 | $dates['m_end'] = 4; |
| 763 | 763 | |
| 764 | - } elseif ( $month_now <= 9 ) { |
|
| 764 | + } elseif ($month_now <= 9) { |
|
| 765 | 765 | |
| 766 | 766 | $dates['m_start'] = 4; |
| 767 | 767 | $dates['m_end'] = 7; |
@@ -777,20 +777,20 @@ discard block |
||
| 777 | 777 | case 'this_year': |
| 778 | 778 | $dates['m_start'] = 1; |
| 779 | 779 | $dates['m_end'] = 12; |
| 780 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 781 | - $dates['year_end'] = date( 'Y', $current_time ); |
|
| 780 | + $dates['year'] = date('Y', $current_time); |
|
| 781 | + $dates['year_end'] = date('Y', $current_time); |
|
| 782 | 782 | break; |
| 783 | 783 | |
| 784 | 784 | case 'last_year': |
| 785 | 785 | $dates['m_start'] = 1; |
| 786 | 786 | $dates['m_end'] = 12; |
| 787 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
| 788 | - $dates['year_end'] = date( 'Y', $current_time ) - 1; |
|
| 787 | + $dates['year'] = date('Y', $current_time) - 1; |
|
| 788 | + $dates['year_end'] = date('Y', $current_time) - 1; |
|
| 789 | 789 | break; |
| 790 | 790 | |
| 791 | 791 | endswitch; |
| 792 | 792 | |
| 793 | - return apply_filters( 'give_report_dates', $dates ); |
|
| 793 | + return apply_filters('give_report_dates', $dates); |
|
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /** |
@@ -801,18 +801,18 @@ discard block |
||
| 801 | 801 | * |
| 802 | 802 | * @param $data |
| 803 | 803 | */ |
| 804 | -function give_parse_report_dates( $data ) { |
|
| 804 | +function give_parse_report_dates($data) { |
|
| 805 | 805 | $dates = give_get_report_dates(); |
| 806 | 806 | |
| 807 | 807 | $view = give_get_reporting_view(); |
| 808 | - $tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'earnings'; |
|
| 809 | - $id = isset( $_GET['form-id'] ) ? $_GET['form-id'] : null; |
|
| 808 | + $tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'earnings'; |
|
| 809 | + $id = isset($_GET['form-id']) ? $_GET['form-id'] : null; |
|
| 810 | 810 | |
| 811 | - wp_redirect( add_query_arg( $dates, admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=' . esc_attr( $tab ) . '&view=' . esc_attr( $view ) . '&form-id=' . absint( $id ) ) ) ); |
|
| 811 | + wp_redirect(add_query_arg($dates, admin_url('edit.php?post_type=give_forms&page=give-reports&tab='.esc_attr($tab).'&view='.esc_attr($view).'&form-id='.absint($id)))); |
|
| 812 | 812 | give_die(); |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | -add_action( 'give_filter_reports', 'give_parse_report_dates' ); |
|
| 815 | +add_action('give_filter_reports', 'give_parse_report_dates'); |
|
| 816 | 816 | |
| 817 | 817 | |
| 818 | 818 | /** |
@@ -835,8 +835,8 @@ discard block |
||
| 835 | 835 | |
| 836 | 836 | echo Give()->tooltips->render_link( |
| 837 | 837 | array( |
| 838 | - 'label' => esc_attr__( 'Clicking this will clear the reports cache.', 'give' ), |
|
| 839 | - 'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>' . esc_html__( 'Refresh Report Data', 'give' ), |
|
| 838 | + 'label' => esc_attr__('Clicking this will clear the reports cache.', 'give'), |
|
| 839 | + 'tag_content' => '<span class="give-admin-button-icon give-admin-button-icon-update"></span>'.esc_html__('Refresh Report Data', 'give'), |
|
| 840 | 840 | 'link' => $url, |
| 841 | 841 | 'position' => 'left', |
| 842 | 842 | 'attributes' => array( |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | ); |
| 847 | 847 | } |
| 848 | 848 | |
| 849 | -add_action( 'give_reports_graph_additional_stats', 'give_reports_refresh_button' ); |
|
| 849 | +add_action('give_reports_graph_additional_stats', 'give_reports_refresh_button'); |
|
| 850 | 850 | |
| 851 | 851 | /** |
| 852 | 852 | * Trigger the refresh of reports transients |
@@ -857,20 +857,20 @@ discard block |
||
| 857 | 857 | * |
| 858 | 858 | * @return void |
| 859 | 859 | */ |
| 860 | -function give_run_refresh_reports_transients( $data ) { |
|
| 860 | +function give_run_refresh_reports_transients($data) { |
|
| 861 | 861 | |
| 862 | - if ( ! wp_verify_nonce( $data['_wpnonce'], 'give-refresh-reports' ) ) { |
|
| 862 | + if ( ! wp_verify_nonce($data['_wpnonce'], 'give-refresh-reports')) { |
|
| 863 | 863 | return; |
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | // Monthly stats. |
| 867 | - Give_Cache::delete( Give_Cache::get_key( 'give_estimated_monthly_stats' ) ); |
|
| 867 | + Give_Cache::delete(Give_Cache::get_key('give_estimated_monthly_stats')); |
|
| 868 | 868 | |
| 869 | 869 | // Total earning. |
| 870 | - delete_option( 'give_earnings_total' ); |
|
| 870 | + delete_option('give_earnings_total'); |
|
| 871 | 871 | |
| 872 | 872 | // @todo: Refresh only range related stat cache |
| 873 | 873 | give_delete_donation_stats(); |
| 874 | 874 | } |
| 875 | 875 | |
| 876 | -add_action( 'give_refresh_reports_transients', 'give_run_refresh_reports_transients' ); |
|
| 876 | +add_action('give_refresh_reports_transients', 'give_run_refresh_reports_transients'); |
|