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

%# content_for 'module' => begin

%# use constant FALSE => 0;
%# use constant TRUE  => 1;

<!-- <div class="card-body"> -->

    % if (config->{debug} == 1) {
        <pre>
            <<%=  dumper $c->current_route %>
            <<%=  dumper $mai_data %>
            <<%=  dumper $c->param('SMTPAuth') %>
        </pre>
    % }

    % if ( stash 'error' ) {
        <br>
        <div class="text-danger">
            <<%=  $c->render_to_string(inline => stash 'error') %>
        </div>
    % }

    <!--<h1><%#=  $title %></h1> -->

    <h2><%= $c->l('mai_DESC_STATE_RECEPTION_BUTTON') %></h2>

    <br>

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

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

        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'mai_LABEL_MODE' %>
            </div>
            <div class="col-auto">
                % param 'FetchmailMethod' => $mai_data->{fetchmailmethod} unless param 'FetchmailMethod';
                <%=  select_field 'FetchmailMethod' => $c->get_retrieval_opt(), class =>"form-select" %>
            </div>
        </div>

        <br>


        <div>
            <div>
                <b><i>Note - this first line was disabled?</b></i>

                <br>
                <%= l 'mai_DESC_SMTP_AUTH_CONTROL' %>
                <br>
                <b><i>/end</b></i>
            </div>

            <br>

            <div>
                <%= l "mai_SMTP_port_(25)" %>
            </div>

            <br>

            <div>
                <%=  l "mai_SMTPS_port_(465)" %>
            </div>

            <br>

            <div>
                <%= %= l "mai_SMTP_Submission" %>
            </div>

        </div>

        <br>

        % my $smtp_mesg=l('SMTP port %u allow client to authenticate:');
        % param 'SMTPAuth' => $c->get_current_smtp_auth( FALSE ) unless param 'SMTPAuth';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%=  sprintf($smtp_mesg,$c->get_db_prop('qpsmtpd','TCPPort',25)); %>
            </div>
            <div class="col-auto">
                <%=  select_field 'SMTPAuth' => $c->get_smtp_auth_opt(), class => "form-select" %>
            </div>
        </div>

        <br>

        % my $smtp_mesg=l('SMTPS SSL/TLS auth: port %u status:');
        % param 'sSMTPAuth' => $c->get_current_smtp_ssl_auth(FALSE,'s', TRUE) unless param 'sSMTPAuth';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%=  sprintf($smtp_mesg,$c->get_db_prop('sqpsmtpd','TCPPort',465)); %>
            </div>
            <div class="col-auto">
                <%=  select_field 'sSMTPAuth' => $c->get_smtp_ssl_auth_opt(), class => "form-select" %>
            </div>
        </div>

        <br>

        % my $smtp_mesg=l('Submission port %u status:');
        % param 'uSMTPAuth' => $c->get_current_smtp_ssl_auth(FALSE,'u', TRUE) unless param 'uSMTPAuth';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%=  sprintf($smtp_mesg,$c->get_db_prop('uqpsmtpd','TCPPort',587)); %>
            </div>
            <div class="col-auto">
                <!--
                <pre>
                    <%=  dumper $c->get_smtp_ssl_auth_opt() %>
                    <%=  dumper $c->get_current_smtp_ssl_auth(FALSE,'s', TRUE) %>
                    <%=  dumper $c->get_current_smtp_ssl_auth(FALSE,'u', TRUE) %>
                    <%=  dumper $c->get_db_prop("uqpsmtpd","access") %>
                    <%=  param 'uSMTPAuth' %>
                </pre>
                -->
                <%=  select_field 'uSMTPAuth' => $c->get_smtp_ssl_auth_opt(), class => "form-select" %>
            </div>
        </div>

        <br>

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

        <br>

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

        <br>

        % param 'SecondaryMailServer' => $mai_data->{secondarymailserver} unless param 'SecondaryMailServer';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputSecondaryMailServer" class="col-form-label"><%= l 'mai_LABEL_SECONDARY' %></label>
            </div>
            <div class="col-auto">
                <input type="text" name="SecondaryMailServer" id="inputSecondaryMailServer" class="form-control" aria-describedby="SecondaryMailServer" value="<%= $mai_data->{secondarymailserver} %>">
            </div>
        </div>

        <br>

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

        % param 'FreqOffice' => $mai_data->{freqoffice} unless param 'FreqOffice';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'mai_LABEL_FETCH_PERIOD' %>
            </div>
            <div class="col-auto">
                <%=  select_field 'FreqOffice' => $c->fetchmail_freq(), class => "form-select" %>
            </div>
        </div>

        <br>

        % param 'FreqOutside' => $mai_data->{freqoutside} unless param 'FreqOutside';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'mai_LABEL_FETCH_PERIOD_NIGHTS' %>
            </div>
            <div class="col-auto">
                <%=  select_field 'FreqOutside' => $c->fetchmail_freq(), class => "form-select" %>
            </div>
        </div>

        <br>

        % param 'FreqWeekend' => $mai_data->{freqweekend} unless param 'FreqWeekend';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'mai_LABEL_FETCH_PERIOD_WEEKENDS' %>
            </div>
            <div class="col-auto">
                <%=  select_field 'FreqWeekend' => $c->fetchmail_freq(), class => "form-select" %>
             </div>
        </div>

        <br>

        % param 'SecondaryMailAccount' => $mai_data->{secondarymailaccount} unless param 'SecondaryMailAccount';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputSecondaryMailAccount" class="col-form-label"><%= l 'mai_LABEL_POP_ACCOUNT' %></label>
            </div>
            <div class="col-auto">
                <input type="text" name="SecondaryMailAccount" id="inputSecondaryMailAccount" class="form-control" aria-describedby="SecondaryMailAccount" value="<%= $mai_data->{secondarymailaccount} %>">
            </div>
        </div>

        <br>

        % param 'SecondaryMailPassword' => $mai_data->{secondarymailpassword} unless param 'SecondaryMailPassword';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="password" class="col-form-label"><%= l 'mai_LABEL_POP_PASS' %></label>
            </div>
            <div class="col-auto">
                <input type="password" name="SecondaryMailPassword" id="password" class="form-control" aria-describedby="SecondaryMailPassword" value="<%= $mai_data->{secondarymailpassword} %>">
            </div>
            <div class="col-auto">
                <span id="togglePassword" class="bi bi-eye"></span>
            </div>
        </div>


        <br>

        % param 'SpecifyHeader' => $mai_data->{specifyheader} unless param 'SpecifyHeader';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'mai_LABEL_SORT_METHOD' %>
            </div>
            <div class="col-auto">
                <%=  select_field 'SpecifyHeader' => [[(l 'mai_DEFAULT') => 'off'], [(l 'mai_SPECIFY_BELOW') => 'on']], class => "form-select" %>
            </div>
        </div>

        <br>

        % param 'SecondaryMailEnvelope' => $mai_data->{secondarymailenvelope} unless param 'SecondaryMailEnvelope';

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputSecondaryMailEnvelope" class="col-form-label"><%= l 'mai_LABEL_SORT_HEADER' %></label>
            </div>
            <div class="col-auto">
                <input type="text" name="SecondaryMailEnvelope" id="inputSecondaryEnvelope" class="form-control" aria-describedby="SecondaryMailEnvelope" value="<%= $mai_data->{secondarymailenvelope} %>">
            </div>
        </div>

        <br>

        % my $btn = l('SAVE');
        % param 'trt' => $mai_data->{trt} unless param 'trt';
        <%=  hidden_field 'trt' => 'REC' %>

        <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>

    </form>

</div>

%#end

