Update 18-09-2024 adding NAS

This commit is contained in:
Claudio 2024-09-18 11:14:23 +02:00
parent 28a074a7e7
commit 225d1f3531
32 changed files with 5968 additions and 520 deletions

View File

@ -0,0 +1,16 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['nameanalysisvoc'];
$kind = $_POST['kindanalysisvoc'];
$conn = new mysqli($servername, $username, $password, $database);
$query = "INSERT INTO analysisvocabulary (nameanalysisvoc, kindanalysisvoc, preferred) VALUES ('$name', '$kind', 'Y')";
if ($conn->query($query)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => true]);
}
}
?>

View File

@ -1,79 +1,79 @@
<?php include('../include/headscript.php'); ?>
<?php
$type = $_POST['type'];
$analysis_name = $_POST['analysis_name'];
$str_name = $_POST['str_name'];
$str_kind = $_POST['str_kind'];
$type = $_POST['type'];
$analysis_name = $_POST['analysis_name'];
$str_name = $_POST['str_name'];
$str_kind = $_POST['str_kind'];
$analysis_refid = 0;
if($analysis_name != "") {
$arr_analysis_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
$arr_analysis_refdata->setQuery("SELECT * FROM analysisvocabulary where nameanalysisvoc like '$analysis_name'");
$arr_analysis_refdata->execute();
$arr_analysis_ref = $arr_analysis_refdata->Results;
if(count($arr_analysis_ref) == 0) {
$analysis_refid = $arr_analysis_ref[0]['refid'];
}
$analysis_refid = 0;
if ($analysis_name != "") {
$arr_analysis_refdata = new WA_MySQLi_RS("rsl", $repnew, 0);
$arr_analysis_refdata->setQuery("SELECT * FROM analysisvocabulary where nameanalysisvoc like '$analysis_name'");
$arr_analysis_refdata->execute();
$arr_analysis_ref = $arr_analysis_refdata->Results;
if (count($arr_analysis_ref) > 0) {
$analysis_refid = $arr_analysis_ref[0]['refid'];
}
}
if ($type == 0) {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "`compundsvocabulary`";
$InsertQuery->bindColumn("namecompoundsvocabulary", "s", "" . $str_name, "WA_DEFAULT");
$InsertQuery->bindColumn("cascompoundvocabulary", "s", "" . $str_kind, "WA_DEFAULT");
$InsertQuery->bindColumn("analysisrefid", "i", "" . $analysis_refid, "WA_DEFAULT");
$InsertQuery->bindColumn("refid", "i", "0", "WA_DEFAULT");
$InsertQuery->bindColumn("preferred", "s", "Y", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$inserted_query = new WA_MySQLi_RS("getquery", $repnew, 0);
$inserted_query->setQuery("SELECT * FROM compundsvocabulary WHERE namecompoundsvocabulary like '$str_name' and preferred like 'Y' and refid=0");
$inserted_query->execute();
$inserted_data = $inserted_query->Results;
$ref_id = 0;
if (count($inserted_data) > 0) {
$ref_id = $inserted_data[0]['idcompoundsvocabulary'];
}
if($type == 0) {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "`compundsvocabulary`";
$InsertQuery->bindColumn("namecompoundsvocabulary", "s", "" . $str_name, "WA_DEFAULT");
$InsertQuery->bindColumn("cascompoundvocabulary", "s", "" .$str_kind, "WA_DEFAULT");
$InsertQuery->bindColumn("analysisrefid", "i", "".$analysis_refid, "WA_DEFAULT");
$InsertQuery->bindColumn("refid", "i", "0", "WA_DEFAULT");
$InsertQuery->bindColumn("preferred", "s", "Y", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
$inserted_query = new WA_MySQLi_RS("getquery", $repnew, 0);
$inserted_query->setQuery("SELECT * FROM compundsvocabulary WHERE namecompoundsvocabulary like '$str_name' and preferred like 'Y' and refid=0");
$inserted_query->execute();
$inserted_data = $inserted_query->Results;
$ref_id = 0;
if(count($inserted_data) > 0) {
$ref_id = $inserted_data[0]['idcompoundsvocabulary'];
}
if($ref_id > 0) {
$UpdateQuery = new WA_MySQLi_Query($repnew);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "`compundsvocabulary`";
$UpdateQuery->bindColumn("refid", "i", "" . $ref_id . "", "WA_DEFAULT");
$UpdateQuery->addFilter("idcompoundsvocabulary", "=", "i", "" . ($ref_id) . "");
$UpdateQuery->execute();
die(json_encode(array(
'code' => "success",
'info' => array(
'name' => $str_name,
'kind' => $str_kind,
'ref_id' => $ref_id,
)
)));
} else {
die("error");
}
} else {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "`compundsvocabulary`";
$InsertQuery->bindColumn("namecompoundsvocabulary", "s", "" . $str_name, "WA_DEFAULT");
$InsertQuery->bindColumn("analysisrefid", "i", "".$analysis_refid, "WA_DEFAULT");
$InsertQuery->bindColumn("refid", "i", $type, "WA_DEFAULT");
$InsertQuery->bindColumn("preferred", "s", "N", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
if ($ref_id > 0) {
$UpdateQuery = new WA_MySQLi_Query($repnew);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "`compundsvocabulary`";
$UpdateQuery->bindColumn("refid", "i", "" . $ref_id . "", "WA_DEFAULT");
$UpdateQuery->addFilter("idcompoundsvocabulary", "=", "i", "" . ($ref_id) . "");
$UpdateQuery->execute();
die(json_encode(array(
'code' => "success",
'info' => array(
'name' => $str_name,
'kind' => $str_kind,
'ref_id' => $type,
'ref_id' => $ref_id,
)
)));
}
} else {
die("error");
}
} else {
$InsertQuery = new WA_MySQLi_Query($repnew);
$InsertQuery->Action = "insert";
$InsertQuery->Table = "`compundsvocabulary`";
$InsertQuery->bindColumn("namecompoundsvocabulary", "s", "" . $str_name, "WA_DEFAULT");
$InsertQuery->bindColumn("analysisrefid", "i", "" . $analysis_refid, "WA_DEFAULT");
$InsertQuery->bindColumn("refid", "i", $type, "WA_DEFAULT");
$InsertQuery->bindColumn("preferred", "s", "N", "WA_DEFAULT");
$InsertQuery->saveInSession("");
$InsertQuery->execute();
die(json_encode(array(
'code' => "success",
'info' => array(
'name' => $str_name,
'kind' => $str_kind,
'ref_id' => $type,
)
)));
}

View File

@ -0,0 +1,19 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['nameanalysisvoc'];
$refid = $_POST['refid'];
$preferred = $_POST['preferred'];
$query = "INSERT INTO analysisvocabulary (nameanalysisvoc, refid, preferred) VALUES ('$name', $refid, '$preferred')";
if ($conn->query($query)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => $conn->error]);
}
}

View File

@ -0,0 +1,19 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['nameanalysisvoc'];
$refid = $_POST['refid'];
$preferred = $_POST['preferred'];
$query = "INSERT INTO analysisvocabulary (nameanalysisvoc, refid, preferred) VALUES ('$name', $refid, '$preferred')";
if ($conn->query($query)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => $conn->error]);
}
}

View File

@ -0,0 +1,504 @@
<?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'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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>
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
<script src="../assets/plugins/select2/select2.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.js"></script>
<style>
.width-100 {
width: 100%;
}
.flex_center {
display: flex;
align-items: center;
}
.mg_none {
margin: 0 !important;
}
.hidden {
display: none !important;
}
.table-custom tr {
height: 40px;
line-height: 40px;
}
#ajax_preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 9999999;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
.padding_none {
padding: 0 !important;
}
.select2-container--open {
z-index: 9999;
}
</style>
</head>
<body class="fixed-left">
<!-- Loader
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div> -->
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<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">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">Importify</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Importify: <?php echo $dashboard; ?></h5>
<br><br>
<div class="table-responsive">
<!-- Button for adding new analysis -->
<button id="add-analysis" class="btn btn-primary mb-3">Add New Analysis</button>
<!-- Form for adding new analysis (hidden by default) -->
<div id="add-analysis-form" class="hidden">
<form id="analysisForm">
<div class="form-row">
<input type="text" name="nameanalysisvoc" class="form-control" placeholder="Analysis Name" required>
<select name="kindanalysisvoc" class="form-control">
<option value="">Type</option>
<option value="Type1">Type1</option>
<option value="Type2">Type2</option>
</select>
<button type="submit" class="btn btn-success">Save</button>
</div>
</form>
</div>
<!-- Table of analysis -->
<!-- Table of analysis -->
<table id="analysisTable" class="table table-striped table-hover">
<thead>
<tr>
<th>Analysis Name</th>
<th>Type</th>
<th>Actions</th>
</tr>
</thead>
<tbody id="analysis-list">
<?php
$conn = new mysqli($servername, $username, $password, $database);
$query = "SELECT * FROM analysisvocabulary WHERE preferred = 'Y'";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
echo '<tr class="main-analysis" data-id="' . $row['idanalysisvocabulary'] . '">';
echo '<td>' . $row['nameanalysisvoc'] . '</td>';
echo '<td>' . $row['kindanalysisvoc'] . '</td>';
echo '<td>
<button class="btn btn-info btn-sm show-synonyms">Synonyms</button>
<button class="btn btn-primary btn-sm add-synonym">Add Synonym</button>
<button class="btn btn-secondary btn-sm show-components" data-id="' . $row['idanalysisvocabulary'] . '">Components</button>
<button class="btn btn-danger btn-sm delete-analysis" data-id="' . $row['idanalysisvocabulary'] . '"><i class="bx bx-trash"></i> Delete</button>
</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
<input id="f_csv" type="file" name="f_csv" style="display: none" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv">
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
// Inizializzazione di DataTables con filtraggio automatico
$('#analysisTable').DataTable();
// Toggle form visibility for adding a new analysis
$('#add-analysis').on('click', function() {
$('#add-analysis-form').toggleClass('hidden');
});
// Handle form submission for adding a new analysis
$('#analysisForm').on('submit', function(e) {
e.preventDefault();
var formData = $(this).serialize();
$.ajax({
type: 'POST',
url: 'add_analysis.php',
data: formData,
success: function(response) {
Swal.fire('Success!', 'Analysis added successfully.', 'success');
location.reload(); // Optionally reload the page to refresh the table
},
error: function() {
Swal.fire('Error!', 'There was an error adding the analysis.', 'error');
}
});
});
// Funzione per cancellare l'analisi principale con tutti i sinonimi
$('#analysisTable').on('click', '.delete-analysis', function() {
var analysisId = $(this).data('id');
var row = $(this).closest('tr');
var table = $('#analysisTable').DataTable(); // Riferimento alla DataTable
// SweetAlert per conferma
Swal.fire({
title: 'Are you sure?',
text: "This will permanently delete the analysis and all its synonyms!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, delete everything!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: 'delete_analysis.php',
type: 'POST',
data: {
idanalysisvocabulary: analysisId
},
success: function(response) {
Swal.fire('Deleted!', 'The analysis and all its synonyms have been deleted.', 'success');
// Rimuovi la riga principale
table.row(row).remove().draw();
// Rimuovi eventuali righe child (sinonimi) se sono visibili
var childRows = row.nextUntil('.main-analysis'); // Seleziona tutte le righe successive finché non incontri un'altra analisi principale
childRows.each(function() {
if ($(this).hasClass('child')) {
table.row($(this)).remove().draw(); // Rimuove le righe dei sinonimi
}
});
},
error: function() {
Swal.fire('Error!', 'There was an error deleting the analysis.', 'error');
}
});
}
});
});
// Gestione del click su "Synonyms" per visualizzare la tabella child
$('#analysisTable').on('click', '.show-synonyms', function() {
var tr = $(this).closest('tr');
var analysisId = tr.data('id');
var row = $('#analysisTable').DataTable().row(tr);
var button = $(this); // Riferimento al pulsante
// Disabilita il pulsante e aggiunge un indicatore di caricamento
button.prop('disabled', true);
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
// Se la riga child è già aperta, la chiude
if (row.child.isShown()) {
row.child.hide();
tr.removeClass('shown');
// Riabilita il pulsante
button.prop('disabled', false);
button.html('Synonyms');
} else {
// Chiamata AJAX per ottenere i sinonimi
$.ajax({
url: 'get_synonyms.php',
type: 'POST',
data: {
idanalysisvocabulary: analysisId
},
success: function(data) {
// Visualizza la tabella child con i sinonimi
row.child(formatSynonyms(data)).show();
tr.addClass('shown');
},
complete: function() {
// Riabilita il pulsante e ripristina il testo originale
button.prop('disabled', false);
button.html('Synonyms');
},
error: function() {
Swal.fire('Error!', 'There was an error loading the synonyms.', 'error');
button.prop('disabled', false);
button.html('Synonyms');
}
});
}
});
// Funzione per formattare i sinonimi nella tabella child
function formatSynonyms(data) {
var html = '<table class="table table-bordered table-striped child-table" style="background-color: #f9f9f9;">';
html += '<thead><tr><th>Synonym Name</th><th>Actions</th></tr></thead>';
html += '<tbody>';
$.each(JSON.parse(data), function(index, synonym) {
html += '<tr><td>' + synonym.nameanalysisvoc + '</td>';
html += '<td><button class="btn btn-danger btn-sm delete-synonym" data-id="' + synonym.idanalysisvocabulary + '"><i class="bx bx-trash"></i></button></td></tr>';
});
html += '</tbody></table>';
return html;
}
// Funzione per cancellare il sinonimo con SweetAlert
$('#analysisTable').on('click', '.delete-synonym', function() {
var synonymId = $(this).data('id');
var row = $(this).closest('tr');
Swal.fire({
title: 'Are you sure?',
text: "This will permanently delete the synonym!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: 'delete_synonym.php',
type: 'POST',
data: {
idanalysisvocabulary: synonymId
},
success: function(response) {
Swal.fire('Deleted!', 'The synonym has been deleted.', 'success');
row.remove(); // Rimuove la riga dalla tabella
},
error: function() {
Swal.fire('Error!', 'There was an error deleting the synonym.', 'error');
}
});
}
});
});
// Funzione per cancellare l'analisi principale con tutti i sinonimi
$('#analysisTable').on('click', '.delete-analysis', function() {
var analysisId = $(this).data('id');
var row = $(this).closest('tr');
Swal.fire({
title: 'Are you sure?',
text: "This will permanently delete the analysis and all its synonyms!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, delete everything!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: 'delete_analysis.php',
type: 'POST',
data: {
idanalysisvocabulary: analysisId
},
success: function(response) {
Swal.fire('Deleted!', 'The analysis and all its synonyms have been deleted.', 'success');
row.remove(); // Rimuove la riga dalla tabella
},
error: function() {
Swal.fire('Error!', 'There was an error deleting the analysis.', 'error');
}
});
}
});
});
// Funzione per mostrare il form di aggiunta sinonimo sotto la riga dell'analisi
$('#analysisTable').on('click', '.add-synonym', function() {
var tr = $(this).closest('tr');
var analysisId = tr.data('id');
if (tr.next('.synonym-form').length) {
tr.next('.synonym-form').toggle();
} else {
var formHtml = '<tr class="synonym-form"><td colspan="3">';
formHtml += '<form class="add-synonym-form">';
formHtml += '<input type="text" name="synonym_name" class="form-control" placeholder="Synonym Name" required>';
formHtml += '<button type="submit" class="btn btn-success btn-sm mt-2">Save</button>';
formHtml += '</form></td></tr>';
tr.after(formHtml);
}
});
// Invia il form di aggiunta sinonimo
$('#analysisTable').on('submit', '.add-synonym-form', function(e) {
e.preventDefault();
var form = $(this);
var synonymName = form.find('input[name="synonym_name"]').val();
var analysisId = form.closest('tr').prev().data('id');
$.ajax({
url: 'add_synonym.php',
type: 'POST',
data: {
nameanalysisvoc: synonymName,
refid: analysisId,
preferred: 'N'
},
success: function(response) {
Swal.fire('Success!', 'Synonym added successfully.', 'success');
form.closest('.synonym-form').hide(); // Nasconde il form dopo il salvataggio
},
error: function() {
Swal.fire('Error!', 'There was an error adding the synonym.', 'error');
}
});
});
// Gestione del pulsante "Components"
$('#analysisTable').on('click', '.show-components', function() {
var analysisId = $(this).data('id');
window.location.href = 'components.php?analysisrefid=' + analysisId; // Reindirizza alla pagina dei componenti con l'ID dell'analisi
});
});
</script>
<!-- plugin JS -->
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/js/common_helper.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
</body>
</html>

