first commit

This commit is contained in:
2026-01-29 21:07:02 +01:00
commit bda2bc85d0
22 changed files with 2594 additions and 0 deletions

164
app/views/calendar/day.php Normal file
View File

@@ -0,0 +1,164 @@
<?php
require_once __DIR__ . '/../layout.php';
$dayNames = [
1 => 'Poniedziałek', 2 => 'Wtorek', 3 => 'Środa', 4 => 'Czwartek',
5 => 'Piątek', 6 => 'Sobota', 7 => 'Niedziela'
];
$monthNames = [
1 => 'stycznia', 2 => 'lutego', 3 => 'marca', 4 => 'kwietnia',
5 => 'maja', 6 => 'czerwca', 7 => 'lipca', 8 => 'sierpnia',
9 => 'września', 10 => 'października', 11 => 'listopada', 12 => 'grudnia'
];
$timestamp = strtotime($date);
$dayOfWeek = date('N', $timestamp);
$day = date('j', $timestamp);
$month = date('n', $timestamp);
$year = date('Y', $timestamp);
$formattedDate = $dayNames[$dayOfWeek] . ', ' . $day . ' ' . $monthNames[$month] . ' ' . $year;
$isToday = ($date === date('Y-m-d'));
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">
<div>
<a href="/kalendarz?rok=<?= $year ?>&miesiac=<?= $month ?>" class="btn btn-outline-light mb-2">
<i class="bi bi-arrow-left me-1"></i>Powrót do kalendarza
</a>
<h2 class="text-white mb-0">
<?php if ($isToday): ?>
<span class="badge bg-success me-2">Dzisiaj</span>
<?php endif; ?>
<?= $formattedDate ?>
</h2>
</div>
<a href="/kalendarz/nowe/<?= $date ?>" class="btn btn-light btn-lg">
<i class="bi bi-plus-lg me-1"></i>Dodaj wydarzenie
</a>
</div>
<?php if (empty($events)): ?>
<div class="card">
<div class="card-body text-center py-5">
<i class="bi bi-calendar-x text-muted" style="font-size: 4rem;"></i>
<h4 class="mt-3 text-muted">Brak wydarzeń</h4>
<p class="text-muted mb-4">Nie masz żadnych wydarzeń zaplanowanych na ten dzień.</p>
<a href="/kalendarz/nowe/<?= $date ?>" class="btn btn-primary">
<i class="bi bi-plus-lg me-1"></i>Dodaj wydarzenie
</a>
</div>
</div>
<?php else: ?>
<div class="row g-3">
<?php foreach ($events as $event): ?>
<div class="col-12">
<div class="card event-card">
<div class="card-body">
<div class="d-flex justify-content-between align-items-start">
<div class="flex-grow-1">
<h5 class="card-title mb-2">
<i class="bi bi-calendar-event text-primary me-2"></i>
<?= htmlspecialchars($event['title']) ?>
</h5>
<?php if (!empty($event['content'])): ?>
<p class="card-text text-muted mb-2">
<?= nl2br(htmlspecialchars($event['content'])) ?>
</p>
<?php endif; ?>
<small class="text-muted">
<i class="bi bi-clock me-1"></i>
Dodano: <?= date('d.m.Y H:i', strtotime($event['created_at'])) ?>
</small>
</div>
<div class="event-actions ms-3">
<a href="/kalendarz/edytuj/<?= $event['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(<?= $event['id'] ?>, '<?= htmlspecialchars(addslashes($event['title'])) ?>')"
title="Usuń">
<i class="bi bi-trash"></i>
</button>
</div>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
<!-- Modal potwierdzenia usunięcia -->
<div class="modal fade" id="deleteModal" tabindex="-1">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header border-0">
<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ąć wydarzenie:</p>
<p class="fw-bold text-primary" id="deleteEventTitle"></p>
<p class="text-muted small mb-0">Ta operacja jest nieodwracalna.</p>
</div>
<div class="modal-footer justify-content-center border-0">
<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>
<style>
.event-card {
border-left: 4px solid #667eea;
transition: transform 0.2s, box-shadow 0.2s;
}
.event-card:hover {
transform: translateX(5px);
box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}
</style>
<script>
function confirmDelete(id, title) {
document.getElementById('deleteEventTitle').textContent = '"' + title + '"';
document.getElementById('deleteForm').action = '/kalendarz/usun/' + id;
new bootstrap.Modal(document.getElementById('deleteModal')).show();
}
</script>
<?php
$content = ob_get_clean();
renderLayout('Wydarzenia - ' . $formattedDate, $content, true, 'kalendarz', 'col-lg-8');

