added intervnetion page
This commit is contained in:
parent
e7ea3ba909
commit
da95ee6c2f
41
public/userarea/importify/delete_json.php
Normal file
41
public/userarea/importify/delete_json.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// Include connection and session files
|
||||
include('../include/headscript.php');
|
||||
include("../class/company.php");
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
// Verifica se l'id è stato passato tramite POST
|
||||
// Verifica se l'id è stato passato tramite POST
|
||||
if (isset($_POST['id'])) {
|
||||
$id = intval($_POST['id']); // Assicura che l'id sia un intero
|
||||
|
||||
// Connessione al database
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
|
||||
// Verifica della connessione
|
||||
if ($conn->connect_error) {
|
||||
echo "error"; // Errore di connessione
|
||||
exit;
|
||||
}
|
||||
|
||||
// Prepara la query di cancellazione
|
||||
$sql = "DELETE FROM temp_json_queue WHERE id = ?";
|
||||
|
||||
// Utilizza una prepared statement per evitare SQL injection
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
// Esegui la query e verifica il risultato
|
||||
if ($stmt->execute()) {
|
||||
// Imposta header per evitare output non necessari
|
||||
header('Content-Type: text/plain');
|
||||
echo "success"; // Cancellazione riuscita
|
||||
} else {
|
||||
echo "error"; // Errore durante la cancellazione
|
||||
}
|
||||
|
||||
// Chiude la connessione e la prepared statement
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
} else {
|
||||
echo "error"; // Errore: nessun ID passato
|
||||
}
|
||||
148
public/userarea/importify/interventionlist.php
Normal file
148
public/userarea/importify/interventionlist.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php include('../include/headscript.php'); ?>
|
||||
<?php include("../class/company.php"); ?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||
<?php include('../include/seo.php'); ?>
|
||||
|
||||
<link rel="shortcut icon" href="../assets/images/favicon.ico">
|
||||
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||
<link href="../assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||
<link href="../assets/css/style.css" rel="stylesheet" type="text/css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/boxicons@2.0.7/css/boxicons.min.css" rel="stylesheet">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.css">
|
||||
<script src="../assets/js/jquery.min.js"></script>
|
||||
<style>
|
||||
/* Custom styles here */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('../include/navigationbar.php'); ?>
|
||||
|
||||
<div class="content-page">
|
||||
<div class="content">
|
||||
|
||||
<?php include('../include/topbar.php'); ?>
|
||||
|
||||
<div class="page-content-wrapper ">
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="page-title-box">
|
||||
<h4 class="page-title">Intervention necessary</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h5 class="header-title pb-3 mt-0">Records</h5>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-custom">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>UUID</th>
|
||||
<th>Lab ID</th>
|
||||
<th>Received At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
// Database connection
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
if ($conn->connect_error) {
|
||||
die("Connection failed: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Query for rows with processed = 2
|
||||
$sql = "SELECT * FROM temp_json_queue WHERE processed = 2";
|
||||
$result = $conn->query($sql);
|
||||
|
||||
if ($result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<tr>";
|
||||
echo "<td>" . $row['id'] . "</td>";
|
||||
echo "<td>" . $row['uuid'] . "</td>";
|
||||
echo "<td>" . $row['lab_id'] . "</td>";
|
||||
echo "<td>" . $row['received_at'] . "</td>";
|
||||
echo "<td>
|
||||
<a href='importjson.php?id=" . $row['id'] . "' class='btn btn-success btn-sm'>Import</a>
|
||||
<button class='btn btn-danger btn-sm' onclick='deleteRow(" . $row['id'] . ")'><i class='bx bx-trash'></i></button>
|
||||
</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
} else {
|
||||
echo "<tr><td colspan='5'>No records found</td></tr>";
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div> <!-- container -->
|
||||
</div> <!-- Page content Wrapper -->
|
||||
</div> <!-- content -->
|
||||
|
||||
<?php include('../include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function deleteRow(id) {
|
||||
Swal.fire({
|
||||
title: 'Are you sure?',
|
||||
text: "This action cannot be undone!",
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Yes, delete it!',
|
||||
cancelButtonText: 'No, cancel!',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
$.ajax({
|
||||
url: 'delete_json.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response); // Controlla cosa viene restituito
|
||||
if (response.trim() == "success") {
|
||||
Swal.fire('Deleted!', 'The record has been deleted.', 'success').then(() => {
|
||||
window.location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire('Error!', 'There was a problem deleting the record.', 'error');
|
||||
}
|
||||
},
|
||||
|
||||
error: function() {
|
||||
Swal.fire('Error!', 'Could not reach the server.', 'error');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Loading…
x
Reference in New Issue
Block a user