View File

@ -0,0 +1,238 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php"); ?>
<?php
$conn = new mysqli($servername, $username, $password, $database);
$analysisrefid = $_GET['analysisrefid']; // Ottieni l'ID dell'analisi dalla query string
// Recupera i componenti associati all'analisi selezionata
$query = "SELECT * FROM compundsvocabulary WHERE analysisrefid = $analysisrefid AND preferred = 'Y'";
$result = $conn->query($query);
// Recupera il nome dell'analisi
$analysisQuery = "SELECT nameanalysisvoc FROM analysisvocabulary WHERE idanalysisvocabulary = $analysisrefid AND preferred = 'Y'";
$analysisResult = $conn->query($analysisQuery);
$analysisn = $analysisResult->fetch_assoc();
$analysisName = $analysisn['nameanalysisvoc']; // Nome dell'analisi
?>
<!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">
<title>Components</title>
<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 rel="stylesheet" href="https://cdn.jsdelivr.net/npm/sweetalert2@10/dist/sweetalert2.min.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>
<script src="../assets/js/jquery.min.js"></script>
<!-- DataTables CSS -->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
<!-- DataTables JS -->
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.min.js"></script>
</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">Components of Analysis: <?php echo $analysisName; ?></h4>
</div>
</div>
</div>
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<div class="table-responsive">
<!-- Tabella dei componenti -->
<table id="componentsTable" class="table table-striped table-hover">
<thead>
<tr>
<th>Component Name</th>
<th>CAS Number</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php
while ($row = $result->fetch_assoc()) {
echo '<tr data-id="' . $row['idcompoundsvocabulary'] . '">';
echo '<td>' . $row['namecompoundsvocabulary'] . '</td>';
echo '<td>' . $row['cascompoundvocabulary'] . '</td>';
echo '<td>
<button class="btn btn-info btn-sm show-synonyms">Synonyms</button>
<button class="btn btn-danger btn-sm delete-component"><i class="bx bx-trash"></i> Delete</button>
</td>';
echo '</tr>';
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div><!-- container -->
</div><!-- Page content Wrapper -->
</div><!-- content -->
<?php include('../include/footer.php'); ?>
</div>
</div>
<script>
$(document).ready(function() {
// Inizializza DataTables sulla tabella dei componenti
$('#componentsTable').DataTable();
// Gestione del click su "Synonyms" per visualizzare la tabella child
$('#componentsTable').on('click', '.show-synonyms', function() {
var tr = $(this).closest('tr');
var componentId = tr.data('id');
var row = $('#componentsTable').DataTable().row(tr);
var button = $(this); // Riferimento al pulsante
// Disabilita il pulsante e aggiunge un indicatore di caricamento
button.prop('disabled', true);
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
// Se la riga child è già aperta, la chiude
if (row.child.isShown()) {
row.child.hide();
tr.removeClass('shown');
// Riabilita il pulsante
button.prop('disabled', false);
button.html('Synonyms');
} else {
// Chiamata AJAX per ottenere i sinonimi del componente
$.ajax({
url: 'get_component_synonyms.php',
type: 'POST',
data: {
refid: componentId
},
success: function(data) {
// Visualizza i sinonimi come tabella child
row.child(formatSynonyms(data)).show();
tr.addClass('shown');
},
complete: function() {
// Riabilita il pulsante e ripristina il testo originale
button.prop('disabled', false);
button.html('Synonyms');
},
error: function() {
Swal.fire('Error!', 'There was an error loading the synonyms.', 'error');
// Riabilita il pulsante in caso di errore
button.prop('disabled', false);
button.html('Synonyms');
}
});
}
});
// Funzione per formattare i sinonimi nella tabella child
function formatSynonyms(data) {
var html = '<table class="table table-bordered child-table">';
html += '<thead><tr><th>Synonym Name</th><th>Actions</th></tr></thead>';
html += '<tbody>';
$.each(JSON.parse(data), function(index, synonym) {
html += '<tr><td>' + synonym.namecompoundsvocabulary + '</td>';
html += '<td><button class="btn btn-danger btn-sm delete-synonym" data-id="' + synonym.idcompoundsvocabulary + '"><i class="bx bx-trash"></i></button></td></tr>';
});
html += '</tbody></table>';
return html;
}
// Funzione per cancellare un singolo sinonimo
$('#componentsTable').on('click', '.delete-synonym', function() {
var synonymId = $(this).data('id');
var row = $(this).closest('tr');
Swal.fire({
title: 'Are you sure?',
text: "This will permanently delete the synonym!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: 'delete_synonymcomp.php',
type: 'POST',
data: {
idcompoundsvocabulary: synonymId
},
success: function(response) {
Swal.fire('Deleted!', 'The synonym has been deleted.', 'success');
$('#componentsTable').DataTable().row(row).remove().draw(); // Rimuovi la riga del sinonimo dalla tabella
},
error: function() {
Swal.fire('Error!', 'There was an error deleting the synonym.', 'error');
}
});
}
});
});
// Funzione per cancellare il componente principale con i suoi sinonimi
$('#componentsTable').on('click', '.delete-component', function() {
var componentId = $(this).closest('tr').data('id');
Swal.fire({
title: 'Are you sure?',
text: "This will permanently delete the component and all its synonyms!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Yes, delete everything!'
}).then((result) => {
if (result.isConfirmed) {
$.ajax({
url: 'delete_component.php',
type: 'POST',
data: {
idcompoundsvocabulary: componentId
},
success: function(response) {
Swal.fire('Deleted!', 'The component and all its synonyms have been deleted.', 'success');
$('#componentsTable').DataTable().row($(this).closest('tr')).remove().draw(); // Rimuovi la riga dalla tabella
},
error: function() {
Swal.fire('Error!', 'There was an error deleting the component.', 'error');
}
});
}
});
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,21 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$idanalysisvocabulary = $_POST['idanalysisvocabulary'];
// Cancella l'analisi principale
$query1 = "DELETE FROM analysisvocabulary WHERE idanalysisvocabulary = $idanalysisvocabulary";
// Cancella tutti i sinonimi collegati
$query2 = "DELETE FROM analysisvocabulary WHERE refid = $idanalysisvocabulary";
if ($conn->query($query1) && $conn->query($query2)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => true]);
}
}

View File

@ -0,0 +1,18 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
$idcompoundsvocabulary = $_POST['idcompoundsvocabulary'];
// Cancella il componente principale
$query1 = "DELETE FROM compundsvocabulary WHERE idcompoundsvocabulary = $idcompoundsvocabulary";
// Cancella i sinonimi del componente
$query2 = "DELETE FROM compundsvocabulary WHERE refid = $idcompoundsvocabulary";
if ($conn->query($query1) && $conn->query($query2)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => true]);
}

View File

@ -0,0 +1,14 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$idanalysisvocabulary = $_POST['idanalysisvocabulary'];
$conn = new mysqli($servername, $username, $password, $database);
$query = "DELETE FROM analysisvocabulary WHERE idanalysisvocabulary = $idanalysisvocabulary";
if ($conn->query($query)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => true]);
}
}
?>

View File

@ -0,0 +1,17 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$idcompoundsvocabulary = $_POST['idcompoundsvocabulary'];
$query = "DELETE FROM compundsvocabulary WHERE idcompoundsvocabulary = $idcompoundsvocabulary";
if ($conn->query($query)) {
echo json_encode(['success' => true]);
} else {
echo json_encode(['error' => true]);
}
}

View File

@ -0,0 +1,16 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
$refid = $_POST['refid'];
$query = "SELECT * FROM compundsvocabulary WHERE refid = $refid AND preferred = 'N'";
$result = $conn->query($query);
$synonyms = [];
while ($row = $result->fetch_assoc()) {
$synonyms[] = $row;
}
echo json_encode($synonyms);

View File

@ -0,0 +1,16 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$idanalysisvocabulary = $_POST['idanalysisvocabulary'];
$conn = new mysqli($servername, $username, $password, $database);
$query = "SELECT idanalysisvocabulary, nameanalysisvoc FROM analysisvocabulary WHERE refid = $idanalysisvocabulary AND preferred = 'N'";
$result = $conn->query($query);
$synonyms = [];
while ($row = $result->fetch_assoc()) {
$synonyms[] = $row;
}
echo json_encode($synonyms);
}

View File

