mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Updated transaction view.
This commit is contained in:
@@ -24,8 +24,11 @@ declare(strict_types=1);
|
|||||||
namespace FireflyIII\Support\Twig;
|
namespace FireflyIII\Support\Twig;
|
||||||
|
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\Transaction as TransactionModel;
|
use FireflyIII\Models\Transaction as TransactionModel;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Support\CacheProperties;
|
||||||
|
use Lang;
|
||||||
use Steam;
|
use Steam;
|
||||||
use Twig_Extension;
|
use Twig_Extension;
|
||||||
use Twig_SimpleFilter;
|
use Twig_SimpleFilter;
|
||||||
@@ -38,6 +41,41 @@ use Twig_SimpleFunction;
|
|||||||
*/
|
*/
|
||||||
class Transaction extends Twig_Extension
|
class Transaction extends Twig_Extension
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return Twig_SimpleFunction
|
||||||
|
*/
|
||||||
|
public function attachmentIndicator(): Twig_SimpleFunction
|
||||||
|
{
|
||||||
|
return new Twig_SimpleFunction(
|
||||||
|
'attachmentIndicator', function (int $journalId) {
|
||||||
|
|
||||||
|
$cache = new CacheProperties;
|
||||||
|
$cache->addProperty('attachments_journal');
|
||||||
|
$cache->addProperty($journalId);
|
||||||
|
if ($cache->has()) {
|
||||||
|
return $cache->get();
|
||||||
|
}
|
||||||
|
$count = Attachment::whereNull('deleted_at')
|
||||||
|
->where('attachable_type', 'FireflyIII\Models\TransactionJournal')
|
||||||
|
->where('attachable_id', $journalId)
|
||||||
|
->count();
|
||||||
|
if ($count > 0) {
|
||||||
|
$res = sprintf('<i class="fa fa-paperclip" title="%s"></i>', Lang::choice('firefly.nr_of_attachments', $count, ['count' => $count]));
|
||||||
|
$cache->store($res);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = '';
|
||||||
|
$cache->store($res);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
|
||||||
|
|
||||||
|
}, ['is_safe' => ['html']]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@@ -63,6 +101,7 @@ class Transaction extends Twig_Extension
|
|||||||
$this->transactionCategories(),
|
$this->transactionCategories(),
|
||||||
$this->transactionIdCategories(),
|
$this->transactionIdCategories(),
|
||||||
$this->splitJournalIndicator(),
|
$this->splitJournalIndicator(),
|
||||||
|
$this->attachmentIndicator(),
|
||||||
];
|
];
|
||||||
|
|
||||||
return $functions;
|
return $functions;
|
||||||
@@ -85,12 +124,25 @@ class Transaction extends Twig_Extension
|
|||||||
{
|
{
|
||||||
return new Twig_SimpleFunction(
|
return new Twig_SimpleFunction(
|
||||||
'splitJournalIndicator', function (int $journalId) {
|
'splitJournalIndicator', function (int $journalId) {
|
||||||
|
|
||||||
|
$cache = new CacheProperties;
|
||||||
|
$cache->addProperty('is_split_journal');
|
||||||
|
$cache->addProperty($journalId);
|
||||||
|
if ($cache->has()) {
|
||||||
|
return $cache->get();
|
||||||
|
}
|
||||||
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
|
$count = TransactionModel::where('transaction_journal_id', $journalId)->whereNull('deleted_at')->count();
|
||||||
if ($count > 2) {
|
if ($count > 2) {
|
||||||
return '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
$res = '<i class="fa fa-fw fa-share-alt" aria-hidden="true"></i>';
|
||||||
|
$cache->store($res);
|
||||||
|
|
||||||
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
return '';
|
$res = '';
|
||||||
|
$cache->store($res);
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
|
||||||
|
|
||||||
}, ['is_safe' => ['html']]
|
}, ['is_safe' => ['html']]
|
||||||
|
@@ -10,17 +10,17 @@
|
|||||||
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
|
<th class="hidden-xs hidden-sm">{{ trans('list.date') }}</th>
|
||||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
|
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.from') }}</th>
|
||||||
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
|
<th class="hidden-xs hidden-sm hidden-md">{{ trans('list.to') }}</th>
|
||||||
<!-- Hide budgets? -->
|
{# Hide budgets? #}
|
||||||
{% if not hideBudgets %}
|
{% if not hideBudgets %}
|
||||||
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
|
<th class="hidden-xs"><i class="fa fa-tasks fa-fw" title="{{ trans('list.budget') }}"></i></th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Hide categories? -->
|
{# Hide categories? #}
|
||||||
{% if not hideCategories %}
|
{% if not hideCategories %}
|
||||||
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
|
<th class="hidden-xs"><i class="fa fa-bar-chart fa-fw" title="{{ trans('list.category') }}"></i></th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- Hide bills? -->
|
{# Hide bills? #}
|
||||||
{% if not hideBills %}
|
{% if not hideBills %}
|
||||||
<th class="hidden-xs"><i class="fa fa-fw fa-calendar-o" title="{{ trans('list.bill') }}"></i></th>
|
<th class="hidden-xs"><i class="fa fa-fw fa-calendar-o" title="{{ trans('list.bill') }}"></i></th>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -29,6 +29,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
{% for transaction in journals %}
|
{% for transaction in journals %}
|
||||||
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
|
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
|
||||||
|
{# input buttons #}
|
||||||
<td class="hidden-xs">
|
<td class="hidden-xs">
|
||||||
<div class="select_single" style="display:none;">
|
<div class="select_single" style="display:none;">
|
||||||
<input name="select_all_single[]" class="select_all_single" value="{{ transaction.journal_id }}" type="checkbox"/>
|
<input name="select_all_single[]" class="select_all_single" value="{{ transaction.journal_id }}" type="checkbox"/>
|
||||||
@@ -40,9 +41,12 @@
|
|||||||
class="fa fa-fw fa-trash-o"></i></a></div>
|
class="fa fa-fw fa-trash-o"></i></a></div>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
{# icon #}
|
||||||
<td class="hidden-xs">
|
<td class="hidden-xs">
|
||||||
{{ transaction|typeIconTransaction }}
|
{{ transaction|typeIconTransaction }}
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
{# description #}
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ route('transactions.show',transaction.journal_id) }}">
|
<a href="{{ route('transactions.show',transaction.journal_id) }}">
|
||||||
|
|
||||||
@@ -52,13 +56,11 @@
|
|||||||
{{ transaction.description }}
|
{{ transaction.description }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
{# is a split journal #}
|
||||||
{{ splitJournalIndicator(transaction.journal_id) }}
|
{{ splitJournalIndicator(transaction.journal_id) }}
|
||||||
{% set countAtt = transaction.transactionJournal.attachments.count %}
|
|
||||||
{% if countAtt > 0 %}
|
|
||||||
<i class="fa fa-paperclip"
|
|
||||||
title="{{ Lang.choice('firefly.nr_of_attachments', countAtt, {count: countAtt}) }}"></i>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
{# count attachments #}
|
||||||
|
{{ attachmentIndicator(transaction.journal_id) }}
|
||||||
</td>
|
</td>
|
||||||
<td style="text-align: right;">
|
<td style="text-align: right;">
|
||||||
<span style="margin-right:5px;">
|
<span style="margin-right:5px;">
|
||||||
|
Reference in New Issue
Block a user