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

% content_for 'module' => begin

<div class="card-body">

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

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

    <h1><%= $title %></h1>
    <br>
    %= $modul
    <% my $btn = l('SAVE'); %>

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

        <br>

        % param 'Ntpstatus' => $dat_datas->{ntpstatus} unless param 'Ntpstatus';
        % param 'Ntpserver' => 'smeserver.pool.ntp.org' unless param 'Ntpserver';

        <br>

        % if ($dat_datas->{ntpstatus} eq 'disabled') {


            <div>
                You can manually set your server time here (static string for testing)<br><br>
            </div>

            <br>

            <div>
                <br>

                <div class="row g-3 align-items-center">
                    <div class="col-md-1">
                        <%= l 'dat_CURRENT_SETTING' %>
                    </div>
                    <div class="col-auto">
                        <b><%= $dat_datas->{now_string} %></b>
                    </div>
                </div>

                <br>
                <div class="row g-3 align-items-center">
                    <div class="col-md-1">
                        <%= l 'dat_NEW_M/D/Y' %>
                    </div>
                    <div class="col-auto">
                        % param 'Month' => $dat_datas->{month} unless param 'Month';
                        %= select_field 'Month' => $c->getMonth_list(), class => "form-select"
                    </div>

                    <div class="col-auto">
                        % param 'Day' => $dat_datas->{day} unless param 'Day';
                        %= text_field 'Day', size => '2', class => ""
                    </div>
                    <div class="col-auto">
                        % param 'Year' => $dat_datas->{year} unless param 'Year';
                        %= text_field 'Year', size => '4', class => ""
                    </div>

                </div>

                <br>


                <div class="row g-3 align-items-center">
                    <div class="col-md-1">
                        <%= l 'dat_NEW_H/M/S' %>
                    </div>
                    <div class="col-auto">
                        % param 'Hour' => $dat_datas->{hour} unless param 'Hour';
                        %= text_field 'Hour', size => '2', class => ""
                    </div>
                    <div class="col-auto">
                        % param 'Minute' => $dat_datas->{minute} unless param 'Minute';
                        %= text_field 'Minute', size => '2', class => ""
                    </div>
                    <div class="col-auto">
                        % param 'Second' => $dat_datas->{second} unless param 'Second';
                        %= text_field 'Second', size => '2', class => ""
                    </div>
                </div>

                <br>

                <div class="row g-3 align-items-center">
                    <div class="col-md-1">
                        <%= l 'dat_AM/PM_AND_TZ' %>
                    </div>
                    <div class="col-auto">
                        % param 'Ampm' => $dat_datas->{ampm} unless param 'Ampm';
                        %= select_field 'Ampm' =>  ['AM', 'PM'], class => "form-select"
                    </div>

                   <div class="col-auto">
                       % param 'Timezone' => $c->getTimezone() unless param 'Timezone';
                       %= select_field 'Timezone' =>  $c->getZone_list(), class => "form-select"
                   </div>

                </div>

                <br>

                <div class="form-check">
                    <label class="form-check-label" for="radioDefault1">
                        <%=l 'dat_NTP_CONFIGURE_TITLE' %>
                    </label>
                    <input class="form-check-input" type="radio" name="Ntpstatus" id="radioDefault1" value="enabled">
                </div>
            </div>

            <%#= hidden_field 'Old_ntpstatus' => $dat_datas->{ntpstatus}; %>

            <%= hidden_field 'Old_ntpstatus' => 'disabled' %>

        % } else {

            <!-- # %  if ($dat_datas->{ntpstatus} eq 'enabled') { -->

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

            <div>

                <div class="row g-3 align-items-center">
                    <div class="col-md-1">
                        <%= l 'dat_CURRENT_SETTING' %>
                    </div>
                    <div class="col-auto">
                        <b><%= $dat_datas->{now_string} %></b>
                    </div>
                </div>

                <br>

                <div class="form-check">
                    <label class="form-check-label" for="radioDefault1">
                        <%=l 'dat_NTP_CONFIGURE_TITLE' %>
                    </label>
                    <input class="form-check-input" type="radio" name="Ntpstatus" id="radioDefault1" value="enabled">
                </div>
                <br>

                <div class="row g-3 align-items-center">
                    <div class="col-md-1">
                        <label for="inputNTPServer" class="col-form-label"><%= l 'dat_NTP_SERVER' %></label>
                    </div>
                    <div class="col-auto">
                        <input type="text" name="Ntpserver" id="inputNTPServer" class="form-control" aria-describedby="NTP Server" value="<%= $dat_datas->{ntpserver} %>">
                    </div>
                </div>

            </div>

            <br>

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

            <br>

            <div class="form-check">
              <label class="form-check-label" for="radioDefault2">
                <%= l 'dat_NTP_DISABLE_TITLE' %>
              </label>
              <input class="form-check-input" type="radio" name="Ntpstatus" id="radioDefault2" value="disabled">
            </div>


            <%= hidden_field 'Old_ntpstatus' => $dat_datas->{ntpstatus}; %>
            <%#= hidden_field 'Old_ntpstatus' => 'disabled' %>

        % }



        <br>




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


    </form>

</div>
%end