status added
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
include('include/headscript.php');
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
// Validazione
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
$nome = trim($_POST['nome'] ?? '');
|
||||
$ordinamento = intval($_POST['ordinamento'] ?? 0);
|
||||
$badge = $_POST['badge_color'] ?? '#6c757d';
|
||||
$line = $_POST['line_color'] ?? '#e9ecef';
|
||||
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['success' => false, 'message' => 'ID non valido']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($nome === '') {
|
||||
echo json_encode(['success' => false, 'message' => 'Il nome è obbligatorio']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Update
|
||||
$stmt = $pdo->prepare("
|
||||
UPDATE production_status
|
||||
SET nome = :nome,
|
||||
ordinamento = :ordinamento,
|
||||
badge_color = :badge,
|
||||
line_color = :line
|
||||
WHERE id = :id
|
||||
");
|
||||
|
||||
$stmt->execute([
|
||||
':nome' => $nome,
|
||||
':ordinamento' => $ordinamento,
|
||||
':badge' => $badge,
|
||||
':line' => $line,
|
||||
':id' => $id
|
||||
]);
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} catch (Exception $e) {
|
||||
echo json_encode(['success' => false, 'message' => $e->getMessage()]);
|
||||
}
|
||||
Reference in New Issue
Block a user