operations.html.twig 7.5 KB
Newer Older
Julien Jorry committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
{% set operations = operations|default(getLastOperations(app.request, app.user, constant('App\\Enum\\CurrencyEnum::CURRENCY_EMLC'))) %}
{% set title = title|default('Dernières opérations'|trans) %}
{% extends '@kohinos/block/block_collapse.html.twig' %}

{% block blocktitle %}
	<i class="fa fa-list-alt mr-4"></i> {{ title }}
{% endblock blocktitle %}
{% block blocksubtitle %}
{% endblock blocksubtitle %}
{% block blockcontent %}
    {% if operations|length > 0 %}
        <div class="table-responsive">
      		<table class="table">
                <thead>
                  <tr>
                    <th scope="col">Date</th>
                    <th scope="col">Type</th>
                    <th scope="col">Operation</th>
                    <th scope="col">Montant</th>
Yvon committed
20
                    {# Display column to store btn to cancel transaction adherent prestataire #}
Yvon committed
21
                    {% if display_cancel_transaction_btn is defined and display_cancel_transaction_btn %}
Yvon committed
22 23
                        <th scope="col"></th>
                    {% endif %}
Julien Jorry committed
24 25 26 27 28 29
                  </tr>
                </thead>
                <tbody>
      			{% for operation in operations %}
                    <tr>
                        <td><span data-toggle="tooltip" data-placement="bottom" title="{{ operation.createdAt|date('d/m/Y H:i') }}">{{ operation.createdAt|date('d/m/Y') }}</span></td>
30 31
                        <td>{{ ((isCurrentAccountable(app.user, operation.flux.expediteur) ? 'exp' : 'des')~'_'~operation.flux.parenttype)|trans({}, 'flux') }}
                        <div id='operationInfo{{loop.index}}' class='collapse operationInfo{{loop.index}}'>
32 33 34 35 36 37 38
                            Référence : {{ operation.flux.reference }}<br/>
                            {% if operation.flux.moyen == constant('App\\Enum\\MoyenEnum::MOYEN_HELLOASSO') %}
                                {% set urlTicket = getPaymentReceiptUrlFromFlux(operation.flux) %}
                                {% if urlTicket is not empty %}
                                    <a href='{{urlTicket}}' target='_blank'>Ticket CB</a>
                                {% endif %}
                            {% endif %}
39 40
                        </div>
                        </td>
Julien Jorry committed
41
                        <td>
42
                            <span style='cursor:pointer;' data-toggle="collapse" data-target=".operationInfo{{loop.index}}">
Julien Jorry committed
43
                                {% if not isCurrentAccountable(app.user, operation.flux.expediteur)  %}
Julien Jorry committed
44 45 46 47 48
                                    {% if operation.flux.expediteur is instanceof("App\\Entity\\Prestataire") and operation.flux.expediteur.isSolidoume == true %}
                                        {{ getSolidoumeParam('name')|default('Sécurité Sociale Alimentaire') }}
                                    {% else %}
                                        {{ operation.flux.expediteur }}
                                    {% endif %}
Julien Jorry committed
49
                                {% elseif not isCurrentAccountable(app.user, operation.flux.destinataire)  %}
Julien Jorry committed
50 51 52 53 54
                                    {% if operation.flux.destinataire is instanceof("App\\Entity\\Prestataire") and operation.flux.destinataire.isSolidoume == true %}
                                        {{ getSolidoumeParam('name')|default('Sécurité Sociale Alimentaire') }}
                                    {% else %}
                                        {{ operation.flux.destinataire }}
                                    {% endif %}
Julien Jorry committed
55 56 57
                                {% endif %}
                                <i class="fa fa-caret-down ml-2" aria-hidden="true"></i>
                            </span>
58
                            <div class='collapse operationInfo{{loop.index}}'>
Julien Jorry committed
59 60 61
                                Moyen : {{ operation.flux.moyen|trans }}
                            </div>
                        </td>
62
                        <td><span class='font-weight-bold {{ (operation.montant < 0)? '':'text-primary' }}'>{{ (operation.montant < 0)? '- ':'+ ' }} {{ operation.montant|abs|number_format(2) }} {{ getCurrencyName(operation.currency) }}</span></td>
Yvon committed
63
                        {# Display btn to cancel transaction adherent prestataire #}
Yvon committed
64
                        {% if display_cancel_transaction_btn is defined and display_cancel_transaction_btn
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
                            and operation.flux.type is same as(constant('App\\Entity\\Transaction::TYPE_TRANSACTION_ADHERENT_PRESTATAIRE'))
                            and app.user in operation.flux.destinataire.users %}
                            <td class='text-right'>
                                {# If transaction has been cancelled already #}
                                {% if operation.flux.cancellerFlux %}
                                    <button class="btn btn-sm" title="Cette transaction a déjà été annulée." disabled>
                                        <i class="fas fa-undo"></i>
                                    </button>
                                {% else %}
                                    <a href="{{ path('cancel_transaction_adherent_prestataire', {'id': operation.flux.id}) }}"
                                       type="button"
                                       class="btn btn-sm btn-primary"
                                       title="Annuler cette transaction."
                                       onclick="return confirm('Êtes-vous sûr de vouloir annuler cette transaction et rembourser le client ? L\'opération est irréversible.')">
                                        <i class="fas fa-undo"></i>
                                    </a>
                                {% endif %}
Yvon committed
82 83
                            </td>
                        {% endif %}
Julien Jorry committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
                    </tr>
      			{% endfor %}
      		  </tbody>
      		</table>
        </div>
    {% else %}
        <div class='my-2 mx-2'>
            {{ 'Aucunes opérations pour le moment ! '|trans }}
        </div>
    {% endif %}
    {% if operations|length > 0 %}
        <a href='{{ path('show_operations', {'currency' : operations[0].currency}) }}' type="button" class="btn btn-primary">
            <i class="fa fa-share-square-o" aria-hidden="true"></i>
            {{ 'Voir toutes les opérations'|trans }}
        </a>
		<br/>
		{# <div class="btn-group">
            <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" id="dropdownMenuLink">
                <i class="fa fa-share-square-o" aria-hidden="true"></i>
                Exporter
                <span class="caret"></span>
            </button>
            <div class="dropdown-menu" aria-labelledby="dropdownMenuLink">
                <a class="dropdown-item" href="{{ path('exportUserOperation', {'format' : 'json'}) }}">
                    <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                    JSON
                </a>
                <a class="dropdown-item" href="{{ path('exportUserOperation', {'format' : 'xml'}) }}">
                    <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                    XML
                </a>
                <a class="dropdown-item" href="{{ path('exportUserOperation', {'format' : 'csv'}) }}">
                    <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                    CSV
                </a>
                <a class="dropdown-item" href="{{ path('exportUserOperation', {'format' : 'xls'}) }}">
                    <i class="fa fa-arrow-circle-o-down" aria-hidden="true"></i>
                    XLS
                </a>
			</div>
        </div> #}
	{% endif %}
{% endblock blockcontent %}