diff --git a/app/Listeners/InvoiceListener.php b/app/Listeners/InvoiceListener.php index 55759ba82ff8..ac4918af1d2a 100644 --- a/app/Listeners/InvoiceListener.php +++ b/app/Listeners/InvoiceListener.php @@ -1,7 +1,10 @@ payment; - $invoice = $payment->invoice; - $adjustment = $payment->amount * -1; - $partial = max(0, $invoice->partial - $payment->amount); + if (Utils::isPro()) { + return; + } - $invoice->updateBalances($adjustment, $partial); - $invoice->updatePaidStatus(); + $invoice = $event->invoice; + $account = Auth::user()->account; + + if ($account->invoice_design_id != $invoice->invoice_design_id) { + $account->invoice_design_id = $invoice->invoice_design_id; + $account->save(); + } } public function updatedInvoice(InvoiceWasUpdated $event) @@ -32,6 +39,17 @@ class InvoiceListener $invitation->markViewed(); } + public function createdPayment(PaymentWasCreated $event) + { + $payment = $event->payment; + $invoice = $payment->invoice; + $adjustment = $payment->amount * -1; + $partial = max(0, $invoice->partial - $payment->amount); + + $invoice->updateBalances($adjustment, $partial); + $invoice->updatePaidStatus(); + } + public function deletedPayment(PaymentWasDeleted $event) { $payment = $event->payment; diff --git a/app/Models/Account.php b/app/Models/Account.php index 456facf62df5..cecb48237406 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -20,7 +20,6 @@ class Account extends Eloquent protected $presenter = 'App\Ninja\Presenters\AccountPresenter'; protected $dates = ['deleted_at']; protected $hidden = ['ip']; - public $fonts_obj = null; public static $basicSettings = [ ACCOUNT_COMPANY_DETAILS, @@ -36,8 +35,8 @@ class Account extends Eloquent public static $advancedSettings = [ ACCOUNT_INVOICE_SETTINGS, ACCOUNT_INVOICE_DESIGN, - ACCOUNT_CLIENT_PORTAL, ACCOUNT_EMAIL_SETTINGS, + ACCOUNT_CLIENT_PORTAL, ACCOUNT_TEMPLATES_AND_REMINDERS, ACCOUNT_CHARTS_AND_REPORTS, ACCOUNT_DATA_VISUALIZATIONS, @@ -897,6 +896,11 @@ class Account extends Eloquent return $css; } + public function hasLargeFont() + { + return stripos($this->getBodyFontName(), 'chinese') || stripos($this->getHeaderFontName(), 'chinese'); + } + public function getFontsUrl($protocol = ''){ if ($this->isPro()){ $bodyFont = $this->body_font_id; diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 7e0743d501c4..37a09fbc44ca 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -31,6 +31,7 @@ class EventServiceProvider extends ServiceProvider { 'App\Events\InvoiceWasCreated' => [ 'App\Listeners\ActivityListener@createdInvoice', 'App\Listeners\SubscriptionListener@createdInvoice', + 'App\Listeners\InvoiceListener@createdInvoice', ], 'App\Events\InvoiceWasUpdated' => [ 'App\Listeners\ActivityListener@updatedInvoice', diff --git a/public/js/built.js b/public/js/built.js index 044b9c6931bd..4331c8699121 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -30926,8 +30926,13 @@ function GetPdfMake(invoice, javascript, callback) { } } - // only show the footer on the last page - if (invoice.is_pro && key === 'footer') { + // only show the header on the first page + // and the footer on the last page + if (key === 'header') { + return function(page, pages) { + return page === 1 ? val : ''; + } + } else if (invoice.is_pro && key === 'footer') { return function(page, pages) { return page === pages ? val : ''; } diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index 52f3910b5020..11403d60cb64 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -54,8 +54,13 @@ function GetPdfMake(invoice, javascript, callback) { } } - // only show the footer on the last page - if (invoice.is_pro && key === 'footer') { + // only show the header on the first page + // and the footer on the last page + if (key === 'header') { + return function(page, pages) { + return page === 1 ? val : ''; + } + } else if (invoice.is_pro && key === 'footer') { return function(page, pages) { return page === pages ? val : ''; } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 3b1582a3df20..10e253be27b0 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1031,4 +1031,5 @@ return array( 'body_font_id' => 'Body Font', 'color_font_help' => 'Note: the primary color and fonts are also used in the client portal and custom email designs.', + 'live_preview' => 'Live Preview', ); \ No newline at end of file diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 38db2a601b11..98dac26a6f5d 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -122,32 +122,46 @@