<?php $viewModel = $block->getData('view_model'); $error = $viewModel->getError(); $runs = $viewModel->getRuns(); $totals = $viewModel->getTotals(); ?> <a href="<?= $escaper->escapeUrl($viewModel->getUrl('autogedal_ean/index/index')) ?>" class="action-default scalable back aget-back"><span><?= $escaper->escapeHtml(__('Back to EAN Tools')) ?></span></a> <div class="admin__page-section"><div class="admin__page-section-title"><span class="title"><?= $escaper->escapeHtml(__('Generated Files')) ?></span></div><?php if ($error !== null): ?> <div class="message message-error"><?= $escaper->escapeHtml($error) ?></div><?php endif; ?> <p class="aget-panel__hint" style="max-width:900px;"><?= $escaper->escapeHtml(__( 'Each tool run keeps its files for %1 days. They are deleted automatically after this period.', $viewModel->getRetentionDays() )) ?></p><div class="aget-stats"><?php foreach ($totals as $total): ?> <div class="aget-stat aget-stat--<?= $escaper->escapeHtmlAttr($total['tone']) ?>"><span class="aget-stat__value"><?= $escaper->escapeHtml($total['value']) ?></span> <span class="aget-stat__label"><?= $escaper->escapeHtml($total['label']) ?></span></div><?php endforeach; ?></div><?php if ($runs === [] && $error === null): ?> <div class="message message-notice"><?= $escaper->escapeHtml(__( 'There are no stored files. Run a tool from the main EAN Tools page.' )) ?></div><?php endif; ?> <?php foreach ($runs as $run): ?> <div class="aget-run"><div class="aget-run__head"><div class="aget-run__meta"><span class="aget-run__title"><?= $escaper->escapeHtml($run['title']) ?></span> <span class="aget-run__status aget-run__status--<?= $escaper->escapeHtmlAttr($run['status']) ?>"><?= $escaper->escapeHtml($run['status_label']) ?></span> <span class="aget-file__sub"><?= $escaper->escapeHtml($run['created_at']) ?></span> <span class="aget-file__sub"><?= $escaper->escapeHtml($viewModel->formatSize((int)$run['size'])) ?></span> <?php if ($run['expires_at'] !== null): ?> <span class="aget-file__sub"><?= $escaper->escapeHtml(__('Files will be deleted on %1', $run['expires_at'])) ?></span> <?php endif; ?></div><a href="<?= $escaper->escapeUrl($run['result_url']) ?>" class="action-default scalable"><span><?= $escaper->escapeHtml(__('View result')) ?></span></a></div><?php if ($run['status'] === 'failed'): ?> <div class="message message-error aget-run__message"><?= $escaper->escapeHtml($run['error'] ?? __('The file could not be generated.')) ?></div><?php elseif (in_array($run['status'], ['queued', 'processing'], true)): ?> <div class="message message-notice aget-run__message"><?= $escaper->escapeHtml( $run['status'] === 'queued' ? __('The request is waiting to be processed by cron.') : __('The file is being generated.') ) ?></div><?php elseif ($run['files'] === []): ?> <p class="aget-file__sub"><?= $escaper->escapeHtml(__( 'This run did not produce any files. The result contains only statistics and notes.' )) ?></p><?php else: ?> <div class="aget-files aget-files--inline"><?php foreach ($run['files'] as $file): ?> <?php $fileClass = 'aget-file aget-file--' . $file['tone'] . ($file['empty'] ? ' aget-file--empty' : ''); ?> <div class="<?= $escaper->escapeHtmlAttr($fileClass) ?>"><div class="aget-file__meta"><span class="aget-file__label"><?= $escaper->escapeHtml($file['label']) ?></span> <span class="aget-file__sub"><?= $escaper->escapeHtml($file['name']) ?> &middot; <?= $escaper->escapeHtml( $file['rows'] === 1 ? __('1 row') : __('%1 rows', number_format((float)$file['rows'], 0, ',', '.')) ) ?> &middot; <?= $escaper->escapeHtml($viewModel->formatSize((int)$file['size'])) ?></span></div><?php if ($file['empty']): ?> <span class="aget-file__sub"><?= $escaper->escapeHtml(__('empty')) ?></span> <?php else: ?> <a href="<?= $escaper->escapeUrl($file['url']) ?>" class="action-default scalable"><span><?= $escaper->escapeHtml(__('Download')) ?></span></a> <?php endif; ?></div><?php endforeach; ?></div><?php endif; ?></div><?php endforeach; ?></div>