diff --git a/app/Models/Company.php b/app/Models/Company.php index 94111e446556..0aa8c1037c5f 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -74,6 +74,20 @@ class Company extends Eloquent return $price - ($price * $this->discount); } + public function daysUntilPlanExpires() + { + if ( ! $this->hasActivePlan()) { + return 0; + } + + return Carbon::parse($this->plan_expires)->diffInDays(Carbon::today()); + } + + public function hasActivePlan() + { + return Carbon::parse($this->plan_expires) >= Carbon::today(); + } + public function hasEarnedPromo() { if ( ! Utils::isNinjaProd() || Utils::isPro()) { diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 0af15db1ef3d..68e3478e5362 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -2284,6 +2284,7 @@ $LANG = array( 'debug' => 'Debug', 'https' => 'HTTPS', 'require' => 'Require', + 'license_expiring' => 'Note: Your license will expire in :count days, :link to renew it.' ); diff --git a/resources/views/header.blade.php b/resources/views/header.blade.php index 2b2dd5fac387..411b11b9ab48 100644 --- a/resources/views/header.blade.php +++ b/resources/views/header.blade.php @@ -589,7 +589,7 @@ ]) !!} @endif @else - @include('partials.white_label') + @include('partials.white_label', ['company' => Auth::user()->account->company]) @endif diff --git a/resources/views/partials/white_label.blade.php b/resources/views/partials/white_label.blade.php index 1460da8c3de7..2135e0913144 100644 --- a/resources/views/partials/white_label.blade.php +++ b/resources/views/partials/white_label.blade.php @@ -1,9 +1,14 @@ {{ trans('texts.powered_by') }} + {{-- Per our license, please do not remove or modify this section. --}} {!! link_to('https://www.invoiceninja.com/?utm_source=powered_by', 'InvoiceNinja.com', ['target' => '_blank', 'title' => trans('texts.created_by', ['name' => 'Hillel Coren'])]) !!} - {!! link_to(RELEASES_URL, 'v' . NINJA_VERSION, ['target' => '_blank', 'title' => trans('texts.trello_roadmap')]) !!} | + @if (Auth::user()->account->hasFeature(FEATURE_WHITE_LABEL)) {{ trans('texts.white_labeled') }} + @if ($company->hasActivePlan() && $company->daysUntilPlanExpires() <= 10) + - {{ trans('texts.license_expiring', ['count' => $company->daysUntilPlanExpires(), 'link' => 'link']) }} + @endif @else {{ trans('texts.white_label_link') }}