Skip to content

Firefly III: a personal finances manager

Attachments for accounts are visible #2828

James Cole2a46756838c3
diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php
index ea8d7bc57f..8dab8f94dc 100644
--- a/app/Http/Controllers/Account/ShowController.php
+++ b/app/Http/Controllers/Account/ShowController.php
@@ -103,6 +103,7 @@ class ShowController extends Controller
[$start, $end] = [$end, $start]; // @codeCoverageIgnore
}
$location = $this->repository->getLocation($account);
+ $attachments = $this->repository->getAttachments($account);
$objectType = config(sprintf('firefly.shortNamesByFullName.%s', $account->accountType->type));
$today = new Carbon;
$subTitleIcon = config(sprintf('firefly.subIconsByIdentifier.%s', $account->accountType->type));
@@ -139,6 +140,7 @@ class ShowController extends Controller
'periods',
'subTitleIcon',
'groups',
+ 'attachments',
'subTitle',
'start',
'end',
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index c3bb6a12f1..fa9662c1c3 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -311,7 +311,7 @@ class AccountRepository implements AccountRepositoryInterface
$query = $this->user->accounts()->with(
['accountmeta' => function (HasMany $query) {
$query->where('name', 'account_role');
- }]
+ }, 'attachments']
);
if (count($types) > 0) {
$query->accountTypeIn($types);
diff --git a/resources/views/v1/accounts/show.twig b/resources/views/v1/accounts/show.twig
index 8a16f6d0da..a291392c01 100644
--- a/resources/views/v1/accounts/show.twig
+++ b/resources/views/v1/accounts/show.twig
@@ -7,7 +7,7 @@
{% block content %}
<div class="row">
- <div class="col-lg-12 col-md-12 col-sm-12 col-xs-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">
@@ -32,6 +32,20 @@
</div>
</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>
{% if not showAll and isLiability %}
<div class="row">
diff --git a/resources/views/v1/list/accounts.twig b/resources/views/v1/list/accounts.twig
index 1dddd28799..00749294d6 100644
--- a/resources/views/v1/list/accounts.twig
+++ b/resources/views/v1/list/accounts.twig
@@ -42,6 +42,9 @@
{% if account.location %}
<i class="fa fa-fw fa-map-marker"></i>
{% endif %}
+ {% if account.attachments.count > 0 %}
+ <i class="fa fa-fw fa-paperclip"></i>
+ {% endif %}
</td>
{% if objectType == "asset" %}
<td class="hidden-sm hidden-xs hidden-md">
diff --git a/resources/views/v1/list/attachments.twig b/resources/views/v1/list/attachments.twig
new file mode 100644
index 0000000000..abfdba55d3
--- /dev/null
+++ b/resources/views/v1/list/attachments.twig
@@ -0,0 +1,47 @@
+<table class="table table-hover">
+ {% for attachment in attachments %}
+ <tr>
+ <td style="width:120px;">
+ <div class="btn-group btn-group-xs">
+ <a href="{{ route('attachments.edit', attachment.id) }}" class="btn btn-default"><i
+ class="fa fa-pencil"></i></a>
+ <a href="{{ route('attachments.delete', attachment.id) }}" class="btn btn-danger"><i
+ class="fa fa-trash"></i></a>
+ {% if attachment.file_exists %}
+ <a href="{{ route('attachments.download', attachment.id) }}" class="btn btn-default"><i
+ class="fa fa-download"></i></a>
+ {% endif %}
+ {% if not attachment.file_exists %}
+ <a href="#" class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i></a>
+ {% endif %}
+ </div>
+ </td>
+ <td>
+ {% if attachment.file_exists %}
+ <i class="fa {{ attachment.mime|mimeIcon }}"></i>
+ <a href="{{ route('attachments.view', attachment.id) }}" title="{{ attachment.filename }}">
+ {% if attachment.title %}
+ {{ attachment.title }}
+ {% else %}
+ {{ attachment.filename }}
+ {% endif %}
+ </a>
+ ({{ attachment.size|filesize }})
+ {% if null != attachment.notes and '' != attachment.notes %}
+ {{ attachment.notes|markdown }}
+ {% endif %}
+ {% endif %}
+ {% if not attachment.file_exists %}
+ <i class="fa fa-fw fa-exclamation-triangle"></i>
+ {% if attachment.title %}
+ {{ attachment.title }}
+ {% else %}
+ {{ attachment.filename }}
+ {% endif %}
+ <br>
+ <span class="text-danger">{{ 'attachment_not_found'|_ }}</span>
+ {% endif %}
+ </td>
+ </tr>
+ {% endfor %}
+</table>
\ No newline at end of file
diff --git a/resources/views/v1/transactions/show.twig b/resources/views/v1/transactions/show.twig
index 7aad96c319..fc6b9810e4 100644
--- a/resources/views/v1/transactions/show.twig
+++ b/resources/views/v1/transactions/show.twig
@@ -325,53 +325,7 @@
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
</div>
<div class="box-body table-responsive no-padding">
- <table class="table table-hover">
- {% for attachment in attachments[journal.transaction_journal_id] %}
- <tr>
- <td style="width:120px;">
- <div class="btn-group btn-group-xs">
- <a href="{{ route('attachments.edit', attachment.id) }}" class="btn btn-default"><i
- class="fa fa-pencil"></i></a>
- <a href="{{ route('attachments.delete', attachment.id) }}" class="btn btn-danger"><i
- class="fa fa-trash"></i></a>
- {% if attachment.file_exists %}
- <a href="{{ route('attachments.download', attachment.id) }}" class="btn btn-default"><i
- class="fa fa-download"></i></a>
- {% endif %}
- {% if not attachment.file_exists %}
- <a href="#" class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i></a>
- {% endif %}
- </div>
- </td>
- <td>
- {% if attachment.file_exists %}
- <i class="fa {{ attachment.mime|mimeIcon }}"></i>
- <a href="{{ route('attachments.view', attachment.id) }}" title="{{ attachment.filename }}">
- {% if attachment.title %}
- {{ attachment.title }}
- {% else %}
- {{ attachment.filename }}
- {% endif %}
- </a>
- ({{ attachment.size|filesize }})
- {% if null != attachment.notes and '' != attachment.notes %}
- {{ attachment.notes|markdown }}
- {% endif %}
- {% endif %}
- {% if not attachment.file_exists %}
- <i class="fa fa-fw fa-exclamation-triangle"></i>
- {% if attachment.title %}
- {{ attachment.title }}
- {% else %}
- {{ attachment.filename }}
- {% endif %}
- <br>
- <span class="text-danger">{{ 'attachment_not_found'|_ }}</span>
- {% endif %}
- </td>
- </tr>
- {% endfor %}
- </table>
+ {% include 'list.attachments' with {attachments: attachments[journal.transaction_journal_id]} %}
</div>
</div>
{% endif %}