mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Will now warn about non-existent attachments.
This commit is contained in:
parent
7380c5096e
commit
edf764aaf4
@ -26,13 +26,16 @@ namespace FireflyIII\Http\Controllers;
|
|||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use FireflyIII\Exceptions\FireflyException;
|
use FireflyIII\Exceptions\FireflyException;
|
||||||
|
use FireflyIII\Helpers\Attachments\AttachmentHelper;
|
||||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||||
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
|
use FireflyIII\Helpers\Filter\CountAttachmentsFilter;
|
||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Helpers\Filter\SplitIndicatorFilter;
|
use FireflyIII\Helpers\Filter\SplitIndicatorFilter;
|
||||||
|
use FireflyIII\Models\Attachment;
|
||||||
use FireflyIII\Models\Transaction;
|
use FireflyIII\Models\Transaction;
|
||||||
use FireflyIII\Models\TransactionJournal;
|
use FireflyIII\Models\TransactionJournal;
|
||||||
use FireflyIII\Models\TransactionType;
|
use FireflyIII\Models\TransactionType;
|
||||||
|
use FireflyIII\Repositories\Attachment\AttachmentRepositoryInterface;
|
||||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||||
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
use FireflyIII\Repositories\LinkType\LinkTypeRepositoryInterface;
|
||||||
use FireflyIII\Support\Http\Controllers\ModelInformation;
|
use FireflyIII\Support\Http\Controllers\ModelInformation;
|
||||||
@ -53,6 +56,8 @@ use View;
|
|||||||
class TransactionController extends Controller
|
class TransactionController extends Controller
|
||||||
{
|
{
|
||||||
use ModelInformation, PeriodOverview;
|
use ModelInformation, PeriodOverview;
|
||||||
|
/** @var AttachmentRepositoryInterface */
|
||||||
|
private $attachmentRepository;
|
||||||
/** @var JournalRepositoryInterface Journals and transactions overview */
|
/** @var JournalRepositoryInterface Journals and transactions overview */
|
||||||
private $repository;
|
private $repository;
|
||||||
|
|
||||||
@ -68,6 +73,7 @@ class TransactionController extends Controller
|
|||||||
app('view')->share('title', (string)trans('firefly.transactions'));
|
app('view')->share('title', (string)trans('firefly.transactions'));
|
||||||
app('view')->share('mainTitleIcon', 'fa-repeat');
|
app('view')->share('mainTitleIcon', 'fa-repeat');
|
||||||
$this->repository = app(JournalRepositoryInterface::class);
|
$this->repository = app(JournalRepositoryInterface::class);
|
||||||
|
$this->attachmentRepository = app(AttachmentRepositoryInterface::class);
|
||||||
|
|
||||||
return $next($request);
|
return $next($request);
|
||||||
}
|
}
|
||||||
@ -212,6 +218,7 @@ class TransactionController extends Controller
|
|||||||
*
|
*
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
* @param LinkTypeRepositoryInterface $linkTypeRepository
|
* @param LinkTypeRepositoryInterface $linkTypeRepository
|
||||||
|
* @param AttachmentHelper $attHelper
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector|View
|
||||||
* @throws FireflyException
|
* @throws FireflyException
|
||||||
@ -228,6 +235,16 @@ class TransactionController extends Controller
|
|||||||
$linkTypes = $linkTypeRepository->get();
|
$linkTypes = $linkTypeRepository->get();
|
||||||
$links = $linkTypeRepository->getLinks($journal);
|
$links = $linkTypeRepository->getLinks($journal);
|
||||||
|
|
||||||
|
// get attachments:
|
||||||
|
$attachments = $this->repository->getAttachments($journal);
|
||||||
|
$attachments = $attachments->each(
|
||||||
|
function (Attachment $attachment) {
|
||||||
|
$attachment->file_exists = $this->attachmentRepository->exists($attachment);
|
||||||
|
|
||||||
|
return $attachment;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// get transactions using the collector:
|
// get transactions using the collector:
|
||||||
$collector = app(TransactionCollectorInterface::class);
|
$collector = app(TransactionCollectorInterface::class);
|
||||||
$collector->setUser(auth()->user());
|
$collector->setUser(auth()->user());
|
||||||
@ -246,7 +263,7 @@ class TransactionController extends Controller
|
|||||||
$what = strtolower($transactionType);
|
$what = strtolower($transactionType);
|
||||||
$subTitle = (string)trans('firefly.' . $what) . ' "' . $journal->description . '"';
|
$subTitle = (string)trans('firefly.' . $what) . ' "' . $journal->description . '"';
|
||||||
|
|
||||||
return view('transactions.show', compact('journal', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));
|
return view('transactions.show', compact('journal','attachments', 'events', 'subTitle', 'what', 'transactions', 'linkTypes', 'links'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ use FireflyIII\Factory\TransactionJournalFactory;
|
|||||||
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
use FireflyIII\Factory\TransactionJournalMetaFactory;
|
||||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||||
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
use FireflyIII\Helpers\Filter\InternalTransferFilter;
|
||||||
use FireflyIII\Helpers\Filter\TransferFilter;
|
|
||||||
use FireflyIII\Models\Account;
|
use FireflyIII\Models\Account;
|
||||||
use FireflyIII\Models\AccountType;
|
use FireflyIII\Models\AccountType;
|
||||||
use FireflyIII\Models\PiggyBankEvent;
|
use FireflyIII\Models\PiggyBankEvent;
|
||||||
@ -263,6 +262,18 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all attachments for journal.
|
||||||
|
*
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAttachments(TransactionJournal $journal): Collection
|
||||||
|
{
|
||||||
|
return $journal->attachments;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the first positive transaction for the journal. Useful when editing journals.
|
* Returns the first positive transaction for the journal. Useful when editing journals.
|
||||||
*
|
*
|
||||||
@ -600,6 +611,7 @@ class JournalRepository implements JournalRepositoryInterface
|
|||||||
//$collector->addFilter(TransferFilter::class);
|
//$collector->addFilter(TransferFilter::class);
|
||||||
|
|
||||||
$collector->setJournals($journals)->withOpposingAccount();
|
$collector->setJournals($journals)->withOpposingAccount();
|
||||||
|
|
||||||
return $collector->getTransactions();
|
return $collector->getTransactions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,6 +38,16 @@ use Illuminate\Support\MessageBag;
|
|||||||
*/
|
*/
|
||||||
interface JournalRepositoryInterface
|
interface JournalRepositoryInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Return all attachments for journal.
|
||||||
|
*
|
||||||
|
* @param TransactionJournal $journal
|
||||||
|
*
|
||||||
|
* @return Collection
|
||||||
|
*/
|
||||||
|
public function getAttachments(TransactionJournal $journal): Collection;
|
||||||
|
|
||||||
|
|
||||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||||
/**
|
/**
|
||||||
* @param TransactionJournal $journal
|
* @param TransactionJournal $journal
|
||||||
|
@ -851,6 +851,7 @@ return [
|
|||||||
'opt_group_l_Credit card' => 'Liability: Credit card',
|
'opt_group_l_Credit card' => 'Liability: Credit card',
|
||||||
'notes' => 'Notes',
|
'notes' => 'Notes',
|
||||||
'unknown_journal_error' => 'Could not store the transaction. Please check the log files.',
|
'unknown_journal_error' => 'Could not store the transaction. Please check the log files.',
|
||||||
|
'attachment_not_found' => 'This attachment could not found in the storage.',
|
||||||
|
|
||||||
// new user:
|
// new user:
|
||||||
'welcome' => 'Welcome to Firefly III!',
|
'welcome' => 'Welcome to Firefly III!',
|
||||||
|
@ -249,7 +249,7 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if journal.attachments|length > 0 %}
|
{% if attachments|length > 0 %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
|
<h3 class="box-title">{{ 'attachments'|_ }}</h3>
|
||||||
@ -262,10 +262,16 @@
|
|||||||
<div class="btn-group btn-group-xs">
|
<div class="btn-group btn-group-xs">
|
||||||
<a href="{{ route('attachments.edit', att.id) }}" class="btn btn-default"><i class="fa fa-pencil"></i></a>
|
<a href="{{ route('attachments.edit', att.id) }}" class="btn btn-default"><i class="fa fa-pencil"></i></a>
|
||||||
<a href="{{ route('attachments.delete', att.id) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
|
<a href="{{ route('attachments.delete', att.id) }}" class="btn btn-danger"><i class="fa fa-trash"></i></a>
|
||||||
|
{% if att.file_exists %}
|
||||||
<a href="{{ route('attachments.download', att.id) }}" class="btn btn-default"><i class="fa fa-download"></i></a>
|
<a href="{{ route('attachments.download', att.id) }}" class="btn btn-default"><i class="fa fa-download"></i></a>
|
||||||
|
{% endif %}
|
||||||
|
{% if not att.file_exists %}
|
||||||
|
<a href="#" class="btn btn-danger"><i class="fa fa-exclamation-triangle"></i></a>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
|
{% if att.file_exists %}
|
||||||
<i class="fa {{ att.mime|mimeIcon }}"></i>
|
<i class="fa {{ att.mime|mimeIcon }}"></i>
|
||||||
<a href="{{ route('attachments.view', att.id) }}" title="{{ att.filename }}">
|
<a href="{{ route('attachments.view', att.id) }}" title="{{ att.filename }}">
|
||||||
{% if att.title %}
|
{% if att.title %}
|
||||||
@ -278,6 +284,17 @@
|
|||||||
{% if att.notes.first %}
|
{% if att.notes.first %}
|
||||||
{{ att.notes.first.text|markdown }}
|
{{ att.notes.first.text|markdown }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% if not att.file_exists %}
|
||||||
|
<i class="fa fa-fw fa-exclamation-triangle"></i>
|
||||||
|
{% if att.title %}
|
||||||
|
{{ att.title }}
|
||||||
|
{% else %}
|
||||||
|
{{ att.filename }}
|
||||||
|
{% endif %}
|
||||||
|
<br>
|
||||||
|
<span class="text-danger">{{ 'attachment_not_found'|_ }}</span>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@ -426,8 +443,10 @@
|
|||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<select id="link_type" class="form-control" name="link_type">
|
<select id="link_type" class="form-control" name="link_type">
|
||||||
{% for linkType in linkTypes %}
|
{% for linkType in linkTypes %}
|
||||||
<option label="{{ journalLinkTranslation('inward', linkType.inward) }}" value="{{ linkType.id }}_inward">{{ journalLinkTranslation('inward', linkType.inward) }}</option>
|
<option label="{{ journalLinkTranslation('inward', linkType.inward) }}"
|
||||||
<option label="{{ journalLinkTranslation('outward', linkType.outward) }}" value="{{ linkType.id }}_outward">{{ journalLinkTranslation('outward', linkType.outward) }}</option>
|
value="{{ linkType.id }}_inward">{{ journalLinkTranslation('inward', linkType.inward) }}</option>
|
||||||
|
<option label="{{ journalLinkTranslation('outward', linkType.outward) }}"
|
||||||
|
value="{{ linkType.id }}_outward">{{ journalLinkTranslation('outward', linkType.outward) }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user