% layout 'AdminLTE', title => "Sme server 2 - remoteaccess";

% content_for 'module' => begin

<div class="card-body">

    % if (config->{debug} == 1) {
        <pre>
        <%= dumper $c->current_route %>
        <%= dumper $rma_datas %>
        </pre>
    % }

    <h1><%= $title%></h1>

    % if ( $notif ) {
        <br>
        <div>
            <%= $c->render_to_string(inline => $notif) %>
        </div>
    %}

    <!--<hr class="" />-->

    <%  my $btn = l('SAVE'); %>


    <form action="/smanager/remoteaccess" method="POST">

    % my $ipsec = $c->get_ipsecrw_status();
    <!-- reetp not tested -->
    % if ( $ipsec) {

        <h2><%= l 'rma_TITLE_IPSECRW' %></h2>
        <div>
            <%= l 'rma_DESC_IPSECRW' %>
        </div>
        <div>
            <%= l 'rma_LABEL_IPSECRW_SESS' %>
        </div>
        <div>
            % param 'IpsecrwSess' => $c->get_ipsecrw_sessions unless param 'IpsecrwSess';
            <%= text_field 'IpsecrwSess', class => "" %>
        </div>
        <br>

        <div>
            <%= $c->render_to_string(inline => $c->l('rma_DESC_IPSECRW_RESET'));  %>
        </div>
        <br>
        <div>
            <%= l 'rma_LABEL_IPSECRW_RESET' %>
        </div>
        <div>
            <input type='checkbox' name='IpsecrwReset'>
        </div>
        <br><br>
    <!--<hr class="" />-->

    % }

    <!-- percequ include 'partials/_rma_pptp' -->

    <h2><%= $c->l('rma_VALIDFROM_TITLE', $c->l('rma_REMOTE_MANAGEMENT')); %></h2>

    <br>

    <div>
        <%= l 'rma_VALIDFROM_DESC' %>
    </div>

    <br><br>

    % my @vals = $self->_get_valid_from();
    % if (@vals) {
        <table class="table table-bordered">
            <thead>
                <tr>
                    <th><%= l 'NETWORK' %></th>
                    <th><%= l 'rma_SUBNET_MASK' %></th>
                    <th><%= l 'rma_NUM_OF_HOSTS' %></th>
                    <th><%= l 'REMOVE' %></th>
                </tr>
            </thead>
            <tbody>

            % foreach my $val ( @vals ) {
                % my ($net, $mask) = split '/', $val;
                % $mask = '255.255.255.255' unless ($mask);
                % my ($numhosts,$a,$b) = esmith::util::computeHostRange($net,$mask);
                <tr class="align-middle">
                    <td><%= $net %></td>
                    <td><%= $mask %></td>
                    <td><%= $numhosts %></td>
                    <td>
                    <input type='checkbox' name='Remove_nets' value='<%= $net.'/'.$mask %>'>
                    </td>
                </tr>
            % }

            </tbody>
        </table>

    <!-- my @cbGroup = $q->checkbox_group(-name => 'validFromRemove',
        -values => [@vals], -labels => { map {$_ => ''} @vals });
            foreach my $val (@vals)
            { esmith::cgi::genSmallCell($q, shift(@cbGroup), } -->
    % } else {
        <br>
        <b><%= l('rma_NO_ENTRIES_YET'); %></b>
    % }

    <br>

    <div>
        <%= l 'rma_DESC_VALID_FROM_ENTRIES' %>
    </div>

    <br><br>

    <div class="row g-3 align-items-center">
         <div class="col-md-1">
            <label for="inputNetwork" class="col-form-label"><%= l 'NETWORK' %></label>
        </div>
        <div class="col-auto">
            <input type="text" name="ValidFromNetwork" id="inputNetwork" class="form-control" aria-describedby="Network">
        </div>
    </div>

    <br>

    <div class="row g-3 align-items-center">
         <div class="col-md-1">
            <label for="inputSubnetMask" class="col-form-label"><%= l 'rma_SUBNET_MASK' %></label>
        </div>
        <div class="col-auto">
            <input type="text" name="ValidFromMask" id="inputSubnetMask" class="form-control" aria-describedby="Subnet">
        </div>
    </div>

    <!--<hr class="" />-->

    <br><br>

    <h2><%= l 'rma_TITLE_SSH' %></h2>

    <br>

    <div>
        <%= l 'rma_DESC_SSH' %>
    </div>

    <br><br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <%= l 'rma_LABEL_SSH' %>
        </div>
        <div class="col-md-2">
        % param 'SshAccess' => $c->get_ssh_access() unless param 'SshAccess';
        <%= select_field 'SshAccess' => $c->networkAccess_list(), class => "form-select" %>
        </div>
    </div>

    <br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <%= l 'rma_LABEL_SSH_ADMIN' %>
        </div>
        <div class="col-auto">
            % param 'SshPermitRootLogin' => $rma_datas->{sshPermitRootLogin} unless param 'SshPermitRootLogin';
            <%= select_field 'SshPermitRootLogin' => [[(l 'NO'), 'no'], [(l 'YES'), 'yes']], class => "form-select" %>
        </div>
    </div>

    <br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <%= l 'rma_LABEL_SSH_PASSWORD_ACCESS' %>
        </div>
        <div class="col-auto">
            % param 'SshPasswordAuthentication' => $c->get_ssh_password_auth() unless param 'SshPasswordAuthentication';
            <%= select_field 'SshPasswordAuthentication' => [[(l 'NO'), 'no'], [(l 'YES'), 'yes']], class => "form-select" %>
        </div>
    </div>

    <br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <label for="inputSSHPort" class="col-form-label"><%= l 'rma_LABEL_SSH_PORT' %></label>
        </div>
        <div class="col-sm-2">
            % param 'SshTCPPort' => $c->get_ssh_port() unless param 'SshTCPPort';
            <input type="text" name="SshTCPPort" id="inputSSHPort" class="form-control" aria-describedby="SSH Port" maxlength="5" value="<%= $c->get_ssh_port() %>">
        </div>
    </div>

    <br>

    <!--<hr class="" />-->

    <br><br>
    <h2><%= l 'rma_TITLE_FTP_ACCESS' %></h2>
    <br>

    <div>
        <%= $c->render_to_string(inline => $c->l('rma_DESC_FTP_ACCESS')); %>
    </div>

    <br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <%= l 'rma_LABEL_FTP_ACCESS' %>
        </div>
        <div class="col-auto">
            % param 'FtpAccess' => $c->get_ftp_access() unless param 'FtpAccess';
            <%= select_field 'FtpAccess' => $c->networkAccess_list(), class => "form-select" %>
        </div>
    </div>

    <br>
    <br>

    <div>
        <%= $c->render_to_string(inline => $c->l('rma_DESC_FTP_LOGIN')); %>
    </div>

    <br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <%= l 'rma_LABEL_FTP_LOGIN' %>
        </div>
        <div class="col-auto">
            % param 'FtpPasswordAccess' => $c->get_ftp_password_login_access() unless param 'FtpPasswordAccess';
            <%= select_field 'FtpPasswordAccess' => $c->passwordLogin_list(), class => "form-select" %>
        </div>
    <div>

    <br>

    % my $mode = $c->get_telnet_mode();
    % if ( $mode ne 'off') {
        <!--<hr class="" />-->

        <h2><%= l 'rma_TITLE_TELNET_ACCESS' %></h2>

        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'rma_DESC_TELNET_ACCESS' %>
            </div>
        <div>

        <br><br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'rma_LABEL_TELNET_ACCESS' %>
            </div>
            <div class="col-auto">
                % param 'TelnetAccess' => $mode unless param 'TelnetAccess';
                <%= select_field 'TelnetAccess' => $c->networkAccess_list(), class => "form-select" %>
            </div>
        </div>

        <br>

    % }

    <br>

    <div class="row g-3 align-items-center">
        <div class="col-md-2">
            <button type="submit" class="btn btn-primary btn-sm"><%= $btn %></button>
        </div>
    </div>

</div>

% end
