{% extends 'layout_default.html.twig' %}

{% block meta_title %}{{ 'Hosting management'|trans }}{% endblock %}

{% set active_menu = 'system' %}

{% block breadcrumbs %}
    <ol class="breadcrumb">
        <li class="breadcrumb-item">
            <a href="{{ '/'|alink }}">
                <svg class="icon">
                    <use xlink:href="#home" />
                </svg>
            </a>
        </li>
        <li class="breadcrumb-item">
            <a href="{{ 'servicehosting'|alink }}">{{ 'Hosting plans and servers'|trans }}</a>
        </li>
        <li class="breadcrumb-item active" aria-current="page">{{ hp.name }}</li>
    </ol>
{% endblock %}

{% block content %}
<div class="card">
    <div class="card-body">
        <h5>{{ 'Manage hosting plan'|trans }}</h5>
        <form method="post" action="{{ 'api/admin/servicehosting/hp_update'|link }}" class="api-form" data-api-msg="{{ 'Hosting plan updated'|trans }}">
            <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Name'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="name" value="{{ hp.name }}" required placeholder="{{ 'Unique name to identify this hosting plan'|trans }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Disk quota'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="quota" value="{{ hp.quota }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Bandwidth'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="bandwidth" value="{{ hp.bandwidth }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Max Addon domains'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="max_addon" value="{{ hp.max_addon }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Max FTP accounts'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="max_ftp" value="{{ hp.max_ftp }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Max SQL Databases'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="max_sql" value="{{ hp.max_sql }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Max Email Accounts'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="max_pop" value="{{ hp.max_pop }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Max Subdomains'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="max_sub" value="{{ hp.max_sub }}">
                </div>
            </div>
            <div class="mb-3 row">
                <label class="form-label col-3 col-form-label">{{ 'Max Parked Domains'|trans }}:</label>
                <div class="col">
                    <input class="form-control" type="text" name="max_park" value="{{ hp.max_park }}">
                </div>
            </div>
            {% if hp.config|length > 0 %}
                <h3>{{ 'Server manager specific parameters'|trans }}</h3>
                {% for name, value in hp.config %}
                <div class="mb-3 row">
                    <label class="form-label col-3 col-form-label">{{ name }}:</label>
                    <div class="col">
                        <textarea class="form-control" name="config[{{ name }}]" rows="1">{{ value }}</textarea>
                    </div>
                </div>
                {% endfor %}
            {% endif %}

            <input type="hidden" name="id" value="{{ hp.id }}">
            <button class="btn btn-primary w-100" type="submit">{{ 'Update hosting plan'|trans }}</button>
        </form>
        <hr>

        <h3>{{ 'Hosting plan additional parameters'|trans }}</h3>
        <p class="text-muted">{{ 'Depending on server manager used to setup hosting account you may require provide additional parameters. List of parameters server managers requires you can find on extensions page.'|trans }}</p>

        <form method="post" action="{{ 'api/admin/servicehosting/hp_update'|link }}" class="api-form" data-api-reload="1">
            <input type="hidden" name="CSRFToken" value="{{ CSRFToken }}"/>
            <div class="mb-3 row g-2">
                <div class="col">
                    <label class="form-label">{{ 'Parameter name'|trans }}:</label>
                    <input class="form-control" type="text" name="new_config_name">
                </div>
                <div class="col">
                    <label class="form-label">{{ 'Parameter value'|trans }}:</label>
                    <textarea class="form-control" name="new_config_value" rows="1"></textarea>
                </div>
            </div>
            <input type="hidden" name="id" value="{{ hp.id }}">
            <button class="btn btn-primary w-100" type="submit">{{ 'Add new field'|trans }}</button>
        </form>
    </div>
</div>
{% endblock %}
