Bug: change plan when company has multiple accounts

This commit is contained in:
Hillel Coren 2016-12-29 22:50:55 +02:00
parent 6e75c240f8
commit 9e051da756
2 changed files with 58 additions and 51 deletions

View File

@ -2291,6 +2291,7 @@ $LANG = array(
'iphone_app_message' => 'Consider downloading our :link', 'iphone_app_message' => 'Consider downloading our :link',
'iphone_app' => 'iPhone app', 'iphone_app' => 'iPhone app',
'logged_in' => 'Logged In', 'logged_in' => 'Logged In',
'switch_to_primary' => 'Switch to your primary company (:name) to manage your plan.'
); );

View File

@ -13,73 +13,79 @@
<h3 class="panel-title">{!! trans('texts.plan_status') !!}</h3> <h3 class="panel-title">{!! trans('texts.plan_status') !!}</h3>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<div class="form-group"> @if (Auth::user()->primaryAccount()->id != Auth::user()->account->id)
<label class="col-sm-4 control-label">{{ trans('texts.plan') }}</label> <center style="font-size:16px;color:#888888;">
<div class="col-sm-8"> {{ trans('texts.switch_to_primary', ['name' => Auth::user()->primaryAccount()->getDisplayName()]) }}
<p class="form-control-static"> </center>
@if ($planDetails && $planDetails['active']) @else
{{ trans('texts.plan_'.$planDetails['plan']) }}
@if ($planDetails['trial'])
({{ trans('texts.plan_trial') }})
@elseif ($planDetails['expires'])
({{ trans('texts.plan_term_'.$planDetails['term'].'ly') }})
@endif
@if ($planDetails['plan'] == PLAN_ENTERPRISE)
{{ trans('texts.min_to_max_users', ['min' => Utils::getMinNumUsers($planDetails['num_users']), 'max' => $planDetails['num_users']])}}
@endif
@elseif(Utils::isNinjaProd())
{{ trans('texts.plan_free') }}
@else
{{ trans('texts.plan_free_self_hosted') }}
@endif
</p>
</div>
</div>
@if ($planDetails && $planDetails['active'])
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label"> <label class="col-sm-4 control-label">{{ trans('texts.plan') }}</label>
{{ trans('texts.renews') }}
</label>
<div class="col-sm-8"> <div class="col-sm-8">
<p class="form-control-static"> <p class="form-control-static">
@if ($planDetails['expires'] === false) @if ($planDetails && $planDetails['active'])
{{ trans('texts.never') }} {{ trans('texts.plan_'.$planDetails['plan']) }}
@if ($planDetails['trial'])
({{ trans('texts.plan_trial') }})
@elseif ($planDetails['expires'])
({{ trans('texts.plan_term_'.$planDetails['term'].'ly') }})
@endif
@if ($planDetails['plan'] == PLAN_ENTERPRISE)
{{ trans('texts.min_to_max_users', ['min' => Utils::getMinNumUsers($planDetails['num_users']), 'max' => $planDetails['num_users']])}}
@endif
@elseif(Utils::isNinjaProd())
{{ trans('texts.plan_free') }}
@else @else
{{ Utils::dateToString($planDetails['expires']) }} {{ trans('texts.plan_free_self_hosted') }}
@endif @endif
</p> </p>
</div> </div>
</div> </div>
@if ($planDetails && $planDetails['active'])
@if ($account->company->hasActiveDiscount())
{!! Former::plaintext('discount')
->value($account->company->present()->discountMessage) !!}
@endif
@if (Utils::isNinjaProd())
{!! Former::actions( Button::info(trans('texts.plan_change'))->large()->withAttributes(['onclick' => 'showChangePlan()'])->appendIcon(Icon::create('edit'))) !!}
@endif
@else
@if ($planDetails)
<div class="form-group"> <div class="form-group">
<label class="col-sm-4 control-label"> <label class="col-sm-4 control-label">
@if ($planDetails['trial']) {{ trans('texts.renews') }}
{{ trans('texts.trial_expired', ['plan'=>trans('texts.plan_'.$planDetails['plan'])]) }}
@else
{{ trans('texts.plan_expired', ['plan'=>trans('texts.plan_'.$planDetails['plan'])]) }}
@endif
</label> </label>
<div class="col-sm-8"> <div class="col-sm-8">
<p class="form-control-static"> <p class="form-control-static">
{{ Utils::dateToString($planDetails['expires']) }} @if ($planDetails['expires'] === false)
{{ trans('texts.never') }}
@else
{{ Utils::dateToString($planDetails['expires']) }}
@endif
</p> </p>
</div> </div>
</div> </div>
@endif
@if (Utils::isNinjaProd()) @if ($account->company->hasActiveDiscount())
{!! Former::actions( Button::success(trans('texts.plan_upgrade'))->large()->withAttributes(['onclick' => 'showChangePlan()'])->appendIcon(Icon::create('plus-sign'))) !!} {!! Former::plaintext('discount')
@elseif (!$account->hasFeature(FEATURE_WHITE_LABEL)) ->value($account->company->present()->discountMessage) !!}
{!! Former::actions( Button::success(trans('texts.white_label_button'))->large()->withAttributes(['onclick' => 'loadImages("#whiteLabelModal");$("#whiteLabelModal").modal("show");'])->appendIcon(Icon::create('plus-sign'))) !!} @endif
@if (Utils::isNinjaProd())
{!! Former::actions( Button::info(trans('texts.plan_change'))->large()->withAttributes(['onclick' => 'showChangePlan()'])->appendIcon(Icon::create('edit'))) !!}
@endif
@else
@if ($planDetails)
<div class="form-group">
<label class="col-sm-4 control-label">
@if ($planDetails['trial'])
{{ trans('texts.trial_expired', ['plan'=>trans('texts.plan_'.$planDetails['plan'])]) }}
@else
{{ trans('texts.plan_expired', ['plan'=>trans('texts.plan_'.$planDetails['plan'])]) }}
@endif
</label>
<div class="col-sm-8">
<p class="form-control-static">
{{ Utils::dateToString($planDetails['expires']) }}
</p>
</div>
</div>
@endif
@if (Utils::isNinjaProd())
{!! Former::actions( Button::success(trans('texts.plan_upgrade'))->large()->withAttributes(['onclick' => 'showChangePlan()'])->appendIcon(Icon::create('plus-sign'))) !!}
@elseif (!$account->hasFeature(FEATURE_WHITE_LABEL))
{!! Former::actions( Button::success(trans('texts.white_label_button'))->large()->withAttributes(['onclick' => 'loadImages("#whiteLabelModal");$("#whiteLabelModal").modal("show");'])->appendIcon(Icon::create('plus-sign'))) !!}
@endif
@endif @endif
@endif @endif
</div> </div>