2015-10-14 16:15:39 +02:00
|
|
|
@extends('header')
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2016-05-26 15:04:53 +02:00
|
|
|
@section('content')
|
2015-03-16 22:45:25 +01:00
|
|
|
@parent
|
2015-10-14 16:15:39 +02:00
|
|
|
@include('accounts.nav', ['selected' => ACCOUNT_USER_MANAGEMENT])
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2018-03-14 12:03:30 +01:00
|
|
|
{!! Former::open($url)->autocomplete('off')->method($method)->addClass('warn-on-exit user-form')->rules(array(
|
2015-03-16 22:45:25 +01:00
|
|
|
'first_name' => 'required',
|
|
|
|
'last_name' => 'required',
|
|
|
|
'email' => 'required|email',
|
2015-04-01 21:57:02 +02:00
|
|
|
)); !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
|
|
|
@if ($user)
|
2016-05-08 20:50:35 +02:00
|
|
|
{!! Former::populate($user) !!}
|
|
|
|
{{ Former::populateField('is_admin', intval($user->is_admin)) }}
|
2015-03-16 22:45:25 +01:00
|
|
|
@endif
|
|
|
|
|
2017-02-28 19:15:55 +01:00
|
|
|
<div style="display:none">
|
|
|
|
{!! Former::text('action') !!}
|
|
|
|
</div>
|
|
|
|
|
2015-04-20 16:34:23 +02:00
|
|
|
<div class="panel panel-default">
|
2015-04-22 21:21:04 +02:00
|
|
|
<div class="panel-heading">
|
2016-03-21 21:00:59 +01:00
|
|
|
<h3 class="panel-title">{!! trans('texts.user_details') !!}</h3>
|
2015-04-22 21:21:04 +02:00
|
|
|
</div>
|
2015-10-14 19:18:19 +02:00
|
|
|
<div class="panel-body form-padding-right">
|
2015-04-20 16:34:23 +02:00
|
|
|
|
2015-04-01 21:57:02 +02:00
|
|
|
{!! Former::text('first_name') !!}
|
|
|
|
{!! Former::text('last_name') !!}
|
|
|
|
{!! Former::text('email') !!}
|
2016-03-21 21:00:59 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<h3 class="panel-title">{!! trans('texts.permissions') !!}</h3>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body form-padding-right">
|
|
|
|
|
2016-05-26 15:04:53 +02:00
|
|
|
@if ( ! Utils::hasFeature(FEATURE_USER_PERMISSIONS))
|
|
|
|
<div class="alert alert-warning">{{ trans('texts.upgrade_for_permissions') }}</div>
|
2017-02-28 19:15:55 +01:00
|
|
|
<script type="text/javascript">
|
2016-05-26 15:04:53 +02:00
|
|
|
$(function() {
|
|
|
|
$('input[type=checkbox]').prop('disabled', true);
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
@endif
|
2016-03-21 21:00:59 +01:00
|
|
|
|
2016-03-16 00:08:00 +01:00
|
|
|
{!! Former::checkbox('is_admin')
|
|
|
|
->label(' ')
|
2017-02-07 16:12:34 +01:00
|
|
|
->value(1)
|
2016-03-16 00:08:00 +01:00
|
|
|
->text(trans('texts.administrator'))
|
|
|
|
->help(trans('texts.administrator_help')) !!}
|
2018-06-07 12:08:34 +02:00
|
|
|
|
|
|
|
@foreach (json_decode(PERMISSION_ENTITIES,1) as $permissionEntity)
|
|
|
|
|
|
|
|
<?php
|
|
|
|
if($user)
|
|
|
|
$permissions = json_decode($user->permissions,1);
|
|
|
|
else
|
|
|
|
$permissions = [];
|
|
|
|
?>
|
|
|
|
|
|
|
|
{!! Former::checkboxes('permissions[]')
|
|
|
|
->label(ucfirst($permissionEntity))
|
|
|
|
->checkboxes([
|
|
|
|
trans('texts.create') => ['id'=> 'create_' . $permissionEntity,
|
|
|
|
'name' => 'permissions[create_' . $permissionEntity . ']',
|
|
|
|
'value' => 'create_' . $permissionEntity . '',
|
|
|
|
'checked' => is_array($permissions) && in_array('create_' . $permissionEntity, $permissions, FALSE) ? true : false],
|
|
|
|
|
|
|
|
trans('texts.view') => ['id'=> 'view_' . $permissionEntity,
|
|
|
|
'name' => 'permissions[view_' . $permissionEntity . ']',
|
|
|
|
'value' => 'view_' . $permissionEntity . '',
|
|
|
|
'checked' => is_array($permissions) && in_array('view_' . $permissionEntity, $permissions, FALSE) ? true : false],
|
|
|
|
|
|
|
|
trans('texts.edit') => ['id'=> 'edit_' . $permissionEntity,
|
|
|
|
'name' => 'permissions[edit_' . $permissionEntity . ']',
|
|
|
|
'value' => 'edit_' . $permissionEntity . '',
|
|
|
|
'checked' => is_array($permissions) && in_array('edit_' . $permissionEntity, $permissions, FALSE) ? true : false],
|
|
|
|
]) !!}
|
|
|
|
@endforeach
|
2016-05-26 15:04:53 +02:00
|
|
|
|
2015-04-20 16:34:23 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2017-11-03 09:19:03 +01:00
|
|
|
<center class="buttons">
|
|
|
|
{!! Button::normal(trans('texts.cancel'))->asLinkTo(URL::to('/settings/user_management'))->appendIcon(Icon::create('remove-circle'))->large() !!}
|
|
|
|
{!! ($user) ? Button::success(trans('texts.save'))->withAttributes(['onclick' => 'submitAction("save")'])->large()->appendIcon(Icon::create('floppy-disk')) : false !!}
|
|
|
|
{!! (! $user || ! $user->confirmed) ? Button::info(trans($user ? 'texts.resend_invite' : 'texts.send_invite'))->withAttributes(['onclick' => 'submitAction("email")'])->large()->appendIcon(Icon::create('send')) : false !!}
|
|
|
|
</center>
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2015-04-01 21:57:02 +02:00
|
|
|
{!! Former::close() !!}
|
2015-03-16 22:45:25 +01:00
|
|
|
|
2017-02-28 19:15:55 +01:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function submitAction(value) {
|
|
|
|
$('#action').val(value);
|
|
|
|
$('.user-form').submit();
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2015-05-09 20:25:16 +02:00
|
|
|
@stop
|
|
|
|
|
|
|
|
@section('onReady')
|
2018-06-07 12:08:34 +02:00
|
|
|
|
|
|
|
//start legacy
|
2015-05-09 20:25:16 +02:00
|
|
|
$('#first_name').focus();
|
2016-03-16 00:08:00 +01:00
|
|
|
$('#is_admin, #permissions_view_all').change(fixCheckboxes);
|
|
|
|
function fixCheckboxes(){
|
|
|
|
var adminChecked = $('#is_admin').is(':checked');
|
|
|
|
var viewChecked = $('#permissions_view_all').is(':checked');
|
|
|
|
|
|
|
|
$('#permissions_view_all').prop('disabled', adminChecked);
|
|
|
|
$('#permissions_create_all').prop('disabled', adminChecked);
|
|
|
|
$('#permissions_edit_all').prop('disabled', adminChecked || !viewChecked);
|
2016-03-17 15:11:14 +01:00
|
|
|
if(!viewChecked)$('#permissions_edit_all').prop('checked',false)
|
2016-03-16 00:08:00 +01:00
|
|
|
}
|
|
|
|
fixCheckboxes();
|
2018-06-07 12:08:34 +02:00
|
|
|
//end legacy
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Iterate over all permission checkboxes and ensure VIEW/EDIT
|
|
|
|
* combinations are enabled/disabled depending on VIEW state.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
$("input[type='checkbox'][id^='view_']").each(function() {
|
|
|
|
|
|
|
|
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name
|
|
|
|
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Checks state of View/Edit checkbox, will enable/disable check/uncheck
|
|
|
|
* dependent on state of VIEW permission.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
$("input[type='checkbox'][id^='view_']").change(function(){
|
|
|
|
|
|
|
|
var entity = $(this).attr('id').split("_")[1].replace("]",""); //get entity name
|
|
|
|
|
|
|
|
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
|
|
|
|
|
|
|
|
if(!$('#view_' + entity).is(':checked')) {
|
|
|
|
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-05-26 15:04:53 +02:00
|
|
|
@stop
|