121 lines
5.3 KiB
PHP
121 lines
5.3 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../layout.php';
|
|
|
|
ob_start();
|
|
?>
|
|
|
|
<?php if (isset($success)): ?>
|
|
<div class="alert alert-success alert-dismissible fade show" role="alert">
|
|
<i class="bi bi-check-circle-fill me-2"></i>
|
|
<?= htmlspecialchars($success) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (isset($error)): ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
|
<?= htmlspecialchars($error) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-4">
|
|
<h2 class="text-white mb-0">
|
|
<i class="bi bi-journal-text me-2"></i>Moje notatki
|
|
</h2>
|
|
<a href="/notatnik/nowa" class="btn btn-light btn-lg">
|
|
<i class="bi bi-plus-lg me-1"></i>Nowa notatka
|
|
</a>
|
|
</div>
|
|
|
|
<?php if (empty($notes)): ?>
|
|
<div class="card">
|
|
<div class="card-body text-center py-5">
|
|
<i class="bi bi-journal-x text-muted" style="font-size: 4rem;"></i>
|
|
<h4 class="mt-3 text-muted">Brak notatek</h4>
|
|
<p class="text-muted mb-4">Nie masz jeszcze żadnych notatek. Utwórz pierwszą!</p>
|
|
<a href="/notatnik/nowa" class="btn btn-primary">
|
|
<i class="bi bi-plus-lg me-1"></i>Utwórz notatkę
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="row g-4">
|
|
<?php foreach ($notes as $note): ?>
|
|
<div class="col-md-6 col-lg-4">
|
|
<div class="card note-card border-top border-4 border-<?= htmlspecialchars($note['color']) ?>">
|
|
<div class="card-body">
|
|
<div class="d-flex justify-content-between align-items-start mb-2">
|
|
<h5 class="card-title mb-0"><?= htmlspecialchars($note['title']) ?></h5>
|
|
<div class="note-actions">
|
|
<a href="/notatnik/edytuj/<?= $note['id'] ?>" class="btn btn-sm btn-outline-primary" title="Edytuj">
|
|
<i class="bi bi-pencil"></i>
|
|
</a>
|
|
<button type="button" class="btn btn-sm btn-outline-danger"
|
|
onclick="confirmDelete(<?= $note['id'] ?>, '<?= htmlspecialchars(addslashes($note['title'])) ?>')"
|
|
title="Usuń">
|
|
<i class="bi bi-trash"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<p class="note-content text-muted small">
|
|
<?= nl2br(htmlspecialchars($note['content'] ?: 'Brak treści')) ?>
|
|
</p>
|
|
<div class="mt-auto pt-2 border-top">
|
|
<small class="text-muted">
|
|
<i class="bi bi-clock me-1"></i>
|
|
<?= date('d.m.Y H:i', strtotime($note['updated_at'])) ?>
|
|
</small>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- Modal potwierdzenia usunięcia -->
|
|
<div class="modal fade modal-confirm" id="deleteModal" tabindex="-1">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<div class="text-center w-100">
|
|
<div class="bg-danger bg-opacity-10 rounded-circle d-inline-flex align-items-center justify-content-center mb-3" style="width: 80px; height: 80px;">
|
|
<i class="bi bi-exclamation-triangle text-danger" style="font-size: 2.5rem;"></i>
|
|
</div>
|
|
<h5 class="modal-title">Potwierdzenie usunięcia</h5>
|
|
</div>
|
|
<button type="button" class="btn-close position-absolute top-0 end-0 m-3" data-bs-dismiss="modal"></button>
|
|
</div>
|
|
<div class="modal-body text-center">
|
|
<p class="mb-1">Czy na pewno chcesz usunąć notatkę:</p>
|
|
<p class="fw-bold text-primary" id="deleteNoteTitle"></p>
|
|
<p class="text-muted small mb-0">Ta operacja jest nieodwracalna.</p>
|
|
</div>
|
|
<div class="modal-footer justify-content-center">
|
|
<button type="button" class="btn btn-secondary px-4" data-bs-dismiss="modal">
|
|
<i class="bi bi-x-lg me-1"></i>Anuluj
|
|
</button>
|
|
<form id="deleteForm" method="POST" class="d-inline">
|
|
<button type="submit" class="btn btn-danger px-4">
|
|
<i class="bi bi-trash me-1"></i>Usuń
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
function confirmDelete(id, title) {
|
|
document.getElementById('deleteNoteTitle').textContent = '"' + title + '"';
|
|
document.getElementById('deleteForm').action = '/notatnik/usun/' + id;
|
|
new bootstrap.Modal(document.getElementById('deleteModal')).show();
|
|
}
|
|
</script>
|
|
|
|
<?php
|
|
$content = ob_get_clean();
|
|
renderLayout('Notatnik', $content, true, 'notatnik', 'col-12');
|