{# @var ea \EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext #}
{# @var field \EasyCorp\Bundle\EasyAdminBundle\Dto\FieldDto #}
{# @var entity \EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto #}
{# {% if ea.crud.currentAction == 'detail' %}
<table class="table table-striped">
<tr>
<th>Id</th>
<th>Link</th>
<th>Estado</th>
<th>Mensaje</th>
<th></th>
</tr>
{% for value in field.value %}
<tr>
<td>{{ value.getGlobalpayId }}</td>
<td><a href="https://link.globalpay.com.co/checkout/{{value.getGlobalpayLtpId}}" target="_blank">{{ value.getGlobalpayLtpId }}</a></td>
<td><span class="badge badge-{{ value.getBadgeColor }}">{{ value.getGlobalpayStatusName }}</span></td>
<td>{{ value.getGlobalpayComment }}</td>
<td>{{ value.getCreatedAt|date('Y-m-d H:i:s') }}</td>
</tr>
{% endfor %}
</table>
{% else %}
<span class="badge badge-secondary">{{ field.formattedValue }}</span>
{% endif %} #}
{% if ea.crud.currentAction == 'detail' %}
{% set groupedValues = {} %}
{% if globalpayEnv == 'prod' %}
{% set globalpayBaseUrl = 'https://link.globalpay.com.co/checkout/' %}
{% else %}
{% set globalpayBaseUrl = 'https://link-stg.globalpay.com.co/checkout/' %}
{% endif %}
{% for value in field.value %}
{% set globalpayLtpId = value.getGlobalpayLtpId %}
{% if groupedValues[globalpayLtpId] is not defined %}
{% set groupedValues = groupedValues|merge({ (globalpayLtpId): [] }) %}
{% endif %}
{% set groupedValues = groupedValues|merge({ (globalpayLtpId): groupedValues[globalpayLtpId]|merge([value]) }) %}
{% endfor %}
<table class="table table-striped">
<tr>
<th>Id</th>
<th>Estado</th>
<th>Mensaje</th>
<th>Fecha</th>
</tr>
{% for globalpayLtpId, values in groupedValues %}
<tr>
{# <td colspan="5"><strong><a href="https://link.globalpay.com.co/checkout/{{globalpayLtpId}}" target="_blank">{{ globalpayLtpId }}</a></strong></td> #}
<td colspan="5"><strong><a href="{{globalpayBaseUrl}}{{globalpayLtpId}}" target="_blank">{{ globalpayLtpId }}</a></strong></td>
</tr>
{% for value in values %}
<tr>
<td>{{ value.getGlobalpayId }}</td>
<td><span class="badge badge-{{ value.getBadgeColor }}">{{ value.getGlobalpayStatusName }}</span></td>
<td><small>{{ value.getGlobalpayComment }}</small></td>
<td>
<small>{{ value.getCreatedAt|date('Y-m-d H:i:s') }} (callcenter)</small><br>
<small>{{ value.getGlobalpayDate|date('Y-m-d H:i:s') }} (globalpay)</small>
</td>
</tr>
{% endfor %}
{% endfor %}
</table>
{% else %}
<span class="badge badge-secondary">{{ field.formattedValue }}</span>
{% endif %}