new project commit

This commit is contained in:
2025-10-24 21:45:33 +02:00
parent 29e4b41874
commit 92ec026afe
233 changed files with 2185 additions and 52098 deletions
+17 -34
View File
@@ -1,39 +1,22 @@
<?php
header('Content-Type: application/json');
include('include/headscript.php');
$dbHandler = DBHandlerSelect::getInstance();
$pdo = $dbHandler->getConnection();
$data = json_decode(file_get_contents('php://input'), true);
$iddatadb = $data['iddatadb'] ?? null;
$parts = $data['parts'] ?? [];
if (!$iddatadb || empty($parts)) {
echo json_encode(['success' => false, 'message' => 'Dati mancanti']);
exit;
}
$part = $parts[0];
$partId = $part['id'] ?? null;
$idmatrice = $part['idmatrice'] ?? null;
if (!$partId) {
echo json_encode(['success' => false, 'message' => 'ID parte mancante']);
exit;
}
header('Content-Type: application/json');
try {
$stmt = $pdo->prepare("UPDATE identification_parts
SET idmatrice = :idmatrice,
updated_at = NOW()
WHERE id = :id");
$stmt->execute([
':id' => $partId,
':idmatrice' => $idmatrice // Può essere NULL
]);
echo json_encode(['success' => true, 'message' => 'Matrice aggiornata con successo']);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'message' => 'Errore nel salvataggio della matrice: ' . $e->getMessage()]);
if (!isset($_POST['nome']) || trim($_POST['nome']) === '') {
throw new Exception("Nome matrice mancante.");
}
$nome = trim($_POST['nome']);
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
// Inserisci nuova matrice
$stmt = $pdo->prepare("INSERT INTO matrice (nome) VALUES (:nome)");
$stmt->bindParam(':nome', $nome, PDO::PARAM_STR);
$stmt->execute();
echo json_encode(["success" => true]);
} catch (Exception $e) {
echo json_encode(["success" => false, "message" => $e->getMessage()]);
}