Add roadmap management, service worker, and user invitation features
- Implemented roadmap.php for managing roadmap items with filtering options by quarter and status. - Added a service worker (sw.js) to handle push notifications and click events for calendar appointments. - Created users.php for admin to manage team members and invitations, including user creation and deletion functionalities.
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* AJAX API voor Roadmap Beheer
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../includes/auth.php';
|
||||
$user = require_auth();
|
||||
$db = get_db_connection();
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$action = $_GET['action'] ?? ($_POST['action'] ?? '');
|
||||
|
||||
try {
|
||||
// 1. Roadmap item toevoegen
|
||||
if ($action === 'add_item') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$title = trim($data['title'] ?? '');
|
||||
$description = trim($data['description'] ?? '');
|
||||
$quarter = $data['quarter'] ?? 'Q3';
|
||||
$type = $data['type'] ?? 'FEATURE';
|
||||
$priority = $data['priority'] ?? 'MEDIUM';
|
||||
$dueDate = !empty($data['due_date']) ? $data['due_date'] : null;
|
||||
$jiraKey = !empty($data['jira_key']) ? trim($data['jira_key']) : null;
|
||||
|
||||
if (empty($title)) {
|
||||
echo json_encode(['error' => 'Titel is verplicht']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt = $db->prepare("
|
||||
INSERT INTO roadmap_items (title, description, quarter, type, priority, status, progress, due_date, jira_issue_key, created_by_id)
|
||||
VALUES (?, ?, ?, ?, ?, 'PLANNED', 0, ?, ?, ?)
|
||||
");
|
||||
$stmt->execute([$title, $description, $quarter, $type, $priority, $dueDate, $jiraKey, $user['id']]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 2. Status of voortgang bijwerken
|
||||
if ($action === 'update_item') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$id = (int)($data['id'] ?? 0);
|
||||
$status = $data['status'] ?? null;
|
||||
$progress = isset($data['progress']) ? (int)$data['progress'] : null;
|
||||
$jiraKey = isset($data['jira_key']) ? trim($data['jira_key']) : null;
|
||||
|
||||
$fields = [];
|
||||
$params = [];
|
||||
|
||||
if ($status !== null) {
|
||||
$fields[] = "status = ?";
|
||||
$params[] = $status;
|
||||
}
|
||||
if ($progress !== null) {
|
||||
$fields[] = "progress = ?";
|
||||
$params[] = max(0, min(100, $progress));
|
||||
}
|
||||
if ($jiraKey !== null) {
|
||||
$fields[] = "jira_issue_key = ?";
|
||||
$params[] = $jiraKey;
|
||||
}
|
||||
|
||||
if (!empty($fields)) {
|
||||
$params[] = $id;
|
||||
$sql = "UPDATE roadmap_items SET " . implode(", ", $fields) . " WHERE id = ?";
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
}
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// 3. Item verwijderen
|
||||
if ($action === 'delete_item') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
$id = (int)($data['id'] ?? 0);
|
||||
|
||||
$stmt = $db->prepare("DELETE FROM roadmap_items WHERE id = ?");
|
||||
$stmt->execute([$id]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
exit;
|
||||
}
|
||||
|
||||
echo json_encode(['error' => 'Onbekende actie']);
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user