Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
A fix in the model and a simple view for attachments.
James Cole359fab315f1a
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.phpindex ac566b257e..2aba22d617 100644--- a/app/Models/TransactionJournal.php+++ b/app/Models/TransactionJournal.php@@ -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');}/**diff --git a/app/Support/Twig/General.php b/app/Support/Twig/General.phpindex b42350a579..d7a0722d14 100644--- a/app/Support/Twig/General.php+++ b/app/Support/Twig/General.php@@ -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_Extensionreturn '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*/diff --git a/resources/twig/list/journals.twig b/resources/twig/list/journals.twigindex ffbdee1e26..e5292f7f2c 100644--- a/resources/twig/list/journals.twig+++ b/resources/twig/list/journals.twig@@ -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 %}diff --git a/resources/twig/transactions/show.twig b/resources/twig/transactions/show.twigindex 766c0791ee..cad7844a82 100644--- a/resources/twig/transactions/show.twig+++ b/resources/twig/transactions/show.twig@@ -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">