mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-20 08:21:34 +02:00
Check primary account isn't deleted first
This commit is contained in:
parent
e6798c58d4
commit
ef9f47b32e
@ -1707,6 +1707,11 @@ class Account extends Eloquent
|
|||||||
return $this->company->accounts->count() > 1;
|
return $this->company->accounts->count() > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPrimaryAccount()
|
||||||
|
{
|
||||||
|
return $this->company->accounts()->orderBy('id')->first();
|
||||||
|
}
|
||||||
|
|
||||||
public function financialYearStart()
|
public function financialYearStart()
|
||||||
{
|
{
|
||||||
if (! $this->financial_year_start) {
|
if (! $this->financial_year_start) {
|
||||||
|
@ -2598,6 +2598,7 @@ $LANG = array(
|
|||||||
'can_view_tasks' => 'Tasks are visible in the portal',
|
'can_view_tasks' => 'Tasks are visible in the portal',
|
||||||
'is_not_sent_reminders' => 'Reminders are not sent',
|
'is_not_sent_reminders' => 'Reminders are not sent',
|
||||||
'promotion_footer' => 'Your promotion will expire soon, :link to upgrade now.',
|
'promotion_footer' => 'Your promotion will expire soon, :link to upgrade now.',
|
||||||
|
'unable_to_delete_primary' => 'Note: to delete this company first delete all linked companies.',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -273,6 +273,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
|
|
||||||
|
@if (! $account->hasMultipleAccounts() || $account->getPrimaryAccount()->id != auth()->user()->account->id)
|
||||||
{!! Former::open('settings/cancel_account')->addClass('cancel-account') !!}
|
{!! Former::open('settings/cancel_account')->addClass('cancel-account') !!}
|
||||||
{!! Former::actions( Button::danger($account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account'))->large()->withAttributes(['onclick' => 'showCancelConfirm()'])->appendIcon(Icon::create('trash'))) !!}
|
{!! Former::actions( Button::danger($account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account'))->large()->withAttributes(['onclick' => 'showCancelConfirm()'])->appendIcon(Icon::create('trash'))) !!}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@ -306,6 +307,14 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@elseif ($account->hasMultipleAccounts())
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
|
||||||
|
<span class="help-block">{{ trans('texts.unable_to_delete_primary') }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user