Skip to content

Firefly III: a personal finances manager

Show attachments for budgets #2828

James Cole417a0d0f83f5
diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php
index 4690f03887..69d4e2dc4d 100644
--- a/app/Http/Controllers/Budget/IndexController.php
+++ b/app/Http/Controllers/Budget/IndexController.php
@@ -160,6 +160,7 @@ class IndexController extends Controller
$array = $current->toArray();
$array['spent'] = [];
$array['budgeted'] = [];
+ $array['attachments'] = $this->repository->getAttachments($current);
$array['auto_budget'] = $this->repository->getAutoBudget($current);
$budgetLimits = $this->blRepository->getBudgetLimits($current, $start, $end);
diff --git a/app/Http/Controllers/Budget/ShowController.php b/app/Http/Controllers/Budget/ShowController.php
index 5676e77660..3938a1d79b 100644
--- a/app/Http/Controllers/Budget/ShowController.php
+++ b/app/Http/Controllers/Budget/ShowController.php
@@ -31,6 +31,7 @@ use FireflyIII\Http\Controllers\Controller;
use FireflyIII\Models\Budget;
use FireflyIII\Models\BudgetLimit;
use FireflyIII\Models\TransactionType;
+use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Support\Http\Controllers\AugumentData;
use FireflyIII\Support\Http\Controllers\PeriodOverview;
@@ -48,6 +49,9 @@ class ShowController extends Controller
/** @var JournalRepositoryInterface */
private $journalRepos;
+ /** @var BudgetRepositoryInterface */
+ private $repository;
+
/**
* ShowController constructor.
*
@@ -62,6 +66,7 @@ class ShowController extends Controller
app('view')->share('title', (string) trans('firefly.budgets'));
app('view')->share('mainTitleIcon', 'fa-tasks');
$this->journalRepos = app(JournalRepositoryInterface::class);
+ $this->repository = app(BudgetRepositoryInterface::class);
return $next($request);
}
@@ -158,6 +163,7 @@ class ShowController extends Controller
$pageSize = (int) app('preferences')->get('listPageSize', 50)->data;
$limits = $this->getLimits($budget, $allStart, $allEnd);
$repetition = null;
+ $attachments = $this->repository->getAttachments($budget);
// collector:
/** @var GroupCollectorInterface $collector */
@@ -170,7 +176,7 @@ class ShowController extends Controller
$subTitle = (string) trans('firefly.all_journals_for_budget', ['name' => $budget->name]);
- return view('budgets.show', compact('limits', 'budget', 'repetition', 'groups', 'subTitle'));
+ return view('budgets.show', compact('limits','attachments', 'budget', 'repetition', 'groups', 'subTitle'));
}
/**
@@ -212,8 +218,9 @@ class ShowController extends Controller
/** @var Carbon $start */
$start = session('first', Carbon::now()->startOfYear());
$end = new Carbon;
+ $attachments = $this->repository->getAttachments($budget);
$limits = $this->getLimits($budget, $start, $end);
- return view('budgets.show', compact('limits', 'budget', 'budgetLimit', 'groups', 'subTitle'));
+ return view('budgets.show', compact('limits','attachments', 'budget', 'budgetLimit', 'groups', 'subTitle'));
}
}
diff --git a/resources/views/v1/bills/show.twig b/resources/views/v1/bills/show.twig
index c23b38dd8c..c9371e745f 100644
--- a/resources/views/v1/bills/show.twig
+++ b/resources/views/v1/bills/show.twig
@@ -114,7 +114,7 @@
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
- {% include 'list.attachments' %}
+ {% include 'list.attachments' %}
</div>
</div>
{% endif %}
diff --git a/resources/views/v1/budgets/index.twig b/resources/views/v1/budgets/index.twig
index 12495926c8..f0a23462c1 100644
--- a/resources/views/v1/budgets/index.twig
+++ b/resources/views/v1/budgets/index.twig
@@ -234,6 +234,7 @@
</div>
</td>
<td data-value="{{ budget.name }}">
+ <a href="{{ route('budgets.show',budget.id) }}" data-id="{{ budget.id }}">{{ budget.name }}</a>
{% if budget.auto_budget %}
{% if 1 == budget.auto_budget.auto_budget_type %}
<i class="fa fa-fw fa-calendar-check-o" title="{{ 'auto_budget_reset_icon'|_ }}"></i>
@@ -242,7 +243,9 @@
<i class="fa fa-fw fa-calendar-plus-o" title="{{ 'auto_budget_rollover_icon'|_ }}"></i>
{% endif %}
{% endif %}
- <a href="{{ route('budgets.show',budget.id) }}" data-id="{{ budget.id }}">{{ budget.name }}</a>
+ {% if budget.attachments.count > 0 %}
+ <i class="fa fa-paperclip"></i>
+ {% endif %}
</td>
<td data-value="-1">
{% if 0==budget.budgeted|length %}
diff --git a/resources/views/v1/budgets/show.twig b/resources/views/v1/budgets/show.twig
index 37657d7435..4168d88229 100644
--- a/resources/views/v1/budgets/show.twig
+++ b/resources/views/v1/budgets/show.twig
@@ -6,7 +6,7 @@
{% block content %}
<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12">
+ <div class="{% if attachments.count == 0 %}col-lg-12 col-md-12 col-sm-12 col-xs-12{% else %}col-lg-8 col-md-6 col-sm-12 col-xs-12{% endif %}">
<div class="box">
<div class="box-header with-border">
<h3 class="box-title">
@@ -38,6 +38,20 @@
{% endif %}
</div>
</div>
+ {% if attachments.count > 0 %}
+ <div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">
+ <div class="box">
+ <div class="box-header with-border">
+ <h3 class="box-title">
+ {{ 'attachments'|_ }}
+ </h3>
+ </div>
+ <div class="box-body table-responsive no-padding">
+ {% include 'list.attachments' %}
+ </div>
+ </div>
+ </div>
+ {% endif %}
</div>
<div class="row">
<div class="col-lg-4 col-md-6 col-sm-12 col-xs-12">