diff --git a/app/Constants.php b/app/Constants.php index 274dc41c01d7..e56cfaeb1e2f 100644 --- a/app/Constants.php +++ b/app/Constants.php @@ -464,7 +464,6 @@ if (!defined('APP_NAME')) define('FEATURE_MORE_CLIENTS', 'more_clients'); // No trial allowed // Whitelabel - define('FEATURE_CLIENT_PORTAL_CSS', 'client_portal_css'); define('FEATURE_WHITE_LABEL', 'feature_white_label'); // Enterprise diff --git a/app/Constants/Domain.php b/app/Constants/Domain.php new file mode 100644 index 000000000000..670d45797d53 --- /dev/null +++ b/app/Constants/Domain.php @@ -0,0 +1,24 @@ +user()->account; $account->fill($request->all()); + $account->subdomain = $request->subdomain; + $account->iframe_url = $request->iframe_url; $account->save(); return redirect('settings/' . ACCOUNT_CLIENT_PORTAL) @@ -805,6 +807,7 @@ class AccountController extends BaseController { $account = $request->user()->account; $account->fill($request->all()); + $account->bcc_email = $request->bcc_email; $account->save(); return redirect('settings/' . ACCOUNT_EMAIL_SETTINGS) diff --git a/app/Models/Account.php b/app/Models/Account.php index 56c1bd2013f5..7b06dc46b55d 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -85,10 +85,8 @@ class Account extends Eloquent 'pdf_email_attachment', 'document_email_attachment', 'email_design_id', - 'bcc_email', 'enable_email_markup', - 'subdomain', - 'iframe_url', + 'domain_id', ]; /** @@ -475,6 +473,17 @@ class Account extends Eloquent return $this->date_format ? $this->date_format->format : DEFAULT_DATE_FORMAT; } + + public function getSampleLink() + { + $invitation = new Invitation(); + $invitation->account = $this; + $invitation->invitation_key = '...'; + + return $invitation->getLink(); + } + + /** * @param $amount * @param null $client @@ -994,7 +1003,6 @@ class Account extends Eloquent return false; } // Fallthrough - case FEATURE_CLIENT_PORTAL_CSS: case FEATURE_REMOVE_CREATED_BY: return !empty($planDetails);// A plan is required even for self-hosted users @@ -1556,9 +1564,7 @@ class Account extends Eloquent if ($headerFont != $bodyFont) { $css .= 'h1,h2,h3,h4,h5,h6,.h1,.h2,.h3,.h4,.h5,.h6{'.$headerFont.'}'; } - } - if ($this->hasFeature(FEATURE_CLIENT_PORTAL_CSS)) { - // For self-hosted users, a white-label license is required for custom CSS + $css .= $this->client_view_css; } @@ -1707,6 +1713,15 @@ class Account extends Eloquent return $invoice->isQuote() ? $this->require_quote_signature : $this->require_invoice_signature; } + + public function emailMarkupEnabled() + { + if ( ! Utils::isNinja()) { + return false; + } + + return $this->enable_email_markup; + } } Account::updated(function ($account) diff --git a/app/Models/Invitation.php b/app/Models/Invitation.php index 370c521b7830..1790ce556e2d 100644 --- a/app/Models/Invitation.php +++ b/app/Models/Invitation.php @@ -68,14 +68,19 @@ class Invitation extends EntityModel $this->load('account'); } + $account = $this->account; + $iframe_url = $account->iframe_url; $url = trim(SITE_URL, '/'); - $iframe_url = $this->account->iframe_url; - if ($this->account->hasFeature(FEATURE_CUSTOM_URL)) { + if ($account->hasFeature(FEATURE_CUSTOM_URL)) { + if (Utils::isNinja()) { + $url = $account->present()->clientPortalLink(); + } + if ($iframe_url && !$forceOnsite) { return "{$iframe_url}?{$this->invitation_key}"; } elseif ($this->account->subdomain) { - $url = Utils::replaceSubdomain($url, $this->account->subdomain); + $url = Utils::replaceSubdomain($url, $account->subdomain); } } diff --git a/app/Ninja/Mailers/Mailer.php b/app/Ninja/Mailers/Mailer.php index 2f5545e67bc6..27b0135d1206 100644 --- a/app/Ninja/Mailers/Mailer.php +++ b/app/Ninja/Mailers/Mailer.php @@ -108,7 +108,7 @@ class Mailer if (! $response) { $error = trans('texts.postmark_error', ['link' => link_to('https://status.postmarkapp.com/')]); Utils::logError($error); - + // TODO throw the exception once all emails are sent using the queue return $error; } @@ -124,7 +124,7 @@ class Mailer $invitation = $data['invitation']; $invitation->email_error = $emailError; $invitation->save(); - } elseif ( ! Utils::isNinja()) { + } elseif ( ! Utils::isNinjaProd()) { Utils::logError(Utils::getErrorString($exception)); } diff --git a/app/Ninja/Presenters/AccountPresenter.php b/app/Ninja/Presenters/AccountPresenter.php index 5408d4f1afd4..00d496461b59 100644 --- a/app/Ninja/Presenters/AccountPresenter.php +++ b/app/Ninja/Presenters/AccountPresenter.php @@ -2,6 +2,7 @@ use stdClass; use Utils; +use Domain; use Laracasts\Presenter\Presenter; /** @@ -36,6 +37,11 @@ class AccountPresenter extends Presenter return $currency->code; } + public function clientPortalLink() + { + return Domain::getLinkFromId($this->entity->domain_id); + } + public function industry() { return $this->entity->industry ? $this->entity->industry->name : ''; diff --git a/config/app.php b/config/app.php index 9d9881dfda23..08eaa5b5d5b1 100644 --- a/config/app.php +++ b/config/app.php @@ -263,6 +263,7 @@ return [ 'Utils' => App\Libraries\Utils::class, 'HTMLUtils' => App\Libraries\HTMLUtils::class, + 'Domain' => App\Constants\Domain::class, ], ]; diff --git a/database/migrations/2017_01_01_214241_add_inclusive_taxes.php b/database/migrations/2017_01_01_214241_add_inclusive_taxes.php index 9e0d7f4c8187..ab392006c207 100644 --- a/database/migrations/2017_01_01_214241_add_inclusive_taxes.php +++ b/database/migrations/2017_01_01_214241_add_inclusive_taxes.php @@ -33,6 +33,7 @@ class AddInclusiveTaxes extends Migration $table->text('client_number_prefix')->nullable(); $table->integer('client_number_counter')->default(0)->nullable(); $table->text('client_number_pattern')->nullable(); + $table->tinyInteger('domain_id')->default(1)->nullable(); }); Schema::table('activities', function ($table) @@ -65,6 +66,7 @@ class AddInclusiveTaxes extends Migration $table->dropColumn('client_number_prefix'); $table->dropColumn('client_number_counter'); $table->dropColumn('client_number_pattern'); + $table->dropColumn('domain_id'); }); Schema::table('activities', function ($table) diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 541ca8fad158..999e2f523c41 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -849,7 +849,7 @@ $LANG = array( 'light' => 'Light', 'dark' => 'Dark', 'industry_help' => 'Used to provide comparisons against the averages of companies of similar size and industry.', - 'subdomain_help' => 'Customize the invoice link subdomain or display the invoice on your own website.', + 'subdomain_help' => 'Set the subdomain or display the invoice on your own website.', 'invoice_number_help' => 'Specify a prefix or use a custom pattern to dynamically set the invoice number.', 'quote_number_help' => 'Specify a prefix or use a custom pattern to dynamically set the quote number.', 'custom_client_fields_helps' => 'Add a field when creating a client and display the label and value on the PDF.', @@ -2313,7 +2313,11 @@ $LANG = array( 'emailed_invoices' => 'Successfully emailed invoices', 'emailed_quotes' => 'Successfully emailed quotes', 'website_url' => 'Website URL', - + 'domain' => 'Domain', + 'domain_help' => 'Used in the client portal and when sending emails.', + 'domain_help_website' => 'Used when sending emails.', + 'preview' => 'Preview', + ); return $LANG; diff --git a/resources/views/accounts/client_portal.blade.php b/resources/views/accounts/client_portal.blade.php index 960aaa98c742..8ad54ca98d95 100644 --- a/resources/views/accounts/client_portal.blade.php +++ b/resources/views/accounts/client_portal.blade.php @@ -11,6 +11,9 @@ .checkbox-inline input[type="checkbox"] { margin-left:-20px !important; } + .iframe_url { + display: none; + } @stop @@ -35,14 +38,6 @@ {!! Former::populateField('require_invoice_signature', intval($account->require_invoice_signature)) !!} {!! Former::populateField('require_quote_signature', intval($account->require_quote_signature)) !!} -@if (!Utils::isNinja() && !Auth::user()->account->hasFeature(FEATURE_WHITE_LABEL)) -
-
- {!! trans('texts.white_label_custom_css', ['price' => WHITE_LABEL_PRICE, 'link'=>''.trans('texts.white_label_purchase_link').'']) !!} -
-
-@endif - @include('accounts.nav', ['selected' => ACCOUNT_CLIENT_PORTAL])
@@ -53,42 +48,91 @@

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

