1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Working on email markup

This commit is contained in:
Hillel Coren 2015-12-16 13:49:26 +02:00
parent f4863d3ec0
commit 4dc7a8d5f1
20 changed files with 79 additions and 29 deletions

View File

@ -9,6 +9,7 @@ class QuoteInvitationWasApproved extends Event {
use SerializesModels;
public $quote;
public $invoice;
public $invitation;
/**
@ -16,9 +17,10 @@ class QuoteInvitationWasApproved extends Event {
*
* @return void
*/
public function __construct($quote, $invitation)
public function __construct($quote, $invoice, $invitation)
{
$this->quote = $quote;
$this->invoice = $invoice;
$this->invitation = $invitation;
}

View File

@ -34,7 +34,6 @@ class StartupCheck
// Ensure all request are over HTTPS in production
if (Utils::requireHTTPS() && !Request::secure()) {
//return Redirect::secure(Request::getRequestUri());
return Redirect::secure(Request::path());
}

View File

@ -445,7 +445,7 @@ if (!defined('CONTACT_EMAIL')) {
define('PHANTOMJS_CLOUD', 'http://api.phantomjscloud.com/api/browser/v2/');
define('PHP_DATE_FORMATS', 'http://php.net/manual/en/function.date.php');
define('REFERRAL_PROGRAM_URL', 'https://www.invoiceninja.com/referral-program/');
define('EMAIL_MARKUP_URL', 'https://developers.google.com/gmail/markup/overview');
define('EMAIL_MARKUP_URL', 'https://developers.google.com/gmail/markup');
define('COUNT_FREE_DESIGNS', 4);
define('COUNT_FREE_DESIGNS_SELF_HOST', 5); // include the custom design

View File

@ -313,6 +313,15 @@ class Invoice extends EntityModel implements BalanceAffecting
return $this->invoice_status_id >= INVOICE_STATUS_PAID;
}
public function isOverdue()
{
if ( ! $this->due_date) {
return false;
}
return time() > strtotime($this->due_date);
}
public function getRequestedAmount()
{
return $this->partial > 0 ? $this->partial : $this->balance;

View File

@ -172,7 +172,12 @@ class ContactMailer extends Mailer
$data = [
'body' => $this->processVariables($emailTemplate, $variables),
'link' => $invitation->getLink(),
'invoice' => $invoice,
'client' => $client,
'account' => $account,
'payment' => $payment,
'entityType' => ENTITY_INVOICE,
];
if ($account->attatchPDF()) {

View File

@ -53,6 +53,7 @@ class UserMailer extends Mailer
'invoiceAmount' => $account->formatMoney($invoice->getRequestedAmount(), $client),
'invoiceNumber' => $invoice->invoice_number,
'invoiceLink' => SITE_URL."/{$entityType}s/{$invoice->public_id}",
'account' => $account,
];
if ($payment) {
@ -70,6 +71,7 @@ class UserMailer extends Mailer
public function sendEmailBounced(Invitation $invitation)
{
$user = $invitation->user;
$account = $user->account;
$invoice = $invitation->invoice;
$entityType = $invoice->getEntityType();

View File

@ -26,6 +26,18 @@ class InvoicePresenter extends Presenter {
}
}
// https://schema.org/PaymentStatusType
public function paymentStatus()
{
if ( ! $this->entity->balance) {
return 'PaymentComplete';
} elseif ($this->entity->isOverdue()) {
return 'PaymentPastDue';
} else {
return 'PaymentDue';
}
}
public function status()
{
$status = $this->entity->invoice_status ? $this->entity->invoice_status->name : 'draft';

View File

@ -627,6 +627,8 @@ class InvoiceRepository extends BaseRepository
if ($recurInvoice->auto_bill) {
if ($this->paymentService->autoBillInvoice($invoice)) {
// update the invoice reference to match its actual state
// this is to ensure a 'payment received' email is sent
$invoice->invoice_status_id = INVOICE_STATUS_PAID;
}
}

View File

@ -74,7 +74,7 @@ class InvoiceService extends BaseService
return $invoice;
}
event(new QuoteInvitationWasApproved($invoice, $invitation));
event(new QuoteInvitationWasApproved($quote, $invoice, $invitation));
foreach ($invoice->invitations as $invoiceInvitation) {
if ($invitation->contact_id == $invoiceInvitation->contact_id) {

View File

@ -15,9 +15,20 @@
</div>
<div class="panel-body form-padding-right">
{!! Former::checkbox('pdf_email_attachment')->text(trans('texts.enable')) !!}
&nbsp;
{{-- Former::select('recurring_hour')->options($recurringHours) --}}
{!! Former::select('email_design_id')
->style('width: 200px')
->addOption(trans('texts.plain'), 1)
->addOption(trans('texts.light'), 2)
->addOption(trans('texts.dark'), 3)
->help(trans('texts.email_design_help')) !!}
&nbsp;
{!! Former::inline_radios('custom_invoice_link')
->onchange('onCustomLinkChange()')
->label(trans('texts.invoice_link'))
@ -41,13 +52,6 @@
->label(' ')
->help(trans('texts.subdomain_help')) !!}
&nbsp;
{!! Former::select('email_design_id')
->style('width: 200px')
->addOption(trans('texts.plain'), 1)
->addOption(trans('texts.light'), 2)
->addOption(trans('texts.dark'), 3)
->help(trans('texts.email_design_help')) !!}
&nbsp;
@if (Utils::isNinja())
{!! Former::checkbox('enable_email_markup')
->text(trans('texts.enable') .

View File

@ -4,9 +4,6 @@
<meta charset="utf-8">
</head>
<body>
@if (false)
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
@endif
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
{{ trans("texts.notification_{$entityType}_bounced", ['contact' => $contactName, 'invoice' => $invoiceNumber]) }} <p/>

View File

@ -5,7 +5,7 @@
</head>
<body>
@if ($account->enable_email_markup)
@include('emails.view_action', ['link' => $link, 'entityType' => $entityType])
@include('emails.partials.client_view_action')
@endif
{!! $body !!}
</body>

View File

@ -4,8 +4,8 @@
<meta charset="utf-8">
</head>
<body>
@if (false)
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
@if ($account->enable_email_markup)
@include('emails.partials.user_view_action')
@endif
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>

View File

@ -4,8 +4,8 @@
<meta charset="utf-8">
</head>
<body>
@if (false)
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
@if ($account->enable_email_markup)
@include('emails.partials.user_view_action')
@endif
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>

View File

@ -4,8 +4,8 @@
<meta charset="utf-8">
</head>
<body>
@if (false)
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
@if ($account->enable_email_markup)
@include('emails.partials.user_view_action')
@endif
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>

View File

@ -7,7 +7,7 @@
<body style="min-height: 700px; color: #000000; font-family: Arial, Helvetica, sans-serif; font-size: 12px; -webkit-text-size-adjust: none; -ms-text-size-adjust: none; background: #F4F5F5; margin: 0; padding: 0;"
alink="#FF0000" link="#FF0000" bgcolor="#F4F5F5" text="#000000" yahoo="fix">
@if ($account->enable_email_markup)
@include('emails.view_action', ['link' => $link, 'entityType' => $entityType])
@include('emails.partials.client_view_action')
@endif
<style type="text/css">

View File

@ -4,7 +4,7 @@
{
"@context": "http://schema.org",
"@type": "Invoice",
"paymentStatus": "PaymentDue",
"paymentStatus": "{{ $invoice->present()->paymentStatus }}",
@if ($invoice->due_date)
"paymentDue": "{{ $invoice->due_date }}T00:00:00+00:00",
@endif
@ -19,7 +19,7 @@
},
"totalPaymentDue": {
"@type": "PriceSpecification",
"price": "{{ $account->formatMoney($invoice->getRequestedAmount(), $client) }}"
"price": "{{ $account->formatMoney(isset($payment) ? $payment->amount : $invoice->getRequestedAmount(), $client) }}"
},
"action": {
"@type": "ViewAction",

View File

@ -0,0 +1,13 @@
<script type="application/ld+json">
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"action": {
"@type": "ViewAction",
"url": "{!! $invoiceLink !!}",
"name": "{{ trans("texts.view_{$entityType}") }}"
}
}
]
</script>

View File

@ -3,5 +3,10 @@
<head>
<meta charset="utf-8">
</head>
<body>{!! $body !!}</body>
<body>
@if ($account->enable_email_markup)
@include('emails.partials.client_view_action', ['link' => $link])
@endif
{!! $body !!}
</body>
</html>

View File

@ -4,12 +4,12 @@
<meta charset="utf-8">
</head>
<body>
@if (false)
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
@if ($account->enable_email_markup)
@include('emails.partials.user_view_action')
@endif
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
{{ trans("texts.notification_{$entityType}_approved", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>
{{ trans("texts.notification_quote_approved", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>
{{ trans('texts.email_signature') }} <br/>
{{ trans('texts.email_from') }} <p/>