PHP_AdminTool_Projekt/public/views/users_import.php

56 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
/**
* Platzhalter-View: Benutzer importieren (CSV)
*/
?>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Benutzer importieren (CSV)</h6>
</div>
<div class="card-body">
<?php if (!empty($errors) && is_array($errors)): ?>
<div class="alert alert-danger">
<ul>
<?php foreach ($errors as $e): ?>
<li><?= htmlspecialchars($e, ENT_QUOTES, 'UTF-8') ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
<?php if (!empty($success)): ?>
<div class="alert alert-success"><?= htmlspecialchars($success, ENT_QUOTES, 'UTF-8') ?></div>
<?php endif; ?>
<form method="post" action="index.php?route=users.import.submit" enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="<?= htmlspecialchars($csrf_token ?? '', ENT_QUOTES, 'UTF-8') ?>">
<div class="form-group">
<label for="csv_file">CSV-Datei</label>
<input type="file" id="csv_file" name="csv_file" accept="text/csv" class="form-control">
</div>
<button type="submit" class="btn btn-primary">Upload & Vorschau</button>
<a href="index.php?route=users" class="btn btn-secondary">Zurück zur Liste</a>
</form>
<?php if (!empty($preview) && is_array($preview)): ?>
<h6 class="mt-4">Vorschau (erste Zeilen)</h6>
<div class="table-responsive">
<table class="table table-sm">
<tbody>
<?php foreach ($preview as $row): ?>
<tr>
<?php foreach ($row as $col): ?>
<td><?= htmlspecialchars((string)$col, ENT_QUOTES, 'UTF-8') ?></td>
<?php endforeach; ?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>