-
- {!! Former::inline_radios('custom_invoice_link') - ->onchange('onCustomLinkChange()') - ->label(trans('texts.website_url')) - ->radios([ - trans('texts.subdomain') => ['value' => 'subdomain', 'name' => 'custom_link'], - trans('texts.website') => ['value' => 'website', 'name' => 'custom_link'], - ])->check($account->iframe_url ? 'website' : 'subdomain') !!} - {{ Former::setOption('capitalize_translations', false) }} +
+ +
- {!! Former::text('subdomain') - ->placeholder(trans('texts.www')) - ->onchange('onSubdomainChange()') - ->addGroupClass('subdomain') - ->label(' ') - ->help(trans('texts.subdomain_help')) !!} +
+ + +
+
- {!! Former::checkbox('enable_client_portal_dashboard') - ->text(trans('texts.enable')) - ->help(trans('texts.enable_client_portal_dashboard_help')) - ->value(1) !!} + {!! Former::textarea('client_view_css') + ->label(trans('texts.custom_css')) + ->rows(10) + ->raw() + ->maxlength(60000) + ->style("min-width:100%;max-width:100%;font-family:'Roboto Mono', 'Lucida Console', Monaco, monospace;font-size:14px;'") !!} + +
+
@@ -252,23 +296,6 @@ - - @if (Utils::hasFeature(FEATURE_CLIENT_PORTAL_CSS)) -
-
-

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

