diff --git a/WorkflowEngine.php b/WorkflowEngine.php
new file mode 100644
index 0000000..d777948
--- /dev/null
+++ b/WorkflowEngine.php
@@ -0,0 +1,263 @@
+pdo = db();
+ }
+
+ /**
+ * Pobiera wszystkie dane niezbędne dla głównej macierzy pulpitu procesów.
+ *
+ * @return array Tablica zawierająca 'people', 'definitions' i zmapowaną tablicę 'instances'.
+ */
+ public function getDashboardMatrix(): array {
+ // Get all people (potential assignees)
+ $stmt_people = $this->pdo->prepare("SELECT id, firstName, lastName, companyName, role, email, phone FROM people ORDER BY lastName, firstName");
+ $stmt_people->execute();
+ $people = $stmt_people->fetchAll(PDO::FETCH_ASSOC);
+
+ // Fetch all process definitions
+ $stmt_defs = $this->pdo->prepare("SELECT id, name FROM process_definitions ORDER BY name");
+ $stmt_defs->execute();
+ $process_definitions = $stmt_defs->fetchAll(PDO::FETCH_ASSOC);
+
+ // Fetch instances
+ $stmt_instances = $this->pdo->prepare("SELECT * FROM process_instances");
+ $stmt_instances->execute();
+ $instances_data = $stmt_instances->fetchAll(PDO::FETCH_ASSOC);
+
+ $instances = [];
+ foreach ($instances_data as $instance) {
+ $instances[$instance['personId']][$instance['processDefinitionId']] = $instance;
+ }
+
+ return [
+ 'people' => $people,
+ 'definitions' => $process_definitions,
+ 'instances' => $instances,
+ ];
+ }
+
+ /**
+ * Rozpoczyna nową instancję procesu dla danej osoby.
+ *
+ * @param string $processCode Unikalny kod definicji procesu.
+ * @param int $personId ID osoby.
+ * @param int $userId ID użytkownika inicjującego akcję.
+ * @return int|null ID nowo utworzonej instancji lub null w przypadku niepowodzenia.
+ */
+ public function startProcess(string $processCode, int $personId, int $userId): ?int {
+ // 1. Znajdź aktywną definicję procesu po kodzie.
+ // 2. Pobierz start_node_id z definicji.
+ // 3. Utwórz nową instancję procesu ze statusem 'in_progress' i current_node_id.
+ // 4. Utwórz zdarzenie systemowe dla rozpoczęcia procesu.
+ // TODO: Implementacja logiki.
+ return null;
+ }
+
+ /**
+ * Pobiera pojedynczą instancję procesu, tworząc ją, jeśli nie istnieje.
+ *
+ * @param int $personId
+ * @param int $processDefinitionId
+ * @param int $userId Użytkownik inicjujący utworzenie, jeśli to nastąpi.
+ * @return array|null Tablica asocjacyjna z danymi instancji.
+ */
+ public function getOrCreateInstanceByDefId(int $personId, int $processDefinitionId, int $userId): ?array {
+ $stmt = $this->pdo->prepare("SELECT * FROM process_instances WHERE personId = ? AND processDefinitionId = ?");
+ $stmt->execute([$personId, $processDefinitionId]);
+ $instance = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$instance) {
+ // Fetch the process definition to get the initial status
+ $stmt_def = $this->pdo->prepare("SELECT definition_json FROM process_definitions WHERE id = ?");
+ $stmt_def->execute([$processDefinitionId]);
+ $definition_raw = $stmt_def->fetchColumn();
+ $definition = $definition_raw ? json_decode($definition_raw, true) : null;
+ $initial_status = $definition['initial_status'] ?? 'none';
+
+ $stmt_insert = $this->pdo->prepare("INSERT INTO process_instances (personId, processDefinitionId, current_status) VALUES (?, ?, ?)");
+ $stmt_insert->execute([$personId, $processDefinitionId, $initial_status]);
+ $instanceId = $this->pdo->lastInsertId();
+
+ // Utwórz zdarzenie systemowe dla utworzenia instancji
+ $this->addEvent($instanceId, 'system', 'Instancja utworzona.', null, [], $userId);
+
+ // Pobierz ponownie nowo utworzoną instancję
+ $stmt->execute([$personId, $processDefinitionId]);
+ $instance = $stmt->fetch(PDO::FETCH_ASSOC);
+ }
+
+ return $instance;
+ }
+
+ /**
+ * Dodaje nowe zdarzenie do historii instancji.
+ * To jest wewnętrzna metoda pomocnicza.
+ */
+ private function addEvent(int $instanceId, string $eventType, string $message, ?string $nodeId, array $payload, int $userId): void {
+ $stmt = $this->pdo->prepare(
+ "INSERT INTO process_events (processInstanceId, event_type, message, node_id, payload_json, createdById) VALUES (?, ?, ?, ?, ?, ?)"
+ );
+ $stmt->execute([$instanceId, $eventType, $message, $nodeId, json_encode($payload), $userId]);
+ }
+
+ /**
+ * Pobiera historię zdarzeń dla danej instancji.
+ *
+ * @param int $instanceId
+ * @return array
+ */
+ public function getEvents(int $instanceId): array {
+ $stmt_events = $this->pdo->prepare("SELECT pe.*, p.email as user_email, p.firstName, p.lastName FROM process_events pe JOIN people p ON pe.createdById = p.id WHERE pe.processInstanceId = ? ORDER BY pe.createdAt DESC");
+ $stmt_events->execute([$instanceId]);
+ return $stmt_events->fetchAll(PDO::FETCH_ASSOC);
+ }
+
+ /**
+ * Pobiera listę dostępnych przejść z bieżącego węzła instancji.
+ *
+ * @param int $instanceId
+ * @return array Lista dostępnych przejść.
+ */
+ public function getAvailableTransitions(int $instanceId): array {
+ $stmt = $this->pdo->prepare(
+ 'SELECT pi.current_status, pd.definition_json '
+ . 'FROM process_instances pi '
+ . 'JOIN process_definitions pd ON pi.processDefinitionId = pd.id '
+ . 'WHERE pi.id = ?'
+ );
+ $stmt->execute([$instanceId]);
+ $result = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$result || empty($result['definition_json'])) {
+ return [];
+ }
+
+ $definition = json_decode($result['definition_json'], true);
+ if (!$definition || !isset($definition['transitions'])) {
+ return [];
+ }
+
+ $current_status = $result['current_status'];
+ $allowed_transitions = $definition['transitions'][$current_status] ?? [];
+
+ $transitions = [];
+ foreach ($allowed_transitions as $target_status) {
+ $transitions[] = [
+ 'id' => 'transition_' . str_replace(' ', '_', strtolower($target_status)), // e.g., transition_in_progress
+ 'name' => 'Oznacz jako ' . $target_status, // e.g., Oznacz jako In Progress
+ 'target_status' => $target_status
+ ];
+ }
+
+ return $transitions;
+ }
+
+ /**
+ * Stosuje przejście do instancji procesu. To jest główna metoda do postępu w przepływie pracy.
+ *
+ * @param int $instanceId ID instancji procesu.
+ * @param string $transitionId ID przejścia do zastosowania (z definition_json).
+ * @param array $inputPayload Dane zebrane od użytkownika dla tego kroku.
+ * @param int $userId ID użytkownika wykonującego akcję.
+ * @return bool True w przypadku sukcesu, false w przypadku porażki.
+ */
+ public function applyTransition(int $instanceId, string $transitionId, array $inputPayload, int $userId): bool {
+ $this->pdo->beginTransaction();
+
+ try {
+ // 1. Pobierz instancję i dostępne przejścia
+ $stmt = $this->pdo->prepare("SELECT * FROM process_instances WHERE id = ?");
+ $stmt->execute([$instanceId]);
+ $instance = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if (!$instance) {
+ // Instancja nie znaleziona
+ $this->pdo->rollBack();
+ return false;
+ }
+
+ $availableTransitions = $this->getAvailableTransitions($instanceId);
+
+ // 2. Sprawdź, czy przejście jest dozwolone
+ $selectedTransition = null;
+ if ($transitionId === 'note') { // Specjalny przypadek dodawania notatki
+ $selectedTransition = ['id' => 'note', 'name' => 'Dodano notatkę', 'target_status' => $instance['current_status']];
+ } else {
+ foreach ($availableTransitions as $trans) {
+ if ($trans['id'] === $transitionId) {
+ $selectedTransition = $trans;
+ break;
+ }
+ }
+ }
+
+ if (!$selectedTransition) {
+ // Nieprawidłowe lub niedozwolone przejście
+ $this->pdo->rollBack();
+ return false;
+ }
+
+ // 3. Utwórz zdarzenie
+ $eventType = ($transitionId === 'note') ? 'note' : 'transition_applied';
+ $message = $inputPayload['message'] ?? $selectedTransition['name'];
+ $this->addEvent($instanceId, $eventType, $message, null, $inputPayload, $userId);
+
+ // 4. Zaktualizuj instancję
+ $stmt_update = $this->pdo->prepare(
+ "UPDATE process_instances SET current_status = ?, lastActivityAt = CURRENT_TIMESTAMP WHERE id = ?"
+ );
+ $stmt_update->execute([$selectedTransition['target_status'], $instanceId]);
+
+ $this->pdo->commit();
+ return true;
+
+ } catch (Exception $e) {
+ $this->pdo->rollBack();
+ error_log("Błąd w applyTransition: " . $e->getMessage());
+ return false;
+ }
+ }
+
+ /**
+ * Masowa operacja stosowania tego samego przejścia do wielu osób dla danego procesu.
+ *
+ * @param string $processCode
+ * @param array $personIds
+ * @param string $transitionId
+ * @param array $inputPayload
+ * @param int $userId
+ * @return array Podsumowanie wyników (np. ['success' => count, 'failed' => count]).
+ */
+ public function bulkApplyTransition(string $processCode, array $personIds, string $transitionId, array $inputPayload, int $userId): array {
+ // 1. Upewnij się, że instancje istnieją dla wszystkich osób (użyj ensureInstances).
+ // 2. Przejdź przez pętlę personIds i wywołaj applyTransition dla każdej z nich.
+ // TODO: Implementacja logiki.
+ return ['success' => 0, 'failed' => 0];
+ }
+
+ /**
+ * Zapewnia, że instancje procesów istnieją dla danego zestawu osób i kodów procesów.
+ * Jeśli instancja brakuje, zostanie utworzona.
+ *
+ * @param array $personIds
+ * @param array $processCodes
+ * @param int $userId
+ * @return array Podsumowanie utworzonych instancji.
+ */
+ public function ensureInstances(array $personIds, array $processCodes, int $userId): array {
+ // TODO: Implementacja logiki do tworzenia brakujących instancji.
+ return ['created' => 0];
+ }
+}
\ No newline at end of file
diff --git a/_add_bni_group.php b/_add_bni_group.php
new file mode 100644
index 0000000..015fcaf
--- /dev/null
+++ b/_add_bni_group.php
@@ -0,0 +1,32 @@
+prepare("INSERT INTO bni_groups (name, city, active, display_order) VALUES (:name, :city, :active, :display_order)");
+ $stmt->bindParam(':name', $name);
+ $stmt->bindParam(':city', $city);
+ $stmt->bindParam(':active', $active, PDO::PARAM_INT);
+ $stmt->bindParam(':display_order', $display_order, PDO::PARAM_INT);
+ $stmt->execute();
+
+ $_SESSION['success_message'] = 'BNI Group added successfully!';
+ } catch (PDOException $e) {
+ $_SESSION['error_message'] = 'Error adding BNI group: ' . $e->getMessage();
+ }
+}
+
+header('Location: bni_groups.php');
+exit;
diff --git a/_add_calendar_event.php b/_add_calendar_event.php
new file mode 100644
index 0000000..036b889
--- /dev/null
+++ b/_add_calendar_event.php
@@ -0,0 +1,88 @@
+beginTransaction();
+
+ // Insert the main event
+ $stmt = $pdo->prepare("INSERT INTO calendar_events (title, description, start_datetime, end_datetime, event_type_id, recurrence, recurrence_end_date) VALUES (?, ?, ?, ?, ?, ?, ?)");
+ $stmt->execute([$title, $description, $start_datetime, $end_datetime, $event_type_id, $recurrence, $recurrence_end_date]);
+ $parent_event_id = $pdo->lastInsertId();
+
+ if ($recurrence && !empty($recurrence_end_date)) {
+ $start_date = new DateTime($start_datetime);
+ $end_date = new DateTime($end_datetime);
+ $recurrence_end = new DateTime($recurrence_end_date);
+ $interval_spec = '';
+
+ switch ($recurrence) {
+ case 'daily':
+ $interval_spec = 'P1D';
+ break;
+ case 'weekly':
+ $interval_spec = 'P1W';
+ break;
+ case 'monthly':
+ $interval_spec = 'P1M';
+ break;
+ }
+
+ if ($interval_spec) {
+ $interval = new DateInterval($interval_spec);
+ $period_start = clone $start_date;
+ $period_start->add($interval);
+
+ $period = new DatePeriod($period_start, $interval, $recurrence_end);
+
+ $stmt_recur = $pdo->prepare("INSERT INTO calendar_events (title, description, start_datetime, end_datetime, event_type_id, parent_event_id) VALUES (?, ?, ?, ?, ?, ?)");
+
+ foreach ($period as $date) {
+ $new_start_datetime = $date->format('Y-m-d H:i:s');
+ $end_date_clone = clone $date;
+ $new_end_datetime = $end_date_clone->add($start_date->diff($end_date))->format('Y-m-d H:i:s');
+ $stmt_recur->execute([$title, $description, $new_start_datetime, $new_end_datetime, $event_type_id, $parent_event_id]);
+ }
+ }
+ }
+
+ $pdo->commit();
+ header("Location: calendar.php");
+ exit();
+
+ } catch (Exception $e) {
+ $pdo->rollBack();
+ error_log($e->getMessage());
+ header("Location: calendar.php?error=db_error");
+ exit();
+ }
+}
diff --git a/_add_event_type.php b/_add_event_type.php
new file mode 100644
index 0000000..d7db0bc
--- /dev/null
+++ b/_add_event_type.php
@@ -0,0 +1,18 @@
+prepare("INSERT INTO event_types (name, color, display_order) VALUES (?, ?, ?)");
+ $stmt->execute([$name, $color, $display_order]);
+
+ session_start();
+ $_SESSION['success_message'] = 'Event type added successfully.';
+ header('Location: event_types.php');
+ exit;
+}
+?>
\ No newline at end of file
diff --git a/_add_function.php b/_add_function.php
new file mode 100644
index 0000000..4d16b79
--- /dev/null
+++ b/_add_function.php
@@ -0,0 +1,21 @@
+prepare("functions (name, display_order) VALUES (:name, :display_order)");
+ $stmt->execute(['name' => $name, 'display_order' => $display_order]);
+ }
+}
+
+header('Location: roles.php');
+exit();
diff --git a/_add_process_event.php b/_add_process_event.php
new file mode 100644
index 0000000..14344a4
--- /dev/null
+++ b/_add_process_event.php
@@ -0,0 +1,31 @@
+prepare("INSERT INTO process_events (processInstanceId, eventType, description, createdBy) VALUES (?, ?, ?, ?)");
+$stmt->execute([$instanceId, $eventType, $description, $userId]);
+
+// Update the last activity time for the instance
+$stmt_update = $pdo->prepare("UPDATE process_instances SET lastActivityAt = NOW() WHERE id = ?");
+$stmt_update->execute([$instanceId]);
+
+// Redirect back to the dashboard
+header("Location: process_dashboard.php");
+exit;
diff --git a/_apply_transition.php b/_apply_transition.php
new file mode 100644
index 0000000..34621ca
--- /dev/null
+++ b/_apply_transition.php
@@ -0,0 +1,43 @@
+ 'danger', 'message' => 'Błąd: Brak wymaganych parametrów.'];
+ header('Location: process_dashboard.php');
+ exit;
+}
+
+$instanceId = (int)$_POST['instanceId'];
+$transitionId = $_POST['transitionId'];
+$userId = $_SESSION['user_id'] ?? null;
+$payload = $_POST['payload'] ?? null;
+
+if (!$userId) {
+ $_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Błąd: Sesja wygasła.'];
+ header('Location: login.php');
+ exit;
+}
+
+try {
+ $engine = new WorkflowEngine();
+ $success = $engine->applyTransition($instanceId, $transitionId, $payload, $userId);
+
+ if ($success) {
+ $_SESSION['flash_message'] = ['type' => 'success', 'message' => 'Akcja została wykonana pomyślnie.'];
+ } else {
+ $_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Błąd: Nie udało się wykonać akcji.'];
+ }
+} catch (Exception $e) {
+ error_log("Error applying transition: " . $e->getMessage());
+ $_SESSION['flash_message'] = ['type' => 'danger', 'message' => 'Wystąpił krytyczny błąd: ' . $e->getMessage()];
+}
+
+header('Location: process_dashboard.php');
+exit;
\ No newline at end of file
diff --git a/_bulk_add_event.php b/_bulk_add_event.php
new file mode 100644
index 0000000..6c554a7
--- /dev/null
+++ b/_bulk_add_event.php
@@ -0,0 +1,53 @@
+prepare("SELECT id FROM process_instances WHERE processDefinitionId = ? AND personId IN ($placeholders)");
+$params = array_merge([$process_id], $person_ids);
+$stmt->execute($params);
+$instance_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
+
+if (!empty($instance_ids)) {
+ $instance_placeholders = implode(',', array_fill(0, count($instance_ids), '?'));
+
+ // Update last activity
+ $stmt_update = $pdo->prepare("UPDATE process_instances SET lastActivityAt = NOW() WHERE id IN ($instance_placeholders)");
+ $stmt_update->execute($instance_ids);
+
+ // Bulk insert events
+ $event_sql = "INSERT INTO process_events (processInstanceId, event_type, message, createdById) VALUES ";
+ $event_rows = [];
+ $event_params = [];
+ foreach($instance_ids as $instance_id) {
+ $event_rows[] = "(?, 'note', ?, ?)";
+ $event_params[] = $instance_id;
+ $event_params[] = $message;
+ $event_params[] = $userId;
+ }
+ $event_sql .= implode(', ', $event_rows);
+ $stmt_event = $pdo->prepare($event_sql);
+ $stmt_event->execute($event_params);
+}
+
+$_SESSION['flash_message'] = "Bulk event addition completed.";
+header('Location: process_dashboard.php');
+exit;
diff --git a/_bulk_init_instances.php b/_bulk_init_instances.php
new file mode 100644
index 0000000..fda7a2e
--- /dev/null
+++ b/_bulk_init_instances.php
@@ -0,0 +1,33 @@
+prepare($sql);
+$stmt->execute($params);
+
+$_SESSION['flash_message'] = "Bulk initialization completed.";
+header('Location: process_dashboard.php');
+exit;
diff --git a/_bulk_update_status.php b/_bulk_update_status.php
new file mode 100644
index 0000000..060be43
--- /dev/null
+++ b/_bulk_update_status.php
@@ -0,0 +1,54 @@
+prepare("SELECT id FROM process_instances WHERE processDefinitionId = ? AND personId IN ($placeholders)");
+$params = array_merge([$process_id], $person_ids);
+$stmt->execute($params);
+$instance_ids = $stmt->fetchAll(PDO::FETCH_COLUMN);
+
+if (!empty($instance_ids)) {
+ $instance_placeholders = implode(',', array_fill(0, count($instance_ids), '?'));
+
+ // Update statuses
+ $stmt_update = $pdo->prepare("UPDATE process_instances SET current_status = ?, lastActivityAt = NOW() WHERE id IN ($instance_placeholders)");
+ $stmt_update->execute(array_merge([$status], $instance_ids));
+
+ // Bulk insert events
+ $event_sql = "INSERT INTO process_events (processInstanceId, event_type, message, createdById) VALUES ";
+ $event_rows = [];
+ $event_params = [];
+ $message = "Status changed to $status";
+ foreach($instance_ids as $instance_id) {
+ $event_rows[] = "(?, 'status_change', ?, ?)";
+ $event_params[] = $instance_id;
+ $event_params[] = $message;
+ $event_params[] = $userId;
+ }
+ $event_sql .= implode(', ', $event_rows);
+ $stmt_event = $pdo->prepare($event_sql);
+ $stmt_event->execute($event_params);
+}
+
+$_SESSION['flash_message'] = "Bulk status update completed.";
+header('Location: process_dashboard.php');
+exit;
diff --git a/_create_person.php b/_create_person.php
new file mode 100644
index 0000000..e904bf5
--- /dev/null
+++ b/_create_person.php
@@ -0,0 +1,53 @@
+prepare($sql);
+ $stmt->execute([$firstName, $lastName, $email, password_hash($password, PASSWORD_DEFAULT), $companyName, $phone, $role]);
+ $personId = $pdo->lastInsertId();
+
+ // Assign functions
+ if (!empty($functions)) {
+ $sql = "INSERT INTO user_functions (user_id, function_id) VALUES (?, ?)";
+ $stmt = $pdo->prepare($sql);
+ foreach ($functions as $functionId) {
+ $stmt->execute([$personId, $functionId]);
+ }
+ }
+
+ $_SESSION['success_message'] = 'Osoba dodana pomyślnie.';
+
+ } catch (PDOException $e) {
+ error_log('Create failed: ' . $e->getMessage());
+ if ($e->errorInfo[1] == 1062) {
+ $_SESSION['error_message'] = 'Błąd: Konto z tym adresem email już istnieje.';
+ } else {
+ $_SESSION['error_message'] = 'Błąd podczas dodawania osoby.';
+ }
+ }
+
+ header('Location: index.php');
+ exit();
+}
+?>
\ No newline at end of file
diff --git a/_delete_bni_group.php b/_delete_bni_group.php
new file mode 100644
index 0000000..e6a55e9
--- /dev/null
+++ b/_delete_bni_group.php
@@ -0,0 +1,20 @@
+prepare("DELETE FROM bni_groups WHERE id = :id");
+ $stmt->bindParam(':id', $id, PDO::PARAM_INT);
+ $stmt->execute();
+
+ $_SESSION['success_message'] = 'BNI Group deleted successfully!';
+ } catch (PDOException $e) {
+ $_SESSION['error_message'] = 'Error deleting BNI group: ' . $e->getMessage();
+ }
+}
+
+header('Location: bni_groups.php');
+exit;
diff --git a/_delete_calendar_event.php b/_delete_calendar_event.php
new file mode 100644
index 0000000..8d96636
--- /dev/null
+++ b/_delete_calendar_event.php
@@ -0,0 +1,48 @@
+beginTransaction();
+
+ // Check if the event is a parent event
+ $stmt = $pdo->prepare("SELECT parent_event_id FROM calendar_events WHERE id = ?");
+ $stmt->execute([$event_id]);
+ $event = $stmt->fetch(PDO::FETCH_ASSOC);
+
+ if ($event) {
+ if ($event['parent_event_id'] === null) {
+ // It's a parent event, delete it and all its children
+ $stmt_delete_children = $pdo->prepare("DELETE FROM calendar_events WHERE parent_event_id = ?");
+ $stmt_delete_children->execute([$event_id]);
+ }
+
+ // Delete the event itself
+ $stmt_delete = $pdo->prepare("DELETE FROM calendar_events WHERE id = ?");
+ $stmt_delete->execute([$event_id]);
+ }
+
+ $pdo->commit();
+ header("Location: calendar.php");
+ exit();
+
+ } catch (Exception $e) {
+ $pdo->rollBack();
+ error_log($e->getMessage());
+ header("Location: calendar.php?error=db_error");
+ exit();
+ }
+} else {
+ header("Location: calendar.php");
+ exit();
+}
diff --git a/_delete_event_type.php b/_delete_event_type.php
new file mode 100644
index 0000000..868a28c
--- /dev/null
+++ b/_delete_event_type.php
@@ -0,0 +1,16 @@
+prepare("DELETE FROM event_types WHERE id = ?");
+ $stmt->execute([$id]);
+
+ session_start();
+ $_SESSION['success_message'] = 'Event type deleted successfully.';
+ header('Location: event_types.php');
+ exit;
+}
+?>
\ No newline at end of file
diff --git a/_delete_function.php b/_delete_function.php
new file mode 100644
index 0000000..bb5b1c1
--- /dev/null
+++ b/_delete_function.php
@@ -0,0 +1,21 @@
+prepare("DELETE FROM functions WHERE id = :id");
+$stmt->execute(['id' => $id]);
+
+// Optional: Also delete user_functions associated with this function
+$stmt = $pdo->prepare("DELETE FROM user_functions WHERE function_id = :function_id");
+$stmt->execute(['function_id' => $id]);
+
+header('Location: functions.php');
+exit();
diff --git a/_delete_person.php b/_delete_person.php
new file mode 100644
index 0000000..2b824f5
--- /dev/null
+++ b/_delete_person.php
@@ -0,0 +1,16 @@
+prepare("DELETE FROM people WHERE id = ?");
+ $stmt->execute([$id]);
+
+ $_SESSION['success_message'] = 'Osoba usunięta pomyślnie.';
+ header('Location: persons.php');
+ exit;
+}
+?>
\ No newline at end of file
diff --git a/_footer.php b/_footer.php
new file mode 100644
index 0000000..6ec3293
--- /dev/null
+++ b/_footer.php
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+