mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Default documents
This commit is contained in:
parent
48dbf0f287
commit
e0c080947b
@ -745,7 +745,9 @@ class ClientPortalController extends BaseController
|
|||||||
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
$document = Document::scope($publicId, $invitation->account_id)->firstOrFail();
|
||||||
|
|
||||||
$authorized = false;
|
$authorized = false;
|
||||||
if ($document->expense && $document->expense->invoice_documents && $document->expense->client_id == $invitation->invoice->client_id) {
|
if ($document->is_default) {
|
||||||
|
$authorized = true;
|
||||||
|
} elseif ($document->expense && $document->expense->invoice_documents && $document->expense->client_id == $invitation->invoice->client_id) {
|
||||||
$authorized = true;
|
$authorized = true;
|
||||||
} elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) {
|
} elseif ($document->invoice && $document->invoice->client_id == $invitation->invoice->client_id) {
|
||||||
$authorized = true;
|
$authorized = true;
|
||||||
|
@ -305,6 +305,23 @@ class Invoice extends EntityModel implements BalanceAffecting
|
|||||||
return $this->hasMany('App\Models\Document')->orderBy('id');
|
return $this->hasMany('App\Models\Document')->orderBy('id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function allDocuments()
|
||||||
|
{
|
||||||
|
$documents = $this->documents;
|
||||||
|
$documents = $documents->merge($this->account->defaultDocuments);
|
||||||
|
|
||||||
|
foreach ($this->expenses as $expense) {
|
||||||
|
if ($expense->invoice_documents) {
|
||||||
|
$documents = $documents->merge($expense->documents);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $documents;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
||||||
*/
|
*/
|
||||||
|
@ -68,14 +68,7 @@ class ContactMailer extends Mailer
|
|||||||
|
|
||||||
$documentStrings = [];
|
$documentStrings = [];
|
||||||
if ($account->document_email_attachment && $invoice->hasDocuments()) {
|
if ($account->document_email_attachment && $invoice->hasDocuments()) {
|
||||||
$documents = $invoice->documents;
|
$documents = $invoice->allDocuments();
|
||||||
|
|
||||||
foreach ($invoice->expenses as $expense) {
|
|
||||||
if ($expense->invoice_documents) {
|
|
||||||
$documents = $documents->merge($expense->documents);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$documents = $documents->sortBy('size');
|
$documents = $documents->sortBy('size');
|
||||||
|
|
||||||
$size = 0;
|
$size = 0;
|
||||||
|
@ -34,16 +34,9 @@ class TemplateService
|
|||||||
|
|
||||||
if ($account->hasFeature(FEATURE_DOCUMENTS) && $invoice->hasDocuments()) {
|
if ($account->hasFeature(FEATURE_DOCUMENTS) && $invoice->hasDocuments()) {
|
||||||
$documentsHTML .= trans('texts.email_documents_header').'<ul>';
|
$documentsHTML .= trans('texts.email_documents_header').'<ul>';
|
||||||
foreach ($invoice->documents as $document) {
|
foreach ($invoice->allDocuments() as $document) {
|
||||||
$documentsHTML .= '<li><a href="'.HTML::entities($document->getClientUrl($invitation)).'">'.HTML::entities($document->name).'</a></li>';
|
$documentsHTML .= '<li><a href="'.HTML::entities($document->getClientUrl($invitation)).'">'.HTML::entities($document->name).'</a></li>';
|
||||||
}
|
}
|
||||||
foreach ($invoice->expenses as $expense) {
|
|
||||||
if ($expense->invoice_documents) {
|
|
||||||
foreach ($expense->documents as $document) {
|
|
||||||
$documentsHTML .= '<li><a href="'.HTML::entities($document->getClientUrl($invitation)).'">'.HTML::entities($document->name).'</a></li>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$documentsHTML .= '</ul>';
|
$documentsHTML .= '</ul>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,16 +151,9 @@
|
|||||||
<div class="invoice-documents">
|
<div class="invoice-documents">
|
||||||
<h3>{{ trans('texts.documents_header') }}</h3>
|
<h3>{{ trans('texts.documents_header') }}</h3>
|
||||||
<ul>
|
<ul>
|
||||||
@foreach ($invoice->documents as $document)
|
@foreach ($invoice->allDocuments() as $document)
|
||||||
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
|
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
|
||||||
@endforeach
|
@endforeach
|
||||||
@foreach ($invoice->expenses as $expense)
|
|
||||||
@if ($expense->invoice_documents)
|
|
||||||
@foreach ($expense->documents as $document)
|
|
||||||
<li><a target="_blank" href="{{ $document->getClientUrl($invitation) }}">{{$document->name}} ({{Form::human_filesize($document->size)}})</a></li>
|
|
||||||
@endforeach
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user