{#
# ---------------------------------------------------------------------
#
# GLPI - Gestionnaire Libre de Parc Informatique
#
# http://glpi-project.org
#
# @copyright 2015-2025 Teclib' and contributors.
# @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 .
#
# ---------------------------------------------------------------------
#}
{% set pending_reason_item_parent = call("PendingReason_Item::getForItem", [item]) %}
{% set display_for_parent = display_for_parent|default(false) %}
{% set pending_reason_contexts = {
'pending': {
'className' : 'badge bg-blue-lt',
'icon' : '',
'text': __('Pending'),
},
'done': {
'className' : 'badge bg-transparent text-muted',
'icon' : '',
'text' : __('Done'),
}
} %}
{% set pending_reason_selected_context = 'pending' %}
{% if display_for_parent %}
{% set pending_reason = pending_reason_item_parent ? call("PendingReason::getById", [pending_reason_item_parent.fields['pendingreasons_id']]) : false %}
{% else %}
{% set pending_item = pending_item ?? call(entry['type'] ~ "::getById", [entry_i['id']]) %}
{% set pending_reason_item = pending_item ? call("PendingReason_Item::getForItem", [pending_item]) : false %}
{% set pending_reason = pending_reason_item ? call("PendingReason::getById", [pending_reason_item.fields['pendingreasons_id']]) : false %}
{% set is_latest_pending = call("PendingReason_Item::isLastPendingForItem", [
item,
pending_item
]) %}
{% set pending_reason_selected_context = is_latest_pending and pending_reason_item_parent != false ? 'pending' : 'done' %}
{% endif %}
{% if pending_reason %}
{{ pending_reason_contexts[pending_reason_selected_context].icon|raw }}
{{ (pending_reason_contexts[pending_reason_selected_context].text ~ ": %s"|format(pending_reason.getLink()))|raw }}
{% if pending_reason_item_parent and (display_for_parent or call("PendingReason_Item::isLastPendingForItem", [
item,
pending_item
])) %}
{% set next_bump = pending_reason_item_parent.getNextFollowupDate() %}
{% if next_bump %}
{% endif %}
{% set resolve = pending_reason_item_parent.getAutoResolvedate() %}
{% if resolve %}
{% endif %}
{% endif %}
{% endif %}