Attachments for accounts are visible #2828

This commit is contained in:
James Cole 2020-03-19 18:20:23 +01:00
parent cdf055065f
commit 2a46756838
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
6 changed files with 69 additions and 49 deletions

View File

@ -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',

View File

@ -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);

View File

@ -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">

View File

@ -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">

View File

@ -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>

View File

@ -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 %}