@ -0,0 +1,153 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
// Recupera il valore di idreports dalla query string
$idreports = isset($_GET['idreports']) ? $_GET['idreports'] : 0;
// Query per ottenere i dettagli del report e del prodotto associato
$queryReportDetails = "
SELECT r.*, p.products_refnumber, p.products_description, p.products_style, p.products_color
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
WHERE r.idreports = ?";
$stmt = $conn->prepare($queryReportDetails);
$stmt->bind_param("i", $idreports);
$stmt->execute();
$reportDetails = $stmt->get_result()->fetch_assoc();
// Query per ottenere le parti e i risultati del report
$queryPartsAndResults = "
SELECT rp.*, a.nameanalysisvoc AS testName, av.nameanalysisvoc AS analytsName
FROM result_project rp
LEFT JOIN analysisvocabulary a ON rp.result_TestName = a.idanalysisvocabulary
LEFT JOIN analysisvocabulary av ON rp.result_AnalytsName = av.idanalysisvocabulary
WHERE rp.idreports = ?";
$stmtParts = $conn->prepare($queryPartsAndResults);
$stmtParts->bind_param("i", $idreports);
$stmtParts->execute();
$partsAndResults = $stmtParts->get_result();
?>
<!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">
<title>Report Details</title>
<!-- 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 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>
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
<script src="../assets/plugins/select2/select2.min.js"></script>
</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">Report Details</h4>
</div>
</div>
</div>
<!-- Dati del Report e del Prodotto -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Report: <?php echo $reportDetails['reportsNumberLab']; ?></h5>
<p><strong>Report Date:</strong> <?php echo $reportDetails['reportDateIn']; ?></p>
<p><strong>Product Ref:</strong> <?php echo $reportDetails['products_refnumber']; ?></p>
<p><strong>Product Description:</strong> <?php echo $reportDetails['products_description']; ?></p>
<p><strong>Style:</strong> <?php echo $reportDetails['products_style']; ?></p>
<p><strong>Color:</strong> <?php echo $reportDetails['products_color']; ?></p>
</div>
</div>
</div>
</div>
<!-- Tabella con Parti e Risultati -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Parts and Results</h5>
<div class="table-responsive">
<table class="table table-bordered">
<thead>
<tr>
<th>Part Number</th>
<th>Test Name</th>
<th>Analyts Name</th>
<th>Result Value</th>
<th>Rating</th>
</tr>
</thead>
<tbody>
<?php while ($row = $partsAndResults->fetch_assoc()) { ?>
<tr>
<td><?php echo $row['partNumber']; ?></td>
<td><?php echo $row['testName']; ?></td>
<td><?php echo $row['analytsName']; ?></td>
<td><?php echo $row['result_Value']; ?></td>
<td><?php echo $row['test_Rating']; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div><!-- container -->
</div><!-- Page content Wrapper -->
</div><!-- content -->
<?php include('../include/footer.php'); ?>
</div>
</div>
<!-- plugin JS -->
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/js/common_helper.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
</body>
</html>

View File

@ -0,0 +1,205 @@
<?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'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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>
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
<script src="../assets/plugins/select2/select2.min.js"></script>
<style>
.width-100 {
width: 100%;
}
.flex_center {
display: flex;
align-items: center;
}
.mg_none {
margin: 0 !important;
}
.hidden {
display: none !important;
}
.table-custom tr {
height: 40px;
line-height: 40px;
}
#ajax_preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 9999999;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
.padding_none {
padding: 0 !important;
}
.select2-container--open {
z-index: 9999;
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<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">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">Importify</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Importify: <?php echo $dashboard; ?></h5>
<br><br>
<div class="table-responsive">
</div><!--end table-responsive-->
<input id="f_csv" type="file" name="f_csv" style="display: none" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel, text/csv">
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<!-- plugin JS -->
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/js/common_helper.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
</body>
</html>

View File

@ -0,0 +1,16 @@
<div class="row">
<div style='margin-right:5px; width: 190px;' class="col-xl-2 alert alert-info alert-dismissible fade show" role="alert">
Filter Selected:
</div>
<?php if (isset($_SESSION['datefiltermin'])) { ?> <div style='margin-right:5px; width: 160px;' class="col-xl-2 alert alert-warning alert-dismissible fade show" role="alert">
Date
<a href="stats-levelone.php?deldatefilter=null"><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></a>
</div> <?php } ?>
<?php if (isset($_SESSION['supplierfilter'])) { ?><div style='margin-right:5px; width: 160px;' class="col-xl-2 alert alert-warning alert-dismissible fade show" role="alert">
Supplier
<a href="stats-levelone.php?delsupplierfilter=null"><button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button></a>
</div><?php } ?>
</div>

View File

@ -1,101 +1,248 @@
<?php
if(isset($analytsname)) {
// fecth trend
// queries creation
$mainquery = "select * from reports left join products ON reports.idreports=products.idreports";
$failqueryvar = " AND LOWER(reports.reportsRating) = 'fail'";
$passqueryvar = " AND reports.reportsRating='PASS'";
$dataqueryvar = " AND reports.reportsRating='//'";
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
// var on off
if (isset($_SESSION['datefiltermin'])) {
$datequeryvar = " AND reports.reportsDateOut BETWEEN '$datefiltermin' AND '$datefiltermax'";
} else {
$datequeryvar = "";
};
if (isset($_SESSION['supplierfilter'])) {
$supplierqueryvar = " AND products.namesupplier IN ('$supplierf')";
} else {
$supplierqueryvar = "";
};
//print_r($_SESSION['supplierfilter']);
?>
<?php
// fetch failed reports
$sqlfail = "select * from reports WHERE LOWER(reports.reportsRating) = 'fail'";
$reportfail = mysqli_query($repnew, $sqlfail) or die("Error in Selecting " . mysqli_error($repnew));
$num_rows_fail = mysqli_num_rows($reportfail);
// fetch data reports
$sqldata = $mainquery . $dataqueryvar . $supplierqueryvar . $datequeryvar;
$reportdata = mysqli_query($repnew, $sqldata) or die("Error in Selecting " . mysqli_error($repnew));
$num_rows_data = mysqli_num_rows($reportdata);
$paramscheck = "SELECT * FROM result_project LEFT JOIN reports ON result_project.idreports=reports.idreports
WHERE reports.iduser='$iduserlog' AND result_project.result_AnalytsName = '$analytsname'
ORDER BY reports.reportDateIn
LIMIT 100;
//fetch table rows from mysql db
//echo $mainquery.$supplierqueryvar.$datequeryvar;
$sql = $mainquery . $supplierqueryvar . $datequeryvar;
$result = mysqli_query($repnew, $sql) or die("Error in Selecting " . mysqli_error($repnew));
$num_rows = mysqli_num_rows($result);
//fetch table rows from analysis
$sqlanalysis = "select * from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports GROUP BY result_project.idPart, reports.reportsNumberLab ";
$resultanalysis = mysqli_query($repnew, $sqlanalysis) or die("Error in Selecting " . mysqli_error($repnew));
$num_rows_analysis = mysqli_num_rows($resultanalysis);
//fetch table rows from analysis fail
$sqlanalysisfail = "
SELECT COUNT(DISTINCT result_project.idPart, reports.reportsNumberLab) AS total_rows
FROM result_project
LEFT JOIN reports ON result_project.idreports = reports.idreports
WHERE result_project.result_Rating = 'FAIL'
";
$resultparamscheck = mysqli_query($predoc, $paramscheck) or die("Error in Selecting " . mysqli_error($predoc));
$resultanalysisfail = mysqli_query($repnew, $sqlanalysisfail) or die("Error in Selecting " . mysqli_error($repnew));
// Fetch the result
$row = mysqli_fetch_assoc($resultanalysisfail);
$num_rows_analysis_fail = $row['total_rows'];
if ($num_rows_analysis > 0) {
$percanalysisfail = round(($num_rows_analysis_fail / $num_rows_analysis) * 100, 1);
} else {
$percanalysisfail = 0; // Oppure un altro valore di default
}
//create an array
if (!function_exists('replaceSmartQuotes')) {
function replaceSmartQuotes($string)
{
$search = array(chr(145), chr(146), chr(147), chr(148), chr(151));
$replace = array("'", "'", '"', '"', '-');
return str_replace($search, $replace, $string);
}
}
if (!function_exists('replaceSmartQuotesInArray')) {
function replaceSmartQuotesInArray($array)
{
foreach ($array as $key => $value) {
if (is_string($value)) {
$array[$key] = replaceSmartQuotes($value);
} elseif (is_array($value)) {
$array[$key] = replaceSmartQuotesInArray($value);
}
}
return $array;
}
}
$reportsarray = array();
while ($row = mysqli_fetch_assoc($result)) {
$reportsarray[] = replaceSmartQuotesInArray($row);
}
//$totalreport=
if ((!empty($num_rows)) && (!empty($num_rows_fail))) {
$perfail = round(($num_rows_fail / $num_rows) * 100, 1);
}
if ((!empty($num_rows)) && (!empty($num_rows_data))) {
$perdata = round(($num_rows_data / $num_rows) * 100, 1);
}
if ((!empty($num_rows)) && (isset($num_rows_fail)) && (!empty($num_rows_data))) {
$numpassres = ($num_rows - $num_rows_data - $num_rows_fail);
}
if ((!empty($perfail)) && (!empty($perdata))) {
$perpass = round(100 - $perfail - $perdata, 1);
}
?>
<?php
// fecth data of top 10 worst analysis
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
$worstanalysis = "SELECT result_TestName, COUNT(*) AS counter
FROM result_project
LEFT JOIN reports ON result_project.idreports = reports.idreports
WHERE result_project.result_Rating = 'FAIL'
GROUP BY result_TestName
ORDER BY counter DESC
LIMIT 10;
";
$resultworstanalysis = mysqli_query($repnew, $worstanalysis) or die("Error in Selecting " . mysqli_error($repnew));
// Print out result
$dateparamcheck=array();
$valueparamcheck=array();
while($row = mysqli_fetch_array($resultparamscheck)) {
$dateparamcheck[]=$row['reportDateIn'];
$valueparamcheck[]=$row['result_Value'];
$ncounter = array();
$testname = array();
while ($row = mysqli_fetch_array($resultworstanalysis)) {
$ncounter[] = $row['counter'];
$testname[] = replaceSmartQuotes($row['result_TestName']);
}
?>
<?php
// fecth data of failed analysis
// Assumi che $dateparamcheck e $valueparamcheck siano già popolati con i dati pertinenti
// Converte le date in timestamp per la regressione
$timestampcheck = array();
foreach ($dateparamcheck as $date) {
$timestampcheck[] = strtotime($date);
}
// Calcola la media dei valori (y) e dei timestamp (x)
$mean_x = array_sum($timestampcheck) / count($timestampcheck);
$mean_y = array_sum($valueparamcheck) / count($valueparamcheck);
// Calcola la regressione lineare
$numerator = 0;
$denominator = 0;
for ($i = 0; $i < count($timestampcheck); $i++) {
$numerator += ($timestampcheck[$i] - $mean_x) * ($valueparamcheck[$i] - $mean_y);
$denominator += ($timestampcheck[$i] - $mean_x) ** 2;
}
// Coefficienti della regressione lineare y = mx + b
$m = $numerator / $denominator;
$b = $mean_y - ($m * $mean_x);
// Stampa i valori previsti per i prossimi 6 mesi
$last_date_timestamp = end($timestampcheck);
for ($j = 1; $j <= 6; $j++) {
$next_month_timestamp = strtotime("+{$j} month", $last_date_timestamp);
$predicted_value = $m * $next_month_timestamp + $b;
}
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
// Array per tenere traccia delle previsioni
$predicted_dates = [];
$predicted_values = [];
$failedanalysis = "SELECT result_TestName, COUNT(*) AS counter
FROM result_project
LEFT JOIN reports ON result_project.idreports = reports.idreports
WHERE result_project.result_Rating = 'FAIL'
GROUP BY result_TestName
ORDER BY counter DESC
LIMIT 50;
";
$resultfailedanalysis = mysqli_query($repnew, $failedanalysis) or die("Error in Selecting " . mysqli_error($repnew));
$last_date_timestamp = end($timestampcheck);
for ($j = 1; $j <= 6; $j++) {
$next_month_timestamp = strtotime("+{$j} month", $last_date_timestamp);
$predicted_value = $m * $next_month_timestamp + $b;
// Formatta il valore previsto con lo stesso numero di decimali dei dati reali
$formatted_predicted_value = number_format($predicted_value, 2);
$predicted_dates[] = date('Y-m-d', $next_month_timestamp);
$predicted_values[] = $formatted_predicted_value;
// Print out result
$ncounterfailed = array();
$testnamefailed = array();
while ($row = mysqli_fetch_array($resultfailedanalysis)) {
$ncounterfailed[] = $row['counter'];
$testnamefailed[] = replaceSmartQuotes($row['result_TestName']);
}
?>
<?php
// fecth limit
// fecth failed components
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
$paramslim = "SELECT * FROM parameterslimit WHERE parameterslimit.nameparameters = '$analytsname' LIMIT 1;";
$resultparamslim = mysqli_query($predoc, $paramslim) or die("Error in Selecting " . mysqli_error($predoc));
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
$lowlim = null;
$highlim = null;
if ($row = mysqli_fetch_assoc($resultparamslim)) {
$lowlim = floatval($row['lowvalue']);
$highlim = floatval($row['highvalue']);
$failedanalyts = "SELECT result_AnalytsName, COUNT(*) AS counter
FROM result_project
LEFT JOIN reports ON result_project.idreports = reports.idreports
WHERE result_project.result_AnalytsRating = 'F'
GROUP BY result_AnalytsName
ORDER BY counter DESC
LIMIT 100;
";
$resultfailedanalyts = mysqli_query($repnew, $failedanalyts) or die("Error in Selecting " . mysqli_error($repnew));
// Print out result
$ncounterfailedanalyts = array();
$testnamefailedanalyts = array();
while ($row = mysqli_fetch_array($resultfailedanalyts)) {
$ncounterfailedanalyts[] = $row['counter'];
$testnamefailedanalyts[] = $row['result_AnalytsName'];
}
?>
<?php
// fecth worst supplier
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
$worstsupplier = "SELECT namesupplier, COUNT(*) AS counter
FROM result_project
LEFT JOIN reports ON result_project.idreports = reports.idreports
LEFT JOIN products ON result_project.idproducts = products.idproducts
WHERE LOWER(result_project.result_Rating) = 'fail'
GROUP BY namesupplier
ORDER BY counter DESC
LIMIT 10;
";
$resultworstsupplier = mysqli_query($repnew, $worstsupplier) or die("Error in Selecting " . mysqli_error($repnew));
// Print out result
$ncounterworstsupplier = array();
$testnameworstsupplier = array();
while ($row = mysqli_fetch_array($resultworstsupplier)) {
$ncounterworstsupplier[] = $row['counter'];
$testnameworstsupplier[] = $row['namesupplier'];
}
?>
<?php
// fecth region area
// $worstanalysis = "select result_project.idAnalysis AS analysisid, result_TestName, name_analysis , COUNT(*) as counter from result_project LEFT JOIN reports ON result_project.idreports=reports.idreports LEFT JOIN analysis ON result_project.idAnalysis=analysis.idanalysis WHERE reports.idcompany='$idcompany' AND result_project.result_Rating='F' GROUP BY result_TestName ORDER by counter DESC LIMIT 10";
$worstregion = "SELECT products_region, COUNT(*) AS counter
FROM result_project
LEFT JOIN reports ON result_project.idreports = reports.idreports
LEFT JOIN products ON result_project.idreports = products.idreports
WHERE result_project.result_Rating = 'FAIL'
GROUP BY namesupplier
ORDER BY counter DESC
LIMIT 10;
";
$resultworstregion = mysqli_query($repnew, $worstregion) or die("Error in Selecting " . mysqli_error($repnew));
// Print out result
$ncounterregion = array();
$nameregion = array();
while ($row = mysqli_fetch_array($resultworstregion)) {
$ncounterregion[] = $row['counter'];
$nameregion[] = $row['products_region'];
}
?>

View File

@ -0,0 +1,53 @@
<?php
// get variable
if (isset($_GET['supplierfilter'])) {
$supplierfArray=array();
$supplierArray=$_GET['supplierfilter'];
foreach ($supplierArray as $suppliername) {
$supplierfArray[]=$suppliername;
}
$_SESSION['supplierfilter']=implode("','",$supplierfArray);
}
if (isset($_GET['daterange'])) {
$vardate=$_GET['daterange'];
$datefilter=explode(" - ",$vardate);
$datefilterminone=str_replace("/","-",$datefilter[0]);
$datefiltermintwo=explode("-",$datefilterminone);
$_SESSION['datefiltermin']=$datefiltermintwo[2].'-'.$datefiltermintwo[0].'-'.$datefiltermintwo[1];
$datefiltermaxone=str_replace("/","-",$datefilter[1]);
$datefiltermaxtwo=explode("-",$datefiltermaxone);
$_SESSION['datefiltermax']=$datefiltermaxtwo[2].'-'.$datefiltermaxtwo[0].'-'.$datefiltermaxtwo[1];
}
// unset variable
if (isset($_GET['delsupplierfilter'])) { unset ($_SESSION["supplierfilter"]); }
if (isset($_GET['deldatefilter'])) { unset ($_SESSION["datefiltermin"]);
unset ($_SESSION["datefiltermax"]);
}
?>
<?php
if (isset($_SESSION['datefiltermin'])) {
$datefiltermin=$_SESSION['datefiltermin']; }
if (isset($_SESSION['datefiltermax'])) {
$datefiltermax=$_SESSION['datefiltermax'];; }
if (isset($_SESSION['supplierfilter'])) {
$supplierf=$_SESSION['supplierfilter']; }
if (!isset($_SESSION['labfilter'])) {
$_SESSION['labfilter']='*'; }
if (!isset($_SESSION['reportnumberfilter'])) {
$_SESSION['reportnumberfilter']='*'; }
if (!isset($_SESSION['prdorefnumberfilter'])) {
$_SESSION['prdorefnumberfilter']='*'; }
if (!isset($_SESSION['proddescriptionfilter'])) {
$_SESSION['proddescriptionfilter']='*'; }
if (!isset($_SESSION['prodskufilter'])) {
$_SESSION['prodskufilter']='*'; }
if (!isset($_SESSION['prodseasonfilter'])) {
$_SESSION['prodseasonfilter']='*'; }
if (!isset($_SESSION['prodbuyerfilter'])) {
$_SESSION['prodbuyerfilter']='*'; }
//print_r($_SESSION['supplierfilter']);
?>

View File

@ -0,0 +1,227 @@
<?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'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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">
<style>
.table-custom tr {
height: 40px;
line-height: 40px;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<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">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Products</li>
</ol>
</div>
<h4 class="page-title">Reports</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Products</h5>
<a class="btn btn-primary" href="insert-importifytemplate.php" role="button">Products</a>
<a class="btn btn-danger" href="../index.php" role="button">Dahboard</a>
<br><br>
<div class="col-sm-12 mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search by Component or CAS">
</div>
<br>
<div class="table-responsive">
<table class="table table-striped table-sm sm-0">
<thead>
<tr>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Test Out</strong></th>
<th><strong>Rating</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php $productslist = new WA_MySQLi_RS("rsl", $repnew, 0);
$productslist->setQuery("SELECT * FROM products");
$productslist->execute();
$wa_startindex = 0;
while (!$productslist->atEnd()) {
$wa_startindex = $productslist->Index;
?> <tr>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsDateOut")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsRating")); ?></td>
<td>
<a class="btn btn-success" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Go"><i class="fas fa-angle-double-right font-size-16 align-middle"></i></a>
<a class="btn btn-primary" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Expand"><i class="fas fa-angle-double-down font-size-16 align-middle"></i></a>
</td>
</tr>
<?php $productslist->moveNext();
}
$productslist->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></tbody>
</table>
</div><!--end table-responsive-->
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<!-- plugin JS -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
</body>
</html>

View File

@ -0,0 +1,22 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if (isset($_POST['reportId'])) {
$reportId = $_POST['reportId'];
// Query per ottenere i dati delle analisi
$query = "SELECT * FROM result_project WHERE idreports = $reportId";
$result = $conn->query($query);
$analysis = [];
while ($row = $result->fetch_assoc()) {
$analysis[] = $row;
}
echo json_encode($analysis);
} else {
echo json_encode([]);
}

View File

@ -0,0 +1,15 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
$productId = $_POST['productId'];
$query = "SELECT * FROM reports WHERE idproducts = $productId";
$result = $conn->query($query);
$reports = [];
while ($row = $result->fetch_assoc()) {
$reports[] = $row;
}
echo json_encode($reports);

View File

@ -0,0 +1,71 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
if (isset($_POST['productId'])) {
$productId = $_POST['productId'];
// Query per ottenere i report associati al prodotto
$queryReports = "SELECT * FROM reports WHERE idproducts = $productId";
$resultReports = $conn->query($queryReports);
$reports = [];
while ($report = $resultReports->fetch_assoc()) {
// Query per ottenere le analisi associate a ogni report con LEFT JOIN su analysisvocabulary
$reportId = $report['idreports'];
$queryAnalysis = "
SELECT rp.*, av.nameanalysisvoc
FROM result_project rp
LEFT JOIN analysisvocabulary av ON rp.result_TestName = av.idanalysisvocabulary
WHERE rp.idreports = $reportId";
$resultAnalysis = $conn->query($queryAnalysis);
// Mappa per aggregare i risultati delle analisi in base a 'result_TestName' e calcolare il peggior rating
$analysisGrouped = [];
while ($analysis = $resultAnalysis->fetch_assoc()) {
$testName = $analysis['nameanalysisvoc'];
// Normalizza il rating per confrontare varianti diverse
$normalizedRating = strtoupper(trim($analysis['test_Rating']));
// Gestiamo anche varianti come "Complies", "Doesn't Comply", "//" e "N/A"
if ($normalizedRating === 'P' || $normalizedRating === 'PASS' || $normalizedRating === 'COMPLIES') {
$normalizedRating = 'PASS';
} elseif ($normalizedRating === 'F' || $normalizedRating === 'FAIL' || $normalizedRating === 'DOESN\'T COMPLY') {
$normalizedRating = 'FAIL';
} elseif ($normalizedRating === '//' || $normalizedRating === 'N/A') {
$normalizedRating = '//';
} else {
$normalizedRating = 'N/A'; // Per valori non riconosciuti
}
// Se l'analisi per questo test è già stata trovata, confronta i rating e prendi il peggiore
if (isset($analysisGrouped[$testName])) {
$currentRating = $analysisGrouped[$testName]['finalRating'];
// Logica di priorità: Fail > // > Pass
if ($currentRating === 'PASS' && ($normalizedRating === 'FAIL' || $normalizedRating === '//')) {
$analysisGrouped[$testName]['finalRating'] = $normalizedRating;
} elseif ($currentRating === '//' && $normalizedRating === 'FAIL') {
$analysisGrouped[$testName]['finalRating'] = 'FAIL'; // Peggiora il rating
}
} else {
// Prima occorrenza dell'analisi, aggiungila alla mappa
$analysisGrouped[$testName] = [
'name' => $testName,
'finalRating' => $normalizedRating
];
}
}
// Aggiungi le analisi raggruppate al report
$report['analysis'] = array_values($analysisGrouped); // Converte la mappa in un array
$reports[] = $report;
}
// Restituisci i report e le analisi in formato JSON
echo json_encode(['reports' => $reports]);
} else {
echo json_encode(['error' => 'Product ID not provided']);
}

View File

@ -1,6 +1,14 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
<?php include("../class/company.php"); ?>
<?php
$conn = new mysqli($servername, $username, $password, $database);
// Query per ottenere tutti i prodotti
$query = "SELECT * FROM products";
$result = $conn->query($query);
?>
<!DOCTYPE html>
<html lang="en">
@ -8,220 +16,241 @@
<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'); ?>
<title>Products</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Includi prima jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="shortcut icon" href="../assets/images/favicon.ico">
<!-- Includi DataTables CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
<!-- Includi DataTables JS -->
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.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 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">
<style>
.table-custom tr {
height: 40px;
line-height: 40px;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
</style>
</head>
<style>
.bg-danger {
background-color: #ff4d4d !important;
/* Rosso per fallimenti */
}
.bg-success {
background-color: #28a745 !important;
/* Verde per successi */
}
.bg-warning {
background-color: #ffc107 !important;
/* Giallo per N/A o // */
}
.text-white {
color: white !important;
}
.text-dark {
color: black !important;
}
</style>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<div class="content">
<?php include('../include/topbar.php'); ?>
<div class="page-content-wrapper ">
<div class="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="page-title-box">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Products</li>
</ol>
</div>
<h4 class="page-title">Reports</h4>
<h4 class="page-title">Products</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Products</h5>
<a class="btn btn-primary" href="insert-importifytemplate.php" role="button">Products</a>
<a class="btn btn-danger" href="../index.php" role="button">Dahboard</a>
<br><br>
<div class="col-sm-12 mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search by Component or CAS">
</div>
<br>
<div class="table-responsive">
<table class="table table-striped table-sm sm-0">
<table id="productsTable" class="table table-striped table-hover">
<thead>
<tr>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Test Out</strong></th>
<th><strong>Rating</strong></th>
<th><strong>Action</strong></th>
<th>Product Ref</th>
<th>Description</th>
<th>Style</th>
<th>Color</th>
<th>Season</th>
<th>Market</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $productslist = new WA_MySQLi_RS("rsl", $repnew, 0);
$productslist->setQuery("SELECT * FROM products");
$productslist->execute();
$wa_startindex = 0;
while (!$productslist->atEnd()) {
$wa_startindex = $productslist->Index;
?> <tr>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsDateOut")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsRating")); ?></td>
<?php while ($row = $result->fetch_assoc()) { ?>
<tr data-productid="<?php echo $row['idproducts']; ?>">
<td><?php echo $row['products_refnumber']; ?></td>
<td><?php echo $row['products_description']; ?></td>
<td><?php echo $row['products_style']; ?></td>
<td><?php echo $row['products_color']; ?></td>
<td><?php echo $row['products_season']; ?></td>
<td><?php echo $row['products_market']; ?></td>
<td>
<a class="btn btn-success" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Go"><i class="fas fa-angle-double-right font-size-16 align-middle"></i></a>
<a class="btn btn-primary" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Expand"><i class="fas fa-angle-double-down font-size-16 align-middle"></i></a>
<button class="btn btn-info btn-sm show-reports">Reports</button>
</td>
</tr>
<?php $productslist->moveNext();
}
$productslist->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></tbody>
<?php } ?>
</tbody>
</table>
</div><!--end table-responsive-->
</div>
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
</div><!-- Page content Wrapper -->
</div><!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
// Inizializza DataTables con filtri per le colonne
var table = $('#productsTable').DataTable({
responsive: true,
"pageLength": 50,
"order": [
[1, 'asc']
], // Ordina per descrizione
initComplete: function() {
// Aggiungi i filtri per ogni colonna
this.api().columns().every(function() {
var column = this;
var input = $('<input class="form-control form-control-sm" type="text" placeholder="Search"/>')
.appendTo($(column.header()))
.on('keyup change clear', function() {
if (column.search() !== this.value) {
column.search(this.value).draw();
}
});
});
}
});
// Gestione del click su "Reports" per visualizzare la tabella report e analisi
$('#productsTable').on('click', '.show-reports', function() {
var tr = $(this).closest('tr');
var productId = tr.data('productid');
var row = $('#productsTable').DataTable().row(tr);
var button = $(this);
console.log('Loading reports and analysis for productId:', productId); // Debug
button.prop('disabled', true);
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
// Se la riga child è già visibile, non facciamo nulla
if (row.child.isShown()) {
button.prop('disabled', false);
button.html('Reports');
return;
}
// Carica i report e le analisi insieme tramite AJAX
$.ajax({
url: 'get_reports_and_analysis.php', // Nuovo script PHP per ottenere sia i report che le analisi
type: 'POST',
data: {
productId: productId
},
success: function(data) {
console.log('Reports and Analysis data loaded:', data); // Debug
row.child(formatReportsAndAnalysis(data)).show();
tr.addClass('shown');
},
complete: function() {
button.prop('disabled', false);
button.html('Reports');
},
error: function() {
Swal.fire('Error!', 'There was an error loading the reports and analysis.', 'error');
button.prop('disabled', false);
button.html('Reports');
}
});
});
// Funzione per formattare i report e le analisi nella stessa tabella
function formatReportsAndAnalysis(data) {
var parsedData = JSON.parse(data);
var reports = parsedData.reports;
var html = '<table class="table table-bordered child-table">';
html += '<thead><tr><th>Report Number</th><th>Report Date</th><th>Rating</th><th>Analysis (Name)</th><th>Final Rating</th><th>Action</th></tr></thead>';
html += '<tbody>';
// Per ogni report, aggiungi il report e le analisi associate
$.each(reports, function(index, report) {
// Riga del report principale
html += '<tr>';
html += '<td>' + report.reportsNumberLab + '</td>';
html += '<td>' + report.reportDateIn + '</td>';
html += '<td>' + report.reportsRating + '</td>';
html += '<td colspan="2"></td>'; // Righe vuote per mantenere l'allineamento
html += '<td><button class="btn btn-primary btn-sm report-details" data-reportid="' + report.idreports + '">Details</button></td>'; // Aggiungi il bottone Details
// Se ci sono analisi associate al report, le aggiungi sotto lo stesso report
if (report.analysis.length > 0) {
$.each(report.analysis, function(i, analysis) {
var ratingClass = ''; // Classe CSS per la colorazione della cella
if (analysis.finalRating === 'FAIL') {
ratingClass = 'bg-danger text-white'; // Colore rosso per i fallimenti
} else if (analysis.finalRating === 'PASS') {
ratingClass = 'bg-success text-white'; // Colore verde per i successi
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A') {
ratingClass = 'bg-warning text-dark'; // Colore giallo per risultati ambigui
}
html += '<tr>';
html += '<td></td>'; // Lascia vuoto per mantenere l'allineamento del report
html += '<td></td>'; // Lascia vuoto per mantenere l'allineamento del report
html += '<td></td>'; // Lascia vuoto per mantenere l'allineamento del report
html += '<td>' + (analysis.name ? analysis.name : 'N/A') + '</td>'; // Nome dell'analisi
html += '<td class="' + ratingClass + '">' + (analysis.finalRating ? analysis.finalRating : 'N/A') + '</td>';
html += '<td></td>'; // Lascia vuoto per non aggiungere il bottone "Details" nella riga dell'analisi
html += '</tr>';
});
} else {
html += '<tr><td colspan="5">No analysis available for this report.</td></tr>';
}
html += '</tr>';
});
html += '</tbody></table>';
return html;
}
});
$(document).on('click', '.report-details', function() {
var reportId = $(this).data('reportid'); // Ottieni l'id del report
window.location.href = 'reportdetails.php?idreports=' + reportId; // Reindirizza alla pagina reportdetails.php con idreports
});
</script>
<!-- plugin JS -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
</body>
</html>

View File

@ -0,0 +1,419 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
// Recupera il valore di idreports dalla query string
$idreports = isset($_GET['idreports']) ? $_GET['idreports'] : 0;
// Query per ottenere i dettagli del report e del prodotto associato
$queryReportDetails = "
SELECT r.*, p.products_refnumber, p.products_description, p.products_style, p.products_color
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
WHERE r.idreports = ?";
$stmt = $conn->prepare($queryReportDetails);
$stmt->bind_param("i", $idreports);
$stmt->execute();
$reportDetails = $stmt->get_result()->fetch_assoc();
// Query per ottenere le parti e i risultati del report con il nome dell'analista e delle parti
$queryPartsAndResults = "
SELECT rp.*,
a.nameanalysisvoc AS testName,
cv.namecompoundsvocabulary AS analytsName,
pr.partsDescription
FROM result_project rp
LEFT JOIN analysisvocabulary a ON rp.result_TestName = a.idanalysisvocabulary
LEFT JOIN compundsvocabulary cv ON rp.result_AnalytsName = cv.idcompoundsvocabulary
LEFT JOIN parts pr ON rp.idPart = pr.idParts
WHERE rp.idreports = ?
ORDER BY rp.result_TestName, rp.idPart";
$stmtParts = $conn->prepare($queryPartsAndResults);
$stmtParts->bind_param("i", $idreports);
$stmtParts->execute();
$partsAndResults = $stmtParts->get_result();
?>
<!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">
<title>Report Details</title>
<!-- 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 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>
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
<script src="../assets/plugins/select2/select2.min.js"></script>
<style>
.section-separator {
background-color: #f1f3f5;
font-weight: bold;
padding: 10px;
margin-top: 20px;
border-top: 3px solid #6c757d;
}
.table-part {
margin-top: 10px;
border: 2px solid #dee2e6;
}
.rating-pass {
background-color: #28a745;
color: white;
}
.rating-fail {
background-color: #dc3545;
color: white;
}
.rating-ambiguous {
background-color: #ffc107;
color: black;
}
.report-header {
background-color: #e9ecef;
padding: 15px;
border-radius: 5px;
}
.report-header h5 {
margin-bottom: 10px;
}
.report-details-table {
width: 100%;
}
.report-details-table td {
padding: 5px;
}
.table-filter {
margin-bottom: 20px;
}
.fixed-width-analyts {
width: 40%;
/* Modifica questo valore per adattare la larghezza */
}
.fixed-width-value {
width: 30%;
/* Modifica questo valore per adattare la larghezza */
}
.fixed-width-rating {
width: 30%;
/* Modifica questo valore per adattare la larghezza */
}
</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">Report Details</h4>
</div>
</div>
</div>
<!-- Dati del Report e del Prodotto -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<div class="report-header">
<h5>Report: <?php echo $reportDetails['reportsNumberLab']; ?></h5>
<table class="report-details-table">
<tr>
<td><strong>Report Date:</strong></td>
<td><?php echo $reportDetails['reportDateIn']; ?></td>
</tr>
<tr>
<td><strong>Product Ref:</strong></td>
<td><?php echo $reportDetails['products_refnumber']; ?></td>
</tr>
<tr>
<td><strong>Product Description:</strong></td>
<td><?php echo $reportDetails['products_description']; ?></td>
</tr>
<tr>
<td><strong>Style:</strong></td>
<td><?php echo $reportDetails['products_style']; ?></td>
</tr>
<tr>
<td><strong>Color:</strong></td>
<td><?php echo $reportDetails['products_color']; ?></td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- Filtri -->
<!-- Aggiungi questo filtro sopra la tabella -->
<div class="row table-filter">
<div class="col-md-4">
<input type="text" id="searchTestName" class="form-control" placeholder="Search by Test Name">
</div>
<div class="col-md-4">
<input type="text" id="searchPart" class="form-control" placeholder="Search by Part">
</div>
<div class="col-md-4">
<select id="searchRating" class="form-control">
<option value="">All Ratings</option>
<option value="pass" class="rating-pass">Pass</option>
<option value="fail" class="rating-fail">Fail</option>
<option value="ambiguous" class="rating-ambiguous">N/A or Ambiguous</option>
</select>
</div>
</div>
<!-- Tabella con Parti e Risultati -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Parts and Results</h5>
<div class="table-responsive">
<?php
$currentTestName = '';
$currentPart = '';
while ($row = $partsAndResults->fetch_assoc()) {
// Debug: Stampa i dati di ogni riga
// Questo serve per stampare i risultati in modo più leggibile e debuggare
$previousPart = '';
// Se il nome dell'analisi cambia, crea una nuova sezione
if ($currentTestName != $row['testName']) {
if ($currentTestName != '') {
echo '</tbody></table>'; // Chiude la tabella precedente
}
$currentTestName = $row['testName'];
echo '<div class="section-separator">Analysis: ' . $currentTestName . '</div>';
}
// Verifica se la parte corrente è diversa dalla precedente per evitare duplicazioni
$currentPart = $row['partsDescription'] ?? 'Unknown Part';
if ($currentPart != $previousPart) {
// Stampa il titolo della parte solo se cambia
echo '<h6>Part: ' . (!empty($row['partsDescription']) ? $currentPart : 'Part Not Specified') . '</h6>';
// Apri una nuova tabella per la parte
echo '<table class="table table-bordered table-part"><thead>';
echo '<tr><th class="fixed-width-analyts">Analyts Name</th><th class="fixed-width-value">Result Value</th><th class="fixed-width-rating">Rating</th></tr>';
echo '</thead><tbody>';
// Aggiorna la variabile di controllo per la parte
$previousPart = $currentPart;
}
// Classificazione del rating
$ratingClass = '';
if (strtoupper($row['test_Rating']) == 'FAIL' || strtoupper($row['test_Rating']) == "DOESN'T COMPLY") {
$ratingClass = 'rating-fail';
} elseif (strtoupper($row['test_Rating']) == 'PASS' || strtoupper($row['test_Rating']) == 'COMPLIES') {
$ratingClass = 'rating-pass';
} else {
$ratingClass = 'rating-ambiguous';
}
// Stampa i dettagli della riga
echo '<tr>';
echo '<td>' . (!empty($row['analytsName']) ? $row['analytsName'] . ' (ID: ' . $row['result_AnalytsName'] . ')' : '&nbsp;') . '</td>';
echo '<td>' . (!empty($row['result_Value']) ? htmlspecialchars($row['result_Value'], ENT_QUOTES, 'UTF-8') : '&nbsp;') . '</td>';
echo '<td class="' . $ratingClass . '">' . (!empty($row['test_Rating']) ? htmlspecialchars($row['test_Rating'], ENT_QUOTES, 'UTF-8') : '&nbsp;') . '</td>';
echo '</tr>';
}
if ($currentTestName != '') {
echo '</tbody></table>'; // Chiude l'ultima tabella
}
?>
</div>
</div>
</div>
</div>
</div>
</div><!-- container -->
</div><!-- Page content Wrapper -->
</div><!-- content -->
<?php include('../include/footer.php'); ?>
</div>
</div>
<script>
$(document).ready(function() {
// Filtro per Test Name
$('#searchTestName').on('keyup', function() {
var value = $(this).val().toLowerCase();
$('.section-separator').each(function() {
var section = $(this);
if (section.text().toLowerCase().includes(value)) {
section.show();
section.nextUntil('.section-separator').show();
} else {
section.hide();
section.nextUntil('.section-separator').hide();
}
});
});
// Filtro per Part Name
$('#searchPart').on('keyup', function() {
var value = $(this).val().toLowerCase();
$('h6').each(function() {
var part = $(this);
if (part.text().toLowerCase().includes(value)) {
part.show();
part.next('table').show();
} else {
part.hide();
part.next('table').hide();
}
});
});
// Filtro per Rating
$('#searchRating').on('change', function() {
var selectedRating = $(this).val().toLowerCase(); // Prende il rating selezionato
$('table.table-part').each(function() {
var table = $(this);
var visibleRows = 0;
// Controlla ogni riga della tabella
table.find('tbody tr').each(function() {
var ratingCell = $(this).find('td:last-child'); // L'ultima cella è quella del rating
var ratingText = ratingCell.text().trim().toLowerCase();
// Mostra/nasconde la riga in base al filtro di rating
if (selectedRating === '' ||
(selectedRating === 'pass' && (ratingText === 'pass' || ratingText === 'complies')) ||
(selectedRating === 'fail' && (ratingText === 'fail' || ratingText === "doesn't comply")) ||
(selectedRating === 'ambiguous' && (ratingText === 'n/a' || ratingText === 'ambiguous' || ratingText === '//'))) {
$(this).show();
visibleRows++;
} else {
$(this).hide();
}
});
// Nasconde l'intera tabella se non ci sono righe visibili
if (visibleRows === 0) {
table.hide();
table.prev('h6').hide(); // Nasconde anche il titolo della parte
} else {
table.show();
table.prev('h6').show(); // Mostra il titolo della parte
}
});
});
});
</script>
<!-- plugin JS -->
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/js/common_helper.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
<script>
$(document).ready(function() {
// Filtro per Test Name
$('#searchTestName').on('keyup', function() {
var value = $(this).val().toLowerCase();
$('.section-separator').each(function() {
var section = $(this);
if (section.text().toLowerCase().includes(value)) {
section.show();
section.nextUntil('.section-separator').show();
} else {
section.hide();
section.nextUntil('.section-separator').hide();
}
});
});
// Filtro per Part Name
$('#searchPart').on('keyup', function() {
var value = $(this).val().toLowerCase();
$('h6').each(function() {
var part = $(this);
if (part.text().toLowerCase().includes(value)) {
part.show();
part.next('table').show();
} else {
part.hide();
part.next('table').hide();
}
});
});
// Filtro per Rating
$('#searchRating').on('change', function() {
var selectedRating = $(this).val().toLowerCase(); // Prende il rating selezionato
$('table.table-part tbody tr').each(function() {
var ratingCell = $(this).find('td:last-child'); // L'ultima cella dovrebbe essere quella del rating
var ratingText = ratingCell.text().trim().toLowerCase();
// Se l'utente non seleziona alcun valore (tutti i rating) o il rating corrisponde
if (selectedRating === '' ||
(selectedRating === 'pass' && (ratingText === 'pass' || ratingText === 'complies')) ||
(selectedRating === 'fail' && (ratingText === 'fail' || ratingText === "doesn't comply")) ||
(selectedRating === 'ambiguous' && (ratingText === 'n/a' || ratingText === 'ambiguous' || ratingText === '//'))) {
$(this).show();
} else {
$(this).hide();
}
});
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,228 @@
<?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'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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">
<style>
.table-custom tr {
height: 40px;
line-height: 40px;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<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">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">Reports</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Reports</h5>
<a class="btn btn-primary" href="insert-importifytemplate.php" role="button">Reports Dahboard</a>
<a class="btn btn-danger" href="../index.php" role="button">Dahboard</a>
<br><br>
<div class="col-sm-12 mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search by Component or CAS">
</div>
<br>
<div class="table-responsive">
<table class="table table-striped table-sm sm-0">
<thead>
<tr>
<th><strong>Report N.</strong></th>
<th><strong>Lab</strong></th>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Test Out</strong></th>
<th><strong>Rating</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php $reportslist = new WA_MySQLi_RS("rsl", $repnew, 0);
$reportslist->setQuery("SELECT * FROM reports LEFT JOIN products ON reports.idproducts=products.idproducts ORDER BY reports.reportsDateOut ");
$reportslist->execute();
$wa_startindex = 0;
while (!$reportslist->atEnd()) {
$wa_startindex = $reportslist->Index;
?> <tr>
<td><?php echo ($reportslist->getColumnVal("reportsNumberLab")); ?></td>
<td><?php echo ($reportslist->getColumnVal("lab")); ?></td>
<td><?php echo ($reportslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo substr($reportslist->getColumnVal("products_description"), 0, 50); ?></td>
<td><?php echo ($reportslist->getColumnVal("reportsDateOut")); ?></td>
<td><?php echo ($reportslist->getColumnVal("reportsRating")); ?></td>
<td>
<a class="btn btn-success" href="material-rsl.php?id=<?php echo ($reportslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Go"><i class="fas fa-angle-double-right font-size-16 align-middle"></i></a>
<a class="btn btn-primary" href="material-rsl.php?id=<?php echo ($reportslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Expand"><i class="fas fa-angle-double-down font-size-16 align-middle"></i></a>
</td>
</tr>
<?php $reportslist->moveNext();
}
$reportslist->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></tbody>
</table>
</div><!--end table-responsive-->
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<!-- plugin JS -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
</body>
</html>

View File

@ -0,0 +1,54 @@
<?php
include('../include/headscript.php');
include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
// Recupera il valore di reportId dal POST
$reportId = isset($_POST['reportId']) ? $_POST['reportId'] : 0;
// Query per ottenere le analisi associate al report, comprese le parti
$query = "
SELECT a.nameanalysisvoc AS name, rp.result_Rating AS finalRating
FROM result_project rp
LEFT JOIN analysisvocabulary a ON rp.result_TestName = a.idanalysisvocabulary
WHERE rp.idreports = ?";
$stmt = $conn->prepare($query);
$stmt->bind_param("i", $reportId);
$stmt->execute();
$result = $stmt->get_result();
// Array per raccogliere le analisi e le relative valutazioni (rating)
$analysis = [];
// Raggruppa le analisi e seleziona il rating più restrittivo
while ($row = $result->fetch_assoc()) {
$name = $row['name'];
$rating = strtoupper($row['finalRating']); // Normalizziamo tutto in maiuscolo per uniformità
if (!isset($analysis[$name])) {
// Se l'analisi non è ancora presente, la aggiungiamo
$analysis[$name] = $rating;
} else {
// Applica il rating più restrittivo: Fail > N/A > Pass
if ($analysis[$name] != 'FAIL' && ($rating == 'FAIL' || $rating == "DOESN'T COMPLY")) {
$analysis[$name] = 'FAIL';
} elseif ($analysis[$name] != 'FAIL' && $analysis[$name] != 'N/A' && ($rating == 'N/A' || $rating == '//')) {
$analysis[$name] = 'N/A';
} elseif ($analysis[$name] == 'PASS' && ($rating == 'PASS' || $rating == 'COMPLIES')) {
$analysis[$name] = 'PASS';
}
}
}
// Trasforma i dati in un array
$finalAnalysis = [];
foreach ($analysis as $name => $finalRating) {
$finalAnalysis[] = [
'name' => $name,
'finalRating' => $finalRating
];
}
// Restituisci i dati come JSON
echo json_encode($finalAnalysis);

View File

@ -1,6 +1,16 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
// 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);
?>
<!DOCTYPE html>
<html lang="en">
@ -8,221 +18,211 @@
<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'); ?>
<title>Reports</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<!-- Includi prima jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="shortcut icon" href="../assets/images/favicon.ico">
<!-- Includi DataTables CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
<!-- Includi DataTables JS -->
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.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 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">
<style>
.table-custom tr {
height: 40px;
line-height: 40px;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
</style>
</head>
<style>
.bg-danger {
background-color: #ff4d4d !important;
/* Rosso per fallimenti */
}
.bg-success {
background-color: #28a745 !important;
/* Verde per successi */
}
.bg-warning {
background-color: #ffc107 !important;
/* Giallo per N/A o // */
}
.text-white {
color: white !important;
}
.text-dark {
color: black !important;
}
</style>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<div class="content">
<?php include('../include/topbar.php'); ?>
<div class="page-content-wrapper ">
<div class="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="page-title-box">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">Reports</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Reports</h5>
<a class="btn btn-primary" href="insert-importifytemplate.php" role="button">Reports Dahboard</a>
<a class="btn btn-danger" href="../index.php" role="button">Dahboard</a>
<br><br>
<div class="col-sm-12 mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search by Component or CAS">
</div>
<br>
<div class="table-responsive">
<table class="table table-striped table-sm sm-0">
<table id="reportsTable" class="table table-striped table-hover">
<thead>
<tr>
<th><strong>Report N.</strong></th>
<th><strong>Lab</strong></th>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Test Out</strong></th>
<th><strong>Rating</strong></th>
<th><strong>Action</strong></th>
<th>Report Number</th>
<th>Report Date</th>
<th>Product Ref</th>
<th>Product Description</th>
<th>Rating</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php $reportslist = new WA_MySQLi_RS("rsl", $repnew, 0);
$reportslist->setQuery("SELECT * FROM reports LEFT JOIN products ON reports.idproducts=products.idproducts ORDER BY reports.reportsDateOut ");
$reportslist->execute();
$wa_startindex = 0;
while (!$reportslist->atEnd()) {
$wa_startindex = $reportslist->Index;
?> <tr>
<td><?php echo ($reportslist->getColumnVal("reportsNumberLab")); ?></td>
<td><?php echo ($reportslist->getColumnVal("lab")); ?></td>
<td><?php echo ($reportslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo substr($reportslist->getColumnVal("products_description"), 0, 50); ?></td>
<td><?php echo ($reportslist->getColumnVal("reportsDateOut")); ?></td>
<td><?php echo ($reportslist->getColumnVal("reportsRating")); ?></td>
<?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>
<td>
<a class="btn btn-success" href="material-rsl.php?id=<?php echo ($reportslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Go"><i class="fas fa-angle-double-right font-size-16 align-middle"></i></a>
<a class="btn btn-primary" href="material-rsl.php?id=<?php echo ($reportslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Expand"><i class="fas fa-angle-double-down font-size-16 align-middle"></i></a>
<button class="btn btn-info btn-sm show-analysis">Analysis</button>
</td>
</tr>
<?php $reportslist->moveNext();
}
$reportslist->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></tbody>
<?php } ?>
</tbody>
</table>
</div><!--end table-responsive-->
</div>
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
</div><!-- Page content Wrapper -->
</div><!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
// Inizializza DataTables con filtri per le colonne
var table = $('#reportsTable').DataTable({
responsive: true,
"pageLength": 50,
"order": [
[0, 'asc']
], // Ordina per numero di report
initComplete: function() {
// Aggiungi i filtri per ogni colonna
this.api().columns().every(function() {
var column = this;
var input = $('<input class="form-control form-control-sm" type="text" placeholder="Search"/>')
.appendTo($(column.header()))
.on('keyup change clear', function() {
if (column.search() !== this.value) {
column.search(this.value).draw();
}
});
});
}
});
// Gestione del click su "Analysis" per visualizzare la tabella delle analisi
$('#reportsTable').on('click', '.show-analysis', function() {
var tr = $(this).closest('tr');
var reportId = tr.data('reportid');
var row = $('#reportsTable').DataTable().row(tr);
var button = $(this);
console.log('Loading analysis for reportId:', reportId); // Debug
button.prop('disabled', true);
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
// Se la riga child è già visibile, non facciamo nulla
if (row.child.isShown()) {
button.prop('disabled', false);
button.html('Analysis');
return;
}
// Carica le analisi tramite AJAX
$.ajax({
url: 'get_analysis_by_report.php', // Nuovo script PHP per ottenere le analisi del report
type: 'POST',
data: {
reportId: reportId
},
success: function(data) {
console.log('Analysis data loaded:', data); // Debug
row.child(formatAnalysis(data)).show();
tr.addClass('shown');
},
complete: function() {
button.prop('disabled', false);
button.html('Analysis');
},
error: function() {
Swal.fire('Error!', 'There was an error loading the analysis.', 'error');
button.prop('disabled', false);
button.html('Analysis');
}
});
});
// Funzione per formattare le analisi
function formatAnalysis(data) {
var parsedData = JSON.parse(data);
var html = '<table class="table table-bordered child-table">';
html += '<thead><tr><th>Analysis Name</th><th>Final Rating</th></tr></thead>';
html += '<tbody>';
// Per ogni analisi, aggiungi la riga corrispondente
$.each(parsedData, function(index, analysis) {
var ratingClass = ''; // Classe CSS per la colorazione della cella
if (analysis.finalRating === 'FAIL') {
ratingClass = 'bg-danger text-white'; // Colore rosso per i fallimenti
} else if (analysis.finalRating === 'PASS') {
ratingClass = 'bg-success text-white'; // Colore verde per i successi
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A') {
ratingClass = 'bg-warning text-dark'; // Colore giallo per risultati ambigui
}
html += '<tr>';
html += '<td>' + (analysis.name ? analysis.name : 'N/A') + '</td>';
html += '<td class="' + ratingClass + '">' + (analysis.finalRating ? analysis.finalRating : 'N/A') + '</td>';
html += '</tr>';
});
html += '</tbody></table>';
return html;
}
});
</script>
<!-- plugin JS -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
</body>
</html>

View File

@ -0,0 +1,260 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
$conn = new mysqli($servername, $username, $password, $database);
// 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);
?>
<!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">
<title>Reports</title>
<!-- Includi prima jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Includi DataTables CSS -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.5/css/jquery.dataTables.min.css">
<!-- Includi DataTables JS -->
<script src="https://cdn.datatables.net/1.11.5/js/jquery.dataTables.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 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">
</head>
<style>
.bg-danger {
background-color: #ff4d4d !important;
/* Rosso per fallimenti */
}
.bg-success {
background-color: #28a745 !important;
/* Verde per successi */
}
.bg-warning {
background-color: #ffc107 !important;
/* Giallo per N/A o // */
}
.text-white {
color: white !important;
}
.text-dark {
color: black !important;
}
/* Stile per le righe del report */
.report-row {
background-color: #f8f9fa;
/* Colore di sfondo leggero per il report */
font-weight: bold;
/* Rendi il testo in grassetto */
border-bottom: 2px solid #dee2e6;
/* Aggiungi un bordo più evidente per separare il report dalle analisi */
}
/* Stile per le righe delle analisi */
.analysis-row {
background-color: #ffffff;
/* Sfondo bianco per le analisi */
font-weight: normal;
/* Testo normale */
border-bottom: 1px solid #dee2e6;
/* Bordo più leggero per le analisi */
}
/* Hover effect per evidenziare */
.report-row:hover,
.analysis-row:hover {
background-color: #e9ecef;
/* Colore di sfondo leggermente più scuro al passaggio del mouse */
}
</style>
<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">Reports</h4>
</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">
<thead>
<tr>
<th>Report Number</th>
<th>Report Date</th>
<th>Product Ref</th>
<th>Product Description</th>
<th>Rating</th>
<th>Action</th>
</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>
<td>
<button class="btn btn-info btn-sm show-analysis">Analysis</button>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div><!-- container -->
</div><!-- Page content Wrapper -->
</div><!-- content -->
<?php include('../include/footer.php'); ?>
</div>
</div>
<script>
$(document).ready(function() {
// Inizializza DataTables con filtri per le colonne
var table = $('#reportsTable').DataTable({
responsive: true,
"pageLength": 50,
"order": [
[0, 'asc']
], // Ordina per numero di report
initComplete: function() {
// Aggiungi i filtri per ogni colonna
this.api().columns().every(function() {
var column = this;
var input = $('<input class="form-control form-control-sm" type="text" placeholder="Search"/>')
.appendTo($(column.header()))
.on('keyup change clear', function() {
if (column.search() !== this.value) {
column.search(this.value).draw();
}
});
});
}
});
// Gestione del click su "Analysis" per visualizzare la tabella delle analisi
$('#reportsTable').on('click', '.show-analysis', function() {
var tr = $(this).closest('tr');
var reportId = tr.data('reportid');
var row = $('#reportsTable').DataTable().row(tr);
var button = $(this);
console.log('Loading analysis for reportId:', reportId); // Debug
button.prop('disabled', true);
button.html('<i class="fa fa-spinner fa-spin"></i> Loading...');
// Se la riga child è già visibile, non facciamo nulla
if (row.child.isShown()) {
button.prop('disabled', false);
button.html('Analysis');
return;
}
// Carica le analisi tramite AJAX
$.ajax({
url: 'get_analysis_by_report.php', // Nuovo script PHP per ottenere le analisi del report
type: 'POST',
data: {
reportId: reportId
},
success: function(data) {
console.log('Analysis data loaded:', data); // Debug
row.child(formatAnalysis(data)).show();
tr.addClass('shown');
},
complete: function() {
button.prop('disabled', false);
button.html('Analysis');
},
error: function() {
Swal.fire('Error!', 'There was an error loading the analysis.', 'error');
button.prop('disabled', false);
button.html('Analysis');
}
});
});
// Funzione per formattare le analisi
function formatAnalysis(data) {
var parsedData = JSON.parse(data);
var html = '<table class="table table-bordered child-table">';
html += '<thead><tr><th>Analysis Name</th><th>Final Rating</th></tr></thead>';
html += '<tbody>';
// Per ogni analisi, aggiungi la riga corrispondente
$.each(parsedData, function(index, analysis) {
var ratingClass = ''; // Classe CSS per la colorazione della cella
if (analysis.finalRating === 'FAIL') {
ratingClass = 'bg-danger text-white'; // Colore rosso per i fallimenti
} else if (analysis.finalRating === 'PASS') {
ratingClass = 'bg-success text-white'; // Colore verde per i successi
} else if (analysis.finalRating === '//' || analysis.finalRating === 'N/A') {
ratingClass = 'bg-warning text-dark'; // Colore giallo per risultati ambigui
}
html += '<tr class="analysis-row">'; // Aggiungi la classe analysis-row
html += '<td>' + (analysis.name ? analysis.name : 'N/A') + '</td>';
html += '<td class="' + ratingClass + '">' + (analysis.finalRating ? analysis.finalRating : 'N/A') + '</td>';
html += '</tr>';
});
html += '</tbody></table>';
return html;
}
// Aggiungi la classe report-row a ogni riga del report
$('#reportsTable tbody tr').each(function() {
$(this).addClass('report-row');
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,610 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
include('parsedatachart.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'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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>
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
<script src="../assets/plugins/select2/select2.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<style>
.width-100 {
width: 100%;
}
.flex_center {
display: flex;
align-items: center;
}
.mg_none {
margin: 0 !important;
}
.hidden {
display: none !important;
}
.table-custom tr {
height: 40px;
line-height: 40px;
}
#ajax_preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 9999999;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
.padding_none {
padding: 0 !important;
}
.select2-container--open {
z-index: 9999;
}
.card {
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
transition: transform 0.2s ease-in-out;
}
.card:hover {
transform: translateY(-3px);
}
.card-body {
padding: 20px;
}
.card h2 {
font-size: 32px;
font-weight: bold;
margin-bottom: 5px;
}
.card h5 {
font-size: 18px;
font-weight: 500;
margin-bottom: 10px;
}
.card {
min-height: 150px;
/* Imposta un'altezza minima per le card */
}
.percentage {
font-size: 18px;
font-weight: bold;
margin-top: 5px;
margin-left: 10px;
}
.bg-light {
background-color: #f8f9fa !important;
}
.border-primary {
border: 2px solid #007bff !important;
}
.border-info {
border: 2px solid #17a2b8 !important;
}
.border-danger {
border: 2px solid #dc3545 !important;
}
.border-success {
border: 2px solid #28a745 !important;
}
.border-warning {
border: 2px solid #ffc107 !important;
}
.row {
margin-top: 20px;
}
.col-md-2 {
margin-bottom: 20px;
}
@media (max-width: 767px) {
.col-md-2 {
flex: 0 0 100%;
max-width: 100%;
}
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<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">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">Importify</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Importify: <?php echo $dashboard; ?></h5>
</div>
</div>
</div>
</div>
<!-- end row -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<!-- cards -->
<div class="row justify-content-between">
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-primary">
<div class="card-body">
<h5 class="card-title">Products</h5>
<h2 id="totalProducts">0</h2>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-info">
<div class="card-body">
<h5 class="card-title">Reports</h5>
<h2 id="totalReports">0</h2>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-danger">
<div class="card-body">
<h5 class="card-title">Failed Reports</h5>
<div class="d-flex justify-content-center align-items-baseline">
<h2 id="failedReports">0</h2>
<span class="percentage text-danger" id="failedReportsPercent" style="margin-left: 10px;">(0%)</span>
</div>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-success">
<div class="card-body">
<h5 class="card-title">Total Tests</h5>
<h2 id="totalTests">0</h2>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-warning">
<div class="card-body">
<h5 class="card-title">Failed Tests</h5>
<div class="d-flex justify-content-center align-items-baseline">
<h2 id="failedTests">0</h2>
<span class="percentage text-danger" id="failedTestsPercent" style="margin-left: 10px;">(0%)</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end row -->
<div class="row">
<div class="col-md-4"> <!-- Colonna per il primo grafico (Pie Chart) -->
<div class="card">
<div class="card-body">
<h5 class="card-title">Reports Overview</h5>
<div id="reportPieChart"></div>
</div>
</div>
</div>
<div class="col-md-8"> <!-- Colonna per il secondo grafico -->
<div class="card">
<div class="card-body">
<h5 class="card-title">Worst Analysis</h5>
<div id="worsttenanalysis"></div> <!-- Questo è lo spazio per il secondo grafico -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Worst Suppliers by Failed Report Percentage</h5>
<div id="worstSuppliersChart"></div> <!-- Il grafico verrà inserito qui -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Number of Products by Supplier</h5>
<div id="productBySupplierChart"></div> <!-- Lo spazio per il grafico -->
</div>
</div>
</div>
</div>
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
document.getElementById('totalProducts').innerText = <?php echo $totalProducts; ?>;
document.getElementById('totalReports').innerText = <?php echo $totalReports; ?>;
document.getElementById('failedReports').innerText = <?php echo $failedReports; ?>;
document.getElementById('failedReportsPercent').innerText = "(<?php echo number_format($failedReportsPercent, 2); ?>%)";
document.getElementById('totalTests').innerText = <?php echo $totalTests; ?>;
document.getElementById('failedTests').innerText = <?php echo $failedTests; ?>;
document.getElementById('failedTestsPercent').innerText = "(<?php echo number_format($failedTestsPercent, 2); ?>%)";
</script>
<script>
// Data for pie chart (Reports: Fail, Pass, Others)
var options = {
series: [<?php echo $failReportsPie; ?>, <?php echo $passReportsPie; ?>, <?php echo $otherReportsPie; ?>],
chart: {
width: '100%', // Mantieni la larghezza al 100% all'interno della colonna Bootstrap
type: 'pie',
},
labels: ['Fail', 'Pass', 'Others'],
colors: ['#FF4D4D', '#28A745', '#FFA500'], // Red for Fail, Green for Pass, Orange for Others
responsive: [{
breakpoint: 480,
options: {
chart: {
width: 250 // Riduci la larghezza sui dispositivi mobili
},
legend: {
position: 'bottom'
}
}
}],
legend: {
position: 'bottom', // Posiziona la legenda sotto il grafico
offsetY: 0,
height: 50, // Altezza della legenda
}
};
var chart = new ApexCharts(document.querySelector("#reportPieChart"), options);
chart.render();
</script>
<script>
// Data for the bar chart
var analysisNames = <?php echo json_encode(array_column($topFailingAnalysis, 'name')); ?>;
var failCounts = <?php echo json_encode(array_column($topFailingAnalysis, 'failCount')); ?>;
var options = {
series: [{
data: failCounts
}],
chart: {
type: 'bar',
height: 350
},
plotOptions: {
bar: {
horizontal: true,
dataLabels: {
position: 'center' // Posiziona i nomi delle analisi al centro delle barre
}
}
},
dataLabels: {
enabled: true,
style: {
colors: ['#fff'], // Colore del testo all'interno delle barre (bianco)
fontSize: '12px'
},
formatter: function(val, opt) {
return analysisNames[opt.dataPointIndex]; // Mostra il nome dell'analisi dentro la barra
}
},
xaxis: {
categories: failCounts, // Visualizza solo i numeri sull'asse X
title: {
text: 'Number of Failures'
}
},
yaxis: {
labels: {
show: false // Nascondiamo le etichette dell'asse Y
},
title: {
text: 'Analysis'
}
},
colors: ['#FF4D4D'], // Rosso per i Fail
responsive: [{
breakpoint: 480,
options: {
chart: {
height: 300
},
xaxis: {
labels: {
show: true
}
}
}
}],
title: {
text: 'Top 10 Analyses with the Most Failures',
align: 'center'
}
};
var chart = new ApexCharts(document.querySelector("#worsttenanalysis"), options);
chart.render();
</script>
<script>
// Data for the bar chart of worst suppliers
var supplierNames = <?php echo json_encode(array_column($worstSuppliers, 'supplier')); ?>;
var failPercentages = <?php echo json_encode(array_column($worstSuppliers, 'failPercentage')); ?>;
var totalReportsForSupplier = <?php echo json_encode(array_column($worstSuppliers, 'totalReports')); ?>;
var failedReportsForSupplier = <?php echo json_encode(array_column($worstSuppliers, 'failedReports')); ?>;
var options = {
series: [{
data: failPercentages
}],
chart: {
type: 'bar',
height: 400
},
plotOptions: {
bar: {
horizontal: true,
dataLabels: {
position: 'center' // Etichette al centro delle barre
}
}
},
dataLabels: {
enabled: true,
style: {
colors: ['#fff'], // Colore del testo all'interno delle barre
fontSize: '12px'
},
formatter: function(val, opt) {
// Aggiungi nome del fornitore, percentuale, numero di fail e numero totale di report
var totalReports = totalReportsForSupplier[opt.dataPointIndex]; // Numero totale di report
var failedReports = failedReportsForSupplier[opt.dataPointIndex]; // Numero di report falliti
return supplierNames[opt.dataPointIndex] + ' (' + val.toFixed(2) + '%) (Fail: ' + failedReports + ' - Total: ' + totalReports + ')';
}
},
xaxis: {
categories: supplierNames, // Visualizza i nomi dei fornitori
title: {
text: 'Failure Percentage (%)'
}
},
yaxis: {
labels: {
show: false // Nascondiamo le etichette dell'asse Y
},
title: {
text: 'Suppliers'
}
},
colors: ['#3368FF'], // Colore blu chiaro per le barre
title: {
text: 'Top 10 Suppliers with the Highest Failed Reports Percentage',
align: 'center'
}
};
var chart = new ApexCharts(document.querySelector("#worstSuppliersChart"), options);
chart.render();
</script>
<script>
// Prepara i dati per il grafico
var supplierNames = <?php echo json_encode(array_column($productBySupplier, 'supplier')); ?>;
var totalProducts = <?php echo json_encode(array_column($productBySupplier, 'totalProducts')); ?>;
var options = {
series: [{
name: 'Total Products',
data: totalProducts
}],
chart: {
type: 'bar',
height: 400
},
plotOptions: {
bar: {
horizontal: false, // Imposta il grafico a barre verticali
columnWidth: '50%',
dataLabels: {
position: 'top', // Etichette nella parte superiore delle barre
}
}
},
dataLabels: {
enabled: true,
offsetY: -20,
style: {
fontSize: '12px',
colors: ['#000']
}
},
xaxis: {
categories: supplierNames,
title: {
text: 'Suppliers'
}
},
yaxis: {
title: {
text: 'Number of Products'
}
},
colors: ['#3368FF'],
title: {
text: 'Number of Products by Supplier',
align: 'center'
}
};
var chart = new ApexCharts(document.querySelector("#productBySupplierChart"), options);
chart.render();
</script>
<!-- plugin JS -->
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/js/common_helper.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
</body>
</html>

View File

@ -0,0 +1,227 @@
<?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'); ?>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<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">
<style>
.table-custom tr {
height: 40px;
line-height: 40px;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
}
.table-custom .btn {
padding: 2px 15px;
line-height: 1.7;
font-size: 14px;
}
.form-row {
display: flex;
align-items: center;
/* Questo allinea verticalmente gli elementi nella riga */
gap: 10px;
/* Questo crea una piccola distanza tra gli elementi nella riga */
}
.table-custom .form-control,
.table-custom .form-select {
height: 25px;
/* Puoi modificare questo valore per adattarlo al tuo design */
padding: 2px 6px;
/* riduce la dimensione del padding */
font-size: 14px;
/* riduce la dimensione del font */
}
.table-custom .form-control-sm.analysis-input {
height: 25px;
/* Questo modifica la dimensione degli input con classe 'form-control-sm' e 'analysis-input' */
padding: 2px 6px;
font-size: 12px;
}
</style>
</head>
<body class="fixed-left">
<!-- Loader -->
<div id="preloader">
<div id="status">
<div class="spinner"></div>
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
<?php include('../include/navigationbar.php'); ?>
<!-- Start right Content here -->
<div class="content-page">
<!-- Start content -->
<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">
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">StatKPI</li>
</ol>
</div>
<h4 class="page-title">StatKPI</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Products</h5>
<a class="btn btn-primary" href="insert-importifytemplate.php" role="button">Products</a>
<a class="btn btn-danger" href="../index.php" role="button">Dahboard</a>
<br><br>
<div class="col-sm-12 mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search by Component or CAS">
</div>
<br>
<div class="table-responsive">
<table class="table table-striped table-sm sm-0">
<thead>
<tr>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Test Out</strong></th>
<th><strong>Rating</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php $productslist = new WA_MySQLi_RS("rsl", $repnew, 0);
$productslist->setQuery("SELECT * FROM products");
$productslist->execute();
$wa_startindex = 0;
while (!$productslist->atEnd()) {
$wa_startindex = $productslist->Index;
?> <tr>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsDateOut")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsRating")); ?></td>
<td>
<a class="btn btn-success" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Go"><i class="fas fa-angle-double-right font-size-16 align-middle"></i></a>
<a class="btn btn-primary" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Expand"><i class="fas fa-angle-double-down font-size-16 align-middle"></i></a>
</td>
</tr>
<?php $productslist->moveNext();
}
$productslist->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></tbody>
</table>
</div><!--end table-responsive-->
</div>
</div>
</div>
</div>
<!-- end row -->
</div><!-- container -->
</div> <!-- Page content Wrapper -->
</div> <!-- content -->
<?php include('../include/footer.php'); ?>
</div>
<!-- End Right content here -->
</div>
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
});
</script>
<!-- plugin JS -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
<script src="../assets/js/detect.js"></script>
<script src="../assets/js/fastclick.js"></script>
<script src="../assets/js/jquery.slimscroll.js"></script>
<script src="../assets/js/jquery.blockUI.js"></script>
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
</body>
</html>

View File

@ -0,0 +1,176 @@
<?php include('../../Connections/repnew.php'); ?>
<?php
$conn = new mysqli($servername, $username, $password, $database);
// Ottieni i filtri dal POST
$startDate = isset($_POST['startDate']) ? $_POST['startDate'] : '';
$endDate = isset($_POST['endDate']) ? $_POST['endDate'] : '';
$supplierFilter = isset($_POST['supplier']) ? $_POST['supplier'] : '';
// Creazione della condizione dei filtri di data e supplier
$filters = "WHERE 1=1";
if (!empty($startDate) && !empty($endDate)) {
$filters .= " AND r.reportsDateOut BETWEEN '$startDate' AND '$endDate'";
}
if (!empty($supplierFilter)) {
$filters .= " AND p.namesupplier = '$supplierFilter'";
}
// Statistic 1: Total number of products (filtered by supplier if necessary)
$totalProductsQuery = "SELECT COUNT(DISTINCT p.idproducts) AS totalProducts FROM products p";
if (!empty($supplierFilter)) {
$totalProductsQuery .= " WHERE p.namesupplier = '$supplierFilter'";
}
$totalProductsResult = $conn->query($totalProductsQuery);
$totalProducts = $totalProductsResult->fetch_assoc()['totalProducts'];
// Statistic 2: Total number of reports
$totalReportsQuery = "
SELECT COUNT(DISTINCT r.idreports) AS totalReports
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters
";
$totalReportsResult = $conn->query($totalReportsQuery);
$totalReports = $totalReportsResult->fetch_assoc()['totalReports'];
// Statistic 3: Number of 'fail' reports and percentage compared to total
$failedReportsQuery = "
SELECT COUNT(DISTINCT r.idreports) AS failedReports
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters AND UPPER(r.reportsRating) IN ('FAIL', 'F', 'DOESN\'T COMPLY')
";
$failedReportsResult = $conn->query($failedReportsQuery);
$failedReports = $failedReportsResult->fetch_assoc()['failedReports'];
$failedReportsPercent = ($totalReports > 0) ? ($failedReports / $totalReports) * 100 : 0;
// Statistic 4: Total number of tests performed (distinct tests)
$totalTestsQuery = "
SELECT COUNT(DISTINCT rp.idreports, rp.idPart, rp.result_TestName) AS totalTests
FROM result_project rp
LEFT JOIN reports r ON rp.idreports = r.idreports
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters
";
$totalTestsResult = $conn->query($totalTestsQuery);
$totalTests = $totalTestsResult->fetch_assoc()['totalTests'];
// Statistic 5: Number of 'fail' tests and percentage (case-insensitive for rating fail)
$failedTestsQuery = "
SELECT COUNT(DISTINCT rp.idreports, rp.idPart, rp.result_TestName) AS failedTests
FROM result_project rp
LEFT JOIN reports r ON rp.idreports = r.idreports
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters AND UPPER(rp.result_Rating) IN ('FAIL', 'F', 'DOESN\'T COMPLY')
";
$failedTestsResult = $conn->query($failedTestsQuery);
$failedTests = $failedTestsResult->fetch_assoc()['failedTests'];
$failedTestsPercent = ($totalTests > 0) ? ($failedTests / $totalTests) * 100 : 0;
// Pie Chart Data for Reports (Fail, Pass, Others)
$failReportsPieQuery = "
SELECT COUNT(*) AS failReports
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters AND UPPER(r.reportsRating) IN ('FAIL', 'F', 'DOESN\'T COMPLY')
";
$failReportsPieResult = $conn->query($failReportsPieQuery);
$failReportsPie = $failReportsPieResult->fetch_assoc()['failReports'];
$passReportsPieQuery = "
SELECT COUNT(*) AS passReports
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters AND UPPER(r.reportsRating) IN ('PASS', 'P', 'COMPLIES')
";
$passReportsPieResult = $conn->query($passReportsPieQuery);
$passReportsPie = $passReportsPieResult->fetch_assoc()['passReports'];
$otherReportsPieQuery = "
SELECT COUNT(*) AS otherReports
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters AND UPPER(r.reportsRating) NOT IN ('FAIL', 'F', 'DOESN\'T COMPLY', 'PASS', 'P', 'COMPLIES')
";
$otherReportsPieResult = $conn->query($otherReportsPieQuery);
$otherReportsPie = $otherReportsPieResult->fetch_assoc()['otherReports'];
// Query to get the top 10 analyses with the most 'Fail' results
$topFailingAnalysisQuery = "
SELECT a.nameanalysisvoc AS analysisName, COUNT(DISTINCT rp.idreports, rp.idPart, rp.result_TestName) AS failCount
FROM result_project rp
LEFT JOIN reports r ON rp.idreports = r.idreports
LEFT JOIN products p ON r.idproducts = p.idproducts
LEFT JOIN analysisvocabulary a ON rp.result_TestName = a.idanalysisvocabulary
$filters AND UPPER(rp.result_Rating) IN ('FAIL', 'F', 'DOESN\'T COMPLY')
GROUP BY rp.result_TestName
ORDER BY failCount DESC
LIMIT 10
";
$topFailingAnalysisResult = $conn->query($topFailingAnalysisQuery);
$topFailingAnalysis = [];
while ($row = $topFailingAnalysisResult->fetch_assoc()) {
$analysisName = (strlen($row['analysisName']) > 80) ? substr($row['analysisName'], 0, 80) . '...' : $row['analysisName'];
$topFailingAnalysis[] = ['name' => $analysisName, 'failCount' => $row['failCount']];
}
// Statistic for worst suppliers based on % of failed reports
$worstSuppliersQuery = "
SELECT p.namesupplier AS supplier, COUNT(r.idreports) AS totalReports,
SUM(CASE WHEN UPPER(r.reportsRating) IN ('FAIL', 'F', 'DOESN\'T COMPLY') THEN 1 ELSE 0 END) AS failedReports,
(SUM(CASE WHEN UPPER(r.reportsRating) IN ('FAIL', 'F', 'DOESN\'T COMPLY') THEN 1 ELSE 0 END) / COUNT(r.idreports)) * 100 AS failPercentage
FROM reports r
LEFT JOIN products p ON r.idproducts = p.idproducts
$filters
GROUP BY p.namesupplier
ORDER BY failPercentage DESC
LIMIT 10
";
$worstSuppliersResult = $conn->query($worstSuppliersQuery);
$worstSuppliers = [];
while ($row = $worstSuppliersResult->fetch_assoc()) {
$worstSuppliers[] = [
'supplier' => $row['supplier'],
'failPercentage' => round($row['failPercentage'], 2),
'totalReports' => $row['totalReports'],
'failedReports' => $row['failedReports']
];
}
// Statistic for products by suppliers
$productBySupplierQuery = "
SELECT p.namesupplier AS supplier, COUNT(p.idproducts) AS totalProducts
FROM products p
WHERE p.namesupplier IS NOT NULL
GROUP BY p.namesupplier
ORDER BY totalProducts DESC";
$productBySupplierResult = $conn->query($productBySupplierQuery);
$productBySupplier = [];
while ($row = $productBySupplierResult->fetch_assoc()) {
$productBySupplier[] = [
'supplier' => $row['supplier'],
'totalProducts' => $row['totalProducts']
];
}
// Ora controlliamo se è una richiesta AJAX
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Rispondi ai dati aggiornati tramite AJAX
echo json_encode([
'totalProducts' => $totalProducts,
'totalReports' => $totalReports,
'failedReports' => $failedReports,
'failedReportsPercent' => $failedReportsPercent,
'totalTests' => $totalTests,
'failedTests' => $failedTests,
'failedTestsPercent' => $failedTestsPercent,
'failReportsPie' => $failReportsPie,
'passReportsPie' => $passReportsPie,
'otherReportsPie' => $otherReportsPie,
'topFailingAnalysis' => $topFailingAnalysis,
'worstSuppliers' => $worstSuppliers,
'productBySupplier' => $productBySupplier
]);
exit; // Ferma l'esecuzione del resto dello script dopo aver risposto all'AJAX
}

View File

@ -1,5 +1,6 @@
<?php include('../include/headscript.php'); ?>
<?php include("../class/company.php");
include('parsedatachart.php');
?>
<!DOCTYPE html>
<html lang="en">
@ -20,12 +21,49 @@
<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>
<link rel="stylesheet" href="../assets/plugins/select2/select2.min.css">
<script src="../assets/plugins/select2/select2.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/4.2.6/gridstack.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/gridstack.js/4.2.6/gridstack-h5.min.js"></script>
<style>
.width-100 {
width: 100%;
}
.flex_center {
display: flex;
align-items: center;
}
.mg_none {
margin: 0 !important;
}
.hidden {
display: none !important;
}
.table-custom tr {
height: 40px;
line-height: 40px;
}
#ajax_preloader {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: transparent;
z-index: 9999999;
}
.table-custom td,
.table-custom th {
padding: 4px 8px;
@ -61,7 +99,103 @@
padding: 2px 6px;
font-size: 12px;
}
.padding_none {
padding: 0 !important;
}
.select2-container--open {
z-index: 9999;
}
.card {
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
transition: transform 0.2s ease-in-out;
}
.card:hover {
transform: translateY(-3px);
}
.card-body {
padding: 20px;
}
.card h2 {
font-size: 32px;
font-weight: bold;
margin-bottom: 5px;
}
.card h5 {
font-size: 18px;
font-weight: 500;
margin-bottom: 10px;
}
.card {
min-height: 150px;
/* Imposta un'altezza minima per le card */
}
.percentage {
font-size: 18px;
font-weight: bold;
margin-top: 5px;
margin-left: 10px;
}
.bg-light {
background-color: #f8f9fa !important;
}
.border-primary {
border: 2px solid #007bff !important;
}
.border-info {
border: 2px solid #17a2b8 !important;
}
.border-danger {
border: 2px solid #dc3545 !important;
}
.border-success {
border: 2px solid #28a745 !important;
}
.border-warning {
border: 2px solid #ffc107 !important;
}
.row {
margin-top: 20px;
}
.col-md-2 {
margin-bottom: 20px;
}
@media (max-width: 767px) {
.col-md-2 {
flex: 0 0 100%;
max-width: 100%;
}
}
.filters-applied {
display: inline-block;
background-color: #3368ff;
color: white;
border-radius: 5px;
padding: 5px 10px;
font-weight: bold;
margin-top: 10px;
}
</style>
</head>
@ -74,6 +208,8 @@
</div>
</div>
<!-- Begin page -->
<div id="wrapper">
@ -97,91 +233,162 @@
<div class="btn-group float-right">
<ol class="breadcrumb hide-phone p-0 m-0">
<li class="breadcrumb-item"><a href="#">Reportify</a></li>
<li class="breadcrumb-item active">StatKPI</li>
<li class="breadcrumb-item active">Importify</li>
</ol>
</div>
<h4 class="page-title">StatKPI</h4>
<h4 class="page-title">Importify</h4>
</div>
</div>
</div>
<!-- end page title end breadcrumb -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<h5 class="header-title pb-3 mt-0">Products</h5>
<a class="btn btn-primary" href="insert-importifytemplate.php" role="button">Products</a>
<a class="btn btn-danger" href="../index.php" role="button">Dahboard</a>
<br><br>
<div class="col-sm-12 mb-3">
<input type="text" class="form-control" id="searchInput" placeholder="Search by Component or CAS">
<h5 class="header-title pb-3 mt-0">Importify: <?php echo $dashboard; ?></h5>
<!-- Filter Section -->
<div class="row">
<div class="col-md-4">
<label for="startDate">Start Date</label>
<input type="date" id="startDate" class="form-control" placeholder="Start Date">
</div>
<div class="col-md-4">
<label for="endDate">End Date</label>
<input type="date" id="endDate" class="form-control" placeholder="End Date">
</div>
<div class="col-md-4">
<label for="supplierFilter">Supplier</label>
<select id="supplierFilter" class="form-control select2">
<option value="">All Suppliers</option>
<?php foreach ($productBySupplier as $supplier): ?>
<option value="<?php echo $supplier['supplier']; ?>"><?php echo $supplier['supplier']; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<hr>
<!-- Active Filters Display -->
<div id="activeFilters" class="mt-3" style="display: none;">
<h6>Active Filters:</h6>
<div id="filterDisplay" class="filters-applied badge badge-info p-2" style="font-size: 16px;"></div>
<button id="clearFilters" class="btn btn-sm btn-warning ml-3">Clear Filters</button>
</div>
<br>
<div class="table-responsive">
<table class="table table-striped table-sm sm-0">
<thead>
<tr>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Ref. Number</strong></th>
<th><strong>Description</strong></th>
<th><strong>Test Out</strong></th>
<th><strong>Rating</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php $productslist = new WA_MySQLi_RS("rsl", $repnew, 0);
$productslist->setQuery("SELECT * FROM products");
$productslist->execute();
$wa_startindex = 0;
while (!$productslist->atEnd()) {
$wa_startindex = $productslist->Index;
?> <tr>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_refnumber")); ?></td>
<td><?php echo ($productslist->getColumnVal("products_description")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsDateOut")); ?></td>
<td><?php echo ($productslist->getColumnVal("reportsRating")); ?></td>
<td>
<a class="btn btn-success" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Go"><i class="fas fa-angle-double-right font-size-16 align-middle"></i></a>
<a class="btn btn-primary" href="material-rsl.php?id=<?php echo ($productslist->getColumnVal("idimporttemplates")); ?>" role="button" data-toggle="tooltip" title="Expand"><i class="fas fa-angle-double-down font-size-16 align-middle"></i></a>
</td>
</tr>
<?php $productslist->moveNext();
}
$productslist->moveFirst(); //return RS to first record
unset($wa_startindex);
unset($wa_repeatcount);
?></tbody>
</table>
</div><!--end table-responsive-->
<hr>
</div>
</div>
</div>
</div>
<!-- end row -->
<div class="row">
<div class="col-xl-12">
<div class="card">
<div class="card-body">
<!-- cards -->
<div class="row justify-content-between">
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-primary">
<div class="card-body">
<h5 class="card-title">Products</h5>
<h2 id="totalProducts">0</h2>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-info">
<div class="card-body">
<h5 class="card-title">Reports</h5>
<h2 id="totalReports">0</h2>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-danger">
<div class="card-body">
<h5 class="card-title">Failed Reports</h5>
<div class="d-flex justify-content-center align-items-baseline">
<h2 id="failedReports">0</h2>
<span class="percentage text-danger" id="failedReportsPercent" style="margin-left: 10px;">(0%)</span>
</div>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-success">
<div class="card-body">
<h5 class="card-title">Total Tests</h5>
<h2 id="totalTests">0</h2>
</div>
</div>
</div>
<div class="col-md-2 col-sm-6">
<div class="card text-center bg-light border-warning">
<div class="card-body">
<h5 class="card-title">Failed Tests</h5>
<div class="d-flex justify-content-center align-items-baseline">
<h2 id="failedTests">0</h2>
<span class="percentage text-danger" id="failedTestsPercent" style="margin-left: 10px;">(0%)</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end row -->
<div class="row">
<div class="col-md-4"> <!-- Colonna per il primo grafico (Pie Chart) -->
<div class="card">
<div class="card-body">
<h5 class="card-title">Reports Overview</h5>
<div id="reportPieChart"></div>
</div>
</div>
</div>
<div class="col-md-8"> <!-- Colonna per il secondo grafico -->
<div class="card">
<div class="card-body">
<h5 class="card-title">Worst Analysis</h5>
<div id="worsttenanalysis"></div> <!-- Questo è lo spazio per il secondo grafico -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Worst Suppliers by Failed Report Percentage</h5>
<div id="worstSuppliersChart"></div> <!-- Il grafico verrà inserito qui -->
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<h5 class="card-title">Number of Products by Supplier</h5>
<div id="productBySupplierChart"></div> <!-- Lo spazio per il grafico -->
</div>
</div>
</div>
</div>
</div><!-- container -->
@ -198,12 +405,304 @@
<!-- END wrapper -->
<script>
$(document).ready(function() {
$('[data-toggle="tooltip"]').tooltip();
// Inizializza Select2 per il filtro supplier
$('#supplierFilter').select2({
placeholder: 'Select a supplier',
allowClear: true
});
// Funzione per aggiornare i dati con AJAX
function updateData() {
var startDate = $('#startDate').val();
var endDate = $('#endDate').val();
var supplier = $('#supplierFilter').val();
$.ajax({
url: 'parsedatachart.php',
method: 'POST',
data: {
startDate: startDate,
endDate: endDate,
supplier: supplier
},
success: function(response) {
// Assicurati di fare il parsing della risposta JSON
var data = JSON.parse(response);
// Aggiorna le cards con i nuovi dati
$('#totalProducts').text(data.totalProducts);
$('#totalReports').text(data.totalReports);
$('#failedReports').text(data.failedReports);
$('#failedReportsPercent').text('(' + data.failedReportsPercent.toFixed(2) + '%)');
$('#totalTests').text(data.totalTests);
$('#failedTests').text(data.failedTests);
$('#failedTestsPercent').text('(' + data.failedTestsPercent.toFixed(2) + '%)');
// Aggiorna il grafico dei report (Pie Chart)
chart.updateSeries([data.failReportsPie, data.passReportsPie, data.otherReportsPie]);
// Mostra i filtri attivi
var filterText = '';
if (startDate && endDate) {
filterText += 'Date: ' + startDate + ' to ' + endDate + ' ';
}
if (supplier) {
filterText += 'Supplier: ' + $('#supplierFilter option:selected').text();
}
$('#filterDisplay').text(filterText);
$('#activeFilters').show();
},
error: function() {
alert('Error retrieving data.');
}
});
}
// Eventi per applicare i filtri
$('#startDate, #endDate, #supplierFilter').on('change', function() {
updateData();
});
// Clear filters
$('#clearFilters').on('click', function() {
$('#startDate').val('');
$('#endDate').val('');
$('#supplierFilter').val('').trigger('change');
updateData();
$('#activeFilters').hide();
});
// Chiamata iniziale per caricare i dati alla prima visualizzazione della pagina
updateData();
});
</script>
<script>
document.getElementById('totalProducts').innerText = <?php echo $totalProducts; ?>;
document.getElementById('totalReports').innerText = <?php echo $totalReports; ?>;
document.getElementById('failedReports').innerText = <?php echo $failedReports; ?>;
document.getElementById('failedReportsPercent').innerText = "(<?php echo number_format($failedReportsPercent, 2); ?>%)";
document.getElementById('totalTests').innerText = <?php echo $totalTests; ?>;
document.getElementById('failedTests').innerText = <?php echo $failedTests; ?>;
document.getElementById('failedTestsPercent').innerText = "(<?php echo number_format($failedTestsPercent, 2); ?>%)";
</script>
<script>
// Data for pie chart (Reports: Fail, Pass, Others)
var options = {
series: [<?php echo $failReportsPie; ?>, <?php echo $passReportsPie; ?>, <?php echo $otherReportsPie; ?>],
chart: {
width: '100%', // Mantieni la larghezza al 100% all'interno della colonna Bootstrap
type: 'pie',
},
labels: ['Fail', 'Pass', 'Others'],
colors: ['#FF4D4D', '#28A745', '#FFA500'], // Red for Fail, Green for Pass, Orange for Others
responsive: [{
breakpoint: 480,
options: {
chart: {
width: 250 // Riduci la larghezza sui dispositivi mobili
},
legend: {
position: 'bottom'
}
}
}],
legend: {
position: 'bottom', // Posiziona la legenda sotto il grafico
offsetY: 0,
height: 50, // Altezza della legenda
}
};
var chart = new ApexCharts(document.querySelector("#reportPieChart"), options);
chart.render();
</script>
<script>
// Data for the bar chart
var analysisNames = <?php echo json_encode(array_column($topFailingAnalysis, 'name')); ?>;
var failCounts = <?php echo json_encode(array_column($topFailingAnalysis, 'failCount')); ?>;
var options = {
series: [{
data: failCounts
}],
chart: {
type: 'bar',
height: 350
},
plotOptions: {
bar: {
horizontal: true,
dataLabels: {
position: 'center' // Posiziona i nomi delle analisi al centro delle barre
}
}
},
dataLabels: {
enabled: true,
style: {
colors: ['#fff'], // Colore del testo all'interno delle barre (bianco)
fontSize: '12px'
},
formatter: function(val, opt) {
return analysisNames[opt.dataPointIndex]; // Mostra il nome dell'analisi dentro la barra
}
},
xaxis: {
categories: failCounts, // Visualizza solo i numeri sull'asse X
title: {
text: 'Number of Failures'
}
},
yaxis: {
labels: {
show: false // Nascondiamo le etichette dell'asse Y
},
title: {
text: 'Analysis'
}
},
colors: ['#FF4D4D'], // Rosso per i Fail
responsive: [{
breakpoint: 480,
options: {
chart: {
height: 300
},
xaxis: {
labels: {
show: true
}
}
}
}],
title: {
text: 'Top 10 Analyses with the Most Failures',
align: 'center'
}
};
var chart = new ApexCharts(document.querySelector("#worsttenanalysis"), options);
chart.render();
</script>
<script>
// Data for the bar chart of worst suppliers
var supplierNames = <?php echo json_encode(array_column($worstSuppliers, 'supplier')); ?>;
var failPercentages = <?php echo json_encode(array_column($worstSuppliers, 'failPercentage')); ?>;
var totalReportsForSupplier = <?php echo json_encode(array_column($worstSuppliers, 'totalReports')); ?>;
var failedReportsForSupplier = <?php echo json_encode(array_column($worstSuppliers, 'failedReports')); ?>;
var options = {
series: [{
data: failPercentages
}],
chart: {
type: 'bar',
height: 400
},
plotOptions: {
bar: {
horizontal: true,
dataLabels: {
position: 'center' // Etichette al centro delle barre
}
}
},
dataLabels: {
enabled: true,
style: {
colors: ['#fff'], // Colore del testo all'interno delle barre
fontSize: '12px'
},
formatter: function(val, opt) {
// Aggiungi nome del fornitore, percentuale, numero di fail e numero totale di report
var totalReports = totalReportsForSupplier[opt.dataPointIndex]; // Numero totale di report
var failedReports = failedReportsForSupplier[opt.dataPointIndex]; // Numero di report falliti
return supplierNames[opt.dataPointIndex] + ' (' + val.toFixed(2) + '%) (Fail: ' + failedReports + ' - Total: ' + totalReports + ')';
}
},
xaxis: {
categories: supplierNames, // Visualizza i nomi dei fornitori
title: {
text: 'Failure Percentage (%)'
}
},
yaxis: {
labels: {
show: false // Nascondiamo le etichette dell'asse Y
},
title: {
text: 'Suppliers'
}
},
colors: ['#3368FF'], // Colore blu chiaro per le barre
title: {
text: 'Top 10 Suppliers with the Highest Failed Reports Percentage',
align: 'center'
}
};
var chart = new ApexCharts(document.querySelector("#worstSuppliersChart"), options);
chart.render();
</script>
<script>
// Prepara i dati per il grafico
var supplierNames = <?php echo json_encode(array_column($productBySupplier, 'supplier')); ?>;
var totalProducts = <?php echo json_encode(array_column($productBySupplier, 'totalProducts')); ?>;
var options = {
series: [{
name: 'Total Products',
data: totalProducts
}],
chart: {
type: 'bar',
height: 400
},
plotOptions: {
bar: {
horizontal: false, // Imposta il grafico a barre verticali
columnWidth: '50%',
dataLabels: {
position: 'top', // Etichette nella parte superiore delle barre
}
}
},
dataLabels: {
enabled: true,
offsetY: -20,
style: {
fontSize: '12px',
colors: ['#000']
}
},
xaxis: {
categories: supplierNames,
title: {
text: 'Suppliers'
}
},
yaxis: {
title: {
text: 'Number of Products'
}
},
colors: ['#3368FF'],
title: {
text: 'Number of Products by Supplier',
align: 'center'
}
};
var chart = new ApexCharts(document.querySelector("#productBySupplierChart"), options);
chart.render();
</script>
<!-- plugin JS -->
<script src="../assets/js/jquery.min.js"></script>
<script src="../assets/js/popper.min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/modernizr.min.js"></script>
@ -214,12 +713,14 @@
<script src="../assets/js/waves.js"></script>
<script src="../assets/js/jquery.nicescroll.js"></script>
<script src="../assets/js/jquery.scrollTo.min.js"></script>
<script src="../assets/js/common_helper.js"></script>
<script src="../assets/plugins/chart.js/chart.min.js"></script>
<script src="../assets/pages/dashboard.js"></script>
<!-- App js -->
<script src="../assets/js/app.js"></script>
<script src="../assets/plugins/alertify/js/alertify.js"></script>
</body>

File diff suppressed because it is too large Load Diff