-
-
-
- {!! Former::textarea('client_view_css') - ->label(trans('texts.custom_css')) - ->rows(10) - ->raw() - ->maxlength(60000) - ->style("min-width:100%;max-width:100%;font-family:'Roboto Mono', 'Lucida Console', Monaco, monospace;font-size:14px;'") !!} -
-
- @endif
diff --git a/resources/views/emails/design2_html.blade.php b/resources/views/emails/design2_html.blade.php index 7cb29e87652d..33f489d091af 100644 --- a/resources/views/emails/design2_html.blade.php +++ b/resources/views/emails/design2_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.client_view_action') @endif @stop diff --git a/resources/views/emails/design3_html.blade.php b/resources/views/emails/design3_html.blade.php index c1880b7f29eb..0c89d0cbc036 100644 --- a/resources/views/emails/design3_html.blade.php +++ b/resources/views/emails/design3_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.client_view_action') @endif @stop diff --git a/resources/views/emails/invoice_html.blade.php b/resources/views/emails/invoice_html.blade.php index 762726e95d81..5e79429077a5 100644 --- a/resources/views/emails/invoice_html.blade.php +++ b/resources/views/emails/invoice_html.blade.php @@ -4,7 +4,7 @@ - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.client_view_action') @endif {!! $body !!} diff --git a/resources/views/emails/invoice_paid_html.blade.php b/resources/views/emails/invoice_paid_html.blade.php index 76dabc82db1d..a4865792dfb9 100644 --- a/resources/views/emails/invoice_paid_html.blade.php +++ b/resources/views/emails/invoice_paid_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master_user') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.user_view_action') @endif @stop diff --git a/resources/views/emails/invoice_payment_failed_html.blade.php b/resources/views/emails/invoice_payment_failed_html.blade.php index 9a021cb5f9ea..07ec14d47be7 100644 --- a/resources/views/emails/invoice_payment_failed_html.blade.php +++ b/resources/views/emails/invoice_payment_failed_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master_user') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.user_view_action') @endif @stop diff --git a/resources/views/emails/invoice_sent_html.blade.php b/resources/views/emails/invoice_sent_html.blade.php index 99b065afa44c..5ae81213ec1c 100644 --- a/resources/views/emails/invoice_sent_html.blade.php +++ b/resources/views/emails/invoice_sent_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master_user') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.user_view_action') @endif @stop diff --git a/resources/views/emails/invoice_viewed_html.blade.php b/resources/views/emails/invoice_viewed_html.blade.php index 377752a7d41e..87b976d07804 100644 --- a/resources/views/emails/invoice_viewed_html.blade.php +++ b/resources/views/emails/invoice_viewed_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master_user') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.user_view_action') @endif @stop diff --git a/resources/views/emails/payment_confirmation_html.blade.php b/resources/views/emails/payment_confirmation_html.blade.php index 87af7aada2c1..90370a737a1f 100644 --- a/resources/views/emails/payment_confirmation_html.blade.php +++ b/resources/views/emails/payment_confirmation_html.blade.php @@ -4,7 +4,7 @@ - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.client_view_action', ['link' => $link]) @endif {!! $body !!} diff --git a/resources/views/emails/quote_approved_html.blade.php b/resources/views/emails/quote_approved_html.blade.php index 758ff76a5d98..147d3996e068 100644 --- a/resources/views/emails/quote_approved_html.blade.php +++ b/resources/views/emails/quote_approved_html.blade.php @@ -1,7 +1,7 @@ @extends('emails.master_user') @section('markup') - @if ($account->enable_email_markup) + @if ($account->emailMarkupEnabled()) @include('emails.partials.user_view_action') @endif @stop