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

% content_for 'module' => begin

<div class="card-body">

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

    % if ( stash 'warning' ) {
        <br>
        <div class="col-md-4 bg-info text-center">
            <%=  $c->render_to_string(inline => stash 'warning') %>
        </div>
        <br>
    % }
    % if ( stash 'error' ) {
        <br>
        <div class="text-danger">
            <%=  $c->render_to_string(inline => stash 'error')  %>
        </div>
        <br>
    % }

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

    <!--br>Still incomplete click here for previous version
    <a href="/server-manager/cgi-bin/backup" target='_blank'><b>(Previous Backup version)</b></a>
    -->

    <br>

    <%= $c->render_to_string(inline => (l 'bac_BACKUP_DESC_DAR', $bac_datas->{module},
    $bac_datas->{dumpsize}, $bac_datas->{tarsize})) %>

    <form action="/smanager/backup" method="POST">
        <br>

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

        <br>

        <div>
            <div>
                <%= l 'bac_TAPE_BACKUPS' %>: <%= $c->l(uc($bac_datas->{'backupStatus'})).'.' %>
            </div>


            % if ( $bac_datas->{'backupStatus'} eq 'enabled' ) {
                <div>
                    <%=  $c->l('bac_BACKUPS_RUN_AT') %>: <%=   $bac_datas->{'backupTime'} %>
                </div>
                <br>
                <div>
                    <%=  $c->l('bac_REMINDER_MESSAGE_AT') %>: <%=  $bac_datas->{'reminderTime'} %>
                </div>
            % }
        </div>

        <br>

        <div>
            <div>
                <%=l 'bac_WORKSTN_BACKUPS' %>:  <%= $c->l(uc($bac_datas->{'backupwkStatus'})) . '.' %>
            </div>
            <div>
                % if ( $bac_datas->{'backupwkStatus'} eq 'enabled' ) {
                    <%= $c->l('bac_WKBACKUPS_RUN_AT') %>: <%= $bac_datas->{'backupwkTime'} %>
                % }
            </div>
        </div>

        <br>

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

            <div class="col-auto">
                % param 'Function' => $bac_datas->{function} unless param 'Function';
                <%= select_field 'Function' => $c->get_function_options(), class => "form-select" %>
            </div>
        </div>

        <br>

        % my $btn = $c->l('PERFORM');

        <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