fixed import fogli di lavoro and disegni tecnici
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
ob_start();
|
||||
include('include/headscript.php');
|
||||
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
|
||||
function jsonOut($success, $message = '')
|
||||
{
|
||||
if (ob_get_length()) ob_clean();
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode(['success' => $success, 'message' => $message]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = (int)($_POST['id'] ?? 0);
|
||||
$value = ($_POST['is_disegno'] ?? '0') === '1' ? 1 : 0;
|
||||
|
||||
if ($id <= 0) {
|
||||
jsonOut(false, 'ID allegato non valido');
|
||||
}
|
||||
|
||||
try {
|
||||
$st = $pdo->prepare("UPDATE matrice_attachments SET is_disegno = ? WHERE id = ?");
|
||||
$st->execute([$value, $id]);
|
||||
jsonOut(true, $value ? 'Segnato come disegno tecnico' : 'Rimosso dai disegni tecnici');
|
||||
} catch (Throwable $e) {
|
||||
jsonOut(false, 'Errore: ' . $e->getMessage());
|
||||
}
|
||||
Reference in New Issue
Block a user