Working on gmail actions

This commit is contained in:
Hillel Coren 2015-11-08 10:43:49 +02:00
parent df8fb6f459
commit bef7454b73
6 changed files with 8454 additions and 18 deletions

View File

@ -2,9 +2,9 @@
use Utils;
use DateTime;
use App\Models\BalanceAffecting;
use Illuminate\Database\Eloquent\SoftDeletes;
use Laracasts\Presenter\PresentableTrait;
use App\Models\BalanceAffecting;
use App\Events\QuoteWasCreated;
use App\Events\QuoteWasUpdated;
use App\Events\InvoiceWasCreated;
@ -14,10 +14,12 @@ use App\Events\QuoteInvitationWasEmailed;
class Invoice extends EntityModel implements BalanceAffecting
{
use PresentableTrait;
use SoftDeletes {
SoftDeletes::trashed as parentTrashed;
}
protected $presenter = 'App\Ninja\Presenters\InvoicePresenter';
protected $dates = ['deleted_at'];
protected $casts = [

View File

@ -92,6 +92,7 @@ class ContactMailer extends Mailer
'invoiceId' => $invoice->id,
'invitation' => $invitation,
'account' => $account,
'invoice' => $invoice,
];
if ($account->attatchPDF()) {

View File

@ -0,0 +1,24 @@
<?php namespace App\Ninja\Presenters;
use Utils;
use Laracasts\Presenter\Presenter;
class InvoicePresenter extends Presenter {
public function minimumAmountDue()
{
$amount = $this->entity->getRequestedAmount();
$currencyId = $this->entity->client->currency_id;
return Utils::formatMoney($amount, $currencyId);
}
public function totalAmountDue()
{
$amount = $this->entity->balance;
$currencyId = $this->entity->client->currency_id;
return Utils::formatMoney($amount, $currencyId);
}
}

8386
composer.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
<meta charset="utf-8">
</head>
<body>
@if (false)
@if (Utils::isNinjaDev())
@include('emails.view_action', ['link' => $link, 'entityType' => $entityType])
@endif
{!! $body !!}

View File

@ -1,17 +1,40 @@
<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 !!}"
}
}
[
@if ($entityType == ENTITY_INVOICE)
{
"@context": "http://schema.org",
"@type": "Invoice",
"minimumPaymentDue": {
"@type": "PriceSpecification",
"price": "{{ $invoice->present()->minimumAmountDue }}"
},
"paymentStatus": "PaymentDue",
@if ($invoice->due_date)
"paymentDue": "{{ $invoice->due_date }}T00:00:00+00:00",
@endif
"provider": {
"@type": "Organization",
"name": "{{ $account->getDisplayName() }}"
},
"broker": {
"@type": "Organization",
"name": "Invoice Ninja",
"url": "{!! NINJA_WEB_URL !!}"
},
"totalPaymentDue": {
"@type": "PriceSpecification",
"price": "{{ $invoice->present()->totalAmountDue }}"
}
},
@endif
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"action": {
"@type": "ViewAction",
"url": "{!! $link !!}",
"name": "View {{ $entityType }}"
}
}
]
</script>