{#
 # This file is part of SolidInvoice package.
 #
 # (c) Pierre du Plessis <open-source@solidworx.co>
 #
 # This source file is subject to the MIT license that is bundled
 # with this source code in the file LICENSE.
 #}

{% set currency = quote.client.currency %}

{% extends "@SolidInvoiceCore/Layout/default.html.twig" %}

{% block page_title %}
    {{ "quote.title"|trans({"%id%" : quote.quoteId}) }}
{% endblock page_title %}

{% block content %}
    <div class="float-right no-print">
        <div class="btn-toolbar" role="toolbar">
            <div class="btn-group mr-2" role="group">
                {% if quote.invoice is not null %}
                    <a href="{{ path('_invoices_view', {'id' : quote.invoice.id}) }}" class="btn btn-secondary">
                        {{ icon('file-text-o') }} {{ "quote.view.toolbar.view_invoice"|trans }}
                    </a>
                {% endif %}
                <a href="{{ path('_quotes_clone', {'id' : quote.id}) }}" class="btn btn-secondary">
                    {{ icon('clone') }} {{ "quote.view.toolbar.clone"|trans }}
                </a>
                {% if workflow_can(quote, 'accept') %}
                    <a href="{{ path('_transition_quote', {'action' : 'accept', 'id' : quote.id}) }}" class="btn btn-success">
                        {{ icon('check') }} {{ "quote.view.toolbar.accept"|trans }}
                    </a>
                {% endif %}

                {% if workflow_can(quote, 'decline') %}
                    <a href="{{ path('_transition_quote', {'action': 'decline', 'id' : quote.id}) }}" class="btn btn-danger">
                        {{ icon('times') }} {{ "quote.view.toolbar.decline"|trans }}
                    </a>
                {% endif %}

                {% if workflow_can(quote, 'reopen') %}
                    <a href="{{ path('_transition_quote', {'action': 'reopen', 'id' : quote.id}) }}" class="btn btn-secondary">
                        {{ icon('reply') }} {{ "quote.view.toolbar.reopen"|trans }}
                    </a>
                {% endif %}

                {% if quote.status not in ['declined', 'cancelled'] %}
                    <a href="{{ path('_send_quote', {'id' : quote.id}) }}" class="btn btn-info">
                        {{ icon('envelope', ['o']) }} {{ (quote.status not in ['pending', 'accepted'] ? "Publish and Send" : "quote.view.toolbar.send")|trans }}
                    </a>
                {% endif %}

                {% if workflow_can(quote, 'publish') %}
                    <a href="{{ path('_transition_quote', {'action' : 'publish', 'id' : quote.id}) }}" class="btn btn-primary">
                        {{ icon('check') }} {{ "Publish"|trans }}
                    </a>
                {% endif %}

                {% if workflow_can(quote, 'cancel') %}
                    <a href="{{ path('_transition_quote', {'action': 'cancel', 'id' : quote.id}) }}" class="btn btn-warning">
                        {{ icon('ban') }} {{ "quote.view.toolbar.cancel"|trans }}
                    </a>
                {% endif %}

                {% if quote.status != 'accepted' %}
                    <a href="{{ path('_quotes_edit', {'id' : quote.id}) }}" class="btn btn-secondary">
                        {{ icon('edit') }} {{ "quote.view.toolbar.edit"|trans }}
                    </a>
                {% endif %}
            </div>
        </div>
    </div>

    <br class="clear"/>
    <br class="clear"/>

    {% embed "@SolidInvoiceQuote/quote_template.html.twig" %}
        {% block footer %}
            {{ parent() }}

            <div class="row no-print">
                <div class="col-12">
                    <div class="btn-group">
                        <a href="javascript:window.print()" class="btn btn-secondary">{{ icon('print') }} {{ 'quote.action.print'|trans }}</a>
                        {% if can_print_pdf() %}
                            <a href="{{ path('_quotes_view', {'id': quote.id, '_format': 'pdf'}) }}" target="_blank" class="btn btn-secondary">{{ icon('file-pdf-o') }} {{ 'quote.action.pdf'|trans }}</a>
                        {% endif %}
                    </div>
                </div>
            </div>
        {% endblock footer %}
    {% endembed %}
{% endblock content %}
{% block footer %}
    {{ parent() }}

    {% if quote.notes is not empty %}
        <div class="col-6 no-print">
            <strong>{{ 'quote.notes'|trans }}</strong>
            <p class="text-muted well well-sm no-shadow">
                {{ quote.notes }}
            </p>
        </div>
    {% endif %}
{% endblock footer %}
