fixed dashboard
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
require_once(__DIR__ . '/class/db-functions.php');
|
||||
|
||||
try {
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Validazione base
|
||||
if (empty($_POST['id']) || !is_numeric($_POST['id'])) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID non valido.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = (int)$_POST['id'];
|
||||
$lineNumber = trim($_POST['lineNumber'] ?? '');
|
||||
$lineName = trim($_POST['lineName'] ?? '');
|
||||
$model = trim($_POST['model'] ?? '');
|
||||
$brand = trim($_POST['brand'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
|
||||
if ($lineNumber === '' || $lineName === '') {
|
||||
echo json_encode(['success' => false, 'message' => 'Numero linea e nome sono obbligatori.']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Query UPDATE
|
||||
$sql = "UPDATE production_lines
|
||||
SET line_number = :line_number,
|
||||
name = :name,
|
||||
model = :model,
|
||||
brand = :brand,
|
||||
status = :status
|
||||
WHERE id = :id";
|
||||
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute([
|
||||
':line_number' => $lineNumber,
|
||||
':name' => $lineName,
|
||||
':model' => $model,
|
||||
':brand' => $brand,
|
||||
':status' => $status,
|
||||
':id' => $id
|
||||
]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => 'Errore server: ' . $e->getMessage()
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user