1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Fixes for view_link in emails

This commit is contained in:
David Bomba 2020-07-29 12:13:12 +10:00
parent ce3ce8a54b
commit 6510536234
8 changed files with 45 additions and 21 deletions

View File

@ -94,4 +94,11 @@ class UpdateInvoiceRequest extends Request
$this->replace($input);
}
public function messages()
{
return [
'id' => ctrans('text.locked_invoice'),
];
}
}

View File

@ -59,7 +59,7 @@ class BouncedEmail extends Mailable implements ShouldQueue
//->bcc('')
->queue(new BouncedEmail($invitation));
return $this->from('turbo124@gmail.com') //todo
return $this->from('x@gmail.com') //todo
->subject(ctrans('texts.confirmation_subject'))
->markdown('email.auth.verify', ['user' => $this->user])
->text('email.auth.verify_text');

View File

@ -39,7 +39,7 @@ class VerifyUser extends Mailable implements ShouldQueue
*/
public function build()
{
return $this->from('turbo124@gmail.com') //todo
return $this->from('x@gmail.com') //todo
->subject(ctrans('texts.confirmation_subject'))
->markdown('email.auth.verify', ['user' => $this->user])
->text('email.auth.verify_text');

View File

@ -103,7 +103,7 @@ class BaseNotification extends Notification implements ShouldQueue
$email_style_custom = $this->settings->email_style_custom;
$body = strtr($email_style_custom, "$body", $body);
}
$data = [
'body' => $body,
'design' => $design_style,
@ -120,4 +120,22 @@ class BaseNotification extends Notification implements ShouldQueue
return $data;
}
public function getTemplateView()
{
switch ($this->settings->email_style) {
case 'plain':
return 'email.template.plain';
break;
case 'custom':
return 'email.template.custom';
break;
default:
return 'email.admin.generic_email';
break;
}
}
}

View File

@ -73,10 +73,11 @@ class SendGenericNotification extends BaseNotification implements ShouldQueue
*/
public function toMail($notifiable)
{
$mail_message = (new MailMessage)
->withSwiftMessage(function ($message) {
$message->getHeaders()->addTextHeader('Tag', $this->invitation->company->company_key);
})->markdown('email.admin.generic_email', $this->buildMailMessageData());
})->markdown($this->getTemplateView(), $this->buildMailMessageData());
$mail_message = $this->buildMailMessageSettings($mail_message);

View File

@ -70,6 +70,9 @@ class ClientContactRepository extends BaseRepository
});
//need to reload here to shake off stale contacts
$client->load('contacts');
//always made sure we have one blank contact to maintain state
if ($client->contacts->count() == 0) {

View File

@ -84,22 +84,10 @@ class HtmlEngine
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private function buildEntityDataArray() :array
public function buildEntityDataArray() :array
{
if (!$this->client->currency()) {
throw new \Exception(debug_backtrace()[1]['function'], 1);
@ -132,21 +120,24 @@ class HtmlEngine
$data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: ' ', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
}
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
}
if ($this->entity_string == 'quote') {
$data['$entity_label'] = ['value' => '', 'label' => ctrans('texts.quote')];
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.quote_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
}
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
}
if ($this->entity_string == 'credit') {
$data['$entity_label'] = ['value' => '', 'label' => ctrans('texts.credit')];
$data['$number'] = ['value' => $this->entity->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$entity.terms'] = ['value' => $this->entity->terms ?: '&nbsp;', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
}
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];

View File

@ -187,6 +187,7 @@ trait MakesInvoiceValues
}
$calc = $this->calc();
$invitation = $this->invitations->where('client_contact_id', $contact->id)->first();
$data = [];
$data['$tax'] = ['value' => '', 'label' => ctrans('texts.tax')];
@ -214,6 +215,7 @@ trait MakesInvoiceValues
$data['$number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.invoice_number')];
$data['$entity.terms'] = ['value' => $this->terms ?: '&nbsp;', 'label' => ctrans('texts.invoice_terms')];
$data['$terms'] = &$data['$entity.terms'];
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_invoice').'</a>', 'label' => ctrans('texts.view_invoice')];
}
if ($this instanceof Quote) {
@ -221,13 +223,15 @@ trait MakesInvoiceValues
$data['$number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.quote_number')];
$data['$entity.terms'] = ['value' => $this->terms ?: '&nbsp;', 'label' => ctrans('texts.quote_terms')];
$data['$terms'] = &$data['$entity.terms'];
}
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_quote').'</a>', 'label' => ctrans('texts.view_quote')];
}
if ($this instanceof Credit) {
$data['$entity_label'] = ['value' => '', 'label' => ctrans('texts.credit')];
$data['$number'] = ['value' => $this->number ?: '&nbsp;', 'label' => ctrans('texts.credit_number')];
$data['$entity.terms'] = ['value' => $this->terms ?: '&nbsp;', 'label' => ctrans('texts.credit_terms')];
$data['$terms'] = &$data['$entity.terms'];
$data['$view_link'] = ['value' => '<a href="' .$invitation->getLink() .'">'. ctrans('texts.view_credit').'</a>', 'label' => ctrans('texts.view_credit')];
}
$data['$entity_number'] = &$data['$number'];