Improved search.

This commit is contained in:
James Cole 2016-11-06 14:52:31 +01:00
parent 1ebb59b352
commit 22a2fe3f61
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
13 changed files with 466 additions and 125 deletions

View File

@ -14,7 +14,7 @@ declare(strict_types = 1);
namespace FireflyIII\Http\Controllers; namespace FireflyIII\Http\Controllers;
use FireflyIII\Support\Search\SearchInterface; use FireflyIII\Support\Search\SearchInterface;
use Input; use Illuminate\Http\Request;
/** /**
* Class SearchController * Class SearchController
@ -30,12 +30,6 @@ class SearchController extends Controller
{ {
parent::__construct(); parent::__construct();
$this->middleware(
function ($request, $next) {
return $next($request);
}
);
} }
/** /**
@ -45,16 +39,21 @@ class SearchController extends Controller
* *
* @return $this * @return $this
*/ */
public function index(SearchInterface $searcher) public function index(Request $request, SearchInterface $searcher)
{ {
$minSearchLen = 1;
$subTitle = null; $subTitle = null;
$query = null; $query = null;
$result = []; $result = [];
$title = trans('firefly.search'); $title = trans('firefly.search');
$limit = 20;
$mainTitleIcon = 'fa-search'; $mainTitleIcon = 'fa-search';
if (!is_null(Input::get('q')) && strlen(Input::get('q')) > 0) {
$query = trim(Input::get('q')); // set limit for search:
$searcher->setLimit($limit);
if (!is_null($request->get('q')) && strlen($request->get('q')) >= $minSearchLen) {
$query = trim(strtolower($request->get('q')));
$words = explode(' ', $query); $words = explode(' ', $query);
$subTitle = trans('firefly.search_results_for', ['query' => $query]); $subTitle = trans('firefly.search_results_for', ['query' => $query]);
@ -67,7 +66,7 @@ class SearchController extends Controller
} }
return view('search.index', compact('title', 'subTitle', 'mainTitleIcon', 'query', 'result')); return view('search.index', compact('title', 'subTitle', 'limit', 'mainTitleIcon', 'query', 'result'));
} }
} }

View File

@ -94,7 +94,6 @@ class FireflyServiceProvider extends ServiceProvider
); );
$this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository'); $this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository');
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
$this->app->bind('FireflyIII\Repositories\User\UserRepositoryInterface', 'FireflyIII\Repositories\User\UserRepository'); $this->app->bind('FireflyIII\Repositories\User\UserRepositoryInterface', 'FireflyIII\Repositories\User\UserRepository');
$this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper'); $this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper');
$this->app->bind( $this->app->bind(

View File

@ -0,0 +1,59 @@
<?php
/**
* AccountServiceProvider.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Providers;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
/**
* Class SearchServiceProvider
*
* @package FireflyIII\Providers
*/
class SearchServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind(
'FireflyIII\Support\Search\SearchInterface',
function (Application $app, array $arguments) {
if (!isset($arguments[0]) && $app->auth->check()) {
return app('FireflyIII\Support\Search\Search', [auth()->user()]);
}
if (!isset($arguments[0]) && !$app->auth->check()) {
throw new FireflyException('There is no user present.');
}
return app('FireflyIII\Support\Search\Search', $arguments);
}
);
}
}

View File

@ -78,7 +78,7 @@ class TransactionMatcher
do { do {
// Fetch a batch of transactions from the database // Fetch a batch of transactions from the database
$collector = new JournalCollector(auth()->user()); $collector = new JournalCollector(auth()->user());
$collector->setAllAssetAccounts()->setLimit($pageSize * 2)->setPage($page)->setTypes($this->transactionTypes); $collector->setAllAssetAccounts()->setLimit($pageSize)->setPage($page)->setTypes($this->transactionTypes);
$set = $collector->getPaginatedJournals(); $set = $collector->getPaginatedJournals();
Log::debug(sprintf('Found %d journals to check. ', $set->count())); Log::debug(sprintf('Found %d journals to check. ', $set->count()));
@ -105,7 +105,7 @@ class TransactionMatcher
Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed)); Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed));
// Check for conditions to finish the loop // Check for conditions to finish the loop
$reachedEndOfList = $set->count() < $pageSize; $reachedEndOfList = $set->count() < 1;
$foundEnough = $result->count() >= $this->limit; $foundEnough = $result->count() >= $this->limit;
$searchedEnough = ($processed >= $this->range); $searchedEnough = ($processed >= $this->range);

