1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 08:02:40 +01:00
invoiceninja/resources/views/users/edit.blade.php

209 lines
8.0 KiB
PHP
Raw Normal View History

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')
@parent
@include('accounts.nav', ['selected' => ACCOUNT_USER_MANAGEMENT])
{!! Former::open($url)->autocomplete('off')->method($method)->addClass('warn-on-exit user-form')->rules(array(
'first_name' => 'required',
'last_name' => 'required',
'email' => 'required|email',
)); !!}
@if ($user)
{!! Former::populate($user) !!}
{{ Former::populateField('is_admin', intval($user->is_admin)) }}
2016-05-26 15:04:53 +02:00
@endif
2016-03-21 21:00:59 +01:00
<div style="display:none">
{!! Former::text('action') !!}
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.user_details') !!}</h3>
</div>
<div class="panel-body form-padding-right">
{!! Former::text('first_name') !!}
{!! Former::text('last_name') !!}
{!! Former::text('email') !!}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.permissions') !!}</h3>
</div>
2018-06-10 13:24:10 +02:00
<div class="panel-body">
@if ( ! Utils::hasFeature(FEATURE_USER_PERMISSIONS))
<div class="alert alert-warning">{{ trans('texts.upgrade_for_permissions') }}</div>
<script type="text/javascript">
$(function() {
$('input[type=checkbox]').prop('disabled', true);
})
</script>
@endif
{!! Former::checkbox('is_admin')
->label('&nbsp;')
->value(1)
->text(trans('texts.administrator'))
->help(trans('texts.administrator_help')) !!}
<div class="panel-body">
2018-06-10 13:24:10 +02:00
<table class="table table-striped dataTable" >
<thead>
<th></th>
2018-06-10 13:24:10 +02:00
<th style="padding-bottom:0px">{!! Former::checkbox('create')
2018-06-08 13:57:39 +02:00
->text( trans('texts.create') )
->value('create_')
->label('&nbsp;')
->id('create_all') !!}</th>
2018-06-10 13:24:10 +02:00
<th style="padding-bottom:0px">{!! Former::checkbox('view')
2018-06-08 13:57:39 +02:00
->text( trans('texts.view') )
->value('view_')
->label('&nbsp;')
->id('view_all') !!}</th>
2018-06-10 13:24:10 +02:00
<th style="padding-bottom:0px">{!! Former::checkbox('edit')
2018-06-08 13:57:39 +02:00
->text( trans('texts.edit') )
->value('edit_')
->label('&nbsp;')
->id('edit_all') !!}</th>
</thead>
<tbody>
@foreach (json_decode(PERMISSION_ENTITIES,1) as $permissionEntity)
<?php
if($user)
$permissions = json_decode($user->permissions,1);
else
$permissions = [];
?>
<tr>
<td>{{ ucfirst($permissionEntity) }}</td>
<td>{!! Former::checkbox('permissions[create_' . $permissionEntity . ']')
2018-06-08 13:57:39 +02:00
->label('&nbsp;')
->value('create_' . $permissionEntity . '')
->id('create_' . $permissionEntity . '')
->check(is_array($permissions) && in_array('create_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
<td>{!! Former::checkbox('permissions[view_' . $permissionEntity . ']')
2018-06-08 13:57:39 +02:00
->label('&nbsp;')
->value('view_' . $permissionEntity . '')
->id('view_' . $permissionEntity . '')
->check(is_array($permissions) && in_array('view_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
<td>{!! Former::checkbox('permissions[edit_' . $permissionEntity . ']')
2018-06-08 13:57:39 +02:00
->label('&nbsp;')
->value('edit_' . $permissionEntity . '')
->id('edit_' . $permissionEntity . '')
->check(is_array($permissions) && in_array('edit_' . $permissionEntity, $permissions, FALSE) ? true : false) !!}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
2016-05-26 15:04:53 +02:00
</div>
</div>
2015-04-20 16:34:23 +02: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
{!! Former::close() !!}
2015-03-16 22:45:25 +01:00
<script type="text/javascript">
2017-02-28 19:15:55 +01:00
function submitAction(value) {
$('#action').val(value);
$('.user-form').submit();
}
2017-02-28 19:15:55 +01:00
</script>
2017-02-28 19:15:55 +01:00
2015-05-09 20:25:16 +02:00
@stop
@section('onReady')
2015-05-09 20:25:16 +02:00
$('#first_name').focus();
/*
*
* 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')
.replace('create_',"")
.replace('view_',"")
.replace('edit_',"")
.replace(']',"")
.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')
.replace('create_',"")
.replace('view_',"")
.replace('edit_',"")
.replace(']',"")
.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.
}
});
2018-06-08 13:57:39 +02:00
$('#create_all, #view_all, #edit_all').change(function(){
var checked = $(this).is(':checked');
var permission_type = $(this).val();
$("input[type='checkbox'][id^=" + permission_type + "]").each(function() {
var entity = $(this).attr('id')
.replace('create_',"")
.replace('view_',"")
.replace('edit_',"")
.replace(']',"")
.replace('[',""); //get entity name
2018-06-08 13:57:39 +02:00
$('#' + permission_type + entity).prop('checked', checked); //set state of edit checkbox
if(!$('#view_' + entity).is(':checked')) {
2018-06-08 13:57:39 +02:00
$('#edit_' + entity).prop('checked', false); //remove checkbox value from edit dependant on View state.
}
$('#edit_' + entity).prop('disabled', !$('#view_' + entity).is(':checked')); //set state of edit checkbox
});
2018-06-08 13:57:39 +02:00
});
2016-05-26 15:04:53 +02:00
@stop