2026-07-07 15:53:33 -03:00
|
|
|
<?php
|
|
|
|
|
|
2026-07-07 16:28:09 -03:00
|
|
|
namespace Kanboard\Plugin\FinanceBuddy;
|
2026-07-07 15:53:33 -03:00
|
|
|
|
|
|
|
|
use Kanboard\Core\Plugin\Base;
|
|
|
|
|
|
|
|
|
|
class Plugin extends Base
|
|
|
|
|
{
|
|
|
|
|
public function initialize()
|
|
|
|
|
{
|
2026-07-07 16:28:09 -03:00
|
|
|
// Plugin stylesheet. Empty for now; the money badge and per-column total styling
|
|
|
|
|
// are added as those features land in later versions.
|
2026-07-07 15:53:33 -03:00
|
|
|
$this->hook->on('template:layout:css', array(
|
2026-07-07 16:28:09 -03:00
|
|
|
'template' => 'plugins/FinanceBuddy/Asset/css/finance.css',
|
2026-07-07 15:53:33 -03:00
|
|
|
));
|
2026-07-07 16:33:23 -03:00
|
|
|
|
|
|
|
|
// Per-board opt-in: a checkbox on the project's Settings -> Integrations page. Nothing
|
|
|
|
|
// else in the plugin renders or saves until a project manager enables it for that board.
|
|
|
|
|
$this->template->hook->attach('template:project:integrations', 'financeBuddy:project/integration');
|
2026-07-07 16:50:40 -03:00
|
|
|
|
|
|
|
|
// Finance fields in the task create/edit form (middle column). The template gates itself
|
|
|
|
|
// on the board being enabled. These are not task columns, so core cannot persist them:
|
|
|
|
|
// FinancePersistence strips them from the task write and stores them in task metadata,
|
|
|
|
|
// all synchronously via the model hooks below.
|
|
|
|
|
$this->template->hook->attach('template:task:form:second-column', 'financeBuddy:task/form_fields');
|
|
|
|
|
|
|
|
|
|
$persistence = new \Kanboard\Plugin\FinanceBuddy\Model\FinancePersistence($this->container);
|
|
|
|
|
$this->hook->on('model:task:creation:prepare', array($persistence, 'onCreationPrepare'));
|
|
|
|
|
$this->hook->on('model:task:creation:aftersave', array($persistence, 'onCreationAfterSave'));
|
|
|
|
|
$this->hook->on('model:task:modification:prepare', array($persistence, 'onModificationPrepare'));
|
2026-07-07 16:59:11 -03:00
|
|
|
|
|
|
|
|
// The line-3 money badge on each board card, rendered directly under the title. Two hooks:
|
|
|
|
|
// "private" is the normal board, "public" is the read-only board shared by token.
|
|
|
|
|
$this->template->hook->attach('template:board:private:task:after-title', 'financeBuddy:board/task_money');
|
|
|
|
|
$this->template->hook->attach('template:board:public:task:after-title', 'financeBuddy:board/task_money');
|
2026-07-07 17:05:03 -03:00
|
|
|
|
|
|
|
|
// Per-column net total (credits - debits) in the column header.
|
|
|
|
|
$this->template->hook->attach('template:board:column:header', 'financeBuddy:board/column_total');
|
2026-07-07 16:33:23 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getHelpers()
|
|
|
|
|
{
|
|
|
|
|
return array(
|
|
|
|
|
'Plugin\FinanceBuddy\Helper' => array('FinanceHelper'),
|
|
|
|
|
);
|
2026-07-07 15:53:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPluginName()
|
|
|
|
|
{
|
2026-07-07 16:28:09 -03:00
|
|
|
return 'FinanceBuddy';
|
2026-07-07 15:53:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPluginDescription()
|
|
|
|
|
{
|
2026-07-07 16:28:09 -03:00
|
|
|
return t('Attach a money value (debit/credit and installments) to board cards, shown on the card and totalled per column. Opt-in per board.');
|
2026-07-07 15:53:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPluginAuthor()
|
|
|
|
|
{
|
|
|
|
|
return 'Ruben (drbeco)';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPluginVersion()
|
|
|
|
|
{
|
2026-07-07 17:11:08 -03:00
|
|
|
return '0.4.1';
|
2026-07-07 15:53:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getPluginHomepage()
|
|
|
|
|
{
|
2026-07-07 16:28:09 -03:00
|
|
|
return 'https://code.beco.cc/beco/FinanceBuddy';
|
2026-07-07 15:53:33 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getCompatibleVersion()
|
|
|
|
|
{
|
|
|
|
|
return '>=1.2.0';
|
|
|
|
|
}
|
|
|
|
|
}
|