Added support for gmail one-click actions

This commit is contained in:
Hillel Coren 2015-03-11 23:37:43 +02:00
parent 228f772f02
commit 2cdf6d517a
9 changed files with 197 additions and 159 deletions

View File

@ -41,6 +41,8 @@ class ContactMailer extends Mailer
]; ];
$data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate); $data['body'] = str_replace(array_keys($variables), array_values($variables), $emailTemplate);
$data['link'] = $invitation->getLink();
$data['entityType'] = $entityType;
$fromEmail = $invitation->user->email; $fromEmail = $invitation->user->email;
$this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data); $this->sendTo($invitation->contact->email, $fromEmail, $accountName, $subject, $view, $data);

View File

@ -3,152 +3,156 @@
@section('content') @section('content')
<div class="row"> <div class="row">
<div class="col-md-4"> <div class="col-md-4">
<div class="panel panel-default"> <div class="panel panel-default">
<div class="panel-body"> <div class="panel-body">
<img src="{{ asset('images/totalincome.png') }}" class="in-image"/> <img src="{{ asset('images/totalincome.png') }}" class="in-image"/>
<div class="in-bold"> <div class="in-bold">
@foreach ($paidToDate as $item) @if (count($paidToDate))
{{ Utils::formatMoney($item->value, $item->currency_id); }}<br/> @foreach ($paidToDate as $item)
@endforeach {{ Utils::formatMoney($item->value, $item->currency_id); }}<br/>
@endforeach
@else
{{ Utils::formatMoney(0) }}
@endif
</div>
<div class="in-thin">
{{ trans('texts.in_total_revenue') }}
</div>
</div>
</div> </div>
<div class="in-thin">
{{ trans('texts.in_total_revenue') }}
</div>
</div>
</div> </div>
</div> <div class="col-md-4">
<div class="col-md-4"> <div class="panel panel-default">
<div class="panel panel-default"> <div class="panel-body">
<div class="panel-body"> <img src="{{ asset('images/clients.png') }}" class="in-image"/>
<img src="{{ asset('images/clients.png') }}" class="in-image"/> <div class="in-bold">
<div class="in-bold"> {{ $billedClients }}
{{ $billedClients }} </div>
<div class="in-thin">
{{ Utils::pluralize('billed_client', $billedClients) }}
</div>
</div>
</div> </div>
<div class="in-thin">
{{ Utils::pluralize('billed_client', $billedClients) }}
</div>
</div>
</div> </div>
</div> <div class="col-md-4">
<div class="col-md-4"> <div class="panel panel-default">
<div class="panel panel-default"> <div class="panel-body">
<div class="panel-body"> <img src="{{ asset('images/totalinvoices.png') }}" class="in-image"/>
<img src="{{ asset('images/totalinvoices.png') }}" class="in-image"/> <div class="in-bold">
<div class="in-bold"> {{ $invoicesSent }}
{{ $invoicesSent }} </div>
<div class="in-thin">
{{ Utils::pluralize('invoice', $invoicesSent) }} {{ trans('texts.sent') }}
</div>
</div>
</div> </div>
<div class="in-thin">
{{ Utils::pluralize('invoice', $invoicesSent) }} {{ trans('texts.sent') }}
</div>
</div>
</div> </div>
</div>
</div> </div>
<p>&nbsp;</p> <p>&nbsp;</p>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="panel panel-default dashboard" style="min-height:320px"> <div class="panel panel-default dashboard" style="min-height:320px">
<div class="panel-heading" style="background-color:#0b4d78"> <div class="panel-heading" style="background-color:#0b4d78">
<h3 class="panel-title in-bold-white"> <h3 class="panel-title in-bold-white">
<i class="glyphicon glyphicon-exclamation-sign"></i> {{ trans('texts.notifications') }} <i class="glyphicon glyphicon-exclamation-sign"></i> {{ trans('texts.notifications') }}
</h3> </h3>
</div> </div>
<ul class="panel-body list-group"> <ul class="panel-body list-group">
@foreach ($activities as $activity) @foreach ($activities as $activity)
<li class="list-group-item"> <li class="list-group-item">
<span style="color:#888;font-style:italic">{{ Utils::timestampToDateString(strtotime($activity->created_at)) }}:</span> <span style="color:#888;font-style:italic">{{ Utils::timestampToDateString(strtotime($activity->created_at)) }}:</span>
{{ Utils::decodeActivity($activity->message) }} {{ Utils::decodeActivity($activity->message) }}
</li> </li>
@endforeach @endforeach
</ul> </ul>
</div>
</div> </div>
</div> <div class="col-md-6">
<div class="col-md-6"> <div class="panel panel-default dashboard" style="min-height:320px">
<div class="panel panel-default dashboard" style="min-height:320px"> <div class="panel-heading" style="background-color:#e37329">
<div class="panel-heading" style="background-color:#e37329"> <h3 class="panel-title in-bold-white">
<h3 class="panel-title in-bold-white"> <i class="glyphicon glyphicon-time"></i> {{ trans('texts.invoices_past_due') }}
<i class="glyphicon glyphicon-time"></i> {{ trans('texts.invoices_past_due') }} </h3>
</h3> </div>
</div> <div class="panel-body">
<div class="panel-body"> <table class="table table-striped">
<table class="table table-striped"> <thead>
<thead> <th>{{ trans('texts.invoice_number_short') }}</th>
<th>{{ trans('texts.invoice_number_short') }}</th> <th>{{ trans('texts.client') }}</th>
<th>{{ trans('texts.client') }}</th> <th>{{ trans('texts.due_date') }}</th>
<th>{{ trans('texts.due_date') }}</th> <th>{{ trans('texts.balance_due') }}</th>
<th>{{ trans('texts.balance_due') }}</th> </thead>
</thead> <tbody>
<tbody> @foreach ($pastDue as $invoice)
@foreach ($pastDue as $invoice) @if (!$invoice->client->trashed())
@if (!$invoice->client->trashed()) <tr>
<tr> <td>{{ $invoice->getLink() }}</td>
<td>{{ $invoice->getLink() }}</td> <td>{{ $invoice->client->getDisplayName() }}</td>
<td>{{ $invoice->client->getDisplayName() }}</td> <td>{{ Utils::fromSqlDate($invoice->due_date) }}</td>
<td>{{ Utils::fromSqlDate($invoice->due_date) }}</td> <td>{{ Utils::formatMoney($invoice->balance, $invoice->client->currency_id) }}</td>
<td>{{ Utils::formatMoney($invoice->balance, $invoice->client->currency_id) }}</td> </tr>
</tr> @endif
@endif @endforeach
@endforeach </tbody>
</tbody> </table>
</table> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<div class="panel panel-default dashboard" style="min-height:320px;"> <div class="panel panel-default dashboard" style="min-height:320px;">
<div class="panel-heading" style="margin:0;"> <div class="panel-heading" style="margin:0;">
<h3 class="panel-title"> <h3 class="panel-title">
<i class="glyphicon glyphicon-time"></i> {{ trans('texts.upcoming_invoices') }} <i class="glyphicon glyphicon-time"></i> {{ trans('texts.upcoming_invoices') }}
</h3> </h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<th>{{ trans('texts.invoice_number_short') }}</th> <th>{{ trans('texts.invoice_number_short') }}</th>
<th>{{ trans('texts.client') }}</th> <th>{{ trans('texts.client') }}</th>
<th>{{ trans('texts.due_date') }}</th> <th>{{ trans('texts.due_date') }}</th>
<th>{{ trans('texts.balance_due') }}</th> <th>{{ trans('texts.balance_due') }}</th>
</thead> </thead>
<tbody> <tbody>
@foreach ($upcoming as $invoice) @foreach ($upcoming as $invoice)
@if (!$invoice->client->trashed()) @if (!$invoice->client->trashed())
<tr> <tr>
<td>{{ $invoice->getLink() }}</td> <td>{{ $invoice->getLink() }}</td>
<td>{{ $invoice->client->getDisplayName() }}</td> <td>{{ $invoice->client->getDisplayName() }}</td>
<td>{{ Utils::fromSqlDate($invoice->due_date) }}</td> <td>{{ Utils::fromSqlDate($invoice->due_date) }}</td>
<td>{{ Utils::formatMoney($invoice->balance, $invoice->client->currency_id) }}</td> <td>{{ Utils::formatMoney($invoice->balance, $invoice->client->currency_id) }}</td>
</tr> </tr>
@endif @endif
@endforeach @endforeach
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
</div> </div>
</div>
<div class="col-md-3">
<div class="active-clients">
<div class="in-bold in-white" style="font-size:42px">{{ $activeClients }}</div>
<div class="in-thin in-white">{{ Utils::pluralize('active_client', $activeClients) }}</div>
</div>
</div>
<div class="col-md-3"> <div class="col-md-3">
<div class="average-invoice"> <div class="active-clients">
<div><b>{{ trans('texts.average_invoice') }}</b></div> <div class="in-bold in-white" style="font-size:42px">{{ $activeClients }}</div>
<div class="in-bold in-white" style="font-size:42px"> <div class="in-thin in-white">{{ Utils::pluralize('active_client', $activeClients) }}</div>
@foreach ($averageInvoice as $item) </div>
{{ Utils::formatMoney($item->invoice_avg, $item->currency_id); }}<br/>
@endforeach
</div>
</div> </div>
<div class="col-md-3">
<div class="average-invoice">
<div><b>{{ trans('texts.average_invoice') }}</b></div>
<div class="in-bold in-white" style="font-size:42px">
@foreach ($averageInvoice as $item)
{{ Utils::formatMoney($item->invoice_avg, $item->currency_id); }}<br/>
@endforeach
</div>
</div>
</div> </div>
</div> </div>
@stop @stop