View File

@@ -0,0 +1,72 @@
<?php
require_once __DIR__ . '/../layout.php';
$error = $_SESSION['error'] ?? null;
unset($_SESSION['error']);
ob_start();
?>
<div class="card">
<div class="card-header text-center text-white">
<i class="bi bi-<?= $isEdit ? 'pencil-square' : 'calendar-plus' ?> icon-large"></i>
<h4 class="mt-2 mb-0"><?= $isEdit ? 'Edytuj wydarzenie' : 'Nowe wydarzenie' ?></h4>
</div>
<div class="card-body p-4">
<?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; ?>
<form method="POST" action="<?= $isEdit ? '/kalendarz/zapisz/' . $event['id'] : '/kalendarz/dodaj' ?>">
<div class="mb-3">
<label for="title" class="form-label">
<i class="bi bi-type me-1"></i>Tytuł wydarzenia
</label>
<input type="text" class="form-control" id="title" name="title"
value="<?= htmlspecialchars($event['title'] ?? '') ?>"
placeholder="Np. Spotkanie z klientem" required autofocus>
</div>
<div class="mb-3">
<label for="event_date" class="form-label">
<i class="bi bi-calendar-date me-1"></i>Data
</label>
<input type="date" class="form-control" id="event_date" name="event_date"
value="<?= htmlspecialchars($event['event_date'] ?? $selectedDate) ?>" required>
</div>
<div class="mb-4">
<label for="content" class="form-label">
<i class="bi bi-text-paragraph me-1"></i>Opis (opcjonalnie)
</label>
<textarea class="form-control" id="content" name="content" rows="4"
placeholder="Dodatkowe informacje o wydarzeniu..."><?= htmlspecialchars($event['content'] ?? '') ?></textarea>
</div>
<div class="d-grid gap-2">
<button type="submit" class="btn btn-primary btn-lg">
<i class="bi bi-check-lg me-2"></i><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj wydarzenie' ?>
</button>
<?php
$backUrl = '/kalendarz';
if ($isEdit && isset($event['event_date'])) {
$backUrl = '/kalendarz/dzien/' . $event['event_date'];
} elseif (isset($selectedDate)) {
$backUrl = '/kalendarz/dzien/' . $selectedDate;
}
?>
<a href="<?= $backUrl ?>" class="btn btn-outline-secondary">
<i class="bi bi-arrow-left me-2"></i>Anuluj
</a>
</div>
</form>
</div>
</div>
<?php
$content = ob_get_clean();
renderLayout($isEdit ? 'Edytuj wydarzenie' : 'Nowe wydarzenie', $content, true, 'kalendarz', 'col-md-6');

View File

