1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-13 22:54:25 +01:00

Reorganize Client Portal Fonts/CSS to allow styling client auth screens

This commit is contained in:
Joshua Dwire 2017-02-15 22:26:55 -05:00
parent 7ce06a28e9
commit fb749092b2
9 changed files with 53 additions and 43 deletions

View File

@ -32,17 +32,6 @@ class AuthController extends Controller
'clientauth' => true, 'clientauth' => true,
]; ];
$contactKey = session('contact_key');
if ($contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && ! $contact->is_deleted) {
$account = $contact->account;
$data['account'] = $account;
$data['clientFontUrl'] = $account->getFontsUrl();
}
}
return view('clientauth.login')->with($data); return view('clientauth.login')->with($data);
} }

View File

@ -52,14 +52,7 @@ class PasswordController extends Controller
'clientauth' => true, 'clientauth' => true,
]; ];
$contactKey = session('contact_key'); $contactKey = session('contact_key');
if ($contactKey) { if (!$contactKey) {
$contact = Contact::where('contact_key', '=', $contactKey)->first();
if ($contact && ! $contact->is_deleted) {
$account = $contact->account;
$data['account'] = $account;
$data['clientFontUrl'] = $account->getFontsUrl();
}
} else {
return \Redirect::to('/client/sessionexpired'); return \Redirect::to('/client/sessionexpired');
} }
@ -136,10 +129,7 @@ class PasswordController extends Controller
} }
} }
if (! empty($account)) { if ( empty($account)) {
$data['account'] = $account;
$data['clientFontUrl'] = $account->getFontsUrl();
} else {
return \Redirect::to('/client/sessionexpired'); return \Redirect::to('/client/sessionexpired');
} }
} }

View File

