mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-08 20:22:42 +01: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;
|
||||
}
|
||||
|
||||
public function getPrimaryAccount()
|
||||
{
|
||||
return $this->company->accounts()->orderBy('id')->first();
|
||||
}
|
||||
|
||||
public function financialYearStart()
|
||||
{
|
||||
if (! $this->financial_year_start) {
|
||||
|
@ -2598,6 +2598,7 @@ $LANG = array(
|
||||
'can_view_tasks' => 'Tasks are visible in the portal',
|
||||
'is_not_sent_reminders' => 'Reminders are not sent',
|
||||
'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,39 +273,48 @@
|
||||
</div>
|
||||
{!! Former::close() !!}
|
||||
|
||||
{!! 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'))) !!}
|
||||
<div class="form-group">
|
||||
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
|
||||
<span class="help-block">{{ $account->hasMultipleAccounts() ? trans('texts.delete_company_help') : trans('texts.cancel_account_help') }}</span>
|
||||
@if (! $account->hasMultipleAccounts() || $account->getPrimaryAccount()->id != auth()->user()->account->id)
|
||||
{!! 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'))) !!}
|
||||
<div class="form-group">
|
||||
<div class="col-lg-8 col-sm-8 col-lg-offset-4 col-sm-offset-4">
|
||||
<span class="help-block">{{ $account->hasMultipleAccounts() ? trans('texts.delete_company_help') : trans('texts.cancel_account_help') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal fade" id="confirmCancelModal" tabindex="-1" role="dialog" aria-labelledby="confirmCancelModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" style="min-width:150px">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="confirmCancelModalLabel">{{ $account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account') }}</h4>
|
||||
</div>
|
||||
<div class="container" style="width: 100%; padding-bottom: 0px !important">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p><b>{{ $account->hasMultipleAccounts() ? trans('texts.delete_company_message') : trans('texts.cancel_account_message') }}</b></p><br/>
|
||||
<p>{!! Former::textarea('reason')
|
||||
->placeholder(trans('texts.reason_for_canceling'))
|
||||
->raw()
|
||||
->rows(4) !!}</p>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 2px">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.go_back') }}</button>
|
||||
<button type="button" class="btn btn-danger" id="deleteButton" onclick="confirmCancel()">{{ $account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account') }}</button>
|
||||
<div class="modal fade" id="confirmCancelModal" tabindex="-1" role="dialog" aria-labelledby="confirmCancelModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog" style="min-width:150px">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="confirmCancelModalLabel">{{ $account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account') }}</h4>
|
||||
</div>
|
||||
<div class="container" style="width: 100%; padding-bottom: 0px !important">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<p><b>{{ $account->hasMultipleAccounts() ? trans('texts.delete_company_message') : trans('texts.cancel_account_message') }}</b></p><br/>
|
||||
<p>{!! Former::textarea('reason')
|
||||
->placeholder(trans('texts.reason_for_canceling'))
|
||||
->raw()
|
||||
->rows(4) !!}</p>
|
||||
<br/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer" style="margin-top: 2px">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('texts.go_back') }}</button>
|
||||
<button type="button" class="btn btn-danger" id="deleteButton" onclick="confirmCancel()">{{ $account->hasMultipleAccounts() ? trans('texts.delete_company') : trans('texts.cancel_account') }}</button>
|
||||
</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() !!}
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user