mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
A fix in the model and a simple view for attachments.
This commit is contained in:
parent
6a9574bab9
commit
359fab315f
@ -472,7 +472,7 @@ class TransactionJournal extends Model
|
||||
*/
|
||||
public function attachments()
|
||||
{
|
||||
return $this->morphMany('App\Models\Attachment', 'attachable');
|
||||
return $this->morphMany('FireflyIII\Models\Attachment', 'attachable');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,8 @@ class General extends Twig_Extension
|
||||
$this->formatAmountPlain(),
|
||||
$this->formatJournal(),
|
||||
$this->balance(),
|
||||
$this->getAccountRole()
|
||||
$this->getAccountRole(),
|
||||
$this->formatFilesize()
|
||||
];
|
||||
|
||||
}
|
||||
@ -66,6 +67,27 @@ class General extends Twig_Extension
|
||||
return 'FireflyIII\Support\Twig\General';
|
||||
}
|
||||
|
||||
protected function formatFilesize()
|
||||
{
|
||||
return new Twig_SimpleFilter(
|
||||
'filesize', function ($size) {
|
||||
$size = intval($size);
|
||||
|
||||
// less than one GB, more than one MB
|
||||
if ($size < (1024 * 1024 * 2014) && $size >= (1024 * 1024)) {
|
||||
return round($size / (1024 * 1024), 2) . ' MB';
|
||||
}
|
||||
|
||||
// less than one MB
|
||||
if ($size < (1024 * 1024)) {
|
||||
return round($size / 1024, 2) . ' KB';
|
||||
}
|
||||
|
||||
return $size . ' bytes';
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Twig_SimpleFilter
|
||||
*/
|
||||
|
@ -52,6 +52,10 @@
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ route('transactions.show',journal.id) }}" title="{{ journal.description }}">{{ journal.description }}</a>
|
||||
{% if journal.attachments|length > 0 %}
|
||||
<i class="fa fa-paperclip pull-right"></i>
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{% if not hideTags %}
|
||||
|
@ -74,6 +74,30 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- attachments -->
|
||||
<div class="box">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
|
||||
</div>
|
||||
<div class="box-body table-responsive no-padding">
|
||||
<table class="table table-hover">
|
||||
{% for att in journal.attachments %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<i class="fa fa-file-pdf-o"></i>
|
||||
<a href="#">{{ att.filename }}</a>
|
||||
({{ att.size|filesize }})
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- events, if present -->
|
||||
{% if journal.piggyBankEvents|length > 0 %}
|
||||
<div class="box">
|
||||
|
Loading…
Reference in New Issue
Block a user