<div>


    % my $btn = l('iba_ADD_IBAY');

    <form action="/smanager/ibays" method="POST">
        <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>
        <%= hidden_field 'trt' => 'ADD'; %>
    </form>

    <br>
    <div>
        <%= l 'iba_FIRSTPAGE_DESC' %>
    </div>

    <br>

    <div>
        <h2>Current List of i-bays - translation string required</h2>
    </div>

    <br>

    % my $numIbays = @$ibays;
    % if ($numIbays == 0) {
        <%= l 'iba_NO_IBAYS' %>
    % } else {

         <table class="table table-bordered">
             <thead>
                 <tr>
                     <th class="col-sm"><%= l 'NAME' %></th>
                     <th class="col-sm"><%= l 'DESCRIPTION' %></th>
                     <th class="col-sm user-valign-center" colspan="3"><%= l 'ACTION' %></th>
                 </tr>
             </thead>

             <tbody>
             % foreach my $ibay (@$ibays)
             % {
             % my $modifiable = $ibay->prop('Modifiable') || 'yes';
             % my $passwordable = $ibay->prop('Passwordable') || 'yes';
             % my $removable = $ibay->prop('Removable') || 'yes';
             % my $needPassword = grep { $_ eq $ibay->prop('PublicAccess') }
             % qw(local-pw global-pw global-pw-remote);

                 <tr>
                     <td><%= $ibay->key %>
                     <td><%= $ibay->prop('Name') %>
                     <td class="">
                         % my ($actionModify, $actionResetPw, $actionRemove) = '&nbsp;';
                         % if ($modifiable eq 'yes') {
                             %my $modify_text = l('MODIFY');  # Localized text
                             %my $csrf_token = "TOKEN";  # CSRF token for security
                             %my $ibays_entry_name = $ibay->key;  # ibays_entry name extracted from the data structure
                             %$actionModify = qq{
                             % <a href="ibaysd?CsrfDef=$csrf_token&trt=UPD&ibay=$ibays_entry_name">
                             %   <button type='button' class="btn btn-primary" title='$modify_text' >
                             % $modify_text
                             %   </button>
                             % </a>
                             %};
                         % }

                         % if ($passwordable eq 'yes') {
                             %my $password_text = l('PASSWORD_RESET');  # Localized text
                             %my $csrf_token = "TOKEN";  # CSRF token for security
                             %my $ibays_entry_name = $ibay->key;  # ibays_entry name extracted from the data structure
                             %if ($ibay->prop('PasswordSet') ne 'yes' && $needPassword) {
                                 %$actionResetPw = qq{
                                 % <a href="ibaysd?CsrfDef=$csrf_token&trt=PWD&ibay=$ibays_entry_name">
                                 %   <button type='button' class="btn btn-danger" title="$password_text - currently unset" >
                                 %       $password_text
                                 %   </button>
                                 % </a>
                                 % };
                             % } else {
                                 %$actionResetPw = qq{
                                 % <a href="ibaysd?CsrfDef=$csrf_token&trt=PWD&ibay=$ibays_entry_name">
                                 %   <button type='button' class="btn btn-primary" title='$password_text' >
                                 %       $password_text
                                 %   </button>
                                 % </a>
                                 %};
                             % }

                         % }

                         % if ($removable eq 'yes')  {
                             %my $remove_text = l('REMOVE');  # Localized text
                             %my $csrf_token = "TOKEN";  # CSRF token for security
                             %my $ibays_entry_name = $ibay->key;  # ibays_entry name extracted from the data structure
                             %$actionRemove = qq{
                             % <a href="ibaysd?CsrfDef=$csrf_token&trt=DEL&ibay=$ibays_entry_name">
                             %   <button type='button' class="btn btn-primary" title='$remove_text' >
                             %       $remove_text
                             %   </button>
                             % </a>
                             %};
                         % }
                         <td class="user-valign-center"><%= $c->render_to_string(inline => $actionModify) %></td>
                         <td class="user-valign-center"><%= $c->render_to_string(inline => $actionResetPw)%></td>
                         <td class="user-valign-center"><%= $c->render_to_string(inline => $actionRemove) %></td>
                     </td>
                 </tr>
             % }
             </tbody>
         </table>
    % }

</div>