View File

@ -1,33 +1,41 @@
<html> <html>
<body> <body>
<script type="application/ld+json"> @if (!$invitationMessage)
<script type="application/ld+json">
{ {
"@context":"http://schema.org", "@context":"http://schema.org",
"@type":"EmailMessage", "@type":"EmailMessage",
"description":"Confirm your Invoice Ninja account", "description":"Confirm your Invoice Ninja account",
"action": "action":
{ {
"@type":"ConfirmAction", "@type":"ConfirmAction",
"name":"Confirm Account", "name":"Confirm account",
"handler": { "handler": {
"@type": "HttpActionHandler", "@type": "HttpActionHandler",
"url": "{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}" "url": "{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}"
},
"publisher": {
"@type": "Organization",
"name": "Invoice Ninja",
"url": "{{{ NINJA_WEB_URL }}}"
}
} }
}
} }
</script> </script>
@endif
<h1>{{ trans('texts.confirmation_header') }}</h1> <h1>{{ trans('texts.confirmation_header') }}</h1>
<p> <p>
{{ $invitationMessage . trans('texts.confirmation_message') }}<br/> {{ $invitationMessage . trans('texts.confirmation_message') }}<br/>
<a href='{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}'> <a href='{{{ URL::to("user/confirm/{$user->confirmation_code}") }}}'>
{{{ URL::to("user/confirm/{$user->confirmation_code}") }}} {{{ URL::to("user/confirm/{$user->confirmation_code}") }}}
</a> </a>
<p/> <p/>
{{ trans('texts.email_signature') }}<br/> {{ trans('texts.email_signature') }}<br/>
{{ trans('texts.email_from') }} {{ trans('texts.email_from') }}
</p>
</body> </body>
</html> </html>

