From 3b5311e9607670c61d162ef0e6dd7c79e29583e3 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 1 Mar 2016 09:36:37 +0200 Subject: [PATCH] Added setting to show/hide client portal dashboard --- app/Http/Controllers/AccountController.php | 2 ++ .../Controllers/PublicClientController.php | 20 +++++++++++-------- resources/lang/en/texts.php | 5 ++++- .../views/accounts/client_portal.blade.php | 18 +++++++++++++++-- resources/views/accounts/nav.blade.php | 6 ++---- resources/views/public/header.blade.php | 8 +++++--- 6 files changed, 41 insertions(+), 18 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 7d141e8cb2..0a5d89262a 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -432,6 +432,7 @@ class AccountController extends BaseController 'client_view_css' => $css, 'title' => trans("texts.client_portal"), 'section' => ACCOUNT_CLIENT_PORTAL, + 'account' => $account, ]; return View::make("accounts.client_portal", $data); @@ -544,6 +545,7 @@ class AccountController extends BaseController $account = Auth::user()->account; $account->client_view_css = $sanitized_css; + $account->enable_client_portal = Input::get('enable_client_portal') ? true : false; $account->save(); Session::flash('message', trans('texts.updated_settings')); diff --git a/app/Http/Controllers/PublicClientController.php b/app/Http/Controllers/PublicClientController.php index 9d806061d8..d9a11e5c94 100644 --- a/app/Http/Controllers/PublicClientController.php +++ b/app/Http/Controllers/PublicClientController.php @@ -34,10 +34,7 @@ class PublicClientController extends BaseController public function view($invitationKey) { if (!$invitation = $this->invoiceRepo->findInvoiceByInvitation($invitationKey)) { - return response()->view('error', [ - 'error' => trans('texts.invoice_not_found'), - 'hideHeader' => true, - ]); + return $this->returnError(); } $invoice = $invitation->invoice; @@ -118,6 +115,7 @@ class PublicClientController extends BaseController 'showBreadcrumbs' => false, 'hideLogo' => $account->isWhiteLabel(), 'hideHeader' => $account->isNinjaAccount(), + 'hideDashboard' => !$account->enable_client_portal, 'clientViewCSS' => $account->clientViewCSS(), 'clientFontUrl' => $account->getFontsUrl(), 'invoice' => $invoice->hidePrivateFields(), @@ -188,11 +186,16 @@ class PublicClientController extends BaseController if (!$invitation = $this->getInvitation()) { return $this->returnError(); } + $account = $invitation->account; $invoice = $invitation->invoice; $client = $invoice->client; $color = $account->primary_color ? $account->primary_color : '#0b4d78'; + if (!$account->enable_client_portal) { + return $this->returnError(); + } + $data = [ 'color' => $color, 'account' => $account, @@ -244,6 +247,7 @@ class PublicClientController extends BaseController $data = [ 'color' => $color, 'hideLogo' => $account->isWhiteLabel(), + 'hideDashboard' => !$account->enable_client_portal, 'clientViewCSS' => $account->clientViewCSS(), 'clientFontUrl' => $account->getFontsUrl(), 'title' => trans('texts.invoices'), @@ -275,6 +279,7 @@ class PublicClientController extends BaseController $data = [ 'color' => $color, 'hideLogo' => $account->isWhiteLabel(), + 'hideDashboard' => !$account->enable_client_portal, 'clientViewCSS' => $account->clientViewCSS(), 'clientFontUrl' => $account->getFontsUrl(), 'entityType' => ENTITY_PAYMENT, @@ -312,6 +317,7 @@ class PublicClientController extends BaseController $data = [ 'color' => $color, 'hideLogo' => $account->isWhiteLabel(), + 'hideDashboard' => !$account->enable_client_portal, 'clientViewCSS' => $account->clientViewCSS(), 'clientFontUrl' => $account->getFontsUrl(), 'title' => trans('texts.quotes'), @@ -332,13 +338,11 @@ class PublicClientController extends BaseController return $this->invoiceRepo->getClientDatatable($invitation->contact_id, ENTITY_QUOTE, Input::get('sSearch')); } - private function returnError() + private function returnError($error = false) { return response()->view('error', [ - 'error' => trans('texts.invoice_not_found'), + 'error' => $error ?: trans('texts.invoice_not_found'), 'hideHeader' => true, - 'clientViewCSS' => $account->clientViewCSS(), - 'clientFontUrl' => $account->getFontsUrl(), ]); } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 9c9c8e9a59..c330dbd894 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -1048,7 +1048,10 @@ $LANG = array( 'invoice_item_fields' => 'Invoice Item Fields', 'custom_invoice_item_fields_help' => 'Add a field when creating an invoice item and display the label and value on the PDF.', 'recurring_invoice_number' => 'Recurring Invoice Number', - 'recurring_invoice_number_prefix_help' => 'Speciy a prefix to be added to the invoice number for recurring invoices. The default value is \'R\'.' + 'recurring_invoice_number_prefix_help' => 'Speciy a prefix to be added to the invoice number for recurring invoices. The default value is \'R\'.', + 'enable_client_portal' => 'Dashboard', + 'enable_client_portal_help' => 'Show/hide the dashboard page in the client portal.', + ); return $LANG; diff --git a/resources/views/accounts/client_portal.blade.php b/resources/views/accounts/client_portal.blade.php index 5ba8fcf5bc..88962e4d0d 100644 --- a/resources/views/accounts/client_portal.blade.php +++ b/resources/views/accounts/client_portal.blade.php @@ -12,6 +12,7 @@ {!! Former::open_for_files() ->addClass('warn-on-exit') !!} + {!! Former::populateField('enable_client_portal', intval($account->enable_client_portal)) !!} {!! Former::populateField('client_view_css', $client_view_css) !!} @if (!Utils::isNinja() && !Auth::user()->account->isWhiteLabel()) @@ -25,7 +26,20 @@ @include('accounts.nav', ['selected' => ACCOUNT_CLIENT_PORTAL])
-
+
+ +
+
+

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

+
+
+
+ {!! Former::checkbox('enable_client_portal') + ->text(trans('texts.enable')) + ->help(trans('texts.enable_client_portal_help')) !!} +
+
+
@@ -43,7 +57,7 @@
-
+
diff --git a/resources/views/accounts/nav.blade.php b/resources/views/accounts/nav.blade.php index b0aa4dd767..ae7f38c2fa 100644 --- a/resources/views/accounts/nav.blade.php +++ b/resources/views/accounts/nav.blade.php @@ -22,10 +22,8 @@