footer.php
6 years ago
form-navigator.php
5 years ago
income-stats.php
6 years ago
introduction.php
6 years ago
progress-bar.php
6 years ago
income-stats.php
77 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @var int $formId |
| 4 | */ |
| 5 | if ( $form->has_goal() ) : ?> |
| 6 | <?php |
| 7 | $goalStats = give_goal_progress_stats( $formId ); |
| 8 | |
| 9 | // Setup default raised value |
| 10 | $raised = give_currency_filter( |
| 11 | give_format_amount( |
| 12 | $form->get_earnings(), |
| 13 | [ |
| 14 | 'sanitize' => false, |
| 15 | 'decimal' => false, |
| 16 | ] |
| 17 | ) |
| 18 | ); |
| 19 | |
| 20 | // Setup default count value |
| 21 | $count = $form->get_sales(); |
| 22 | |
| 23 | // Setup default count label |
| 24 | $countLabel = _n( 'donation', 'donations', $count, 'give' ); |
| 25 | |
| 26 | // Setup default goal value |
| 27 | $goal = give_currency_filter( |
| 28 | give_format_amount( |
| 29 | $form->get_goal(), |
| 30 | [ |
| 31 | 'sanitize' => false, |
| 32 | 'decimal' => false, |
| 33 | ] |
| 34 | ) |
| 35 | ); |
| 36 | |
| 37 | // Change values and labels based on goal format |
| 38 | switch ( $goalStats['format'] ) { |
| 39 | case 'percentage': { |
| 40 | $raised = "{$goalStats['progress']}%"; |
| 41 | break; |
| 42 | } |
| 43 | case 'donation': { |
| 44 | $count = $goalStats['actual']; |
| 45 | $goal = $goalStats['goal']; |
| 46 | break; |
| 47 | } |
| 48 | case 'donors': { |
| 49 | $count = $goalStats['actual']; |
| 50 | $countLabel = _n( 'donor', 'donors', $count, 'give' ); |
| 51 | $goal = $goalStats['goal']; |
| 52 | break; |
| 53 | } |
| 54 | } |
| 55 | ?> |
| 56 | <div class="income-stats"> |
| 57 | <div class="raised"> |
| 58 | <div class="number"> |
| 59 | <?php echo $raised; ?> |
| 60 | </div> |
| 61 | <div class="text"><?php _e( 'raised', 'give' ); ?></div> |
| 62 | </div> |
| 63 | <div class="count"> |
| 64 | <div class="number"> |
| 65 | <?php echo $count; ?> |
| 66 | </div> |
| 67 | <div class="text"><?php echo $countLabel; ?></div> |
| 68 | </div> |
| 69 | <div class="goal"> |
| 70 | <div class="number"> |
| 71 | <?php echo $goal; ?> |
| 72 | </div> |
| 73 | <div class="text"><?php _e( 'goal', 'give' ); ?></div> |
| 74 | </div> |
| 75 | </div> |
| 76 | <?php endif; ?> |
| 77 |