{% extends "base_bootstrap.html.twig" %}

{% block content %}
    <div class="container">
        <div class="col-md-offset-3 col-md-6">
            <div class="row">
                <div class="col-md-12">
                    <div class="row">
                        <h2>Welcome to your Zer.ooo install</h2>
                    </div>
                    <div class="row">
                        <h3>Checking for extensions and settings</h3>
                    </div>
                    <div class="row">
                        {% if error %}
                            <div class="alert alert-warning" role="alert">
                                {{ error }}
                            </div>
                        {% endif %}
                    </div>
                    <div class="row">
                        <table class="table">
                            <tbody>
                            <tr>
                                <td>{{ hasExecEnabled ? 'Yes' : 'No' }}</td>
                                <td>Is <kbd>exec</kbd> available?</td>
                            </tr>
                            <tr>
                                <td>{{ hasOpenSsl ? 'Yes' : 'No' }}</td>
                                <td>Is the <kbd>openssl</kbd> binary available?</td>
                            </tr>
                            <tr>
                                <td>{{ hasOpenSslExtension ? 'Yes' : 'No' }}</td>
                                <td>Is the openssl module loaded?</td>
                            </tr>
                            <tr>
                                <td>{{ hasZipExtension ? 'Yes' : 'No' }}</td>
                                <td>Is the zip module loaded?</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                    {% if not (hasExecEnabled and hasOpenSslExtension and hasOpenSsl and hasZipExtension) %}
                        <div class="row">
                            Those functions are essential for the functionality of Zer.ooo, please enable them<br>
                            <br>
                            <a href="/install" class="btn btn-primary">Refresh</a>
                        </div>
                    {% else %}
                        <div class="row">
                            <h3>Create your superuser</h3>
                        </div>
                        <form method="post" action="/install">
                            <div class="row">
                                <div class="form-group">
                                    <label for="username">Username</label>
                                    <input id="username" class="form-control" type="text" name="username">
                                </div>
                                <div class="form-group">
                                    <label for="password">Password</label>
                                    <input id="password" class="form-control" type="password" name="password">
                                </div>
                            </div>
                            <div class="row">
                                <h3>Server details</h3>
                            </div>
                            <div class="row">
                                <div class="form-group">
                                    <label for="ca-cn">CA Common Name</label>
                                    <input type="text" id="ca-cn" name="ca-cn" class="form-control" value="{{ hostname }}" />
                                </div>
                                <div class="form-group">
                                    <label for="domainWithPort">HTTP Host (NOT HTTPS! needed for CRL)</label>
                                    <input type="text" id="domainWithPort" name="domainWithPort" class="form-control" value="{{ hostnameWithPort }}" />
                                </div>
                                <div class="form-group">
                                    <button type="submit" class="btn btn-primary pull-right">Finish install</button>
                                </div>
                            </div>
                        </form>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
{% endblock %}