View File

@ -14,11 +14,15 @@ declare(strict_types = 1);
namespace FireflyIII\Support\Search; namespace FireflyIII\Support\Search;
use FireflyIII\Helpers\Collector\JournalCollector;
use FireflyIII\Models\Account;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use FireflyIII\Models\TransactionJournal; use FireflyIII\Models\Tag;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder; use FireflyIII\Models\Transaction;
use FireflyIII\User;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
/** /**
* Class Search * Class Search
@ -27,20 +31,46 @@ use Illuminate\Support\Collection;
*/ */
class Search implements SearchInterface class Search implements SearchInterface
{ {
/** @var int */
private $limit = 100;
/** @var User */
private $user;
/** /**
* AttachmentRepository constructor.
*
* @param User $user
*/
public function __construct(User $user)
{
$this->user = $user;
}
/**
* The search will assume that the user does not have so many accounts
* that this search should be paginated.
*
* @param array $words * @param array $words
* *
* @return Collection * @return Collection
*/ */
public function searchAccounts(array $words): Collection public function searchAccounts(array $words): Collection
{ {
return auth()->user()->accounts()->with('accounttype')->where( $accounts = $this->user->accounts()->get();
function (EloquentBuilder $q) use ($words) { /** @var Collection $result */
foreach ($words as $word) { $result = $accounts->filter(
$q->orWhere('name', 'LIKE', '%' . e($word) . '%'); function (Account $account) use ($words) {
if ($this->strpos_arr(strtolower($account->name), $words)) {
return $account;
} }
return false;
} }
)->get(); );
$result = $result->slice(0, $this->limit);
return $result;
} }
/** /**
@ -51,46 +81,46 @@ class Search implements SearchInterface
public function searchBudgets(array $words): Collection public function searchBudgets(array $words): Collection
{ {
/** @var Collection $set */ /** @var Collection $set */
$set = auth()->user()->budgets()->get(); $set = auth()->user()->budgets()->get();
$newSet = $set->filter( /** @var Collection $result */
function (Budget $b) use ($words) { $result = $set->filter(
$found = 0; function (Budget $budget) use ($words) {
foreach ($words as $word) { if ($this->strpos_arr(strtolower($budget->name), $words)) {
if (!(strpos(strtolower($b->name), strtolower($word)) === false)) { return $budget;
$found++;
}
} }
return $found > 0; return false;
} }
); );
return $newSet; $result = $result->slice(0, $this->limit);
return $result;
} }
/** /**
* Search assumes the user does not have that many categories. So no paginated search.
*
* @param array $words * @param array $words
* *
* @return Collection * @return Collection
*/ */
public function searchCategories(array $words): Collection public function searchCategories(array $words): Collection
{ {
/** @var Collection $set */ $categories = $this->user->categories()->get();
$set = auth()->user()->categories()->get(); /** @var Collection $result */
$newSet = $set->filter( $result = $categories->filter(
function (Category $c) use ($words) { function (Category $category) use ($words) {
$found = 0; if ($this->strpos_arr(strtolower($category->name), $words)) {
foreach ($words as $word) { return $category;
if (!(strpos(strtolower($c->name), strtolower($word)) === false)) {
$found++;
}
} }
return $found > 0; return false;
} }
); );
$result = $result->slice(0, $this->limit);
return $newSet; return $result;
} }
/** /**
@ -101,7 +131,21 @@ class Search implements SearchInterface
*/ */
public function searchTags(array $words): Collection public function searchTags(array $words): Collection
{ {
return new Collection; $tags = $this->user->tags()->get();
/** @var Collection $result */
$result = $tags->filter(
function (Tag $tag) use ($words) {
if ($this->strpos_arr(strtolower($tag->tag), $words)) {
return $tag;
}
return false;
}
);
$result = $result->slice(0, $this->limit);
return $result;
} }
/** /**
@ -111,40 +155,86 @@ class Search implements SearchInterface
*/ */
public function searchTransactions(array $words): Collection public function searchTransactions(array $words): Collection
{ {
// decrypted transaction journals: $pageSize = 100;
$decrypted = auth()->user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 0)->where( $processed = 0;
function (EloquentBuilder $q) use ($words) { $page = 1;
foreach ($words as $word) { $result = new Collection();
$q->orWhere('transaction_journals.description', 'LIKE', '%' . e($word) . '%'); do {
} $collector = new JournalCollector($this->user);
} $collector->setAllAssetAccounts()->setLimit($pageSize)->setPage($page);
)->get(TransactionJournal::queryFields()); $set = $collector->getPaginatedJournals();
Log::debug(sprintf('Found %d journals to check. ', $set->count()));
// encrypted // Filter transactions that match the given triggers.
$all = auth()->user()->transactionJournals()->expanded()->where('transaction_journals.encrypted', 1)->get(TransactionJournal::queryFields()); $filtered = $set->filter(
$set = $all->filter( function (Transaction $transaction) use ($words) {
function (TransactionJournal $journal) use ($words) { // check descr of journal:
foreach ($words as $word) { if ($this->strpos_arr(strtolower(strval($transaction->description)), $words)) {
$haystack = strtolower($journal->description); return $transaction;
$word = strtolower($word);
if (!(strpos($haystack, $word) === false)) {
return $journal;
} }
// check descr of transaction
if ($this->strpos_arr(strtolower(strval($transaction->transaction_description)), $words)) {
return $transaction;
}
// return false:
return false;
} }
);
return null; Log::debug(sprintf('Found %d journals that match.', $filtered->count()));
// merge:
/** @var Collection $result */
$result = $result->merge($filtered);
Log::debug(sprintf('Total count is now %d', $result->count()));
// Update counters
$page++;
$processed += count($set);
Log::debug(sprintf('Page is now %d, processed is %d', $page, $processed));
// Check for conditions to finish the loop
$reachedEndOfList = $set->count() < 1;
$foundEnough = $result->count() >= $this->limit;
Log::debug(sprintf('reachedEndOfList: %s', var_export($reachedEndOfList, true)));
Log::debug(sprintf('foundEnough: %s', var_export($foundEnough, true)));
} while (!$reachedEndOfList && !$foundEnough);
$result = $result->slice(0, $this->limit);
return $result;
}
/**
* @param int $limit
*/
public function setLimit(int $limit)
{
$this->limit = $limit;
}
/**
* @param string $haystack
* @param array $needle
*
* @return bool
*/
private function strpos_arr(string $haystack, array $needle)
{
if (strlen($haystack) === 0) {
return false;
}
foreach ($needle as $what) {
if (($pos = strpos($haystack, $what)) !== false) {
return true;
} }
); }
$filtered = $set->merge($decrypted);
$filtered = $filtered->sortBy(
function (TransactionJournal $journal) {
return intval($journal->date->format('U'));
}
);
$filtered = $filtered->reverse(); return false;
return $filtered;
} }
} }

