mapping fixed

This commit is contained in:
2026-02-24 09:06:45 +01:00
parent b9852ba226
commit b0024edb70
6 changed files with 365 additions and 8 deletions
+31
View File
@@ -0,0 +1,31 @@
<?php
require_once 'include/headscript.php';
header('Content-Type: application/json');
$data = json_decode(file_get_contents('php://input'), true);
$template_id = isset($data['template_id']) ? (int)$data['template_id'] : 0;
$mapping_id = isset($data['mapping_id']) ? (int)$data['mapping_id'] : 0;
$value = isset($data['value']) ? (int)$data['value'] : null;
// Validate input
if ($template_id <= 0 || $mapping_id <= 0 || $value === null) {
echo json_encode(['success' => false, 'message' => 'Invalid input']);
exit;
}
// Normalize to 0/1
$value = ($value === 1) ? 1 : 0;
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
$stmt = $pdo->prepare("UPDATE template_mapping SET is_visible_parts = ? WHERE id = ? AND template_id = ?");
$result = $stmt->execute([$value, $mapping_id, $template_id]);
if ($result) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['success' => false, 'message' => 'Failed to update is_visible_parts']);
}