update entra id
This commit is contained in:
@@ -1,26 +1,48 @@
|
||||
<?php include('../include/headscript.php'); ?>
|
||||
<?php include("../class/company.php");
|
||||
<?php
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
include('../include/headscript.php');
|
||||
include("../class/company.php");
|
||||
require_once '../class/db-functions.php'; // Includo DBHandlerSelect
|
||||
|
||||
$page = 'reports'; // Nome della pagina specifica per salvare/ripristinare le impostazioni
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
$page = 'reports';
|
||||
|
||||
// Inizializzo la connessione con DBHandlerSelect
|
||||
$dbHandler = new DBHandlerSelect();
|
||||
$conn = $dbHandler->getConnection();
|
||||
|
||||
// Validazione iduserlogin
|
||||
if (!isset($iduserlogin) || !is_numeric($iduserlogin)) {
|
||||
die("Errore: ID utente non valido.");
|
||||
}
|
||||
|
||||
// Recupera le impostazioni delle colonne e dell'ordinamento dal database
|
||||
$query = "SELECT column_visibility, column_order FROM user_table_settings WHERE iduser = ? AND page = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("is", $iduserlogin, $page);
|
||||
$stmt->execute();
|
||||
$stmt->bind_result($column_visibility, $column_order);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
try {
|
||||
$stmt = $conn->prepare("SELECT column_visibility, column_order FROM user_table_settings WHERE iduser = :iduser AND page = :page");
|
||||
$stmt->execute(['iduser' => $iduserlogin, 'page' => $page]);
|
||||
$userSettings = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
$column_visibility = $userSettings['column_visibility'] ?? null;
|
||||
$column_order = $userSettings['column_order'] ?? null;
|
||||
} catch (PDOException $e) {
|
||||
error_log("Errore query user_table_settings: " . $e->getMessage());
|
||||
die("Errore nel caricamento delle impostazioni.");
|
||||
}
|
||||
|
||||
// Query per ottenere tutti i report e i prodotti associati
|
||||
$query = "
|
||||
SELECT r.*, p.products_refnumber, p.products_description
|
||||
FROM reports r
|
||||
LEFT JOIN products p ON r.idproducts = p.idproducts";
|
||||
$result = $conn->query($query);
|
||||
try {
|
||||
$stmt = $conn->prepare("
|
||||
SELECT r.idreports, r.reportsNumberLab, r.reportDateIn, r.reportsRating, p.products_refnumber, p.products_description
|
||||
FROM reports r
|
||||
LEFT JOIN products p ON r.idproducts = p.idproducts
|
||||
");
|
||||
$stmt->execute();
|
||||
$reports = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
} catch (PDOException $e) {
|
||||
error_log("Errore query reports: " . $e->getMessage());
|
||||
die("Errore nel caricamento dei report: " . htmlspecialchars($e->getMessage(), ENT_QUOTES, 'UTF-8'));
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -31,8 +53,8 @@ $result = $conn->query($query);
|
||||
<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">
|
||||
<title>Reports</title>
|
||||
<link rel="shortcut icon" href="../assets/images/favicon.ico">
|
||||
|
||||
<!-- Includi prima jQuery -->
|
||||
<!-- Includi prima jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
||||
@@ -52,15 +74,8 @@ $result = $conn->query($query);
|
||||
<!-- ColReorder JS -->
|
||||
<script src="https://cdn.datatables.net/colreorder/1.5.6/js/dataTables.colReorder.min.js"></script>
|
||||
|
||||
|
||||
<!-- Altri riferimenti al CSS e JS -->
|
||||
<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 rel="shortcut icon" href="../assets/images/favicon.ico">
|
||||
<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">
|
||||
<?php include('../products/cssinclude.php'); ?>
|
||||
</head>
|
||||
|
||||
<style>
|
||||
@@ -89,7 +104,6 @@ $result = $conn->query($query);
|
||||
</style>
|
||||
|
||||
<body class="fixed-left">
|
||||
|
||||
<div id="wrapper">
|
||||
<?php include('../include/navigationbar.php'); ?>
|
||||
<div class="content-page">
|
||||
@@ -97,7 +111,6 @@ $result = $conn->query($query);
|
||||
<?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">
|
||||
@@ -105,13 +118,12 @@ $result = $conn->query($query);
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="reportsTable" class="table table-striped table-hover" data-user="<?php echo $iduserlogin; ?>" data-table="reports">
|
||||
<table id="reportsTable" class="table table-striped table-hover" data-user="<?php echo htmlspecialchars($iduserlogin, ENT_QUOTES, 'UTF-8'); ?>" data-table="reports">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Report Number</th>
|
||||
@@ -123,31 +135,29 @@ $result = $conn->query($query);
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($row = $result->fetch_assoc()) { ?>
|
||||
<tr data-reportid="<?php echo $row['idreports']; ?>">
|
||||
<td><?php echo $row['reportsNumberLab']; ?></td>
|
||||
<td><?php echo $row['reportDateIn']; ?></td>
|
||||
<td><?php echo $row['products_refnumber']; ?></td>
|
||||
<td><?php echo $row['products_description']; ?></td>
|
||||
<td><?php echo $row['reportsRating']; ?></td>
|
||||
<?php foreach ($reports as $row) { ?>
|
||||
<tr data-reportid="<?php echo htmlspecialchars($row['idreports'], ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<td><?php echo htmlspecialchars($row['reportsNumberLab'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['reportDateIn'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['products_refnumber'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['products_description'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td><?php echo htmlspecialchars($row['reportsRating'] ?? '', ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
<td>
|
||||
<button class="btn btn-info btn-sm show-analysis">Analysis</button>
|
||||
<a class="btn btn-primary btn-sm report-details" href="../products/reportdetails.php?idreports=<?php echo $row['idreports']; ?>">Details</a>
|
||||
<a class="btn btn-primary btn-sm report-details" href="../products/reportdetails.php?idreports=<?php echo htmlspecialchars($row['idreports'], ENT_QUOTES, 'UTF-8'); ?>">Details</a>
|
||||
</td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div><!-- container -->
|
||||
</div><!-- Page content Wrapper -->
|
||||
</div><!-- content -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php include('../include/footer.php'); ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -155,13 +165,10 @@ $result = $conn->query($query);
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
var hasUserInteracted = false;
|
||||
|
||||
// Recupera le impostazioni salvate dal server prima di inizializzare DataTables
|
||||
var columnSettings = {};
|
||||
var userId = $('#reportsTable').data('user');
|
||||
var tableName = $('#reportsTable').data('table');
|
||||
|
||||
// Recupera le impostazioni salvate
|
||||
$.ajax({
|
||||
url: 'get_user_table_settings_reports.php',
|
||||
method: 'POST',
|
||||
@@ -179,7 +186,6 @@ $result = $conn->query($query);
|
||||
}
|
||||
});
|
||||
|
||||
// Inizializza DataTables con ColReorder, filtri e ColVis
|
||||
var table = $('#reportsTable').DataTable({
|
||||
responsive: true,
|
||||
pageLength: 50,
|
||||
@@ -189,16 +195,15 @@ $result = $conn->query($query);
|
||||
colReorder: {
|
||||
order: columnSettings && columnSettings.ColReorder ? columnSettings.ColReorder : null
|
||||
},
|
||||
dom: 'Bfrtip', // Integra i bottoni
|
||||
dom: 'Bfrtip',
|
||||
buttons: [{
|
||||
extend: 'colvis',
|
||||
text: 'Select Columns',
|
||||
collectionLayout: 'fixed four-column',
|
||||
postfixButtons: ['colvisRestore'],
|
||||
columns: ':not(:last-child)' // Escludi l'ultima colonna (Actions)
|
||||
columns: ':not(:last-child)'
|
||||
}],
|
||||
initComplete: function() {
|
||||
// Applica le impostazioni di visibilità delle colonne, se presenti
|
||||
if (columnSettings && columnSettings.columns) {
|
||||
console.log("Applico visibilità colonne:", columnSettings.columns);
|
||||
this.api().columns().every(function(index) {
|
||||
@@ -206,13 +211,10 @@ $result = $conn->query($query);
|
||||
column.visible(columnSettings.columns[index].visible, false);
|
||||
});
|
||||
}
|
||||
|
||||
this.api().columns.adjust().draw(false);
|
||||
|
||||
// Aggiungi i filtri per ogni colonna (eccetto la colonna delle azioni)
|
||||
this.api().columns().every(function() {
|
||||
var column = this;
|
||||
if (column.index() !== 5) { // Escludi la colonna "Action"
|
||||
if (column.index() !== 5) {
|
||||
$('<input class="form-control form-control-sm" type="text" placeholder="Search"/>')
|
||||
.appendTo($(column.header()))
|
||||
.on('keyup change clear', function() {
|
||||
@@ -245,7 +247,6 @@ $result = $conn->query($query);
|
||||
}
|
||||
});
|
||||
|
||||
// Imposta il flag `hasUserInteracted` quando l'utente modifica qualcosa (colonne o riordina)
|
||||
table.on('column-reorder', function() {
|
||||
hasUserInteracted = true;
|
||||
console.log("Colonne riordinate");
|
||||
@@ -256,7 +257,6 @@ $result = $conn->query($query);
|
||||
console.log("Visibilità colonna cambiata");
|
||||
});
|
||||
|
||||
// Gestione del click su "Analysis" per visualizzare la tabella child con le analisi
|
||||
$('#reportsTable').on('click', '.show-analysis', function() {
|
||||
var tr = $(this).closest('tr');
|
||||
var reportId = tr.data('reportid');
|
||||
@@ -288,8 +288,8 @@ $result = $conn->query($query);
|
||||
button.prop('disabled', false);
|
||||
button.html('Analysis');
|
||||
},
|
||||
error: function() {
|
||||
Swal.fire('Error!', 'There was an error loading the analysis.', 'error');
|
||||
error: function(xhr) {
|
||||
Swal.fire('Errore!', xhr.status === 404 ? 'Risorsa non trovata.' : 'Errore nel caricamento delle analisi.', 'error');
|
||||
button.prop('disabled', false);
|
||||
button.html('Analysis');
|
||||
}
|
||||
@@ -304,17 +304,18 @@ $result = $conn->query($query);
|
||||
|
||||
$.each(parsedData, function(index, analysis) {
|
||||
var ratingClass = '';
|
||||
if (analysis.finalRating === 'FAIL') {
|
||||
var ratingValue = (analysis.finalRating || '').toUpperCase();
|
||||
if (ratingValue === 'FAIL') {
|
||||
ratingClass = 'bg-danger text-white';
|
||||
} else if (analysis.finalRating === 'PASS') {
|
||||
} else if (ratingValue === 'PASS') {
|
||||
ratingClass = 'bg-success text-white';
|
||||
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A' || analysis.finalRating === 'DATA') {
|
||||
} else if (ratingValue === '//' || ratingValue === 'N/A' || ratingValue === 'DATA') {
|
||||
ratingClass = 'bg-warning text-dark';
|
||||
}
|
||||
|
||||
html += '<tr>';
|
||||
html += '<td>' + (analysis.name ? analysis.name : 'N/A') + '</td>';
|
||||
html += '<td class="' + ratingClass + '">' + (analysis.finalRating ? analysis.finalRating : 'N/A') + '</td>';
|
||||
html += '<td class="' + ratingClass + '">' + (ratingValue || 'N/A') + '</td>';
|
||||
html += '</tr>';
|
||||
});
|
||||
|
||||
@@ -323,10 +324,6 @@ $result = $conn->query($query);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user