{% extends '@MauticCore/Default/content.html.twig' %}

{% block headerTitle 'Delete Stage' %}

{% block content %}
    {{ include('@DealFlow/Deal/_nav.html.twig') }}

    <div class="panel panel-default">
        <div class="panel-heading"><strong>Delete {{ stage.getName() }}</strong></div>
        <div class="panel-body">
            {% if errorMessage %}
                <div class="alert alert-danger">{{ errorMessage }}</div>
            {% endif %}

            {% if not canDelete %}
                <p class="mb-md">You cannot delete the last remaining stage in the pipeline.</p>
            {% else %}
                <p class="mb-md">
                    This stage currently has <strong>{{ dealCount }}</strong> deal{{ dealCount == 1 ? '' : 's' }}.
                </p>

                <form method="post">
                    <input type="hidden" name="_token" value="{{ csrf_token('dealflow_stage_delete_' ~ stage.getId()) }}">
                    {% if dealCount > 0 %}
                        <div class="form-group">
                            <label for="replacement_stage_id">Move existing deals to</label>
                            <select class="form-control" id="replacement_stage_id" name="replacement_stage_id" required>
                                <option value="">Select a destination stage</option>
                                {% for item in replacementStages %}
                                    <option value="{{ item.getId() }}">{{ item.getName() }}</option>
                                {% endfor %}
                            </select>
                        </div>
                    {% endif %}

                    <div class="btn-group">
                        <button class="btn btn-danger" type="submit">Delete Stage</button>
                        <a class="btn btn-default" href="{{ cancelUrl }}">Cancel</a>
                    </div>
                </form>
            {% endif %}
        </div>
    </div>
{% endblock %}
