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

% content_for 'module' => begin

<div class="card-body">

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

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

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

    <br>

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

    <br>

    <div>
        <%= $c->render_to_string(inline => (l 'bac_CONFIGURE_WORKSTN_BACKUP_DESC')) %>
    <div>

    <br>

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

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'bac_ENABLE_WORKSTN_BACKUP' %>
            </div>
            <div class="col-auto">
            % if ( $bac_datas->{status} eq 'checked' ) {
                <input type='checkbox' name='Workstnbackup' aria-describedby="enabled" checked >
            % } else {
                <input type='checkbox' name='Workstnbackup' aria-describedby="disabled">
            % }
            </div>
        </div>

        </p>
        <p>
        <h3>
        %= l 'bac_WORKSTATION_BACKUP_DEST'
        </h3>
        <br>

        % if ( $bac_datas->{vfstype} =~ m/cifs|nfs/s ) {
        <div class="row g-3 align-items-center">
            <div class="col-md-2">
              <label for="inputBackupWorkStationName" class="col-form-label"><%= l 'bac_WORKSTN_NAME' %></label>
            </div>
            <div class="col-auto">
            % param 'BackupwkStation' => $bac_datas->{station} unless param 'BackupwkStation';
                <input type="text" name="BackupwkStation" id="inputBackupWorkStationName" class="form-control"
                size="20" aria-describedby="Workstation Name" value="<%= $bac_datas->{station} %>">
            </div>
        </div>

        <br>

        % }

        % if (  $bac_datas->{vfstype} eq 'usb' ) {

            <div class="row g-3 align-items-center">
                <div class="col-md-2">
                    <%= l 'bac_local removable disk' %>
                </div>
                <div class="col-auto">
                    % param 'BackupwkFolder' => $bac_datas->{mount} unless param 'BackupwkFolder';
                    <%= select_field 'BackupwkFolder' => $c->get_BackupwkDest_options( $bac_datas->{vfstype}), class => "form-select" %>
                </div>
            </div>

            <br>

        % } elsif ( $bac_datas->{vfstype} eq 'mnt') {

            <div class="row g-3 align-items-center">
                <div class="col-md-2">
                    <%= l 'bac_Mounted disk' %>
                </div>
                <div class="col-auto">
                    % param 'BackupwkFolder' => $bac_datas->{folder} unless param 'BackupwkFolder';
                    <%= select_field 'BackupwkFolder' => $c->get_BackupwkDest_options( $bac_datas->{vfstype}), class => "form-select" %>
                </div>
            </div>

            <br>

        % } else {

            <div class="row g-3 align-items-center">
                <div class="col-md-2">
                    <label for="inputBackupSharedFolderName" class="col-form-label"><%= l 'bac_SHARED_FOLDER_NAME' %></label>
                </div>
                <div class="col-auto">
                    <input type="text" name="BackupwkFolder" id="inputBackupSharedFolderName" class="form-control"
                    size="20" aria-describedby="Backup Shared Folder Name" value="<%= $bac_datas->{folder} %>">
                </div>
            </div>

            <br>

        % }

        % if (  $bac_datas->{vfstype} eq 'cifs' ) {
            <div class="row g-3 align-items-center">
                <div class="col-md-2">
                    <label for="inputBackupWorkLogin" class="col-form-label"><%= l 'bac_WORKSTN_LOGIN' %></label>
                </div>
                <div class="col-auto">
                    % param 'BackupwkLogin' => $bac_datas->{login} unless param 'BackupwkLogin';
                    <input type="text" name="BackupwkLogin" id="inputBackupWorkLogin" class="form-control"
                    size="12" aria-describedby="Backup Workstation Login" value="<%= $bac_datas->{login} %>">
                </div>
            </div>

            <br>

            <div class="row g-3 align-items-center">
                <div class="col-md-2">
                    <label for="password" class="col-form-label"><%= l 'bac_PASSWORD' %></label>
                </div>
                <div class="col-auto">
                    % param 'BackupwkPassword' => $bac_datas->{password} unless param 'BackupwkPassword';
                    <input type="password" name="BackupwkPassword" id="password" class="form-control" size="12" aria-describedby="Backup Workstation Password" value="<%= $bac_datas->{password} %>">
                </div>
                <div class="col-auto">
                    <span id="togglePassword" class="bi bi-eye"></span>
                </div>
            </div>
        % }

        <br>

        <h3><%= l 'bac_WORKSTN_BACKUP_SETTINGS' %></h3>

        <br>

       <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputNumberofSets" class="col-form-label"><%= l 'bac_NUMBER_OF_SETS' %></label>
            </div>
            <div class="col-auto">
                % param 'SetsNumber' => $bac_datas->{setsNumber} unless param 'SetsNumber';
                <input type="text" name="SetsNumber" id="inputNumberofSets" class="form-control" maxlength="3" size="3" aria-describedby="Number of sets" value="<%= $bac_datas->{setsNumber} %>">
            </div>
        </div>




         <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputFilesinSet" class="col-form-label"><%= l 'bac_NUMBER_OF_FILES_IN_SET' %></label>
            </div>
            <div class="col-auto">
                % param 'Filesinset' => $bac_datas->{filesinset} unless param 'Filesinset';
                <input type="text" name="Filesinset" id="inputFilesinSet" class="form-control" maxlength="3" size="3" aria-describedby="Files in set" value="<%= $bac_datas->{filesinset} %>">
            </div>
        </div>




        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputWorkstationBackupHour" class="col-form-label"><%= l 'bac_WORKSTN_BACKUP_TIME' %></label>
                <label for="inputWorkstationBackupMin" class="col-form-label"></label>
            </div>
            <div class="col-auto">
                % param 'BackupwkHour' => $bac_datas->{hour} unless param 'BackupwkHour';
                <input type="text" name="BackupwkHour" id="inputWorkstationBackupHour" class="form-control" maxlength="2" size="4" aria-describedby="Backup Hour" value="<%= $bac_datas->{hour} %>">
            </div>
            <div class="col-auto">
                % param 'BackupwkMin' => $bac_datas->{min} unless param 'BackupwkMin';
                <input type="text" name="BackupwkMin" id="inputWorkstationBackupMin" class="form-control" maxlength="2" size="4" aria-describedby="Backup Minute" value="<%= $bac_datas->{min} %>">
            </div>
            <div class="col-auto">
                <%= l 'AM/PM:' %>
            </div>
            <div class="col-auto">
                % param 'BackupwkAMPM' => $bac_datas->{ampm} unless param 'BackupwkAMPM';
                <%= select_field 'BackupwkAMPM' => ['AM', 'PM'], class => "form-select" %>
            </div>
        </div>

        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputWorkstationTimeout" class="col-form-label"><%= l 'bac_WORKSTN_TIMEOUT' %></label>
            </div>
            <div class="col-auto">
                % param 'BackupwkTimeout' => $bac_datas->{timeout} unless param 'BackupwkTimeout';
                <input type="text" name="BackupwkTimeout" id="inputWorkstationTimeout" class="form-control" maxlength="2" size="2" aria-describedby="Workstation Timeout" value="<%= $bac_datas->{timeout} %>">
            </div>
        </div>

        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'bac_INC_ONLY_TIMEOUT' %>
            </div>
            <div class="col-auto">
            % if ( $bac_datas->{incOnlyTimeout} eq 'checked' ) {
                <input type='checkbox' name='IncOnlyTimeout' aria-describedby="enabled" checked >
            % } else {
                <input type='checkbox' name='IncOnlyTimeout' aria-describedby="disabled">
            % }
            </div>
        </div>

        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <label for="inputBackupCompression" class="col-form-label"><%= l 'bac_COMPRESSION_LEVEL' %></label>
            </div>
            <div class="col-auto">
                % param 'Compression' => $bac_datas->{compression} unless param 'Compression';
                <input type="text" name="Compression" id="inputBackupCompression" class="form-control" maxlength="1" size="1" aria-describedby="Compression level" value="<%= $bac_datas->{compression} %>">
            </div>
        </div>

        <br>

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <%= l 'bac_FULL_ONLY_ON' %>
            </div>
            <div class="col-auto">
                % param 'Dof' => $bac_datas->{dof} unless param 'Dof';
                %= select_field 'Dof' => $c->get_dow_list(), class => "form-select"
            </div>
        </div>

        <br>

        %= hidden_field 'Function' => $bac_datas->{function}
        %= hidden_field 'VFSType' => $bac_datas->{vfstype}
        % my $btn = l('bac_UPDATE_CONF');

        <div class="row g-3 align-items-center">
            <div class="col-md-2">
                <button type="submit" class="btn btn-primary btn-sm" value="<%=$c->l('NEXT')%>"><%= $btn %></button>
            </div>
        </div>

        <br>

    </form>

</div>

% end