{% extends "layouts/app.twig" %}

{% block title %} {{ lang.EMAIL_EMAIL_FORWARD }} {% endblock %}

{% block content %}
    <div class="page-wrapper">
        <div class="page-content">

            <!--breadcrumb-->
            <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
                <div class="breadcrumb-title pe-3"><a href="{{route('email.index')}}" class="text-dark">{{ lang.EMAIL_EMAIL_FORWARD }}</a></div>
                <div class="ps-3">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb mb-0 p-0">
                            <li class="breadcrumb-item active" aria-current="page">{{ lang.add }}</li>
                        </ol>
                    </nav>
                </div>
                <div class="ms-auto">
                    <div class="btn-group btn-group-sm">
                        <a class="btn btn-primary btn-sm" href="{{route('email.index')}}"><i class="bi bi-reply font16"></i> {{ lang.go_back }}</a>
                    </div>
                </div>
            </div>
            <!--end breadcrumb-->

            <div class="row">
                <div class="col-xl-7 mx-auto">
                    <div class="card border shadow-none">
                        <div class="card-body p-5">
                            {% include 'partials/flash.twig' %}
                            <form method="post" action="{{ route('email.forward') }}">
                                <div class="modal-body row g-3 p-3">
                                    {{ csrf.field | raw }}

                                    <div class="col-md-12">
                                        <label for="email" class="form-label visually-hidden">{{ lang.email }}</label>
                                        <input type="email" value="{{ email }}" placeholder="{{ lang.email }}" class="form-control {{ errors.email ? ' is-invalid' : '' }}" id="email" name="email" readonly>
                                    </div>

                                    <div class="col-md-12">
                                        <label for="email_forward" class="form-label">{{ lang.cp_email_forward }}</label>
                                        <input type="email" placeholder="{{ lang.cp_email_forward_add }}" class="form-control {{ errors.email_forward ? ' is-invalid' : '' }}" id="email_forward" name="email_forward" required>
                                        {% if errors.email_forward %}
                                            <div class="invalid-feedback">{{ errors.email_forward | first }}</div>
                                        {% endif %}
                                    </div>

                                    <div class="col-md-12 mb-2">
                                        {% if forwards|length > 0 %}
                                        <ul class="list-group">
                                            <li class="list-group-item active" aria-current="true">Forwards</li>
                                            {% for fwd in forwards %}
                                                <li class="list-group-item d-flex justify-content-between align-items-center">
                                                    {{ fwd.forward }}
                                                    <span class="badge bg-danger rounded-pill">
                                                    <a href="{{route('email.forward.create',{'email':baseEncode(email)})}}?fwdemail={{ baseEncode(fwd.forward) }}" class="btn btn-default btn-sm" onclick="return confirm('Are you sure you want this forward email')"><i class="bi bi-trash text-white"></i></a>
                                                </span>
                                                </li>
                                            {% endfor %}
                                        </ul>
                                        {% endif %}
                                    </div>

                                    <div class="col-12 right">
                                        <button type="submit" class="btn btn-primary px-5">{{ lang.update }}</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
