2021-03-15 22:47:13 +01:00
|
|
|
<?php
|
2021-10-20 22:29:23 +02:00
|
|
|
$combinedForm = $this->element('genericElements/Form/genericForm', [
|
|
|
|
'entity' => $userEntity,
|
|
|
|
'ajax' => false,
|
|
|
|
'raw' => true,
|
|
|
|
'data' => [
|
|
|
|
'description' => __('Create user account'),
|
|
|
|
'model' => 'User',
|
|
|
|
'fields' => [
|
|
|
|
[
|
|
|
|
'field' => 'individual_id',
|
|
|
|
'type' => 'dropdown',
|
|
|
|
'label' => __('Associated individual'),
|
|
|
|
'options' => $dropdownData['individual'],
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'username',
|
|
|
|
'autocomplete' => 'off',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'role_id',
|
|
|
|
'type' => 'dropdown',
|
|
|
|
'label' => __('Role'),
|
|
|
|
'options' => $dropdownData['role']
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'disabled',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'label' => 'Disable'
|
2021-03-16 08:45:37 +01:00
|
|
|
],
|
|
|
|
|
2021-10-20 22:29:23 +02:00
|
|
|
sprintf('<div class="pb-2 fs-4">%s</div>', __('Create individual')),
|
|
|
|
[
|
|
|
|
'field' => 'email',
|
|
|
|
'autocomplete' => 'off'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'uuid',
|
|
|
|
'label' => 'UUID',
|
|
|
|
'type' => 'uuid',
|
|
|
|
'autocomplete' => 'off'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'first_name',
|
|
|
|
'autocomplete' => 'off'
|
2021-03-15 22:47:13 +01:00
|
|
|
],
|
2021-10-20 22:29:23 +02:00
|
|
|
[
|
|
|
|
'field' => 'last_name',
|
|
|
|
'autocomplete' => 'off'
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'field' => 'position',
|
|
|
|
'autocomplete' => 'off'
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'submit' => [
|
|
|
|
'action' => $this->request->getParam('action')
|
2021-03-15 22:47:13 +01:00
|
|
|
]
|
2021-10-20 22:29:23 +02:00
|
|
|
]
|
|
|
|
]);
|
|
|
|
|
2021-03-15 22:47:13 +01:00
|
|
|
|
2021-10-20 22:29:23 +02:00
|
|
|
echo $this->Bootstrap->modal([
|
|
|
|
'title' => __('Register user'),
|
|
|
|
'size' => 'lg',
|
|
|
|
'type' => 'confirm',
|
|
|
|
'bodyHtml' => sprintf(
|
|
|
|
'<div class="form-container">%s</div>',
|
|
|
|
$combinedForm
|
|
|
|
),
|
|
|
|
'confirmText' => __('Create user'),
|
|
|
|
'confirmFunction' => 'submitRegistration'
|
|
|
|
]);
|
2021-03-15 22:47:13 +01:00
|
|
|
?>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
2021-03-18 14:01:14 +01:00
|
|
|
function submitRegistration(modalObject, tmpApi) {
|
2021-10-20 22:29:23 +02:00
|
|
|
const $form = modalObject.$modal.find('form')
|
|
|
|
tmpApi.postForm($form[0]).then(() => {
|
|
|
|
const url = '/inbox/index'
|
|
|
|
const $container = $('div[id^="table-container-"]')
|
|
|
|
const randomValue = $container.attr('id').split('-')[2]
|
|
|
|
UI.reload(url, $(`#table-container-${randomValue}`), $(`#table-container-${randomValue} table.table`))
|
|
|
|
})
|
2021-03-15 22:47:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$('div.user-container #individual_id-field').change(function() {
|
|
|
|
if ($(this).val() == -1) {
|
|
|
|
$('div.individual-container').show()
|
|
|
|
} else {
|
|
|
|
$('div.individual-container').hide()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
function getFormData(form) {
|
2021-10-20 22:29:23 +02:00
|
|
|
return Object.values(form).reduce((obj, field) => {
|
2021-03-15 22:47:13 +01:00
|
|
|
if (field.type === 'checkbox') {
|
|
|
|
obj[field.name] = field.checked;
|
|
|
|
} else {
|
|
|
|
obj[field.name] = field.value;
|
|
|
|
}
|
|
|
|
return obj
|
|
|
|
}, {})
|
|
|
|
}
|
|
|
|
</script>
|
2021-03-16 08:45:37 +01:00
|
|
|
|
|
|
|
<style>
|
2021-10-20 22:29:23 +02:00
|
|
|
div.individual-container>div,
|
|
|
|
div.user-container>div {
|
|
|
|
font-size: 1.5rem;
|
|
|
|
}
|
2021-03-16 08:45:37 +01:00
|
|
|
</style>
|