View File

@ -1,7 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
</head> </head>
<body>{{ $body }}</body> <body>
@include('emails.view_action', ['link' => $link, 'entityType' => $entityType])
{{ $body }}
</body>
</html> </html>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
</head> </head>
<body> <body>
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/> {{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
{{ trans("texts.notification_{$entityType}_paid", ['amount' => $paymentAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/> {{ trans("texts.notification_{$entityType}_paid", ['amount' => $paymentAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
</head> </head>
<body> <body>
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/> {{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
{{ trans("texts.notification_{$entityType}_sent", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/> {{ trans("texts.notification_{$entityType}_sent", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>

View File

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
</head> </head>
<body> <body>
@include('emails.view_action', ['link' => $invoiceLink, 'entityType' => $entityType])
{{ trans('texts.email_salutation', ['name' => $userName]) }} <p/> {{ trans('texts.email_salutation', ['name' => $userName]) }} <p/>
{{ trans("texts.notification_{$entityType}_viewed", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/> {{ trans("texts.notification_{$entityType}_viewed", ['amount' => $invoiceAmount, 'client' => $clientName, 'invoice' => $invoiceNumber]) }} <p/>

View File

@ -0,0 +1,17 @@
<script type="application/ld+json">
{
"@context":"http://schema.org",
"@type":"EmailMessage",
"description":"View your {{ $entityType }}",
"action": {
"@type": "ViewAction",
"url": "{{{ $link }}}",
"name": "View {{ $entityType }}"
},
"publisher": {
"@type": "Organization",
"name": "Invoice Ninja",
"url": "{{{ NINJA_WEB_URL }}}"
}
}
</script>

View File

@ -366,6 +366,10 @@ Want something changed? We're {{ link_to('https://github.com/hillelcoren/invoice
<div class="modal-footer" id="signUpFooter" style="margin-top: 0px"> <div class="modal-footer" id="signUpFooter" style="margin-top: 0px">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }} </button> <button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.close') }} </button>
{{-- DropdownButton::success_lg(trans('texts.buy'), [
['url' => URL::to(""), 'label' => trans('texts.pay_with_paypal')],
['url' => URL::to(""), 'label' => trans('texts.pay_with_card')]
])->addClass('btn-lg') --}}
<button type="button" class="btn btn-primary" onclick="buyProduct('{{ WHITE_LABEL_AFFILIATE_KEY }}', '{{ PRODUCT_WHITE_LABEL }}')">{{ trans('texts.buy') }} </button> <button type="button" class="btn btn-primary" onclick="buyProduct('{{ WHITE_LABEL_AFFILIATE_KEY }}', '{{ PRODUCT_WHITE_LABEL }}')">{{ trans('texts.buy') }} </button>
</div> </div>
</div> </div>