@@ -0,0 +1,200 @@
<?php
require_once __DIR__ . '/../layout.php';
$monthNames = [
1 => 'Styczeń', 2 => 'Luty', 3 => 'Marzec', 4 => 'Kwiecień',
5 => 'Maj', 6 => 'Czerwiec', 7 => 'Lipiec', 8 => 'Sierpień',
9 => 'Wrzesień', 10 => 'Październik', 11 => 'Listopad', 12 => 'Grudzień'
];
$dayNames = ['Pon', 'Wt', 'Śr', 'Czw', 'Pt', 'Sob', 'Ndz'];
// Obliczenia kalendarza
$firstDayOfMonth = mktime(0, 0, 0, $month, 1, $year);
$daysInMonth = cal_days_in_month(CAL_GREGORIAN, $month, $year);
$dayOfWeek = date('N', $firstDayOfMonth); // 1 = poniedziałek, 7 = niedziela
$prevMonth = $month - 1;
$prevYear = $year;
if ($prevMonth < 1) {
$prevMonth = 12;
$prevYear--;
}
$nextMonth = $month + 1;
$nextYear = $year;
if ($nextMonth > 12) {
$nextMonth = 1;
$nextYear++;
}
$today = date('Y-m-d');
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="card">
<div class="card-header bg-transparent">
<div class="d-flex justify-content-between align-items-center">
<a href="/kalendarz?rok=<?= $prevYear ?>&miesiac=<?= $prevMonth ?>" class="btn btn-outline-primary">
<i class="bi bi-chevron-left"></i>
</a>
<h4 class="mb-0">
<i class="bi bi-calendar3 me-2"></i>
<?= $monthNames[$month] ?> <?= $year ?>
</h4>
<a href="/kalendarz?rok=<?= $nextYear ?>&miesiac=<?= $nextMonth ?>" class="btn btn-outline-primary">
<i class="bi bi-chevron-right"></i>
</a>
</div>
</div>
<div class="card-body p-0">
<table class="table table-bordered mb-0 calendar-table">
<thead>
<tr>
<?php foreach ($dayNames as $dayName): ?>
<th class="text-center py-2 bg-light"><?= $dayName ?></th>
<?php endforeach; ?>
</tr>
</thead>
<tbody>
<?php
$currentDay = 1;
$started = false;
for ($week = 0; $week < 6; $week++):
if ($currentDay > $daysInMonth) break;
?>
<tr>
<?php for ($dow = 1; $dow <= 7; $dow++):
$cellDate = null;
$isToday = false;
$hasEvents = false;
$dayEvents = [];
if (!$started && $dow == $dayOfWeek) {
$started = true;
}
if ($started && $currentDay <= $daysInMonth) {
$cellDate = sprintf('%04d-%02d-%02d', $year, $month, $currentDay);
$isToday = ($cellDate === $today);
$hasEvents = isset($eventsByDate[$cellDate]);
if ($hasEvents) {
$dayEvents = $eventsByDate[$cellDate];
}
$displayDay = $currentDay;
$currentDay++;
} else {
$displayDay = null;
}
?>
<td class="calendar-cell <?= $isToday ? 'today' : '' ?> <?= $hasEvents ? 'has-events' : '' ?>"
<?php if ($cellDate): ?>onclick="window.location='/kalendarz/dzien/<?= $cellDate ?>'"<?php endif; ?>>
<?php if ($displayDay): ?>
<div class="day-number <?= $isToday ? 'bg-primary text-white' : '' ?>">
<?= $displayDay ?>
</div>
<?php if ($hasEvents): ?>
<div class="day-events">
<?php foreach (array_slice($dayEvents, 0, 2) as $evt): ?>
<div class="event-dot" title="<?= htmlspecialchars($evt['title']) ?>">
<?= htmlspecialchars(mb_substr($evt['title'], 0, 15)) ?><?= mb_strlen($evt['title']) > 15 ? '...' : '' ?>
</div>
<?php endforeach; ?>
<?php if (count($dayEvents) > 2): ?>
<div class="event-more">+<?= count($dayEvents) - 2 ?> więcej</div>
<?php endif; ?>
</div>
<?php endif; ?>
<?php endif; ?>
</td>
<?php endfor; ?>
</tr>
<?php endfor; ?>
</tbody>
</table>
</div>
<div class="card-footer bg-transparent">
<div class="d-flex justify-content-between align-items-center">
<a href="/kalendarz?rok=<?= date('Y') ?>&miesiac=<?= date('m') ?>" class="btn btn-outline-secondary">
<i class="bi bi-calendar-check me-1"></i>Dzisiaj
</a>
<a href="/kalendarz/nowe" class="btn btn-primary">
<i class="bi bi-plus-lg me-1"></i>Nowe wydarzenie
</a>
</div>
</div>
</div>
<style>
.calendar-table {
table-layout: fixed;
}
.calendar-cell {
height: 100px;
vertical-align: top;
padding: 5px !important;
cursor: pointer;
transition: background-color 0.2s;
}
.calendar-cell:hover {
background-color: #f8f9fa;
}
.calendar-cell.today {
background-color: #e7f1ff;
}
.calendar-cell.has-events {
background-color: #fff3cd;
}
.calendar-cell.today.has-events {
background-color: #d1e7dd;
}
.day-number {
display: inline-block;
width: 28px;
height: 28px;
line-height: 28px;
text-align: center;
border-radius: 50%;
font-weight: 600;
margin-bottom: 3px;
}
.day-events {
font-size: 0.7rem;
}
.event-dot {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 1px 5px;
border-radius: 3px;
margin-bottom: 2px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.event-more {
color: #6c757d;
font-style: italic;
}
</style>
<?php
$content = ob_get_clean();
renderLayout('Kalendarz', $content, true, 'kalendarz', 'col-lg-10');