Files
orderPRO/resources/views/settings/database.php
Jacek Pyziak 933dfcc67b feat(120): alert component unification
Phase 120 - Plan 01:
- Reusable PHP alert component (resources/views/components/alert.php)
  with inline SVG icon per type, optional dismiss button.
- Missing .alert--info SCSS variant added (#eff6ff/#bfdbfe/#1e3a8a) -
  fixes black-on-white alert after Fakturownia test connection.
- Flash::push(type, message) + Flash::all() with BC for set/get;
  legacy key heuristic (error/.save/warning -> typed entries).
- Central flash renderer in 3 layouts (app/auth/public) iterating
  Flash::all() through component (.alerts-stack wrap).
- Vanilla JS alert-dismiss.js with idempotent guard and delegated
  click handler on [data-alert-dismiss].
- 36 views migrated off inline <div class="alert alert--TYPE">;
  .flash--error/success removed from views (orders/show, shipments/prepare).
- SCSS rebuilt: public/assets/css/{app,login}.css.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 18:47:41 +02:00

80 lines
3.3 KiB
PHP

<?php
$migrationStatus = is_array($status ?? null) ? $status : [];
$pending = (int) ($migrationStatus['pending'] ?? 0);
$total = (int) ($migrationStatus['total'] ?? 0);
$applied = (int) ($migrationStatus['applied'] ?? 0);
$pendingFiles = (array) ($migrationStatus['pending_files'] ?? []);
$logs = (array) ($runLogs ?? []);
?>
<section class="card">
<h2 class="section-title"><?= $e($t('settings.database.title')) ?></h2>
<?php if (!empty($errorMessage)): ?>
<div class="mt-12"><?php $type='danger'; $message=(string) $errorMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
<?php endif; ?>
<?php if (!empty($successMessage)): ?>
<div class="mt-12"><?php $type='success'; $message=(string) $successMessage; $dismissible=true; include dirname(__DIR__) . '/components/alert.php'; ?></div>
<?php endif; ?>
<div class="settings-grid mt-16">
<div class="settings-stat">
<span class="settings-stat__label"><?= $e($t('settings.database.stats.total')) ?></span>
<strong class="settings-stat__value"><?= $e((string) $total) ?></strong>
</div>
<div class="settings-stat">
<span class="settings-stat__label"><?= $e($t('settings.database.stats.applied')) ?></span>
<strong class="settings-stat__value"><?= $e((string) $applied) ?></strong>
</div>
<div class="settings-stat">
<span class="settings-stat__label"><?= $e($t('settings.database.stats.pending')) ?></span>
<strong class="settings-stat__value"><?= $e((string) $pending) ?></strong>
</div>
</div>
<?php if ($pending > 0): ?>
<div class="mt-16"><?php $type='warning'; $message=(string) $t('settings.database.state.needs_update'); $dismissible=false; include dirname(__DIR__) . '/components/alert.php'; ?></div>
<form class="mt-16" action="/settings/database/migrate" method="post">
<input type="hidden" name="_token" value="<?= $e($csrfToken ?? '') ?>">
<button type="submit" class="btn btn--primary"><?= $e($t('settings.database.actions.run_update')) ?></button>
</form>
<?php else: ?>
<div class="mt-16"><?php $type='success'; $message=(string) $t('settings.database.state.up_to_date'); $dismissible=false; include dirname(__DIR__) . '/components/alert.php'; ?></div>
<?php endif; ?>
</section>
<section class="card mt-16">
<h2 class="section-title"><?= $e($t('settings.database.pending_files_title')) ?></h2>
<div class="table-wrap mt-12">
<table class="table">
<thead>
<tr>
<th><?= $e($t('settings.database.fields.filename')) ?></th>
</tr>
</thead>
<tbody>
<?php if (empty($pendingFiles)): ?>
<tr>
<td class="muted"><?= $e($t('settings.database.pending_files_empty')) ?></td>
</tr>
<?php else: ?>
<?php foreach ($pendingFiles as $filename): ?>
<tr>
<td><?= $e((string) $filename) ?></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</section>
<?php if (!empty($logs)): ?>
<section class="card mt-16">
<h2 class="section-title"><?= $e($t('settings.database.last_run_logs')) ?></h2>
<pre class="settings-logs mt-12"><?php foreach ($logs as $line): ?><?= $e((string) $line) . "\n" ?><?php endforeach; ?></pre>
</section>
<?php endif; ?>