From 48dbf0f287db207fee118ab8d7a93bbf91f95ec8 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Fri, 21 Jul 2017 13:44:36 +0300 Subject: [PATCH] Fix expense include documents --- app/Ninja/Mailers/ContactMailer.php | 4 +++- app/Services/TemplateService.php | 6 ++++-- resources/views/invoices/view.blade.php | 8 ++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/Ninja/Mailers/ContactMailer.php b/app/Ninja/Mailers/ContactMailer.php index 9c3b15d861..a9803550eb 100644 --- a/app/Ninja/Mailers/ContactMailer.php +++ b/app/Ninja/Mailers/ContactMailer.php @@ -71,7 +71,9 @@ class ContactMailer extends Mailer $documents = $invoice->documents; foreach ($invoice->expenses as $expense) { - $documents = $documents->merge($expense->documents); + if ($expense->invoice_documents) { + $documents = $documents->merge($expense->documents); + } } $documents = $documents->sortBy('size'); diff --git a/app/Services/TemplateService.php b/app/Services/TemplateService.php index 6d778b79aa..6d9b1a66c8 100644 --- a/app/Services/TemplateService.php +++ b/app/Services/TemplateService.php @@ -38,8 +38,10 @@ class TemplateService $documentsHTML .= '
  • '.HTML::entities($document->name).'
  • '; } foreach ($invoice->expenses as $expense) { - foreach ($expense->documents as $document) { - $documentsHTML .= '
  • '.HTML::entities($document->name).'
  • '; + if ($expense->invoice_documents) { + foreach ($expense->documents as $document) { + $documentsHTML .= '
  • '.HTML::entities($document->name).'
  • '; + } } } $documentsHTML .= ''; diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php index f2633f66df..778f92753c 100644 --- a/resources/views/invoices/view.blade.php +++ b/resources/views/invoices/view.blade.php @@ -155,11 +155,11 @@
  • {{$document->name}} ({{Form::human_filesize($document->size)}})
  • @endforeach @foreach ($invoice->expenses as $expense) - @foreach ($expense->documents as $document) - @if ($expense->invoice_documents) + @if ($expense->invoice_documents) + @foreach ($expense->documents as $document)
  • {{$document->name}} ({{Form::human_filesize($document->size)}})
  • - @endif - @endforeach + @endforeach + @endif @endforeach