update historical trf and navbar
This commit is contained in:
parent
22e4e652b5
commit
06dd7883c2
64
public/userarea/delete_record.php
Normal file
64
public/userarea/delete_record.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
// Enable errors for debugging
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
ini_set('log_errors', 1);
|
||||
ini_set('error_log', __DIR__ . '/delete_record_debug.log');
|
||||
|
||||
// Log iniziale
|
||||
error_log("Inizio cancellazione record alle " . date('Y-m-d H:i:s'));
|
||||
|
||||
// Includi il file di configurazione del database
|
||||
include('include/headscript.php');
|
||||
|
||||
// Ricevi l'ID dalla richiesta POST
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$iddatadb = isset($input['id']) ? intval($input['id']) : 0;
|
||||
|
||||
if ($iddatadb <= 0) {
|
||||
http_response_code(400);
|
||||
echo json_encode(['success' => false, 'message' => 'ID non valido']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Connessione al database
|
||||
try {
|
||||
$db = DBHandlerSelect::getInstance();
|
||||
$pdo = $db->getConnection();
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['success' => false, 'message' => 'Errore di connessione al database: ' . $e->getMessage()]);
|
||||
error_log("Errore di connessione al database: " . $e->getMessage());
|
||||
exit;
|
||||
}
|
||||
|
||||
// Inizia una transazione
|
||||
$pdo->beginTransaction();
|
||||
|
||||
try {
|
||||
// Elimina i dettagli associati dal tavolo import_data_details
|
||||
$stmt = $pdo->prepare("DELETE FROM import_data_details WHERE id = ?");
|
||||
$stmt->execute([$iddatadb]);
|
||||
|
||||
// Elimina il record principale dal tavolo datadb
|
||||
$stmt = $pdo->prepare("DELETE FROM datadb WHERE iddatadb = ?");
|
||||
$stmt->execute([$iddatadb]);
|
||||
|
||||
// Verifica se il record è stato eliminato
|
||||
if ($stmt->rowCount() > 0) {
|
||||
$pdo->commit();
|
||||
echo json_encode(['success' => true, 'message' => 'Record eliminato con successo']);
|
||||
error_log("Record con iddatadb=$iddatadb eliminato con successo");
|
||||
} else {
|
||||
$pdo->rollBack();
|
||||
http_response_code(404);
|
||||
echo json_encode(['success' => false, 'message' => 'Record non trovato']);
|
||||
error_log("Record con iddatadb=$iddatadb non trovato");
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$pdo->rollBack();
|
||||
http_response_code(500);
|
||||
echo json_encode(['success' => false, 'message' => 'Errore durante la cancellazione: ' . $e->getMessage()]);
|
||||
error_log("Errore durante la cancellazione del record con iddatadb=$iddatadb: " . $e->getMessage());
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -126,7 +126,11 @@ error_log("Loaded template: " . print_r($template, true));
|
||||
<div class="page-wrapper">
|
||||
<div class="page-content">
|
||||
<?php include('top_stat_widget.php'); ?>
|
||||
|
||||
<div class="mb-3 text">
|
||||
<a href="historical_trf.php?id=<?= $id ?>&status=i" class="btn btn-warning me-2">Imported (i)</a>
|
||||
<a href="historical_trf.php?id=<?= $id ?>&status=P" class="btn btn-primary me-2">In Progress (P)</a>
|
||||
<a href="historical_trf.php?id=<?= $id ?>&status=l" class="btn btn-success">To LIMS (l)</a>
|
||||
</div>
|
||||
<div class="card radius-10">
|
||||
<div class="card-header">
|
||||
<div class="d-flex align-items-center">
|
||||
@ -136,6 +140,7 @@ error_log("Loaded template: " . print_r($template, true));
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<!-- Form per caricare il file -->
|
||||
<form id="uploadForm" enctype="multipart/form-data" class="mb-4">
|
||||
|
||||
@ -24,8 +24,7 @@
|
||||
</li> -->
|
||||
<li> <a href="import_dashboard.php"><i class='bx bx-radio-circle'></i>XLS Import</a>
|
||||
</li>
|
||||
<li> <a href="historical_trf.php"><i class='bx bx-radio-circle'></i>Historical TRF</a>
|
||||
</li>
|
||||
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user