diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index e6f9ce229bf4..54475fbb6983 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -730,9 +730,27 @@ class AccountController extends BaseController */ private function saveAccountManagement() { - $account = Auth::user()->account; + $user = Auth::user(); + $account = $user->account; $modules = Input::get('modules'); + $user->force_pdfjs = Input::get('force_pdfjs') ? true : false; + $user->save(); + + $account->live_preview = Input::get('live_preview') ? true : false; + + // Automatically disable live preview when using a large font + $fonts = Cache::get('fonts')->filter(function($font) use ($account) { + if ($font->google_font) { + return false; + } + return $font->id == $account->header_font_id || $font->id == $account->body_font_id; + }); + if ($account->live_preview && count($fonts)) { + $account->live_preview = false; + Session::flash('warning', trans('texts.live_preview_disabled')); + } + $account->enabled_modules = $modules ? array_sum($modules) : 0; $account->save(); @@ -1045,19 +1063,6 @@ class AccountController extends BaseController $account->invoice_design_id = Input::get('invoice_design_id'); $account->font_size = intval(Input::get('font_size')); $account->page_size = Input::get('page_size'); - $account->live_preview = Input::get('live_preview') ? true : false; - - // Automatically disable live preview when using a large font - $fonts = Cache::get('fonts')->filter(function($font) use ($account) { - if ($font->google_font) { - return false; - } - return $font->id == $account->header_font_id || $font->id == $account->body_font_id; - }); - if ($account->live_preview && count($fonts)) { - $account->live_preview = false; - Session::flash('warning', trans('texts.live_preview_disabled')); - } $labels = []; foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms', 'balance_due', 'partial_due', 'subtotal', 'paid_to_date', 'discount', 'tax'] as $field) { diff --git a/app/Http/routes.php b/app/Http/routes.php index 7255fb3facac..157356357d1b 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -664,6 +664,8 @@ if (!defined('CONTACT_EMAIL')) { define('OFX_HOME_URL', env('OFX_HOME_URL', 'http://www.ofxhome.com/index.php/home/directory/all')); define('GOOGLE_ANALYITCS_URL', env('GOOGLE_ANALYITCS_URL', 'https://www.google-analytics.com/collect')); define('TRANSIFEX_URL', env('TRANSIFEX_URL', 'https://www.transifex.com/invoice-ninja/invoice-ninja')); + define('CHROME_PDF_HELP_URL', 'https://support.google.com/chrome/answer/6213030?hl=en'); + define('FIREFOX_PDF_HELP_URL', 'https://support.mozilla.org/en-US/kb/view-pdf-files-firefox'); define('MSBOT_LOGIN_URL', 'https://login.microsoftonline.com/common/oauth2/v2.0/token'); define('MSBOT_LUIS_URL', 'https://api.projectoxford.ai/luis/v1/application'); diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 1c644b97aad6..9eb3cac17e12 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2252,6 +2252,9 @@ $LANG = array( 'update_credit' => 'Update Credit', 'updated_credit' => 'Successfully updated credit', 'edit_credit' => 'Edit Credit', + 'live_preview_help' => 'Display a live PDF preview on the invoice page.
Disable this to improve performance when editing invoices.', + 'force_pdfjs_help' => 'Replace the built-in PDF viewer in :chrome_link or :firefox_link.
Enable this if your browser is automatically downloading the PDF.', + 'force_pdfjs' => 'PDF Viewer', ); diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 550ef5757eab..6bb524c6869f 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -120,7 +120,6 @@ {!! Former::populateField('invoice_design_id', $account->invoice_design_id) !!} {!! Former::populateField('body_font_id', $account->getBodyFontId()) !!} {!! Former::populateField('header_font_id', $account->getHeaderFontId()) !!} - {!! Former::populateField('live_preview', intval($account->live_preview)) !!} {!! Former::populateField('font_size', $account->font_size) !!} {!! Former::populateField('page_size', $account->page_size) !!} {!! Former::populateField('invoice_embed_documents', intval($account->invoice_embed_documents)) !!} @@ -175,8 +174,6 @@ {!! Former::select('header_font_id') ->fromQuery($invoiceFonts, 'name', 'id') !!} - {!! Former::checkbox('live_preview')->text(trans('texts.enable')) !!} -
diff --git a/resources/views/accounts/management.blade.php b/resources/views/accounts/management.blade.php index bf6d123fc7ae..c94733ba5c9d 100644 --- a/resources/views/accounts/management.blade.php +++ b/resources/views/accounts/management.blade.php @@ -142,6 +142,9 @@ {!! Former::open('settings/account_management') !!} + {!! Former::populateField('live_preview', intval($account->live_preview)) !!} + {!! Former::populateField('force_pdfjs', intval(Auth::user()->force_pdfjs)) !!} +

{!! trans('texts.modules') !!}

@@ -167,6 +170,33 @@
+ +
+
+

{!! trans('texts.pdf_settings') !!}

+
+
+ + {!! Former::checkbox('live_preview') + ->text(trans('texts.enable')) + ->help('live_preview_help') !!} + + {!! Former::checkbox('force_pdfjs') + ->text(trans('texts.enable')) + ->help(trans('texts.force_pdfjs_help', [ + 'chrome_link' => link_to(CHROME_PDF_HELP_URL, 'Chrome', ['target' => '_blank']), + 'firefox_link' => link_to(FIREFOX_PDF_HELP_URL, 'Firefox', ['target' => '_blank']), + ])) !!} + +
+ +
+ {!! Button::success(trans('texts.save'))->submit()->large()->appendIcon(Icon::create('floppy-disk')) !!} +
+
+
+
+ {!! Former::close() !!} {!! Former::open('settings/cancel_account')->addClass('cancel-account') !!}