DateCreatedColumn.php
3 years ago
DonationCountColumn.php
8 months ago
DonationRevenueColumn.php
1 year ago
GoalColumn.php
1 year ago
IdColumn.php
3 years ago
LevelsColumn.php
3 years ago
ShortcodeColumn.php
3 years ago
StatusColumn.php
1 year ago
TitleColumn.php
1 year ago
DonationRevenueColumn.php
66 lines
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Give\DonationForms\V2\ListTable\Columns; |
| 6 | |
| 7 | use Give\DonationForms\Repositories\DonationFormDataRepository; |
| 8 | use Give\DonationForms\V2\Models\DonationForm; |
| 9 | use Give\Framework\ListTable\ModelColumn; |
| 10 | use Give\Framework\Support\ValueObjects\Money; |
| 11 | |
| 12 | /** |
| 13 | * @since 2.24.0 |
| 14 | * |
| 15 | * @extends ModelColumn<DonationForm> |
| 16 | */ |
| 17 | class DonationRevenueColumn extends ModelColumn |
| 18 | { |
| 19 | |
| 20 | /** |
| 21 | * @since 2.24.0 |
| 22 | * |
| 23 | * @inheritDoc |
| 24 | */ |
| 25 | public static function getId(): string |
| 26 | { |
| 27 | return 'donationRevenue'; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @since 2.24.0 |
| 32 | * |
| 33 | * @inheritDoc |
| 34 | */ |
| 35 | public function getLabel(): string |
| 36 | { |
| 37 | return __('Revenue', 'give'); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * @since 4.3.0 use DonationFormDataRepository |
| 42 | * @since 3.16.0 Add filter to change the cell value content |
| 43 | * @since 2.24.0 |
| 44 | * |
| 45 | * @inheritDoc |
| 46 | * |
| 47 | * @param DonationForm $model |
| 48 | */ |
| 49 | public function getCellValue($model, $locale = ''): string |
| 50 | { |
| 51 | /** |
| 52 | * @var DonationFormDataRepository $donationFormData |
| 53 | */ |
| 54 | $donationFormData = $this->getListTableData(); |
| 55 | |
| 56 | $revenue = Money::fromDecimal($donationFormData->getRevenue($model), give_get_currency())->formatToLocale(); |
| 57 | |
| 58 | return sprintf( |
| 59 | '<a class="column-earnings-value" href="%s" aria-label="%s">%s</a>', |
| 60 | admin_url("edit.php?post_type=give_forms&page=give-reports&tab=forms&legacy=true&form-id=$model->id"), |
| 61 | __('Visit form reports page', 'give'), |
| 62 | apply_filters("givewp_list_table_cell_value_{$this::getId()}_content", $revenue, $model, $this) |
| 63 | ); |
| 64 | } |
| 65 | } |
| 66 |