added quesionnaire export and import
This commit is contained in:
@ -11,6 +11,24 @@ if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($_GET['bundle'])) {
|
||||
$role = $tokenRec['role'] ?? '';
|
||||
if (!in_array($role, ['admin', 'supervisor'], true)) {
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
http_response_code(403);
|
||||
echo json_encode(["error" => "Permission denied"]);
|
||||
exit;
|
||||
}
|
||||
[$pdo, $tmpDb, $lockFp] = qdb_open(false);
|
||||
$bundle = qdb_export_all_questionnaires_bundle($pdo);
|
||||
qdb_discard($tmpDb, $lockFp);
|
||||
$filename = 'questionnaires_bundle_' . date('Y-m-d_His') . '.json';
|
||||
header('Content-Type: application/json; charset=UTF-8');
|
||||
header('Content-Disposition: attachment; filename="' . $filename . '"');
|
||||
echo json_encode($bundle, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
|
||||
exit;
|
||||
}
|
||||
|
||||
$qnID = $_GET['questionnaireID'] ?? '';
|
||||
$format = strtolower($_GET['format'] ?? 'csv');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user