1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-22 01:11:34 +02:00
invoiceninja/resources/views/accounts/user_details.blade.php

274 lines
11 KiB
PHP
Raw Normal View History

2015-10-14 16:15:39 +02:00
@extends('header')
2016-07-28 18:55:23 +02:00
@section('content')
2015-10-14 16:15:39 +02:00
@parent
{!! Former::open_for_files()->addClass('warn-on-exit')->rules(array(
2016-10-10 10:40:04 +02:00
'first_name' => 'required',
'last_name' => 'required',
'email' => 'email|required',
'phone' => $user->google_2fa_secret ? 'required' : ''
2015-10-14 16:15:39 +02:00
)) !!}
{{ Former::populate($account) }}
{{ Former::populateField('first_name', $user->first_name) }}
{{ Former::populateField('last_name', $user->last_name) }}
2016-07-28 18:55:23 +02:00
{{ Former::populateField('email', $user->email) }}
2015-10-14 16:15:39 +02:00
{{ Former::populateField('phone', $user->phone) }}
2017-06-19 13:19:25 +02:00
{{ Former::populateField('dark_mode', intval($user->dark_mode)) }}
{{ Former::populateField('enable_two_factor', $user->google_2fa_secret ? 1 : 0) }}
2015-10-18 09:30:28 +02:00
@if (Input::has('affiliate'))
{{ Former::populateField('referral_code', true) }}
@endif
2016-03-16 00:08:00 +01:00
@if (Utils::isAdmin())
@include('accounts.nav', ['selected' => ACCOUNT_USER_DETAILS])
@endif
2015-10-14 16:15:39 +02:00
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.user_details') !!}</h3>
</div>
2015-10-14 19:18:19 +02:00
<div class="panel-body form-padding-right">
2015-10-14 16:15:39 +02:00
{!! Former::text('first_name') !!}
{!! Former::text('last_name') !!}
{!! Former::text('email') !!}
{!! Former::text('phone') !!}
2015-10-18 09:30:28 +02:00
<br/>
2015-11-01 19:21:11 +01:00
@if (Utils::isOAuthEnabled())
2015-10-14 16:15:39 +02:00
{!! Former::plaintext('oneclick_login')->value(
2016-07-28 18:55:23 +02:00
$user->oauth_provider_id ?
$oauthProviderName . ' - ' . link_to('#', trans('texts.disable'), ['onclick' => 'disableSocialLogin()']) :
2015-10-14 16:15:39 +02:00
DropdownButton::primary(trans('texts.enable'))->withContents($oauthLoginUrls)->small()
2015-10-18 09:30:28 +02:00
)->help('oneclick_login_help')
!!}
2015-10-14 16:15:39 +02:00
@endif
2017-11-05 10:54:32 +01:00
@if ($user->confirmed)
@if ($user->google_2fa_secret)
{!! Former::checkbox('enable_two_factor')
->help(trans('texts.enable_two_factor_help'))
->text(trans('texts.enable'))
->value(1) !!}
@elseif ($user->phone)
{!! Former::plaintext('enable_two_factor')->value(
Button::primary(trans('texts.enable'))->asLinkTo(url('settings/enable_two_factor'))->small()
)->help('enable_two_factor_help') !!}
@else
{!! Former::plaintext('enable_two_factor')
->value('<span class="text-muted">' . trans('texts.set_phone_for_two_factor') . '</span>') !!}
@endif
@endif
2017-06-19 13:19:25 +02:00
{!! Former::checkbox('dark_mode')
->help(trans('texts.dark_mode_help'))
->text(trans('texts.enable'))
->value(1) !!}
2015-10-18 09:30:28 +02:00
@if (Utils::isNinja())
2015-10-14 16:15:39 +02:00
@if ($user->referral_code)
2015-11-01 19:21:11 +01:00
{{ Former::setOption('capitalize_translations', false) }}
2015-10-14 16:15:39 +02:00
{!! Former::plaintext('referral_code')
2016-07-28 18:55:23 +02:00
->help($referralCounts['free'] . ' ' . trans('texts.free') . ' | ' .
$referralCounts['pro'] . ' ' . trans('texts.pro') .
2015-11-18 15:40:50 +01:00
'<a href="'.REFERRAL_PROGRAM_URL.'" target="_blank" title="'.trans('texts.learn_more').'">' . Icon::create('question-sign') . '</a> ')
->value(NINJA_APP_URL . '/invoice_now?rc=' . $user->referral_code) !!}
2015-11-01 19:21:11 +01:00
@else
2015-10-14 16:15:39 +02:00
{!! Former::checkbox('referral_code')
2015-10-18 09:30:28 +02:00
->help(trans('texts.referral_code_help'))
->text(trans('texts.enable') . ' <a href="'.REFERRAL_PROGRAM_URL.'" target="_blank" title="'.trans('texts.learn_more').'">' . Icon::create('question-sign') . '</a>')
->value(1) !!}
2015-11-18 15:40:50 +01:00
@endif
2015-10-14 16:15:39 +02:00
@endif
</div>
</div>
</div>
</div>
2017-03-29 20:34:50 +02:00
@if ( ! Auth::user()->is_admin)
@include('accounts.partials.notifications')
@endif
2017-11-03 09:19:03 +01:00
<center class="buttons">
@if (Auth::user()->confirmed)
{!! Button::primary(trans('texts.change_password'))
->appendIcon(Icon::create('lock'))
->large()->withAttributes(['onclick'=>'showChangePassword()']) !!}
@elseif (Auth::user()->registered && Utils::isNinja())
{!! Button::primary(trans('texts.resend_confirmation'))
->appendIcon(Icon::create('send'))
->asLinkTo(URL::to('/resend_confirmation'))->large() !!}
@endif
{!! Button::success(trans('texts.save'))
->submit()->large()
->appendIcon(Icon::create('floppy-disk')) !!}
</center>
2015-10-14 16:15:39 +02:00
<div class="modal fade" id="passwordModal" tabindex="-1" role="dialog" aria-labelledby="passwordModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="passwordModalLabel">{{ trans('texts.change_password') }}</h4>
</div>
2017-03-26 10:45:17 +02:00
<div class="container" style="width: 100%; padding-bottom: 0px !important">
<div class="panel panel-default">
<div class="panel-body">
2015-10-14 16:15:39 +02:00
2017-03-26 10:45:17 +02:00
<div style="background-color: #fff" id="changePasswordDiv" onkeyup="validateChangePassword()" onclick="validateChangePassword()" onkeydown="checkForEnter(event)">
&nbsp;
2015-10-14 16:15:39 +02:00
2017-03-26 10:45:17 +02:00
{!! Former::password('current_password')->style('width:300px') !!}
{!! Former::password('newer_password')->style('width:300px')->label(trans('texts.new_password')) !!}
{!! Former::password('confirm_password')->style('width:300px') !!}
2015-10-14 16:15:39 +02:00
2017-03-26 10:45:17 +02:00
&nbsp;
<br/>
<center>
<div id="changePasswordError"></div>
</center>
<br/>
</div>
<div style="padding-left:40px;padding-right:40px;display:none;min-height:130px" id="working">
<h3>{{ trans('texts.working') }}...</h3>
<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%"></div>
</div>
2015-10-14 16:15:39 +02:00
</div>
2017-03-26 10:45:17 +02:00
<div style="background-color: #fff; padding-right:20px;padding-left:20px; display:none" id="successDiv">
<br/>
<h3>{{ trans('texts.success') }}</h3>
{{ trans('texts.updated_password') }}
<br/>
</div>
</div>
</div>
2015-10-14 16:15:39 +02:00
</div>
2017-03-26 10:45:17 +02:00
<div class="modal-footer" id="changePasswordFooter">
2015-10-20 10:23:38 +02:00
<button type="button" class="btn btn-default" id="cancelChangePasswordButton" data-dismiss="modal">
{{ trans('texts.cancel') }}
<i class="glyphicon glyphicon-remove-circle"></i>
</button>
2015-10-14 16:15:39 +02:00
<button type="button" class="btn btn-success" onclick="submitChangePassword()" id="changePasswordButton" disabled>
{{ trans('texts.save') }}
<i class="glyphicon glyphicon-floppy-disk"></i>
2016-07-28 18:55:23 +02:00
</button>
2015-10-14 16:15:39 +02:00
</div>
</div>
</div>
</div>
{!! Former::close() !!}
<script type="text/javascript">
$(function() {
2016-07-28 18:55:23 +02:00
$('#passwordModal').on('hidden.bs.modal', function () {
2015-10-14 16:15:39 +02:00
$(['current_password', 'newer_password', 'confirm_password']).each(function(i, field) {
var $input = $('form #'+field);
$input.val('');
2016-07-28 18:55:23 +02:00
$input.closest('div.form-group').removeClass('has-success');
2015-10-14 16:15:39 +02:00
});
$('#changePasswordButton').prop('disabled', true);
})
2016-07-28 18:55:23 +02:00
$('#passwordModal').on('shown.bs.modal', function () {
2015-10-14 16:15:39 +02:00
$('#current_password').focus();
})
});
2016-07-28 18:55:23 +02:00
2015-10-14 16:15:39 +02:00
function showChangePassword() {
2016-07-28 18:55:23 +02:00
$('#passwordModal').modal('show');
2015-10-14 16:15:39 +02:00
}
2016-07-28 18:55:23 +02:00
function validateChangePassword(showError)
2015-10-14 16:15:39 +02:00
{
var isFormValid = true;
$(['current_password', 'newer_password', 'confirm_password']).each(function(i, field) {
var $input = $('form #'+field),
val = $.trim($input.val());
var isValid = val;
if (field != 'current_password') {
isValid = val.length >= 6;
}
2015-10-14 16:15:39 +02:00
if (isValid && field == 'confirm_password') {
isValid = val == $.trim($('#newer_password').val());
}
if (isValid) {
$input.closest('div.form-group').removeClass('has-error').addClass('has-success');
} else {
isFormValid = false;
$input.closest('div.form-group').removeClass('has-success');
if (showError) {
$input.closest('div.form-group').addClass('has-error');
}
}
});
$('#changePasswordButton').prop('disabled', !isFormValid);
return isFormValid;
}
function submitChangePassword()
{
if (!validateChangePassword(true)) {
return;
}
$('#changePasswordDiv, #changePasswordFooter').hide();
$('#working').show();
$.ajax({
type: 'POST',
url: '{{ URL::to('/users/change_password') }}',
2016-07-28 18:55:23 +02:00
data: 'current_password=' + encodeURIComponent($('form #current_password').val()) +
'&new_password=' + encodeURIComponent($('form #newer_password').val()) +
2015-10-14 16:15:39 +02:00
'&confirm_password=' + encodeURIComponent($('form #confirm_password').val()),
2016-07-28 18:55:23 +02:00
success: function(result) {
2015-10-14 16:15:39 +02:00
if (result == 'success') {
NINJA.formIsChanged = false;
$('#changePasswordButton').hide();
$('#successDiv').show();
$('#cancelChangePasswordButton').html('{{ trans('texts.close') }}');
} else {
$('#changePasswordError').html(result);
2016-07-28 18:55:23 +02:00
$('#changePasswordDiv').show();
2015-10-14 16:15:39 +02:00
}
$('#changePasswordFooter').show();
$('#working').hide();
}
2016-07-28 18:55:23 +02:00
});
2015-10-14 16:15:39 +02:00
}
function disableSocialLogin() {
2016-07-28 18:55:23 +02:00
sweetConfirm(function() {
window.location = '{{ URL::to('/auth_unlink') }}';
});
2015-10-14 16:15:39 +02:00
}
</script>
@stop
@section('onReady')
$('#first_name').focus();
2016-07-28 18:55:23 +02:00
@stop