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

{% block title %}{{ lang.add }} {{ lang.user }}{% 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.users }}</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 }} {{ lang.user }}</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 class="row g-3" method="post" action="{{ route('email.store') }}">
                                {{ csrf.field | raw }}
                                <div class="col-md-12">
                                    <label for="username" class="form-label">{{ lang.user_email }}</label>
                                    <div class="input-group">
                                        <input type="text" placeholder="{{ lang.user_username }}" class="form-control {{ errors.username ? ' is-invalid' : '' }}" id="username" name="username">
                                        <span class="input-group-text">@{{ domain }}</span>
                                        {% if errors.username %}
                                            <div class="invalid-feedback">{{ errors.username | first }}</div>
                                        {% endif %}
                                    </div>
                                </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">
                                    {% if errors.email_forward %}
                                        <div class="invalid-feedback">{{ errors.email_forward | first }}</div>
                                    {% endif %}
                                </div>
                                <div class="col-md-12">
                                    <label for="email_quota" class="form-label">{{ lang.cp_email_quota }} (MB)</label>
                                    <input type="number" min="0" value="{{ quotasize }}" class="form-control {{ errors.email_quota ? ' is-invalid' : '' }}" id="email_quota" name="email_quota">
                                    {% if errors.email_quota %}
                                        <div class="invalid-feedback">{{ errors.email_quota | first }}</div>
                                    {% endif %}
                                </div>
                                <div class="col-md-12 mb-2">
                                    <label for="password" class="form-label">{{ lang.user_password }}</label>
                                    <div class="input-group">
                                        <input type="password" name="password" placeholder="{{ lang.user_password }}" id="password" class="form-control {{ errors.password ? ' is-invalid' : '' }}" />
                                        <span class="input-group-text"><a href="javascript:;" class="text-dark" onclick="showPassword()">Show</a></span>
                                        {% if errors.password %}
                                            <div class="invalid-feedback">{{ errors.password | first }}</div>
                                        {% endif %}
                                    </div>
                                </div>
                                <div class="col-12">
                                    <button type="submit" class="btn btn-primary px-5">{{ lang.create }}</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block innerjs %}
    <script>
        function showPassword() {
            var x = document.getElementById("password");
            if (x.type === "password") {
                x.type = "text";
            } else {
                x.type = "password";
            }
        }
    </script>
{% endblock %}
