diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php
index 8744038427..2e2037ed34 100644
--- a/app/Http/Controllers/TransactionController.php
+++ b/app/Http/Controllers/TransactionController.php
@@ -6,6 +6,7 @@ use Config;
use ExpandedForm;
use FireflyIII\Events\JournalCreated;
use FireflyIII\Events\JournalSaved;
+use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
use FireflyIII\Http\Requests\JournalFormRequest;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionJournal;
@@ -256,21 +257,37 @@ class TransactionController extends Controller
*
* @return \Illuminate\Http\RedirectResponse
*/
- public function store(JournalFormRequest $request, JournalRepositoryInterface $repository)
+ public function store(JournalFormRequest $request, JournalRepositoryInterface $repository, AttachmentHelperInterface $att)
{
$journalData = $request->getJournalData();
// if not withdrawal, unset budgetid.
- if($journalData['what'] != 'withdrawal') {
+ if ($journalData['what'] != 'withdrawal') {
$journalData['budget_id'] = 0;
}
- $journal = $repository->store($journalData);
+ $journal = $repository->store($journalData);
+
+ // save attachments:
+ $att->saveAttachmentsForModel($journal);
+
+ if ($att->getErrors()->count() > 0) {
+ // todo moet beter
+ Session::flash('error', '
' . join('', $att->getErrors()->get('attachments', '- :message
')) . '
');
+ }
+ if ($att->getMessages()->count() > 0) {
+ // todo moet beter
+ Session::flash('info', '' . join('', $att->getMessages()->get('attachments', '- :message
')) . '
');
+ }
+
+
+ // do something with the messages?
+
// rescan journal, UpdateJournalConnection
event(new JournalSaved($journal));
- // ConnectJournalToPiggyBank
+
if ($journal->transactionType->type == 'Transfer' && intval($request->get('piggy_bank_id')) > 0) {
event(new JournalCreated($journal, intval($request->get('piggy_bank_id'))));
}
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php
index 5f3b310017..a08a908fde 100644
--- a/app/Providers/FireflyServiceProvider.php
+++ b/app/Providers/FireflyServiceProvider.php
@@ -93,6 +93,9 @@ class FireflyServiceProvider extends ServiceProvider
// CSV import
$this->app->bind('FireflyIII\Helpers\Csv\WizardInterface', 'FireflyIII\Helpers\Csv\Wizard');
+ // attachments
+ $this->app->bind('FireflyIII\Helpers\Attachments\AttachmentHelperInterface', 'FireflyIII\Helpers\Attachments\AttachmentHelper');
+
// make charts:
// alternative is Google instead of ChartJs
$this->app->bind('FireflyIII\Generator\Chart\Account\AccountChartGenerator', 'FireflyIII\Generator\Chart\Account\ChartJsAccountChartGenerator');
diff --git a/resources/twig/partials/flashes.twig b/resources/twig/partials/flashes.twig
index b22d3ceb1d..d71dd9f381 100644
--- a/resources/twig/partials/flashes.twig
+++ b/resources/twig/partials/flashes.twig
@@ -8,7 +8,7 @@
{% if Session.has('info') %}
- Info: {{ Session.get('info') }}
+ Info: {{ Session.get('info')|raw }}
{% endif %}
@@ -22,6 +22,6 @@
{% if Session.has('error') %}
- Error! {{ Session.get('error') }}
+ Error! {{ Session.get('error')|raw }}
{% endif %}