Files
FinanceBuddy/Template/board/task_money.php

33 lines
1.4 KiB
PHP

<?php
// Line-3 money badge, rendered under the card title via the after-title hooks. Server-side, so
// it re-renders correctly on every board refresh. Nothing shows unless the board is enabled and
// the card has a positive amount.
if (empty($task['project_id']) || ! $this->FinanceHelper->isEnabled($task['project_id'])) {
return;
}
$fb = $this->FinanceHelper->get($task['id']);
if ($fb['amount'] === '' || (float) $fb['amount'] <= 0) {
return;
}
$credit = $fb['direction'] === 'credit';
$sign = $credit ? '+' : '-';
$total = $fb['installment_total'];
$current = $fb['installment_current'];
// Installments: "p2/10" when a total is set; "p2" (open-ended) when only the current is set;
// nothing when neither is set. Default the current to 1 if only a total was entered.
$show_installments = $current !== '' || $total !== '';
$current_display = $current !== '' ? $current : '1';
?>
<div class="fb-line">
<span class="fb-badge <?= $credit ? 'fb-badge-credit' : 'fb-badge-debit' ?>">
<?= $sign ?><?= $this->text->e($this->FinanceHelper->currency($task['project_id'])) ?><?= \Kanboard\Plugin\FinanceBuddy\Helper\FinanceHelper::money($fb['amount']) ?>
</span>
<?php if ($show_installments): ?>
<span class="fb-installments">p<?= $this->text->e($current_display) ?><?= $total !== '' ? '/'.$this->text->e($total) : '' ?></span>
<?php endif ?>
</div>