<div id="ctrl_<?= $this->strId ?>" class="dcawizard">
  <?php if ($this->globalOperations): ?>
    <div id="tl_buttons" style="margin-top:-28px">
      <?php foreach ($this->globalOperations as $operation): ?>
        <?= $this->generateGlobalOperation($operation); ?>
      <?php endforeach; ?>
    </div>
  <?php endif; ?>
  <div class="selector_container">
    <?php if ($this->hasListCallback): ?>
      <?= $this->listCallbackContent ?>
    <?php elseif ($this->hasRows): ?>
      <table class="tl_listing showColumns">
        <thead>
          <tr>
            <?php foreach ($this->headerFields as $field): ?>
              <th class="tl_folder_tlist"><?= $this->dcaLabel($field) ?></th>
            <?php endforeach; ?>
            <?php if ($this->showOperations): ?>
              <th class="tl_folder_tlist"></th>
            <?php endif; ?>
          </tr>
        </thead>
        <tbody>
        <?php foreach ($this->rows as $row): ?>
          <tr class="<?= '0' === (string) ($row['tstamp'] ?? null) ? 'draft ' : '' ?> hover-row">
            <?php foreach ($this->fields as $field): ?>
              <td class="tl_file_list"><?= $this->dcaValue($field, $row[$field]) ?: '-' ?></td>
            <?php endforeach; ?>

            <?php if ($this->showOperations): ?>
              <td class="tl_file_list tl_right_nowrap">
                <?php foreach ($this->operations as $operation): ?>
                  <?= $this->generateOperation($operation, $row) ?><?php endforeach; ?>
              </td>
            <?php endif; ?>
          </tr>
        <?php endforeach; ?>
        </tbody>
      </table>
    <?php elseif ($this->emptyLabel): ?>
      <p><?= $this->emptyLabel ?></p>
    <?php endif; ?>

    <?php if (!$this->hideButton): ?>
      <p style="margin-top:9px;">
        <a href="<?= $this->buttonHref ?>"
           class="tl_submit"
           data-options="<?= $this->dcaWizardOptions; ?>"
           onclick="Backend.getScrollOffset();DcaWizard.openModalWindow(JSON.parse(this.getAttribute('data-options')));return false"
        >
          <?= $this->buttonLabel ?>
        </a>
      </p>
    <?php endif; ?>
  </div>
</div>

<?php // <script src="..."> would not be loaded when the widget is added in a subpalette?>
<script>
  var script = document.createElement('script');
  script.setAttribute('type', 'text/javascript');
  script.setAttribute('src', '<?= $this->asset('dcawizard.js', 'terminal42_dcawizard') ?>');
  document.getElementsByTagName('head').item(0).appendChild(script);
</script>
