create identification parts functions

This commit is contained in:
2025-05-09 09:12:08 +02:00
parent 7d0224ac19
commit 7c111b0dba
10 changed files with 407 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
<?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];
$partNumber = $part['part_number'] ?? null;
$partDescription = $part['part_description'] ?? '';
if ($partDescription) {
try {
$stmt = $pdo->prepare("INSERT INTO identification_parts (iddatadb, part_number, part_description, created_at, updated_at) VALUES (:iddatadb, :part_number, :part_description, NOW(), NOW())");
$stmt->execute([
':iddatadb' => $iddatadb,
':part_number' => $partNumber,
':part_description' => $partDescription
]);
echo json_encode(['success' => true, 'message' => 'Parte salvata con successo']);
} catch (PDOException $e) {
echo json_encode(['success' => false, 'message' => 'Errore nel salvataggio: ' . $e->getMessage()]);
}
} else {
echo json_encode(['success' => false, 'message' => 'Descrizione mancante']);
}