View File

@ -208,6 +208,7 @@ return [
FireflyIII\Providers\PiggyBankServiceProvider::class, FireflyIII\Providers\PiggyBankServiceProvider::class,
FireflyIII\Providers\RuleServiceProvider::class, FireflyIII\Providers\RuleServiceProvider::class,
FireflyIII\Providers\RuleGroupServiceProvider::class, FireflyIII\Providers\RuleGroupServiceProvider::class,
FireflyIII\Providers\SearchServiceProvider::class,
FireflyIII\Providers\TagServiceProvider::class, FireflyIII\Providers\TagServiceProvider::class,

View File

@ -67,7 +67,19 @@ return [
'warning_much_data' => ':days days of data may take a while to load.', 'warning_much_data' => ':days days of data may take a while to load.',
'registered' => 'You have registered successfully!', 'registered' => 'You have registered successfully!',
'search' => 'Search', 'search' => 'Search',
'search_found_accounts' => 'Found :count account(s) for your query.',
'search_found_categories' => 'Found :count category(ies) for your query.',
'search_found_budgets' => 'Found :count budget(s) for your query.',
'search_found_tags' => 'Found :count tag(s) for your query.',
'search_found_transactions' => 'Found :count transaction(s) for your query.',
'results_limited' => 'The results are limited to :count entries.',
'tagbalancingAct' => 'Balancing act',
'tagadvancePayment' => 'Advance payment',
'tagnothing' => '',
'Default asset account' => 'Default asset account',
'no_budget_pointer' => 'You seem to have no budgets yet. You should create some on the <a href="/budgets">budgets</a>-page. Budgets can help you keep track of expenses.', 'no_budget_pointer' => 'You seem to have no budgets yet. You should create some on the <a href="/budgets">budgets</a>-page. Budgets can help you keep track of expenses.',
'Savings account' => 'Savings account',
'Credit card' => 'Credit card',
'source_accounts' => 'Source account(s)', 'source_accounts' => 'Source account(s)',
'destination_accounts' => 'Destination account(s)', 'destination_accounts' => 'Destination account(s)',
'user_id_is' => 'Your user id is <strong>:user</strong>', 'user_id_is' => 'Your user id is <strong>:user</strong>',

View File

@ -5,19 +5,35 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
{% if query %} {% if query == "" %}
<div class="row"> <div class="row">
<div class="col-lg-12">
<p>{{ 'no_results_for_empty_search'|_ }}</p>
</div>
</div>
{% endif %}
{% if query %}
<div class="row">
<div class="col-lg-12">
<p>{{ trans('firefly.results_limited', {count: limit}) }}</p>
</div>
</div>
<div class="row">
{% if result.transactions|length > 0 %} {% if result.transactions|length > 0 %}
<div class="col-lg-6 col-md-12 col-sm-12"> <div class="col-lg-6 col-md-12 col-sm-12">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Transactions</h3> <h3 class="box-title">{{ 'transactions'|_ }}</h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body">
{% include 'list.journals-tiny' with {'transactions' : result.transactions} %} <p>
</div> {{ trans('firefly.search_found_transactions', {count: result.transactions|length}) }}
<div class="box-footer"> </p>
<span class="pull-right">Results: {{ result.transactions|length }}</span> {% include 'search.partials.transactions' with {'transactions' : result.transactions} %}
</div> </div>
</div> </div>
</div> </div>
@ -26,19 +42,13 @@
<div class="col-lg-6 col-md-12 col-sm-12"> <div class="col-lg-6 col-md-12 col-sm-12">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Categories</h3> <h3 class="box-title">{{ 'categories'|_ }}</h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body">
<div class="list-group"> <p>
{% for category in result.categories %} {{ trans('firefly.search_found_categories', {count: result.categories|length}) }}
<a class="list-group-item" title="{{ category.name }}" href="{{ route('categories.show',category.id) }}"> </p>
{{ category.name }} {% include 'search.partials.categories' %}
</a>
{% endfor %}
</div>
</div>
<div class="box-footer">
<span class="pull-right">Results: {{ result['categories']|length }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -47,13 +57,13 @@
<div class="col-lg-6 col-md-12 col-sm-12"> <div class="col-lg-6 col-md-12 col-sm-12">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Tags</h3> <h3 class="box-title">{{ 'tags'|_ }}</h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body">
<p>Bla bla</p> <p>
</div> {{ trans('firefly.search_found_tags', {count: result.tags|length}) }}
<div class="box-footer"> </p>
<span class="pull-right">Results: {{ result['tags']|length }}</span> {% include 'search.partials.tags' %}
</div> </div>
</div> </div>
</div> </div>
@ -62,19 +72,13 @@
<div class="col-lg-6 col-md-12 col-sm-12"> <div class="col-lg-6 col-md-12 col-sm-12">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Accounts</h3> <h3 class="box-title">{{ 'accounts'|_ }}</h3>
</div> </div>
<div class="box-body no-padding"> <div class="box-body">
<div class="list-group"> <p>
{% for account in result.accounts %} {{ trans('firefly.search_found_accounts', {count: result.accounts|length}) }}
<a class="list-group-item" title="{{ account.name }}" href="{{ route('accounts.show',account.id) }}"> </p>
{{ account.name }} {% include 'search.partials.accounts' %}
</a>
{% endfor %}
</div>
</div>
<div class="box-footer">
<span class="pull-right">Results: {{ result['accounts'].count() }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -83,19 +87,13 @@
<div class="col-lg-6 col-md-12 col-sm-12"> <div class="col-lg-6 col-md-12 col-sm-12">
<div class="box"> <div class="box">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Budgets</h3> <h3 class="box-title">{{ 'budgets'|_ }}</h3>
</div> </div>
<div class="box-body"> <div class="box-body">
<div class="list-group"> <p>
{% for budget in result.budgets %} {{ trans('firefly.search_found_budgets', {count: result.budgets|length}) }}
<a class="list-group-item" title="{{ budget.name }}" href="{{ route('budgets.show',budget.id) }}"> </p>
{{ budget.name }} {% include 'search.partials.budgets' %}
</a>
{% endfor %}
</div>
</div>
<div class="box-footer">
<span class="pull-right">Results: {{ result['budgets'].count() }}</span>
</div> </div>
</div> </div>
</div> </div>
@ -106,8 +104,8 @@
{% endblock %} {% endblock %}
{% block scripts %} {% block scripts %}
<script type="text/javascript"> <script type="text/javascript">
var query = '{{ query }}'; var query = '{{ query }}';
</script> </script>
{% endblock %} {% endblock %}

View File

@ -0,0 +1,34 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th>{{ trans('list.name') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.type') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.role') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.iban') }}</th>
</tr>
</thead>
<tbody>
{% for account in result.accounts %}
<tr>
<td class="hidden-sm hidden-xs">
<div class="btn-group btn-group-xs">
<a class="btn btn-default btn-xs" href="{{ route('accounts.edit',account.id) }}"><i class="fa fa-fw fa-pencil"></i></a>
<a class="btn btn-danger btn-xs" href="{{ route('accounts.delete',account.id) }}"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td><a href="{{ route('accounts.show',account.id) }}">{{ account.name }}</a></td>
<td>{{ trans('firefly.'~account.accountType.type) }}</td>
<td class="hidden-sm hidden-xs">
{% for entry in account.accountmeta %}
{% if entry.name == 'accountRole' %}
{{ trans('firefly.'~entry.data|getAccountRole) }}
{% endif %}
{% endfor %}
</td>
<td class="hidden-sm hidden-xs">{{ account.iban }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -0,0 +1,22 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th>{{ trans('list.name') }}</th>
</tr>
</thead>
<tbody>
{% for budget in result.budgets %}
<tr>
<td class="hidden-sm hidden-xs" style="width:10%;">
<div class="btn-group btn-group-xs">
<a class="btn btn-default btn-xs" href="{{ route('budgets.edit', budget.id) }}"><i class="fa fa-fw fa-pencil"></i></a>
<a class="btn btn-danger btn-xs" href="{{ route('budgets.delete', budget.id) }}"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td><a href="{{ route('budgets.show',budget.id) }}">{{ budget.name }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -0,0 +1,22 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th>{{ trans('list.name') }}</th>
</tr>
</thead>
<tbody>
{% for category in result.categories %}
<tr>
<td class="hidden-sm hidden-xs" style="width:10%;">
<div class="btn-group btn-group-xs">
<a class="btn btn-default btn-xs" href="{{ route('categories.edit',category.id) }}"><i class="fa fa-fw fa-pencil"></i></a>
<a class="btn btn-danger btn-xs" href="{{ route('categories.delete',category.id) }}"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td><a href="{{ route('categories.show',category.id) }}">{{ category.name }}</a></td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -0,0 +1,24 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th class="hidden-sm hidden-xs" data-defaultsort="disabled">&nbsp;</th>
<th>{{ trans('list.name') }}</th>
<th>{{ trans('list.type') }}</th>
</tr>
</thead>
<tbody>
{% for tag in result.tags %}
<tr>
<td class="hidden-sm hidden-xs" style="width:10%;">
<div class="btn-group btn-group-xs">
<a class="btn btn-default btn-xs" href="{{ route('tags.edit', tag.id) }}"><i class="fa fa-fw fa-pencil"></i></a>
<a class="btn btn-danger btn-xs" href="{{ route('tags.delete', tag.id) }}"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td><a href="{{ route('tags.show',tag.id) }}">{{ tag.tag }}</a></td>
<td>{{ ('tag'~tag.tagMode)|_ }}</td>
</tr>
{% endfor %}
</tbody>
</table>

View File

@ -0,0 +1,81 @@
{{ journals.render|raw }}
<table class="table table-hover table-compressed {% if sorting %}sortable-table{% endif %}">
<thead>
<tr class="ignore">
<th class="hidden-xs" colspan="2">&nbsp;</th>
<th>{{ trans('list.description') }}</th>
<th>{{ trans('list.amount') }}</th>
<th class="hidden-sm hidden-xs">{{ trans('list.date') }}</th>
</tr>
</thead>
<tbody>
{% for transaction in transactions %}
<tr class="drag" data-date="{{ transaction.date.format('Y-m-d') }}" data-id="{{ transaction.journal_id }}">
<td class="hidden-xs">
<div class="btn-group btn-group-xs edit_buttons">
<a href="{{ route('transactions.edit',transaction.journal_id) }}" class="btn btn-xs btn-default"><i class="fa fa-fw fa-pencil"></i></a>
<a href="{{ route('transactions.delete',transaction.journal_id) }}" class="btn btn-xs btn-danger"><i class="fa fa-fw fa-trash-o"></i></a>
</div>
</td>
<td class="hidden-xs">
{{ transaction|typeIconTransaction }}
</td>
<td>
<a href="{{ route('transactions.show',transaction.journal_id) }}">
{% if transaction.transaction_description|length > 0 %}
{{ transaction.transaction_description }} ({{ transaction.description }})
{% else %}
{{ transaction.description }}
{% endif %}
</a>
{{ splitJournalIndicator(transaction.journal_id) }}
{% if transaction.transactionJournal.attachments|length > 0 %}
<i class="fa fa-paperclip"
title="{{ Lang.choice('firefly.nr_of_attachments', journal.attachments|length, {count: journal.attachments|length}) }}"></i>
{% endif %}
</td>
<td>
<!-- format amount of transaction -->
{{ formatAmountWithCode(transaction.transaction_amount, transaction.transaction_currency_code) }}
<!-- and then amount of journal itself. -->
{{ optionalJournalAmount(transaction.journal_id, transaction.transaction_amount,
transaction.transaction_currency_code, transaction.transaction_type_type) }}
</td>
<td class="hidden-sm hidden-xs">
{{ transaction.date.formatLocalized(monthAndDayFormat) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row mass_edit_all" style="display: none;">
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
<div class="mass_button_options btn-group btn-group" style="display:none;">
<a href="#" class="btn btn-default mass_edit"><i class="fa fa-fw fa-pencil"></i> <span>{{ 'edit_selected'|_ }}</span></a>
<a href="#" class="btn btn-danger mass_delete"><i class="fa fa-fw fa-trash"></i> <span>{{ 'delete_selected'|_ }}</span></a>
</div>
</div>
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
<div class="mass_buttons btn-group btn-group pull-right">
<a href="#" class="btn btn-default mass_select"><i class="fa fa-fw fa-check-square-o"></i> {{ 'select_transactions'|_ }}</a>
<a href="#" class="btn btn-default mass_stop_select" style="display:none;"><i class="fa faw-fw fa-square-o"
aria-hidden="true"></i> {{ 'stop_selection'|_ }}</a>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
{{ journals.render|raw }}
</div>
</div>
<script type="text/javascript">
var edit_selected_txt = "{{ 'edit_selected'|_ }}";
var delete_selected_txt = "{{ 'delete_selected'|_ }}";
</script>