*/
class StatusColumn extends ModelColumn
{
protected $sortColumn = 'status';
/**
* @since 2.24.0
*
* @inheritDoc
*/
public static function getId(): string
{
return 'status';
}
/**
* @since 2.24.0
*
* @inheritDoc
*/
public function getLabel(): string
{
return __('Status', 'give');
}
/**
* @since 2.24.0
*
* @inheritDoc
*
* @param Subscription $model
*/
public function getCellValue($model): string
{
$template = '
';
$extraTemplate = '
%4$s
';
if ($model->status->isFailing()) {
$extra = [
'label' => __('failed', 'give'),
'status' => 'failed',
'text' => __('This subscription has failed', 'give'),
];
} elseif ($model->isIndefinite()) {
$extra = [
'label' => __('indefinite', 'give'),
'status' => 'indefinite',
'text' => __('This subscription continues indefinitely', 'give'),
];
} elseif ($model->hasExceededTheMaxInstallments()) {
$extra = [
'label' => __('exceeded', 'give'),
'status' => 'exceeded',
'text' => __('This subscription has exceeded the expected donations. Try syncing with the gateway and cancelling if necessary.',
'give'),
];
} elseif (0 < ($remainingInstallments = $model->remainingInstallments())) {
$extra = [
'label' => __('limited', 'give'),
'status' => 'limited',
'text' => sprintf(
_n(
'This subscription has %s remaining donation',
'This subscription has %s remaining donations',
$remainingInstallments,
'give'
),
$remainingInstallments
),
];
}
return sprintf(
$template,
$model->status,
$model->status->label(),
isset($extra) ? sprintf(
$extraTemplate,
GIVE_PLUGIN_URL . 'build/assets/dist/images/list-table/' . $extra['status'] . '-subscription-icon.svg',
$extra['label'],
$extra['status'],
$extra['text']
) : ''
);
}
}