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