Current File : /home/escuelai/public_html/it/templates/components/itilobject/timeline/form_validation.html.twig |
{#
# ---------------------------------------------------------------------
#
# GLPI - Gestionnaire Libre de Parc Informatique
#
# http://glpi-project.org
#
# @copyright 2015-2022 Teclib' and contributors.
# @copyright 2003-2014 by the INDEPNET Development Team.
# @licence https://www.gnu.org/licenses/gpl-3.0.html
#
# ---------------------------------------------------------------------
#
# LICENSE
#
# This file is part of GLPI.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# ---------------------------------------------------------------------
#}
{% extends 'components/itilobject/timeline/form_timeline_item.html.twig' %}
{% import 'components/form/fields_macros.html.twig' as fields %}
{% set params = params|default({}) %}
{% block timeline_card %}
{% if form_mode == 'view' %}
<div class="read-only-content w-100">
{{ entry_i['content']|raw }}
{% if entry_i['comment_submission']|length %}
<div class='alert alert-info mt-2'>
<div class='d-flex'>
<div><i class='ti ti-quote me-2'></i></div>
<div>
{{ entry_i['comment_submission']|enhanced_html({
'user_mentions': true,
'images_gallery': true
}) }}
</div>
</div>
</div>
{% endif %}
{% if entry_i['comment_validation']|length %}
<div class='alert alert-info mt-2'>
<div class='d-flex'>
<div><i class='ti ti-quote me-2'></i></div>
<div>
{{ entry_i['comment_validation']|enhanced_html({
'user_mentions': true,
'images_gallery': true
}) }}
</div>
</div>
</div>
{% endif %}
{% if entry_i['can_answer'] %}
<hr class="my-2" />
<form id="validationanswers_id_{{ entry_i['id'] }}"
action="{{ entry['type']|itemtype_form_path }}" method="post" data-submit-once>
<input type="hidden" name="id" value="{{ entry_i['id'] }}" />
<input type="hidden" name="users_id_validate" value="{{ entry_i['users_id_validate'] }}" />
<input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
{{ call_plugin_hook('pre_item_form', {"item": subitem, 'options': params}) }}
<div class="mb-3 comment-part">
{{ fields.textareaField(
'comment_validation',
'',
_n('Comment', 'Comments', 1),
{
'full_width': true,
'enable_richtext': true,
'is_horizontal': false,
'enable_fileupload': true,
'enable_mentions': true,
'rand': rand,
}
) }}
</div>
<div class="validation-footer">
<button type="submit" class="btn btn-outline-green" name="approval_action" value="approve">
<i class="fas fa-thumbs-up"></i>
<span class="validation-label">{{ __('Approve') }}</span>
</button>
<button type="submit" class="btn btn-outline-red" name="approval_action" value="refuse">
<i class="fas fa-thumbs-down"></i>
<span class="validation-label">{{ __('Refuse') }}</span>
</button>
</div>
</form>
{% endif %}
</div>
{% elseif form_mode == 'answer' %}
<form name="asset_form" style="width: 100%;" class="d-flex flex-column" method="post"
action="{{ subitem.getFormURL() }}" enctype="multipart/form-data" data-track-changes="true" data-submit-once>
<input type="hidden" name="id" value="{{ subitem.fields['id'] }}" />
<input type="hidden" name="users_id_validate" value="{{ subitem.fields['users_id_validate'] }}" />
<input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
{{ call_plugin_hook('pre_item_form', {"item": subitem, 'options': params}) }}
<div class="mb-3 comment-part">
{{ fields.textareaField(
'comment_validation',
subitem.fields['comment_validation'],
_n('Comment', 'Comments', 1),
{
'full_width': true,
'enable_richtext': true,
'is_horizontal': false,
'enable_fileupload': true,
'enable_mentions': true,
'rand': rand,
}
) }}
</div>
<div class="validation-footer">
<button type="submit" class="btn btn-outline-green" name="approval_action" value="approve">
<i class="fas fa-thumbs-up"></i>
<span class="validation-label">{{ __('Approve') }}</span>
</button>
<button type="submit" class="btn btn-outline-red" name="approval_action" value="refuse">
<i class="fas fa-thumbs-down"></i>
<span class="validation-label">{{ __('Refuse') }}</span>
</button>
</div>
</form>
{% else %}
<div class="itilvalidation card mt-4">
<form name="asset_form" style="width: 100%;" class="d-flex flex-column" method="post"
action="{{ subitem.getFormURL() }}" enctype="multipart/form-data" data-track-changes="true" data-submit-once>
<input type="hidden" name="itemtype" value="{{ item.getType() }}" />
<input type="hidden" name="{{ item.getForeignKeyField() }}" value="{{ item.fields['id'] }}" />
<div class="card-header">
<h3 class="cart-title">{{ __("Validation request") }}</h3>
</div>
<div class="card-body">
{{ fields.readOnlyField(
'approval_requester',
get_current_user().getFriendlyName(),
_n('Requester', 'Requesters', 1),
{
'full_width': true,
'rand': rand,
}
) }}
{% if subitem.isNewItem() %}
{{ fields.dropdownArrayField('validatortype', subitem.fields['validatortype'], {
'User': 'User'|itemtype_name,
'Group': 'Group'|itemtype_name
}, __('Approver'), {
'display_emptychoice': true,
'rand': rand,
'field_class': 'col-12',
'label_class': 'col-xxl-4',
'input_class': 'col-xxl-8 flex-wrap',
'add_field_html': '<span id="show_validator_field' ~ rand ~ '" class="flex-grow-1"> </span>',
}) }}
{% if subitem.fields['validatortype'] is not null %}
<script type="application/javascript">
$('#show_validator_field{{ rand }}').load(CFG_GLPI.root_doc + '/ajax/dropdownValidator.php', {
id: {{ subitem.fields['id'] }},
entity: {{ item.fields['entities_id'] }},
right: "{{ item.getType() is same as 'Ticket' and item.fields['type'] == 2 ? 'validate_request' : 'validate_incident' }}",
validatortype: "{{ subitem.fields['users_id_validate']['groups_id'] is defined ? 'Group' : (subitem.fields['users_id_validate'] is not empty ? 'User' : '') }}"
});
</script>
{% else %}
<script type="application/javascript">
updateItemOnSelectEvent("dropdown_validatortype{{ rand }}", '#show_validator_field{{ rand }}',
CFG_GLPI.root_doc + '/ajax/dropdownValidator.php', {
id: 0,
entity: {{ item.fields['entities_id'] }},
right: "{{ item.getType() is same as 'Ticket' and item.fields['type'] == 2 ? 'validate_request' : 'validate_incident' }}",
validatortype: '__VALUE__',
groups_id: 0
});
</script>
{% endif %}
{% else %}
{{ fields.dropdownField(
'User',
'users_id_validate',
subitem.fields['users_id_validate'],
__('Approver'),
{
'disabled': true,
'full_width': true,
}
) }}
{% endif %}
{{ fields.textareaField(
'comment_submission',
subitem.fields['comment_submission'],
_n('Comment', 'Comments', 1),
{
'full_width': true,
'enable_richtext': true,
'enable_fileupload': true,
'enable_mentions': true,
'rand': rand,
}
) }}
</div>
{{ call_plugin_hook('post_item_form', {"item": subitem, 'options': params}) }}
<div class="d-flex justify-content-center card-footer">
{% if subitem.fields['id'] <= 0 %}
<button class="btn btn-primary me-2" type="submit" name="add">
<i class="fas fa-plus"></i>
<span>{{ _x('button', 'Add') }}</span>
</button>
{% else %}
<input type="hidden" name="id" value="{{ subitem.fields['id'] }}" />
<button class="btn btn-primary me-2" type="submit" name="update">
<i class="far fa-save"></i>
<span>{{ _x('button', 'Save') }}</span>
</button>
{% if subitem.can(id, constant('PURGE')) %}
<button class="btn btn-outline-danger me-2" type="submit" name="purge"
onclick="return confirm('{{ __('Confirm the final deletion?') }}');">
<i class="fas fa-trash-alt"></i>
<span>{{ _x('button', 'Delete permanently') }}</span>
</button>
{% endif %}
{% endif %}
</div>
<input type="hidden" name="_glpi_csrf_token" value="{{ csrf_token() }}" />
</form>
</div>
<script type="text/javascript">
window.scrollTo(0,document.body.scrollHeight);
</script>
{% endif %}
{% endblock %}