diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index 07c9baede124..05da6eea544b 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -590,8 +590,8 @@ class AccountController extends BaseController } $labels = []; - foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total'] as $field) { - $labels[$field] = trim(Input::get("labels_{$field}")); + foreach (['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms'] as $field) { + $labels[$field] = Input::get("labels_{$field}"); } $account->invoice_labels = json_encode($labels); diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php index 2966a9fd8362..5ed231cedc82 100644 --- a/app/Http/Controllers/Auth/AuthController.php +++ b/app/Http/Controllers/Auth/AuthController.php @@ -79,7 +79,7 @@ class AuthController extends Controller { $userId = Auth::check() ? Auth::user()->id : null; $user = User::where('email', '=', $request->input('email'))->first(); - if ($user && $user->failed_logins >= 3) { + if ($user && $user->failed_logins >= MAX_FAILED_LOGINS) { Session::flash('error', trans('texts.invalid_credentials')); return redirect()->to('login'); } diff --git a/app/Http/routes.php b/app/Http/routes.php index 2251193bbcc1..8ae71049a78a 100644 --- a/app/Http/routes.php +++ b/app/Http/routes.php @@ -338,6 +338,7 @@ if (!defined('CONTACT_EMAIL')) { define('MAX_SUBDOMAIN_LENGTH', 30); define('MAX_IFRAME_URL_LENGTH', 250); define('MAX_LOGO_FILE_SIZE', 200); // KB + define('MAX_FAILED_LOGINS', 5); define('DEFAULT_FONT_SIZE', 9); define('DEFAULT_SEND_RECURRING_HOUR', 8); @@ -488,6 +489,12 @@ if (!defined('CONTACT_EMAIL')) { define('SOCIAL_GITHUB', 'GitHub'); define('SOCIAL_LINKEDIN', 'LinkedIn'); + define('USER_STATE_ACTIVE', 'active'); + define('USER_STATE_PENDING', 'pending'); + define('USER_STATE_DISABLED', 'disabled'); + define('USER_STATE_ADMIN', 'admin'); + + $creditCards = [ 1 => ['card' => 'images/credit_cards/Test-Visa-Icon.png', 'text' => 'Visa'], 2 => ['card' => 'images/credit_cards/Test-MasterCard-Icon.png', 'text' => 'Master Card'], diff --git a/app/Ninja/Repositories/UserRepository.php b/app/Ninja/Repositories/UserRepository.php index 5305e2ae9108..01b7017fa0a0 100644 --- a/app/Ninja/Repositories/UserRepository.php +++ b/app/Ninja/Repositories/UserRepository.php @@ -22,8 +22,7 @@ class UserRepository extends BaseRepository $query->where('users.deleted_at', '=', null); } - $query->where('users.public_id', '>', 0) - ->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id', 'users.deleted_at'); + $query->select('users.public_id', 'users.first_name', 'users.last_name', 'users.email', 'users.confirmed', 'users.public_id', 'users.deleted_at'); return $query; } diff --git a/app/Services/DatatableService.php b/app/Services/DatatableService.php index 067e5a574d34..32d5909800f2 100644 --- a/app/Services/DatatableService.php +++ b/app/Services/DatatableService.php @@ -80,7 +80,9 @@ class DatatableService $str .= "
  • "; } - $str .= "
  • public_id})\">" . trans("texts.archive_{$entityType}") . "
  • "; + if ($entityType != ENTITY_USER || $model->public_id) { + $str .= "
  • public_id})\">" . trans("texts.archive_{$entityType}") . "
  • "; + } } else { $str .= "
  • public_id})\">" . trans("texts.restore_{$entityType}") . "
  • "; } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index 5e8e1b02ad0a..77547b8df849 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -52,7 +52,15 @@ class UserService extends BaseService [ 'confirmed', function ($model) { - return $model->deleted_at ? trans('texts.deleted') : ($model->confirmed ? trans('texts.active') : trans('texts.pending')); + if (!$model->public_id) { + return self::getStatusLabel(USER_STATE_ADMIN); + } elseif ($model->deleted_at) { + return self::getStatusLabel(USER_STATE_DISABLED); + } elseif ($model->confirmed) { + return self::getStatusLabel(USER_STATE_ACTIVE); + } else { + return self::getStatusLabel(USER_STATE_PENDING); + } } ], ]; @@ -65,6 +73,9 @@ class UserService extends BaseService uctrans('texts.edit_user'), function ($model) { return URL::to("users/{$model->public_id}/edit"); + }, + function ($model) { + return $model->public_id; } ], [ @@ -73,10 +84,31 @@ class UserService extends BaseService return URL::to("send_confirmation/{$model->public_id}"); }, function ($model) { - return !$model->confirmed; + return $model->public_id && ! $model->confirmed; } ] ]; } + private function getStatusLabel($state) + { + $label = trans("texts.{$state}"); + $class = 'default'; + switch ($state) { + case USER_STATE_PENDING: + $class = 'info'; + break; + case USER_STATE_ACTIVE: + $class = 'primary'; + break; + case USER_STATE_DISABLED: + $class = 'warning'; + break; + case USER_STATE_ADMIN: + $class = 'success'; + break; + } + return "

    $label

    "; + } + } \ No newline at end of file diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index b47b6a1a14fe..82941ea6298a 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -942,5 +942,7 @@ return array( ], 'client_portal' => 'Client Portal', - + 'admin' => 'Admin', + 'disabled' => 'Disabled', + 'show_archived_users' => 'Show archived users', ); diff --git a/resources/views/accounts/invoice_design.blade.php b/resources/views/accounts/invoice_design.blade.php index 0ec6d4d94337..23e72a26c456 100644 --- a/resources/views/accounts/invoice_design.blade.php +++ b/resources/views/accounts/invoice_design.blade.php @@ -37,7 +37,7 @@ NINJA.secondaryColor = $('#secondary_color').val(); NINJA.fontSize = parseInt($('#font_size').val()); - var fields = ['item', 'description', 'unit_cost', 'quantity', 'line_total']; + var fields = ['item', 'description', 'unit_cost', 'quantity', 'line_total', 'terms']; invoiceLabels.old = {}; for (var i=0; i @if (!Utils::isPro() || \App\Models\InvoiceDesign::count() == COUNT_FREE_DESIGNS_SELF_HOST) - {!! Former::select('invoice_design_id')->style('display:inline')->fromQuery($invoiceDesigns, 'name', 'id')->addOption(trans('texts.more_designs') . '...', '-1') !!} + {!! Former::select('invoice_design_id') + ->style('display:inline; width:300px') + ->fromQuery($invoiceDesigns, 'name', 'id') + ->addOption(trans('texts.more_designs') . '...', '-1') !!} @else - {!! Former::select('invoice_design_id')->style('display:inline')->fromQuery($invoiceDesigns, 'name', 'id') !!} + {!! Former::select('invoice_design_id') + ->style('display:inline; width:300px') + ->fromQuery($invoiceDesigns, 'name', 'id') !!} @endif - {!! Former::text('font_size')->type('number')->min('0')->step('1') !!} + {!! Former::text('font_size') + ->style('width:300px') + ->type('number') + ->min('0') + ->step('1') !!} + {!! Former::text('primary_color') !!} {!! Former::text('secondary_color') !!} @@ -116,13 +126,18 @@
    - - {!! Former::text('labels_item')->label(trans('texts.item')) !!} - {!! Former::text('labels_description')->label(trans('texts.description')) !!} - {!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!} - {!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!} - {!! Former::text('labels_line_total')->label(trans('texts.line_total')) !!} - +
    +
    + {!! Former::text('labels_item')->label(trans('texts.item')) !!} + {!! Former::text('labels_description')->label(trans('texts.description')) !!} + {!! Former::text('labels_unit_cost')->label(trans('texts.unit_cost')) !!} +
    +
    + {!! Former::text('labels_quantity')->label(trans('texts.quantity')) !!} + {!! Former::text('labels_line_total')->label(trans('texts.line_total')) !!} + {!! Former::text('labels_terms')->label(trans('texts.terms')) !!} +
    +
    diff --git a/resources/views/accounts/user_management.blade.php b/resources/views/accounts/user_management.blade.php index f3930c677338..969154faec0b 100644 --- a/resources/views/accounts/user_management.blade.php +++ b/resources/views/accounts/user_management.blade.php @@ -14,7 +14,7 @@ @include('partials.bulk_form', ['entityType' => ENTITY_USER]) diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 7666952780bd..206e46bdfe1b 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -68,7 +68,7 @@
    diff --git a/resources/views/invoices/pdf.blade.php b/resources/views/invoices/pdf.blade.php index 3dcd365f9e6b..c4400e6c06ab 100644 --- a/resources/views/invoices/pdf.blade.php +++ b/resources/views/invoices/pdf.blade.php @@ -72,7 +72,7 @@ @endif var NINJA = NINJA || {}; - @if (Utils::isPro()) + @if ($account->isPro()) NINJA.primaryColor = "{{ $account->primary_color }}"; NINJA.secondaryColor = "{{ $account->secondary_color }}"; NINJA.fontSize = {{ $account->font_size }}; diff --git a/resources/views/invoices/view.blade.php b/resources/views/invoices/view.blade.php index 38ff4d143cb8..b96c39e76d4c 100644 --- a/resources/views/invoices/view.blade.php +++ b/resources/views/invoices/view.blade.php @@ -50,12 +50,20 @@ return generatePDF(invoice, invoice.invoice_design.javascript, true, cb); } + if (window.hasOwnProperty('pjsc_meta')) { + window['pjsc_meta'].remainingTasks++; + } + $(function() { @if (Input::has('phantomjs')) doc = getPDFString(); doc.getDataUrl(function(pdfString) { document.write(pdfString); document.close(); + + if (window.hasOwnProperty('pjsc_meta')) { + window['pjsc_meta'].remainingTasks--; + } }); @else refreshPDF();