@ -131,7 +131,6 @@ class ClientPortalController extends BaseController
'account' => $account, 'account' => $account,
'showApprove' => $showApprove, 'showApprove' => $showApprove,
'showBreadcrumbs' => false, 'showBreadcrumbs' => false,
'clientFontUrl' => $account->getFontsUrl(),
'invoice' => $invoice->hidePrivateFields(), 'invoice' => $invoice->hidePrivateFields(),
'invitation' => $invitation, 'invitation' => $invitation,
'invoiceLabels' => $account->getInvoiceLabels(), 'invoiceLabels' => $account->getInvoiceLabels(),
@ -252,7 +251,6 @@ class ClientPortalController extends BaseController
'contact' => $contact, 'contact' => $contact,
'account' => $account, 'account' => $account,
'client' => $client, 'client' => $client,
'clientFontUrl' => $account->getFontsUrl(),
'gateway' => $account->getTokenGateway(), 'gateway' => $account->getTokenGateway(),
'paymentMethods' => $customer ? $customer->payment_methods : false, 'paymentMethods' => $customer ? $customer->payment_methods : false,
'transactionToken' => $paymentDriver ? $paymentDriver->createTransactionToken() : false, 'transactionToken' => $paymentDriver ? $paymentDriver->createTransactionToken() : false,
@ -318,7 +316,6 @@ class ClientPortalController extends BaseController
'color' => $color, 'color' => $color,
'account' => $account, 'account' => $account,
'client' => $contact->client, 'client' => $contact->client,
'clientFontUrl' => $account->getFontsUrl(),
'title' => trans('texts.recurring_invoices'), 'title' => trans('texts.recurring_invoices'),
'entityType' => ENTITY_RECURRING_INVOICE, 'entityType' => ENTITY_RECURRING_INVOICE,
'columns' => Utils::trans(['frequency', 'start_date', 'end_date', 'invoice_total', 'auto_bill']), 'columns' => Utils::trans(['frequency', 'start_date', 'end_date', 'invoice_total', 'auto_bill']),
@ -346,7 +343,6 @@ class ClientPortalController extends BaseController
'color' => $color, 'color' => $color,
'account' => $account, 'account' => $account,
'client' => $contact->client, 'client' => $contact->client,
'clientFontUrl' => $account->getFontsUrl(),
'title' => trans('texts.invoices'), 'title' => trans('texts.invoices'),
'entityType' => ENTITY_INVOICE, 'entityType' => ENTITY_INVOICE,
'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date']), 'columns' => Utils::trans(['invoice_number', 'invoice_date', 'invoice_total', 'balance_due', 'due_date']),
@ -391,7 +387,6 @@ class ClientPortalController extends BaseController
$data = [ $data = [
'color' => $color, 'color' => $color,
'account' => $account, 'account' => $account,
'clientFontUrl' => $account->getFontsUrl(),
'entityType' => ENTITY_PAYMENT, 'entityType' => ENTITY_PAYMENT,
'title' => trans('texts.payments'), 'title' => trans('texts.payments'),
'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date', 'status']), 'columns' => Utils::trans(['invoice', 'transaction_reference', 'method', 'payment_amount', 'payment_date', 'status']),
@ -476,7 +471,6 @@ class ClientPortalController extends BaseController
$data = [ $data = [
'color' => $color, 'color' => $color,
'account' => $account, 'account' => $account,
'clientFontUrl' => $account->getFontsUrl(),
'title' => trans('texts.quotes'), 'title' => trans('texts.quotes'),
'entityType' => ENTITY_QUOTE, 'entityType' => ENTITY_QUOTE,
'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date']), 'columns' => Utils::trans(['quote_number', 'quote_date', 'quote_total', 'due_date']),
@ -512,7 +506,6 @@ class ClientPortalController extends BaseController
$data = [ $data = [
'color' => $color, 'color' => $color,
'account' => $account, 'account' => $account,
'clientFontUrl' => $account->getFontsUrl(),
'title' => trans('texts.credits'), 'title' => trans('texts.credits'),
'entityType' => ENTITY_CREDIT, 'entityType' => ENTITY_CREDIT,
'columns' => Utils::trans(['credit_date', 'credit_amount', 'credit_balance']), 'columns' => Utils::trans(['credit_date', 'credit_amount', 'credit_balance']),
@ -548,7 +541,6 @@ class ClientPortalController extends BaseController
$data = [ $data = [
'color' => $color, 'color' => $color,
'account' => $account, 'account' => $account,
'clientFontUrl' => $account->getFontsUrl(),
'title' => trans('texts.documents'), 'title' => trans('texts.documents'),
'entityType' => ENTITY_DOCUMENT, 'entityType' => ENTITY_DOCUMENT,
'columns' => Utils::trans(['invoice_number', 'name', 'document_date', 'document_size']), 'columns' => Utils::trans(['invoice_number', 'name', 'document_date', 'document_size']),
@ -757,8 +749,6 @@ class ClientPortalController extends BaseController
'contact' => $contact, 'contact' => $contact,
'color' => $account->primary_color ? $account->primary_color : '#0b4d78', 'color' => $account->primary_color ? $account->primary_color : '#0b4d78',
'client' => $client, 'client' => $client,
'clientViewCSS' => $account->clientViewCSS(),
'clientFontUrl' => $account->getFontsUrl(),
'paymentMethods' => $customer ? $customer->payment_methods : false, 'paymentMethods' => $customer ? $customer->payment_methods : false,
'gateway' => $account->getTokenGateway(), 'gateway' => $account->getTokenGateway(),
'title' => trans('texts.payment_methods'), 'title' => trans('texts.payment_methods'),

View File

@ -102,6 +102,46 @@ class Utils
return self::getResllerType() ? true : false; return self::getResllerType() ? true : false;
} }
public static function clientViewCSS()
{
$account = false;
if (Auth::check()) {
$account = Auth::user()->account;
} elseif ($contactKey = session('contact_key')) {
if ($contact = \App\Models\Contact::whereContactKey($contactKey)->first()) {
$account = $contact->account;
}
}
if ( !$account && ! self::isNinja()) {
// For self-hosted accounts, pick the first account
$account = \App\Models\Account::first();
}
return $account ? $account->clientViewCSS() : '';
}
public static function getAccountFontsUrl($protocol = '')
{
$account = false;
if (Auth::check()) {
$account = Auth::user()->account;
} elseif ($contactKey = session('contact_key')) {
if ($contact = \App\Models\Contact::whereContactKey($contactKey)->first()) {
$account = $contact->account;
}
}
if ( !$account && ! self::isNinja()) {
// For self-hosted accounts, pick the first account
$account = \App\Models\Account::first();
}
return $account ? $account->getFontsUrl($protocol) : false;
}
public static function isWhiteLabel() public static function isWhiteLabel()
{ {
$account = false; $account = false;

View File

@ -166,7 +166,6 @@ class BasePaymentDriver
'currencyCode' => $this->client()->getCurrencyCode(), 'currencyCode' => $this->client()->getCurrencyCode(),
'account' => $this->account(), 'account' => $this->account(),
'sourceId' => $sourceId, 'sourceId' => $sourceId,
'clientFontUrl' => $this->account()->getFontsUrl(),
'tokenize' => $this->tokenize(), 'tokenize' => $this->tokenize(),
'transactionToken' => $this->createTransactionToken(), 'transactionToken' => $this->createTransactionToken(),
]; ];

View File

@ -3,6 +3,6 @@
<div class="form-signin"> <div class="form-signin">
<h2 class="form-signin-heading">{{ trans('texts.session_expired') }}</h2> <h2 class="form-signin-heading">{{ trans('texts.session_expired') }}</h2>
<hr class="green"> <hr class="green">
<h4><center>{{ trans('texts.client_session_expired_message') }}</center></h4> <div><center>{{ trans('texts.client_session_expired_message') }}</center></div>
</div> </div>
@endsection @endsection

View File

@ -3,7 +3,9 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--[if !mso]><!-- --> <!--[if !mso]><!-- -->
<link href="{{ isset($account) ? $account->getFontsUrl('http') : '' }}" rel="stylesheet" type="text/css" /> @if($fontsUrl = Utils::getAccountFontsUrl())
<link href="{{ $fontsUrl }}" rel="stylesheet" type="text/css" />
@endif
<!--<![endif]--> <!--<![endif]-->
</head> </head>
<body style="color: #000000;{!! isset($account) ? $account->getBodyFontCss() : '' !!}font-size: 12px; -webkit-text-size-adjust: none; -ms-text-size-adjust: none; background: #F4F5F5; margin: 0; padding: 0;" <body style="color: #000000;{!! isset($account) ? $account->getBodyFontCss() : '' !!}font-size: 12px; -webkit-text-size-adjust: none; -ms-text-size-adjust: none; background: #F4F5F5; margin: 0; padding: 0;"

View File

@ -1,18 +1,18 @@
@extends('master') @extends('master')
@section('head') @section('head')
@if (!empty($clientauth) && !empty($clientFontUrl)) @if (!empty($clientauth) && $fontsUrl = Utils::getAccountFontsUrl())
<link href="{!! $clientFontUrl !!}" rel="stylesheet" type="text/css"> <link href="{!! $fontsUrl !!}" rel="stylesheet" type="text/css">
@endif @endif
<link href="{{ asset('css/built.public.css') }}?no_cache={{ NINJA_VERSION }}" rel="stylesheet" type="text/css"/> <link href="{{ asset('css/built.public.css') }}?no_cache={{ NINJA_VERSION }}" rel="stylesheet" type="text/css"/>
@if (!empty($clientauth) && !empty($account))
<style type="text/css">{!! $account->clientViewCSS() !!}</style>
@endif
<link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css"/> <link href="{{ asset('css/bootstrap.min.css') }}" rel="stylesheet" type="text/css"/>
<link href="{{ asset('css/built.css') }}" rel="stylesheet" type="text/css"/> <link href="{{ asset('css/built.css') }}" rel="stylesheet" type="text/css"/>
<link href="{{ asset('css/built.login.css') }}" rel="stylesheet" type="text/css"/> <link href="{{ asset('css/built.login.css') }}" rel="stylesheet" type="text/css"/>
@if (!empty($clientauth))
<style type="text/css">{!! Utils::clientViewCSS() !!}</style>
@endif
@endsection @endsection
@section('body') @section('body')

View File

@ -5,7 +5,7 @@
<link href="{!! $clientFontUrl !!}" rel="stylesheet" type="text/css"> <link href="{!! $clientFontUrl !!}" rel="stylesheet" type="text/css">
@endif @endif
<link href="{{ asset('css/built.public.css') }}?no_cache={{ NINJA_VERSION }}" rel="stylesheet" type="text/css"/> <link href="{{ asset('css/built.public.css') }}?no_cache={{ NINJA_VERSION }}" rel="stylesheet" type="text/css"/>
<style type="text/css">{!! isset($account)?$account->clientViewCSS():'' !!}</style> <style type="text/css">{!! Utils::clientViewCSS() !!}</style>
@stop @stop
@section('body') @section('body')