added rate&go
BIN
public/download/Report12-11-2024-10-07.pdf
Normal file
78
public/userarea/ratego/calculate_supplier_ratings.php
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
<?php
|
||||||
|
include('../include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die(json_encode(['message' => "Connection failed: " . $conn->connect_error]));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calcolo rating dei fornitori con dettagli
|
||||||
|
$query = "
|
||||||
|
INSERT INTO supplier_ratings (
|
||||||
|
name,
|
||||||
|
total_products,
|
||||||
|
total_analyses,
|
||||||
|
pass_analyses,
|
||||||
|
fail_analyses,
|
||||||
|
data_analyses,
|
||||||
|
rating,
|
||||||
|
calculation_date
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
p.namesupplier AS name,
|
||||||
|
COUNT(DISTINCT p.idproducts) AS total_products,
|
||||||
|
COUNT(ap.idAnalysis_Project) AS total_analyses,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN LOWER(ap.test_Rating) IN ('pass', 'p', 'comply', 'complies') THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS pass_analyses,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS fail_analyses,
|
||||||
|
SUM(CASE
|
||||||
|
WHEN LOWER(ap.test_Rating) NOT IN ('pass', 'p', 'comply', 'complies', 'fail', 'f', 'doesn\'t comply') THEN 1
|
||||||
|
ELSE 0
|
||||||
|
END) AS data_analyses,
|
||||||
|
GREATEST(0, 10 - (
|
||||||
|
SUM(
|
||||||
|
CASE
|
||||||
|
WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN
|
||||||
|
COALESCE(asv.severity, 1) *
|
||||||
|
CASE WHEN COALESCE(asv.is_legal, 'N') = 'Y' THEN 1.5 ELSE 1.0 END
|
||||||
|
ELSE 0
|
||||||
|
END
|
||||||
|
) * (1 + SUM(CASE WHEN LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply') THEN 1 ELSE 0 END) / NULLIF(COUNT(ap.idAnalysis_Project), 0))
|
||||||
|
/ NULLIF(COUNT(ap.idAnalysis_Project), 0) * 100
|
||||||
|
)) AS rating,
|
||||||
|
NOW() AS calculation_date
|
||||||
|
FROM products p
|
||||||
|
JOIN reports r ON p.idproducts = r.idproducts
|
||||||
|
JOIN parts pt ON r.idreports = pt.idreports
|
||||||
|
JOIN analysis_project ap ON pt.idParts = ap.idPart
|
||||||
|
LEFT JOIN analysis_severity asv ON ap.idAnalysis = asv.idanalysisvocabulary
|
||||||
|
GROUP BY p.namesupplier
|
||||||
|
ON DUPLICATE KEY UPDATE
|
||||||
|
total_products = VALUES(total_products),
|
||||||
|
total_analyses = VALUES(total_analyses),
|
||||||
|
pass_analyses = VALUES(pass_analyses),
|
||||||
|
fail_analyses = VALUES(fail_analyses),
|
||||||
|
data_analyses = VALUES(data_analyses),
|
||||||
|
rating = VALUES(rating),
|
||||||
|
calculation_date = VALUES(calculation_date);
|
||||||
|
|
||||||
|
";
|
||||||
|
|
||||||
|
if ($conn->query($query) === TRUE) {
|
||||||
|
echo json_encode(['message' => 'Ratings calculated successfully!']);
|
||||||
|
} else {
|
||||||
|
echo json_encode([
|
||||||
|
'message' => $conn->error,
|
||||||
|
'exception' => 'mysqli_sql_exception',
|
||||||
|
'file' => __FILE__,
|
||||||
|
'line' => __LINE__
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
71
public/userarea/ratego/get_analysis_data.php
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
include('../include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera il nome del fornitore
|
||||||
|
$supplierName = isset($_GET['supplier']) ? $conn->real_escape_string($_GET['supplier']) : '';
|
||||||
|
|
||||||
|
// Verifica che il nome del fornitore sia presente
|
||||||
|
if (empty($supplierName)) {
|
||||||
|
die(json_encode(['error' => 'Supplier name is missing']));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query per la distribuzione totale delle analisi
|
||||||
|
$queryDistribution = "
|
||||||
|
SELECT
|
||||||
|
av.nameanalysisvoc AS analysis_name,
|
||||||
|
COUNT(ap.idAnalysis_Project) AS total
|
||||||
|
FROM products p
|
||||||
|
JOIN reports r ON p.idproducts = r.idproducts
|
||||||
|
JOIN parts pt ON r.idreports = pt.idreports
|
||||||
|
JOIN analysis_project ap ON pt.idParts = ap.idPart
|
||||||
|
LEFT JOIN analysisvocabulary av ON ap.result_TestName = av.idanalysisvocabulary
|
||||||
|
WHERE p.namesupplier = '$supplierName' AND av.preferred = 'Y'
|
||||||
|
GROUP BY av.nameanalysisvoc
|
||||||
|
ORDER BY total DESC
|
||||||
|
LIMIT 10;
|
||||||
|
";
|
||||||
|
|
||||||
|
$resultDistribution = $conn->query($queryDistribution);
|
||||||
|
$analysisDistribution = [];
|
||||||
|
while ($row = $resultDistribution->fetch_assoc()) {
|
||||||
|
$analysisDistribution[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query per la distribuzione delle analisi FAIL
|
||||||
|
$queryFail = "
|
||||||
|
SELECT
|
||||||
|
av.nameanalysisvoc AS analysis_name,
|
||||||
|
COUNT(*) AS fail
|
||||||
|
FROM products p
|
||||||
|
LEFT JOIN reports r ON p.idproducts = r.idproducts
|
||||||
|
LEFT JOIN parts pt ON r.idreports = pt.idreports
|
||||||
|
LEFT JOIN analysis_project ap ON pt.idParts = ap.idPart
|
||||||
|
LEFT JOIN analysisvocabulary av ON ap.result_TestName = av.idanalysisvocabulary
|
||||||
|
WHERE
|
||||||
|
p.namesupplier = '$supplierName'
|
||||||
|
AND LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply')
|
||||||
|
AND av.preferred = 'Y'
|
||||||
|
GROUP BY av.nameanalysisvoc
|
||||||
|
ORDER BY fail DESC
|
||||||
|
LIMIT 10;
|
||||||
|
|
||||||
|
";
|
||||||
|
|
||||||
|
$resultFail = $conn->query($queryFail);
|
||||||
|
$failDistribution = [];
|
||||||
|
while ($row = $resultFail->fetch_assoc()) {
|
||||||
|
$failDistribution[] = $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restituisci i dati come JSON
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode([
|
||||||
|
'analysisDistribution' => $analysisDistribution,
|
||||||
|
'failDistribution' => $failDistribution
|
||||||
|
]);
|
||||||
51
public/userarea/ratego/get_fail_details.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
include('../include/headscript.php');
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera il nome del fornitore
|
||||||
|
$supplierName = isset($_GET['supplier']) ? $conn->real_escape_string($_GET['supplier']) : '';
|
||||||
|
|
||||||
|
if (empty($supplierName)) {
|
||||||
|
echo json_encode(['error' => 'Supplier name not provided.']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Query SQL per ottenere i dettagli delle analisi FAIL
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
av.nameanalysisvoc AS analysis_name,
|
||||||
|
r.reportsNumberLab AS report_number, -- Numero del rapporto
|
||||||
|
p.products_description AS product_description,
|
||||||
|
p.products_refnumber AS product_refnumber, -- Numero di riferimento del prodotto
|
||||||
|
r.idreports AS report_id -- ID del rapporto per eventuali azioni o collegamenti
|
||||||
|
FROM products p
|
||||||
|
JOIN reports r ON p.idproducts = r.idproducts
|
||||||
|
JOIN parts pt ON r.idreports = pt.idreports
|
||||||
|
JOIN analysis_project ap ON pt.idParts = ap.idPart
|
||||||
|
JOIN analysisvocabulary av ON ap.result_TestName = av.idanalysisvocabulary
|
||||||
|
WHERE p.namesupplier = 'PONTOGLIO S.P.A.'
|
||||||
|
AND LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply');
|
||||||
|
";
|
||||||
|
|
||||||
|
$result = $conn->query($query);
|
||||||
|
|
||||||
|
if (!$result) {
|
||||||
|
echo json_encode(['error' => $conn->error]);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$failDetails = [];
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$failDetails[] = [
|
||||||
|
'analysis_name' => $row['analysis_name'],
|
||||||
|
'report_number' => $row['report_number'],
|
||||||
|
'product_refnumber' => $row['product_refnumber'],
|
||||||
|
'product_description' => $row['product_description'],
|
||||||
|
'report_id' => $row['report_id'],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode(['failDetails' => $failDetails]);
|
||||||
47
public/userarea/ratego/get_supplier_ratings.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
include('../include/headscript.php');
|
||||||
|
|
||||||
|
// Connessione al database
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera i dati dei fornitori con dettagli aggiuntivi
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
total_products,
|
||||||
|
total_analyses,
|
||||||
|
pass_analyses,
|
||||||
|
fail_analyses,
|
||||||
|
data_analyses,
|
||||||
|
rating,
|
||||||
|
calculation_date
|
||||||
|
FROM supplier_ratings
|
||||||
|
ORDER BY rating DESC
|
||||||
|
";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
|
||||||
|
$data = [];
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$color = $row['rating'] >= 8 ? '#28a745' : ($row['rating'] >= 5 ? '#ffc107' : '#dc3545');
|
||||||
|
$data[] = [
|
||||||
|
'id' => $row['id'],
|
||||||
|
'name' => $row['name'],
|
||||||
|
'total_products' => $row['total_products'],
|
||||||
|
'total_analyses' => $row['total_analyses'],
|
||||||
|
'pass_analyses' => $row['pass_analyses'],
|
||||||
|
'fail_analyses' => $row['fail_analyses'],
|
||||||
|
'data_analyses' => $row['data_analyses'],
|
||||||
|
'rating' => $row['rating'],
|
||||||
|
'date' => $row['calculation_date'],
|
||||||
|
'color' => $color
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($data);
|
||||||
|
|
||||||
|
$conn->close();
|
||||||
200
public/userarea/ratego/ratego.php
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
<?php include('../include/headscript.php'); ?>
|
||||||
|
<?php include("../class/company.php"); ?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||||
|
<?php include('../include/seo.php'); ?>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.ico">
|
||||||
|
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||||
|
<link href="../assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||||
|
<link href="../assets/css/style.css" rel="stylesheet" type="text/css">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
||||||
|
<script src="../assets/js/jquery.min.js"></script>
|
||||||
|
|
||||||
|
<!-- DataTables CSS -->
|
||||||
|
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.5/css/jquery.dataTables.min.css">
|
||||||
|
|
||||||
|
<!-- DataTables JS -->
|
||||||
|
<script src="https://cdn.datatables.net/1.13.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">Supplier Ratings</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Button for Rating Calculation -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12 text-right">
|
||||||
|
<button id="calculate-rating" class="btn btn-primary mb-3">
|
||||||
|
Calculate Ratings
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Chart Section -->
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div id="supplier-rating-chart"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Table Section -->
|
||||||
|
<div class="row mt-4">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table id="supplierTable" class="table table-bordered table-striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Supplier Name</th>
|
||||||
|
<th>Number of Products</th>
|
||||||
|
<th>Total Analyses</th>
|
||||||
|
<th>PASS Analyses</th>
|
||||||
|
<th>FAIL Analyses</th>
|
||||||
|
<th>DATA Analyses</th>
|
||||||
|
<th>Rating</th>
|
||||||
|
<th>Date Calculated</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<!-- DataTables popolerà dinamicamente il contenuto -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php include('../include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
// Funzione per aggiornare il grafico
|
||||||
|
function updateChart(response) {
|
||||||
|
const suppliers = response.map(s => s.name);
|
||||||
|
const ratings = response.map(s => s.rating);
|
||||||
|
const colors = response.map(s => s.color);
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
series: [{
|
||||||
|
data: ratings
|
||||||
|
}],
|
||||||
|
chart: {
|
||||||
|
type: 'bar',
|
||||||
|
height: 400
|
||||||
|
},
|
||||||
|
colors: colors,
|
||||||
|
xaxis: {
|
||||||
|
categories: suppliers
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
text: 'Supplier Ratings',
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Renderizza il grafico
|
||||||
|
const chart = new ApexCharts(
|
||||||
|
document.querySelector("#supplier-rating-chart"),
|
||||||
|
options
|
||||||
|
);
|
||||||
|
chart.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Inizializza DataTables
|
||||||
|
const supplierTable = $('#supplierTable').DataTable({
|
||||||
|
ajax: {
|
||||||
|
url: 'get_supplier_ratings.php',
|
||||||
|
dataSrc: '' // I dati JSON sono un array diretto
|
||||||
|
},
|
||||||
|
columns: [{
|
||||||
|
data: 'name',
|
||||||
|
render: function(data, type, row) {
|
||||||
|
return `<a href="supplier-detail.php?id=${row.id}" class="text-primary">${data}</a>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'total_products'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'total_analyses'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'pass_analyses'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'fail_analyses'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'data_analyses'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'rating',
|
||||||
|
render: function(data, type, row) {
|
||||||
|
const color = data >= 8 ? '#28a745' : data >= 5 ? '#ffc107' : '#dc3545';
|
||||||
|
return `<span style="color: ${color}; font-weight: bold;">${data}</span>`;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'date'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
order: [
|
||||||
|
[6, 'desc']
|
||||||
|
], // Ordina per rating di default
|
||||||
|
pageLength: 50, // Mostra 10 righe per pagina
|
||||||
|
responsive: true, // Adatta il layout alla finestra
|
||||||
|
initComplete: function(settings, json) {
|
||||||
|
updateChart(json); // Aggiorna il grafico dopo aver caricato la tabella
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Funzione per calcolare i rating e aggiornare grafico e tabella
|
||||||
|
$('#calculate-rating').on('click', function() {
|
||||||
|
$.ajax({
|
||||||
|
url: 'calculate_supplier_ratings.php',
|
||||||
|
method: 'POST',
|
||||||
|
success: function() {
|
||||||
|
alert('Ratings calculated successfully!');
|
||||||
|
supplierTable.ajax.reload(); // Ricarica la tabella
|
||||||
|
$.get('get_supplier_ratings.php', function(response) {
|
||||||
|
updateChart(response); // Aggiorna il grafico
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert('Error calculating ratings.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
540
public/userarea/ratego/supplier-detail.php
Normal file
@ -0,0 +1,540 @@
|
|||||||
|
<?php include('../include/headscript.php'); ?>
|
||||||
|
<?php include("../class/company.php"); ?>
|
||||||
|
<?php
|
||||||
|
// Connessione al database
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recupera l'ID del fornitore
|
||||||
|
$supplierId = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
name,
|
||||||
|
total_products,
|
||||||
|
total_analyses,
|
||||||
|
pass_analyses,
|
||||||
|
fail_analyses,
|
||||||
|
data_analyses,
|
||||||
|
rating
|
||||||
|
FROM supplier_ratings
|
||||||
|
WHERE id = $supplierId
|
||||||
|
LIMIT 1
|
||||||
|
";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
$supplier = $result->fetch_assoc();
|
||||||
|
if (!$supplier) {
|
||||||
|
die("Supplier not found.");
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
|
||||||
|
<?php include('../include/seo.php'); ?>
|
||||||
|
|
||||||
|
<link rel="shortcut icon" href="../assets/images/favicon.ico">
|
||||||
|
<link href="../assets/css/bootstrap.min.css" rel="stylesheet" type="text/css">
|
||||||
|
<link href="../assets/css/icons.css" rel="stylesheet" type="text/css">
|
||||||
|
<link href="../assets/css/style.css" rel="stylesheet" type="text/css">
|
||||||
|
<script src="../assets/js/jquery.min.js"></script>
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/boxicons@2.0.7/css/boxicons.min.css" rel="stylesheet">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script>
|
||||||
|
<style>
|
||||||
|
.collapsible {
|
||||||
|
background-color: green;
|
||||||
|
color: white;
|
||||||
|
padding: 5px 10px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.collapsible.active {
|
||||||
|
background-color: #d3d3d3;
|
||||||
|
}
|
||||||
|
|
||||||
|
.collapsible-content {
|
||||||
|
display: none;
|
||||||
|
overflow: hidden;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-details {
|
||||||
|
background-color: #dc3545;
|
||||||
|
color: white;
|
||||||
|
padding: 5px 10px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 5px;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-details:hover {
|
||||||
|
background-color: #c82333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-box {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-score {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: bold;
|
||||||
|
color: white;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-high {
|
||||||
|
background-color: #28a745;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-medium {
|
||||||
|
background-color: #ffc107;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rating-low {
|
||||||
|
background-color: #dc3545;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-card {
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 10px;
|
||||||
|
margin: 10px 0;
|
||||||
|
transition: transform 0.3s, box-shadow 0.3s;
|
||||||
|
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-card:hover {
|
||||||
|
transform: scale(1.05);
|
||||||
|
box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-title {
|
||||||
|
font-size: 1.1rem;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-value {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
font-weight: bold;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data-label {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: gray;
|
||||||
|
}
|
||||||
|
</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">Supplier Details</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Supplier Info Section -->
|
||||||
|
<div class="row mb-4">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card p-4">
|
||||||
|
<div class="rating-box">
|
||||||
|
<h3 class="m-0">
|
||||||
|
<?php echo htmlspecialchars($supplier['name']); ?>
|
||||||
|
</h3>
|
||||||
|
<div class="rating-score
|
||||||
|
<?php echo $supplier['rating'] >= 8 ? 'rating-high' : ($supplier['rating'] >= 5 ? 'rating-medium' : 'rating-low'); ?>">
|
||||||
|
<?php echo number_format($supplier['rating'], 2); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Supplier Stats Section -->
|
||||||
|
<div class="row text-center">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="data-card bg-primary text-white">
|
||||||
|
<i class="bx bx-box h1"></i>
|
||||||
|
<div class="data-title">Products</div>
|
||||||
|
<div class="data-value"><?php echo $supplier['total_products']; ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<div class="data-card bg-info text-white">
|
||||||
|
<i class="bx bx-bar-chart-alt h1"></i>
|
||||||
|
<div class="data-title">Total Analyses</div>
|
||||||
|
<div class="data-value"><?php echo $supplier['total_analyses']; ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="data-card bg-success text-white">
|
||||||
|
<i class="bx bx-check-circle h1"></i>
|
||||||
|
<div class="data-title">PASS</div>
|
||||||
|
<div class="data-value"><?php echo $supplier['pass_analyses']; ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="data-card bg-danger text-white">
|
||||||
|
<i class="bx bx-x-circle h1"></i>
|
||||||
|
<div class="data-title">FAIL</div>
|
||||||
|
<div class="data-value"><?php echo $supplier['fail_analyses']; ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-2">
|
||||||
|
<div class="data-card bg-warning text-white">
|
||||||
|
<i class="bx bx-info-circle h1"></i>
|
||||||
|
<div class="data-title">DATA</div>
|
||||||
|
<div class="data-value"><?php echo $supplier['data_analyses']; ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mt-4">
|
||||||
|
<!-- Pie Chart -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Analysis Distribution</h5>
|
||||||
|
<div id="pie-chart"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- Horizontal Stacked Bar Chart -->
|
||||||
|
<div class="col-md-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Analysis Summary</h5>
|
||||||
|
<div id="stacked-bar-chart"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<!-- Distribuzione delle Analisi -->
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Total Analysis Distribution</h5>
|
||||||
|
<div id="distribution-bar-chart"></div>
|
||||||
|
<button class="collapsible">Toggle Table</button>
|
||||||
|
<div class="collapsible-content">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Analysis Name</th>
|
||||||
|
<th>Total</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="distribution-table-body">
|
||||||
|
<!-- Data loaded dynamically -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row mt-4">
|
||||||
|
<!-- Analisi FAIL -->
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">Top FAIL Analyses</h5>
|
||||||
|
<div id="fail-bar-chart"></div>
|
||||||
|
<!-- Pulsante Toggle Table -->
|
||||||
|
<button id="toggle-fail-table" class="btn btn-secondary">Toggle Table</button>
|
||||||
|
<div id="fail-table-container" style="display: none;">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Analysis Name</th>
|
||||||
|
<th>Fail Count</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="fail-table-body">
|
||||||
|
<!-- Popolato dinamicamente -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!-- Pulsante View Fail Details -->
|
||||||
|
<button id="view-fail-details" class="btn btn-primary">View Fail Details</button>
|
||||||
|
<div id="fail-details-container" style="display: none;">
|
||||||
|
<table class="table table-bordered">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Analysis Name</th>
|
||||||
|
<th>Report Number</th>
|
||||||
|
<th>Ref Numb.</th>
|
||||||
|
<th>Product Description</th>
|
||||||
|
<th>Action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="fail-details-table-body">
|
||||||
|
<!-- Popolato dinamicamente -->
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
// Dati per i grafici principali
|
||||||
|
const passCount = <?php echo isset($supplier['pass_analyses']) ? $supplier['pass_analyses'] : 0; ?>;
|
||||||
|
const failCount = <?php echo isset($supplier['fail_analyses']) ? $supplier['fail_analyses'] : 0; ?>;
|
||||||
|
const dataCount = <?php echo isset($supplier['data_analyses']) ? $supplier['data_analyses'] : 0; ?>;
|
||||||
|
|
||||||
|
// Pie Chart Configuration
|
||||||
|
const pieChartOptions = {
|
||||||
|
series: [passCount, failCount, dataCount],
|
||||||
|
chart: {
|
||||||
|
type: 'pie',
|
||||||
|
height: 350
|
||||||
|
},
|
||||||
|
labels: ['PASS', 'FAIL', 'DATA'],
|
||||||
|
colors: ['#28a745', '#dc3545', '#ffc107'],
|
||||||
|
title: {
|
||||||
|
text: 'Analysis Distribution',
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'bottom'
|
||||||
|
},
|
||||||
|
dataLabels: {
|
||||||
|
enabled: true,
|
||||||
|
formatter: function(val, opts) {
|
||||||
|
return opts.w.globals.series[opts.seriesIndex] + " (" + val.toFixed(2) + "%)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const pieChart = new ApexCharts(document.querySelector("#pie-chart"), pieChartOptions);
|
||||||
|
pieChart.render();
|
||||||
|
|
||||||
|
// Stacked Bar Chart Configuration
|
||||||
|
const stackedBarChartOptions = {
|
||||||
|
series: [{
|
||||||
|
name: 'PASS',
|
||||||
|
data: [passCount]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'FAIL',
|
||||||
|
data: [failCount]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'DATA',
|
||||||
|
data: [dataCount]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
chart: {
|
||||||
|
type: 'bar',
|
||||||
|
height: 350,
|
||||||
|
stacked: true,
|
||||||
|
horizontal: true
|
||||||
|
},
|
||||||
|
colors: ['#28a745', '#dc3545', '#ffc107'],
|
||||||
|
xaxis: {
|
||||||
|
categories: ['Analysis'],
|
||||||
|
title: {
|
||||||
|
text: 'Count'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
plotOptions: {
|
||||||
|
bar: {
|
||||||
|
horizontal: true,
|
||||||
|
barHeight: '70%'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
text: 'Analysis Summary',
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
position: 'bottom'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const stackedBarChart = new ApexCharts(document.querySelector("#stacked-bar-chart"), stackedBarChartOptions);
|
||||||
|
stackedBarChart.render();
|
||||||
|
|
||||||
|
// Fetch and populate data for additional charts and tables
|
||||||
|
const supplierName = "<?php echo htmlspecialchars($supplier['name']); ?>";
|
||||||
|
|
||||||
|
$.getJSON(`get_analysis_data.php?supplier=${supplierName}`, function(data) {
|
||||||
|
if (data.error) {
|
||||||
|
alert(data.error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Distribuzione delle analisi totali
|
||||||
|
const distributionChartOptions = {
|
||||||
|
series: [{
|
||||||
|
data: data.analysisDistribution.map(item => item.total)
|
||||||
|
}],
|
||||||
|
chart: {
|
||||||
|
type: 'bar',
|
||||||
|
height: 350,
|
||||||
|
horizontal: true
|
||||||
|
},
|
||||||
|
plotOptions: {
|
||||||
|
bar: {
|
||||||
|
horizontal: true,
|
||||||
|
barHeight: '50%'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
xaxis: {
|
||||||
|
categories: data.analysisDistribution.map(item => item.analysis_name),
|
||||||
|
title: {
|
||||||
|
text: 'Total Analyses'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors: ['#007bff'],
|
||||||
|
title: {
|
||||||
|
text: 'Total Analysis Distribution',
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const distributionChart = new ApexCharts(document.querySelector("#distribution-bar-chart"), distributionChartOptions);
|
||||||
|
distributionChart.render();
|
||||||
|
|
||||||
|
// Aggiorna tabella per Distribuzione Totale
|
||||||
|
const distTableBody = document.querySelector("#distribution-table-body");
|
||||||
|
data.analysisDistribution.forEach(row => {
|
||||||
|
distTableBody.innerHTML += `<tr>
|
||||||
|
<td>${row.analysis_name}</td>
|
||||||
|
<td>${row.total}</td>
|
||||||
|
</tr>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Distribuzione delle analisi FAIL
|
||||||
|
const failChartOptions = {
|
||||||
|
series: [{
|
||||||
|
data: data.failDistribution.map(item => item.fail)
|
||||||
|
}],
|
||||||
|
chart: {
|
||||||
|
type: 'bar',
|
||||||
|
height: 350,
|
||||||
|
horizontal: true
|
||||||
|
},
|
||||||
|
plotOptions: {
|
||||||
|
bar: {
|
||||||
|
horizontal: true,
|
||||||
|
barHeight: '50%'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
xaxis: {
|
||||||
|
categories: data.failDistribution.map(item => item.analysis_name),
|
||||||
|
title: {
|
||||||
|
text: 'Fail Count'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
colors: ['#dc3545'],
|
||||||
|
title: {
|
||||||
|
text: 'Top FAIL Analyses',
|
||||||
|
align: 'center'
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const failChart = new ApexCharts(document.querySelector("#fail-bar-chart"), failChartOptions);
|
||||||
|
failChart.render();
|
||||||
|
|
||||||
|
// Aggiorna tabella per Distribuzione FAIL
|
||||||
|
const failTableBody = document.querySelector("#fail-table-body");
|
||||||
|
data.failDistribution.forEach(row => {
|
||||||
|
failTableBody.innerHTML += `<tr>
|
||||||
|
<td>${row.analysis_name}</td>
|
||||||
|
<td>${row.fail}</td>
|
||||||
|
</tr>`;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gestione Toggle Table
|
||||||
|
document.querySelector("#toggle-fail-table").addEventListener("click", function() {
|
||||||
|
const table = document.querySelector("#fail-table-container");
|
||||||
|
table.style.display = table.style.display === "block" ? "none" : "block";
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gestione View Fail Details
|
||||||
|
document.querySelector("#view-fail-details").addEventListener("click", function() {
|
||||||
|
const table = document.querySelector("#fail-details-container");
|
||||||
|
|
||||||
|
// Evita di richiamare più volte lo stesso contenuto
|
||||||
|
if (!table.hasAttribute("data-loaded")) {
|
||||||
|
$.getJSON(`get_fail_details.php?supplier=${supplierName}`, function(data) {
|
||||||
|
const failDetailsTableBody = document.querySelector("#fail-details-table-body");
|
||||||
|
|
||||||
|
data.failDetails.forEach(row => {
|
||||||
|
failDetailsTableBody.innerHTML += `
|
||||||
|
<tr>
|
||||||
|
<td>${row.analysis_name}</td>
|
||||||
|
<td>${row.report_number}</td>
|
||||||
|
<td>${row.product_refnumber}</td>
|
||||||
|
<td>${row.product_description}</td>
|
||||||
|
<td>
|
||||||
|
<a href="../products/reportdetails.php?idreports=${row.report_id}" target="_blank" class="btn btn-sm btn-primary">
|
||||||
|
View Details
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
table.setAttribute("data-loaded", "true");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
table.style.display = table.style.display === "block" ? "none" : "block";
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php include('../include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
51
public/userarea/ratego/update_analysis.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
include('../include/headscript.php');
|
||||||
|
include('../class/company.php'); // Ricorda di includere anche $conn
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||||
|
$id = intval($_POST['id']);
|
||||||
|
$severity = intval($_POST['severity']);
|
||||||
|
$is_legal = $_POST['is_legal'] === 'Y' ? 'Y' : 'N';
|
||||||
|
|
||||||
|
// Validazione del valore di severity
|
||||||
|
if ($severity < 1 || $severity > 10) {
|
||||||
|
echo 'Error: Severity must be between 1 and 10.';
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verifica se esiste già un record per questa analisi
|
||||||
|
$checkQuery = "SELECT COUNT(*) AS count FROM analysis_severity WHERE idanalysisvocabulary = ?";
|
||||||
|
$stmt = $conn->prepare($checkQuery);
|
||||||
|
$stmt->bind_param('i', $id);
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$row = $result->fetch_assoc();
|
||||||
|
$exists = $row['count'] > 0;
|
||||||
|
$stmt->close();
|
||||||
|
|
||||||
|
if ($exists) {
|
||||||
|
// Aggiorna il record esistente
|
||||||
|
$updateQuery = "
|
||||||
|
UPDATE analysis_severity
|
||||||
|
SET severity = ?, is_legal = ?
|
||||||
|
WHERE idanalysisvocabulary = ?
|
||||||
|
";
|
||||||
|
$stmt = $conn->prepare($updateQuery);
|
||||||
|
$stmt->bind_param('isi', $severity, $is_legal, $id);
|
||||||
|
} else {
|
||||||
|
// Inserisce un nuovo record
|
||||||
|
$insertQuery = "
|
||||||
|
INSERT INTO analysis_severity (idanalysisvocabulary, severity, is_legal)
|
||||||
|
VALUES (?, ?, ?)
|
||||||
|
";
|
||||||
|
$stmt = $conn->prepare($insertQuery);
|
||||||
|
$stmt->bind_param('iis', $id, $severity, $is_legal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
echo 'success';
|
||||||
|
} else {
|
||||||
|
echo 'Error: Database error - ' . $stmt->error;
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
}
|
||||||
205
public/userarea/ratego/weightanalysis.php
Normal 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'); ?>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
</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">
|
||||||
|
<h4 class="page-title">Preferred Analyses</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-xl-12">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table table-bordered table-custom">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Analysis Name</th>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Test Method</th>
|
||||||
|
<th>Severity</th>
|
||||||
|
<th>Legal</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
$query = "
|
||||||
|
SELECT
|
||||||
|
av.idanalysisvocabulary,
|
||||||
|
av.nameanalysisvoc,
|
||||||
|
av.category_analysis,
|
||||||
|
av.testmethod_name,
|
||||||
|
COALESCE(asv.severity, '') AS severity,
|
||||||
|
COALESCE(asv.is_legal, 'N') AS is_legal
|
||||||
|
FROM analysisvocabulary av
|
||||||
|
LEFT JOIN analysis_severity asv
|
||||||
|
ON av.idanalysisvocabulary = asv.idanalysisvocabulary
|
||||||
|
WHERE av.preferred = 'Y'
|
||||||
|
";
|
||||||
|
$result = $conn->query($query);
|
||||||
|
if ($result->num_rows > 0) {
|
||||||
|
while ($row = $result->fetch_assoc()) {
|
||||||
|
$severity = $row['severity'];
|
||||||
|
$is_legal = $row['is_legal'];
|
||||||
|
echo "<tr>";
|
||||||
|
echo "<td>{$row['idanalysisvocabulary']}</td>";
|
||||||
|
echo "<td>{$row['nameanalysisvoc']}</td>";
|
||||||
|
echo "<td>{$row['category_analysis']}</td>";
|
||||||
|
echo "<td>{$row['testmethod_name']}</td>";
|
||||||
|
echo "<td>
|
||||||
|
<input type='number' class='form-control form-control-sm severity-input'
|
||||||
|
value='{$severity}'
|
||||||
|
data-id='{$row['idanalysisvocabulary']}'
|
||||||
|
min='1' max='10'>
|
||||||
|
</td>";
|
||||||
|
echo "<td>
|
||||||
|
<select class='form-select form-select-sm legal-select'
|
||||||
|
data-id='{$row['idanalysisvocabulary']}'>
|
||||||
|
<option value='Y' " . ($is_legal === 'Y' ? 'selected' : '') . ">Yes</option>
|
||||||
|
<option value='N' " . ($is_legal === 'N' ? 'selected' : '') . ">No</option>
|
||||||
|
</select>
|
||||||
|
</td>";
|
||||||
|
echo "<td>
|
||||||
|
<button class='btn btn-success btn-sm save-btn'
|
||||||
|
data-id='{$row['idanalysisvocabulary']}'>Save</button>
|
||||||
|
</td>";
|
||||||
|
echo "</tr>";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "<tr><td colspan='7' class='text-center'>No data available</td></tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php include('../include/footer.php'); ?>
|
||||||
|
</div>
|
||||||
|
<!-- End Right content here -->
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- END wrapper -->
|
||||||
|
<script>
|
||||||
|
$(document).on('click', '.save-btn', function() {
|
||||||
|
const id = $(this).data('id');
|
||||||
|
const severity = $(this).closest('tr').find('.severity-input').val();
|
||||||
|
const isLegal = $(this).closest('tr').find('.legal-select').val();
|
||||||
|
|
||||||
|
// Validazione del campo severity lato client
|
||||||
|
if (severity < 1 || severity > 10 || isNaN(severity)) {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Invalid Input',
|
||||||
|
text: 'Severity must be a number between 1 and 10.',
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invio dati tramite AJAX
|
||||||
|
$.ajax({
|
||||||
|
url: 'update_analysis.php',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
id: id,
|
||||||
|
severity: severity,
|
||||||
|
is_legal: isLegal
|
||||||
|
},
|
||||||
|
success: function(response) {
|
||||||
|
// Debug del valore ricevuto
|
||||||
|
console.log('Response:', response.trim());
|
||||||
|
if (response.trim() === 'success') {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'success',
|
||||||
|
title: 'Updated',
|
||||||
|
text: 'The analysis has been updated successfully.',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Error',
|
||||||
|
text: response.trim(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
Swal.fire({
|
||||||
|
icon: 'error',
|
||||||
|
title: 'Error',
|
||||||
|
text: 'Failed to connect to the server.',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script src="../assets/js/popper.min.js"></script>
|
||||||
|
<script src="../assets/js/bootstrap.min.js"></script>
|
||||||
|
<script src="../assets/js/jquery.blockUI.js"></script>
|
||||||
|
<script src="../assets/js/waves.js"></script>
|
||||||
|
<script src="../assets/js/app.js"></script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
BIN
public/userarea/report_files/67320c0439523_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/67320c0439523_details1.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/67320c0439523_details2.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
public/userarea/report_files/67320c0439523_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/67320c0439523_reportdata.pdf
Normal file
BIN
public/userarea/report_files/673212ff8c801_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/673212ff8c801_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/67321a3352e64_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/67321a3352e64_details1.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/67321a3352e64_details2.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
public/userarea/report_files/67321a3352e64_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/67321a3352e64_reportdata.pdf
Normal file
BIN
public/userarea/report_files/6733647d567a0_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/6733647d567a0_details1.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/6733647d567a0_details2.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
public/userarea/report_files/6733647d567a0_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/6733647d567a0_reportdata.pdf
Normal file
BIN
public/userarea/report_files/67348e5b8a21b_details1.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/67348e5b8a21b_details2.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
public/userarea/report_files/67348e5b8a21b_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/67348e5b8a21b_reportdata.pdf
Normal file
BIN
public/userarea/report_files/67348f9f38e11_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/67348f9f38e11_details1.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/67348f9f38e11_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
BIN
public/userarea/report_files/673490ba4af72_TEST REPORT.pdf
Normal file
BIN
public/userarea/report_files/673490ba4af72_details1.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
public/userarea/report_files/673490ba4af72_productjacket.png
Normal file
|
After Width: | Height: | Size: 162 KiB |
240
public/userarea/statkpi/createPdf.php
Normal file
@ -0,0 +1,240 @@
|
|||||||
|
<?php
|
||||||
|
require '../../vendor/autoload.php';
|
||||||
|
include '../include/headscript.php';
|
||||||
|
include '../../Connections/repnew.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
use Dompdf\Dompdf;
|
||||||
|
use Dompdf\Options;
|
||||||
|
|
||||||
|
$currentDate = date('d-m-Y');
|
||||||
|
$title = $_POST['title'];
|
||||||
|
$content = $_POST['content'];
|
||||||
|
$filterStart = $_POST['filterStart'];
|
||||||
|
$filterEnd = $_POST['filterEnd'];
|
||||||
|
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die(json_encode(["error" => "Connection failed: " . $conn->connect_error]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT * from company");
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$logoname = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("DELETE from reportsections");
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt = $conn->prepare("INSERT INTO reportsections (
|
||||||
|
cover_title, cover_subtitle, instructionsdetails_title, instructiondetails_text,
|
||||||
|
overviewstatistic_title, overviewstatistic_text, supplieristatistic_title, supplieristatistic_text,
|
||||||
|
analysisstatistic_title, analysisstatistic_text, analytscompounds_title, analytscompounds_text,
|
||||||
|
finalevaluation_title, finalevaluation_text
|
||||||
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
|
if ($stmt === false) {
|
||||||
|
die(json_encode(["error" => "Prepare statement failed: " . $conn->error]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->bind_param(
|
||||||
|
'ssssssssssssss',
|
||||||
|
$title[0],
|
||||||
|
$content[0],
|
||||||
|
$title[1],
|
||||||
|
$content[1],
|
||||||
|
$title[2],
|
||||||
|
$content[2],
|
||||||
|
$title[3],
|
||||||
|
$content[3],
|
||||||
|
$title[4],
|
||||||
|
$content[4],
|
||||||
|
$title[5],
|
||||||
|
$content[5],
|
||||||
|
$title[6],
|
||||||
|
$content[6]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
die(json_encode(["error" => "Execute statement failed: " . $stmt->error]));
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
$chartdata0 = file_get_contents('../../../resources/charts/chart0.ch');
|
||||||
|
$chartdata1 = file_get_contents('../../../resources/charts/chart1.ch');
|
||||||
|
$chartdata2 = file_get_contents('../../../resources/charts/chart2.ch');
|
||||||
|
$chartdata3 = file_get_contents('../../../resources/charts/chart3.ch');
|
||||||
|
$chartdata4 = file_get_contents('../../../resources/charts/chart4.ch');
|
||||||
|
$chartdata5 = file_get_contents('../../../resources/charts/chart5.ch');
|
||||||
|
|
||||||
|
$tmplogo = file_get_contents('../uploadlogo/' . $logoname[0]['logocompany']);
|
||||||
|
$base64logo = base64_encode($tmplogo);
|
||||||
|
$logodata = 'data:image/jpeg;base64,' . $base64logo;
|
||||||
|
|
||||||
|
$page =
|
||||||
|
'<html>
|
||||||
|
<head>
|
||||||
|
<title>Financial Report</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
#headerdate {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
display: inline-block;
|
||||||
|
width: 450px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
display: "inline-block";
|
||||||
|
margin-top:500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div > h3 {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filter{
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
font-size: 20px;
|
||||||
|
margin-left: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-break { page-break-before: always; }
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="page1">
|
||||||
|
<div>
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<div id="headerdate" style="font-family: Dejavu Sans;">Date: ' . $currentDate . '</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div style="text-align: center; font-size: 70px; margin-top: 200px; font-family: Dejavu Sans;">' . $title[0] . ' </div>
|
||||||
|
<div style="margin-left: 20px; text-align: center; font-size: 30px; font-family: Dejavu Sans;">' . $content[0] . '</div>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top: 500px;">
|
||||||
|
<div style="margin-left: 50px;display: inline-block;width: 40%;font-size: 15px; font-family: Dejavu Sans;"> Created by: ' . $nameuser . '</div>
|
||||||
|
<div style="margin-left: 50px;display: inline-block;width: 40%;font-size: 15px; font-family: Dejavu Sans;"> Date ' . $currentDate . '</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="page-break-before: always;" ></div>
|
||||||
|
<div id="page2">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[1] . '</h3>
|
||||||
|
<hr />
|
||||||
|
<p id = "content" style="font-family: Dejavu Sans; font-size: 20px;">' . $content[1] . '</p>
|
||||||
|
<div>
|
||||||
|
<p id="filtertitle" style="margin-top: 450px; font-family: Dejavu Sans;">FILTERS APPLIED</p>
|
||||||
|
<p id="filterdata" style="font-family: Dejavu Sans;">From Date ' . $filterStart . ' to Date ' . $filterEnd . '</p>
|
||||||
|
<p id="filterdata" style="font-family: Dejavu Sans;">Other Filters</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="page-break-before: always;"> </div>
|
||||||
|
<div id="page3">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[2] . '</h3>
|
||||||
|
<hr />
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;"">
|
||||||
|
' . $content[2] . '
|
||||||
|
</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata0 . ' width="700px" />
|
||||||
|
<img src=' . $chartdata1 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="page-break-before: always;" ></div>
|
||||||
|
<div id="page4">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[3] . '</h3>
|
||||||
|
<hr />
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;"">' . $content[3] . '</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata2 . ' width="700px" />
|
||||||
|
<img src=' . $chartdata3 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="page-break-before: always;"> </div>
|
||||||
|
<div id="page4">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[4] . '</h3>
|
||||||
|
<hr />
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;"">' . $content[4] . '</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata4 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="page-break-before: always;" > </div>
|
||||||
|
<div id="page6">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[5] . '</h3>
|
||||||
|
<hr />
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;">' . $content[5] . '</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata5 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="page-break-before: always;" > </div>
|
||||||
|
<div id="page7">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[6] . '</h3>
|
||||||
|
<hr />
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;">' . $content[6] . '</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>';
|
||||||
|
|
||||||
|
$options = new Options();
|
||||||
|
$options->set('isHtml5ParserEnabled', true);
|
||||||
|
$options->set('isRemoteEnabled', true);
|
||||||
|
$dompdf = new Dompdf($options);
|
||||||
|
$dompdf->loadHtml($page);
|
||||||
|
$dompdf->setPaper('A4', 'portrait');
|
||||||
|
$dompdf->render();
|
||||||
|
$filePath = "../../download/";
|
||||||
|
$filename = "Report" . date('d-m-Y-H-i') . ".pdf";
|
||||||
|
|
||||||
|
if (!is_dir('../../download/')) {
|
||||||
|
mkdir('../../download/', 0777, true);
|
||||||
|
}
|
||||||
|
file_put_contents($filePath . $filename, $dompdf->output());
|
||||||
|
|
||||||
|
if (file_exists($filePath . $filename)) {
|
||||||
|
$response['status'] = 'success';
|
||||||
|
$response['message'] = 'http://127.0.0.1/reportifynew/public/download/';
|
||||||
|
$response['file'] = $filename;
|
||||||
|
} else {
|
||||||
|
$response['status'] = 'error';
|
||||||
|
$response['message'] = 'PDF download fail';
|
||||||
|
}
|
||||||
|
echo json_encode($response);
|
||||||
229
public/userarea/statkpi/createWord.php
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
<?php
|
||||||
|
require '../../vendor/autoload.php';
|
||||||
|
include '../include/headscript.php';
|
||||||
|
include '../../Connections/repnew.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
$currentDate = date('d-m-Y');
|
||||||
|
$title = $_POST['title'];
|
||||||
|
$content = $_POST['content'];
|
||||||
|
$filterStart = $_POST['filterStart'];
|
||||||
|
$filterEnd = $_POST['filterEnd'];
|
||||||
|
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die(json_encode(["error" => "Connection failed: " . $conn->connect_error]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT * from company");
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$logoname = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("DELETE from reportsections");
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt = $conn->prepare("INSERT INTO reportsections (
|
||||||
|
cover_title, cover_subtitle, instructionsdetails_title, instructiondetails_text,
|
||||||
|
overviewstatistic_title, overviewstatistic_text, supplieristatistic_title, supplieristatistic_text,
|
||||||
|
analysisstatistic_title, analysisstatistic_text, analytscompounds_title, analytscompounds_text,
|
||||||
|
finalevaluation_title, finalevaluation_text
|
||||||
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
|
||||||
|
|
||||||
|
if ($stmt === false) {
|
||||||
|
die(json_encode(["error" => "Prepare statement failed: " . $conn->error]));
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt->bind_param(
|
||||||
|
'ssssssssssssss',
|
||||||
|
$title[0],
|
||||||
|
$content[0],
|
||||||
|
$title[1],
|
||||||
|
$content[1],
|
||||||
|
$title[2],
|
||||||
|
$content[2],
|
||||||
|
$title[3],
|
||||||
|
$content[3],
|
||||||
|
$title[4],
|
||||||
|
$content[4],
|
||||||
|
$title[5],
|
||||||
|
$content[5],
|
||||||
|
$title[6],
|
||||||
|
$content[6]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!$stmt->execute()) {
|
||||||
|
die(json_encode(["error" => "Execute statement failed: " . $stmt->error]));
|
||||||
|
}
|
||||||
|
$stmt->close();
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
$chartdata0 = file_get_contents('../../../resources/charts/chart0.ch');
|
||||||
|
$chartdata1 = file_get_contents('../../../resources/charts/chart1.ch');
|
||||||
|
$chartdata2 = file_get_contents('../../../resources/charts/chart2.ch');
|
||||||
|
$chartdata3 = file_get_contents('../../../resources/charts/chart3.ch');
|
||||||
|
$chartdata4 = file_get_contents('../../../resources/charts/chart4.ch');
|
||||||
|
$chartdata5 = file_get_contents('../../../resources/charts/chart5.ch');
|
||||||
|
|
||||||
|
$tmplogo = file_get_contents('../uploadlogo/' . $logoname[0]['logocompany']);
|
||||||
|
$base64logo = base64_encode($tmplogo);
|
||||||
|
$logodata = 'data:image/jpeg;base64,' . $base64logo;
|
||||||
|
|
||||||
|
$page =
|
||||||
|
'<html>
|
||||||
|
<head>
|
||||||
|
<title>Financial Report</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
}
|
||||||
|
|
||||||
|
#headerdate {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
display: inline-block;
|
||||||
|
width: 450px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
display: "inline-block";
|
||||||
|
margin-top:500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
div > h3 {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
font-size: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#filter{
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
font-size: 20px;
|
||||||
|
margin-left: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content {
|
||||||
|
font-family: DejaVu Sans;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="page1">
|
||||||
|
<div>
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<div id="headerdate" style="font-family: Dejavu Sans;">Date: ' . $currentDate . '</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div style="text-align: center; font-size: 70px; margin-top: 200px; font-family: Dejavu Sans;">' . $title[0] . ' </div>
|
||||||
|
<div style="margin-left: 20px; text-align: center; font-size: 30px; font-family: Dejavu Sans;">' . $content[0] . '</div>
|
||||||
|
</div>
|
||||||
|
<div style="margin-top: 500px;margin-left: 50px;display: inline-block;width: 40%;font-size: 15px; font-family: Dejavu Sans;"> Created by: ' . $nameuser . ' Date ' . $currentDate . '</div>
|
||||||
|
</div>
|
||||||
|
<br style="page-break-before: always;" />
|
||||||
|
<div id="page2">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[1] . '</h3>
|
||||||
|
<p style="font-size: 20px; font-weight: bolder; font-family: Dejavu Sans;">---------------------------------------------------------------------------------</p>
|
||||||
|
<p id = "content" style="font-family: Dejavu Sans; font-size: 20px;">' . $content[1] . '</p>
|
||||||
|
<div>
|
||||||
|
<p id="filtertitle" style="margin-top: 650px; font-family: Dejavu Sans;">FILTERS APPLIED</p>
|
||||||
|
<p id="filterdata" style="font-family: Dejavu Sans;">From Date ' . $filterStart . ' to Date ' . $filterEnd . '</p>
|
||||||
|
<p id="filterdata" style="font-family: Dejavu Sans;">Other Filters</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br style="page-break-before: always;" />
|
||||||
|
<div id="page3">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[2] . '</h3>
|
||||||
|
<p style="font-size: 20px; font-weight: bolder; font-family: Dejavu Sans;">---------------------------------------------------------------------------------</p>
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;"">
|
||||||
|
' . $content[2] . '
|
||||||
|
</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata0 . ' width="700px" />
|
||||||
|
<img src=' . $chartdata1 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br style="page-break-before: always;" />
|
||||||
|
<div id="page4">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[3] . '</h3>
|
||||||
|
<p style="font-size: 20px; font-weight: bolder; font-family: Dejavu Sans;">---------------------------------------------------------------------------------</p>
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;"">' . $content[3] . '</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata2 . ' width="700px" />
|
||||||
|
<img src=' . $chartdata3 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br style="page-break-before: always;" />
|
||||||
|
<div id="page4">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[4] . '</h3>
|
||||||
|
<p style="font-size: 20px; font-weight: bolder; font-family: Dejavu Sans;">---------------------------------------------------------------------------------</p>
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;"">' . $content[4] . '</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata4 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br style="page-break-before: always;" />
|
||||||
|
<div id="page6">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[5] . '</h3>
|
||||||
|
<p style="font-size: 20px; font-weight: bolder; font-family: Dejavu Sans;">---------------------------------------------------------------------------------</p>
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;">' . $content[5] . '</p>
|
||||||
|
<div id="chart">
|
||||||
|
<img src=' . $chartdata5 . ' width="700px" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br style="page-break-before: always;" />
|
||||||
|
<div id="page7">
|
||||||
|
<img
|
||||||
|
src=' . $logodata . '
|
||||||
|
alt="Brand Logo" class="logo" width="150px" height="40px"
|
||||||
|
/>
|
||||||
|
<h3 style="font-family: Dejavu Sans; font-size: 30px;">' . $title[6] . '</h3>
|
||||||
|
<p style="font-size: 20px; font-weight: bolder; font-family: Dejavu Sans;">---------------------------------------------------------------------------------</p>
|
||||||
|
<p id = "content" style = "font-family: Dejavu Sans; font-size: 20px;">' . $content[6] . '</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>';
|
||||||
|
$filePath = "../../download/";
|
||||||
|
$filename = "Report" . date('d-m-Y-H-i') . ".docx";
|
||||||
|
|
||||||
|
if (!is_dir('../../download/')) {
|
||||||
|
mkdir('../../download/', 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
file_put_contents('../../download/report.html', $page);
|
||||||
|
|
||||||
|
$command = 'soffice --headless --convert-to docx:"MS Word 2007 XML" ../../download/report.html --outdir "../../download/"';
|
||||||
|
|
||||||
|
$output = shell_exec($command);
|
||||||
|
if (rename('../../download/report.docx', '../../download/Report' . date('d-m-Y-H-i') . '.docx')) {
|
||||||
|
$response['status'] = 'success';
|
||||||
|
$response['message'] = 'http://127.0.0.1/reportifynew/public/download/';
|
||||||
|
$response['file'] = $filename;
|
||||||
|
} else {
|
||||||
|
$response['status'] = 'error';
|
||||||
|
$response['message'] = 'WORD download fail';
|
||||||
|
}
|
||||||
|
echo json_encode($response);
|
||||||
|
unlink('../../download/report.html');
|
||||||
24
public/userarea/statkpi/create_chart.php
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
if (isset($_POST['chartfile'])) {
|
||||||
|
$uploadDir = '../../../resources/charts/';
|
||||||
|
$responses = [];
|
||||||
|
|
||||||
|
if (!is_dir($uploadDir)) {
|
||||||
|
mkdir($uploadDir, 0777, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($_POST['chartfile'] as $key => $base64Image) {
|
||||||
|
$fileName = 'chart' . $key . '.ch';
|
||||||
|
$filePath = $uploadDir . $fileName;
|
||||||
|
|
||||||
|
if (file_put_contents($filePath, $base64Image)) {
|
||||||
|
$responses[] = "File uploaded successfully";
|
||||||
|
} else {
|
||||||
|
$responses[] = "Failed to save file";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo json_encode($responses);
|
||||||
|
} else {
|
||||||
|
echo json_encode(["error" => "No images uploaded."]);
|
||||||
|
}
|
||||||
441
public/userarea/statkpi/documentModal.php
Normal file
@ -0,0 +1,441 @@
|
|||||||
|
<?php
|
||||||
|
// Attiva errori PHP per debug
|
||||||
|
error_reporting(E_ALL);
|
||||||
|
ini_set('display_errors', 1);
|
||||||
|
|
||||||
|
// Connessione al database e query
|
||||||
|
include '../../Connections/repnew.php';
|
||||||
|
$conn = new mysqli($servername, $username, $password, $database);
|
||||||
|
if ($conn->connect_error) {
|
||||||
|
die("Connection failed: " . $conn->connect_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $conn->prepare("SELECT * FROM reportsections LIMIT 1");
|
||||||
|
if (!$stmt) {
|
||||||
|
die("Statement preparation failed: " . $conn->error);
|
||||||
|
}
|
||||||
|
$stmt->execute();
|
||||||
|
$result = $stmt->get_result();
|
||||||
|
$insertdata = $result->fetch_all(MYSQLI_ASSOC);
|
||||||
|
$stmt->close();
|
||||||
|
$conn->close();
|
||||||
|
|
||||||
|
// Verifica dei dati
|
||||||
|
if (empty($insertdata)) {
|
||||||
|
die("No data found in reportsections.");
|
||||||
|
}
|
||||||
|
|
||||||
|
$jsonData = json_encode($insertdata[0], JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.modal-dialog {
|
||||||
|
max-width: none !important;
|
||||||
|
width: auto !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-modal-dialog {
|
||||||
|
max-width: 70vw !important;
|
||||||
|
width: 70vw !important;
|
||||||
|
height: 85vh !important;
|
||||||
|
margin: 50px auto !important;
|
||||||
|
display: flex !important;
|
||||||
|
align-items: center !important;
|
||||||
|
justify-content: center !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-content {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagetitle {
|
||||||
|
font-size: 1.5vw !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.custom-textarea {
|
||||||
|
font-size: 1vw !important;
|
||||||
|
width: 100% !important;
|
||||||
|
height: 20vh !important;
|
||||||
|
padding: 10px !important;
|
||||||
|
border-radius: 10px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-body {
|
||||||
|
overflow-y: auto !important;
|
||||||
|
height: 60vh !important;
|
||||||
|
padding: 20px !important;
|
||||||
|
box-sizing: border-box !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modalspinner {
|
||||||
|
border: 8px solid #f3f3f3;
|
||||||
|
border-top: 8px solid #3498db;
|
||||||
|
border-radius: 50%;
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
position: fixed;
|
||||||
|
top: 40%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-90%, -50%);
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
0% {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: rotate(360deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<!-- Modale -->
|
||||||
|
<div class="modal fade" id="documentModal" tabindex="-1" aria-labelledby="documentModalLabel" aria-hidden="true"
|
||||||
|
role="dialog" data-backdrop="static" data-bs-keyboard="false">
|
||||||
|
|
||||||
|
<div class="modal-dialog custom-modal-dialog custom-modal-dialog-centered">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="pagetitle">Finalcial Report</h5>
|
||||||
|
<button type="button" class="btn-close" data-dismiss="modal" aria-label="false" id="btn-close">
|
||||||
|
<span>×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<div id="modalspinner" class="modalspinner" style="display: none;"></div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="title" class="col-sm-1 col-form-label">Title</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="title" value="<?php echo ($insertdata[0]['cover_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="subtitle" class="col-sm-1 col-form-label">Subtitle</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="subtitle" value="<?php echo ($insertdata[0]['cover_subtitle']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="page1">
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="section1" class="col-sm-1 col-form-label">Section1</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="section1" placeholder="section1" value="<?php echo ($insertdata[0]['instructionsdetails_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div type="text" class="content" id="content1"><?php echo ($insertdata[0]['instructiondetails_text']) ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="page2">
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="section2" class="col-sm-1 col-form-label">Section2</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="section2" placeholder="section2" value="<?php echo ($insertdata[0]['overviewstatistic_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div type="text" class="content" id="content2"><?php echo ($insertdata[0]['overviewstatistic_text']) ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="page3">
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="section3" class="col-sm-1 col-form-label">Section3</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="section3" placeholder="section3" value="<?php echo ($insertdata[0]['supplieristatistic_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div type="text" class="content" id="content3"><?php echo ($insertdata[0]['supplieristatistic_text']) ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="page4">
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="section4" class="col-sm-1 col-form-label">Section4</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="section4" placeholder="section4" value="<?php echo ($insertdata[0]['analysisstatistic_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div type="text" class="content" id="content4"><?php echo ($insertdata[0]['analysisstatistic_text']) ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="page5">
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="section5" class="col-sm-1 col-form-label">Section5</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="section5" placeholder="section5" value="<?php echo ($insertdata[0]['analytscompounds_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div type="text" class="content" id="content5"><?php echo ($insertdata[0]['analytscompounds_text']) ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="page6">
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<label for="section6" class="col-sm-1 col-form-label">Section6</label>
|
||||||
|
<div class="col-sm-11">
|
||||||
|
<input type="text" class="form-control" id="section6" placeholder="section6" value="<?php echo ($insertdata[0]['finalevaluation_title']) ?>">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="mb-3 row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<div type="text" class="content" id="content6"><?php echo ($insertdata[0]['finalevaluation_text']) ?></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer mb-3">
|
||||||
|
<button type="button" class="btn btn-danger" id="createPdf">PDF</button>
|
||||||
|
<button type="button" class="btn btn-success" id="createWord">Word</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Bootstrap, jQuery, CKEditor e html2canvas -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
|
||||||
|
<script src="https://cdn.ckeditor.com/ckeditor5/39.0.1/classic/ckeditor.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let titles = [];
|
||||||
|
let contents = [];
|
||||||
|
let chartdata = [];
|
||||||
|
const editors = [];
|
||||||
|
const spinner = document.getElementById('modalspinner');
|
||||||
|
|
||||||
|
for (let i = 1; i < 7; i++) {
|
||||||
|
ClassicEditor
|
||||||
|
.create(document.querySelector('#content' + i), {
|
||||||
|
toolbar: [
|
||||||
|
'bold', 'italic', 'bulletedList', 'numberedList', 'alignment', 'undo', 'redo'
|
||||||
|
]
|
||||||
|
})
|
||||||
|
.then(editor => {
|
||||||
|
editors[i - 1] = editor;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error initializing CKEditor for content' + i + ':', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function disableModal(flag) {
|
||||||
|
document.getElementById('btn-close').disabled = flag;
|
||||||
|
document.getElementById('title').disabled = flag;
|
||||||
|
document.getElementById('subtitle').disabled = flag;
|
||||||
|
document.getElementById('section1').disabled = flag;
|
||||||
|
document.getElementById('content1').disabled = flag;
|
||||||
|
document.getElementById('section2').disabled = flag;
|
||||||
|
document.getElementById('content2').disabled = flag;
|
||||||
|
document.getElementById('section3').disabled = flag;
|
||||||
|
document.getElementById('content3').disabled = flag;
|
||||||
|
document.getElementById('section4').disabled = flag;
|
||||||
|
document.getElementById('content4').disabled = flag;
|
||||||
|
document.getElementById('section5').disabled = flag;
|
||||||
|
document.getElementById('content5').disabled = flag;
|
||||||
|
document.getElementById('section6').disabled = flag;
|
||||||
|
document.getElementById('content6').disabled = flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('createPdf').addEventListener('click', function() {
|
||||||
|
disableModal(true);
|
||||||
|
spinner.style.display = 'block';
|
||||||
|
contents = [];
|
||||||
|
contents.push(document.getElementById('subtitle').value);
|
||||||
|
editors.forEach((editor, index) => {
|
||||||
|
const data = editor.getData();
|
||||||
|
const selectedElement = editor.model.document.selection.getSelectedElement();
|
||||||
|
const styles = selectedElement ? selectedElement.getAttribute('style') || 'No style applied' : 'No style applied';
|
||||||
|
contents.push(data);
|
||||||
|
});
|
||||||
|
getTitleData();
|
||||||
|
createChart('pdf');
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('createWord').addEventListener('click', function() {
|
||||||
|
disableModal(true);
|
||||||
|
spinner.style.display = 'block';
|
||||||
|
contents = [];
|
||||||
|
contents.push(document.getElementById('subtitle').value);
|
||||||
|
editors.forEach((editor, index) => {
|
||||||
|
const data = editor.getData();
|
||||||
|
const selectedElement = editor.model.document.selection.getSelectedElement();
|
||||||
|
const styles = selectedElement ? selectedElement.getAttribute('style') || 'No style applied' : 'No style applied';
|
||||||
|
contents.push(data);
|
||||||
|
});
|
||||||
|
getTitleData();
|
||||||
|
createChart('word');
|
||||||
|
});
|
||||||
|
|
||||||
|
function getTitleData() {
|
||||||
|
titles = [];
|
||||||
|
titles.push(document.getElementById('title').value);
|
||||||
|
for (let i = 1; i < 7; i++) {
|
||||||
|
titles.push(document.getElementById('section' + i).value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createPdf() {
|
||||||
|
filterStart = document.getElementById('startDate').value;
|
||||||
|
filterEnd = document.getElementById('endDate').value;
|
||||||
|
try {
|
||||||
|
$.ajax({
|
||||||
|
url: 'createPdf.php',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
title: titles,
|
||||||
|
content: contents,
|
||||||
|
filterStart: filterStart,
|
||||||
|
filterEnd: filterEnd
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
const fileurl = response['message'] + response['file'];
|
||||||
|
const filename = response['file'];
|
||||||
|
fetch(fileurl)
|
||||||
|
.then((response) => response.blob())
|
||||||
|
.then((blob) => {
|
||||||
|
console.log("blob", blob);
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.style.display = "none";
|
||||||
|
a.href = url;
|
||||||
|
console.log('second - ', url);
|
||||||
|
console.log(filename);
|
||||||
|
a.download = filename;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
|
.catch((error) => console.error("error downloading file", error));
|
||||||
|
console.log('success', response);
|
||||||
|
},
|
||||||
|
error: function(response) {
|
||||||
|
alert('PDF download fail');
|
||||||
|
console.log('error', response);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
alert(error);
|
||||||
|
} finally {
|
||||||
|
disableModal(false);
|
||||||
|
spinner.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const chartIds = [1, 2, 3, 4, 5, 6];
|
||||||
|
|
||||||
|
async function createChart(flag) {
|
||||||
|
var formData = new FormData();
|
||||||
|
|
||||||
|
for (const chartId of chartIds) {
|
||||||
|
try {
|
||||||
|
let chartElement = document.getElementById('chart' + chartId);
|
||||||
|
const canvas = await html2canvas(chartElement, {
|
||||||
|
backgroundColor: 'ffffff',
|
||||||
|
scale: 5
|
||||||
|
});
|
||||||
|
const chartImg = canvas.toDataURL('image/png');
|
||||||
|
|
||||||
|
formData.append('chartfile[]', chartImg);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Capture error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('create_chart.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
console.error('Error creating images:', errorText);
|
||||||
|
} else {
|
||||||
|
const result = await response.text();
|
||||||
|
if (flag == 'pdf') createPdf();
|
||||||
|
if (flag == 'word') createWord();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Fetch error:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWord() {
|
||||||
|
filterStart = document.getElementById('startDate').value;
|
||||||
|
filterEnd = document.getElementById('endDate').value;
|
||||||
|
createChart();
|
||||||
|
try {
|
||||||
|
$.ajax({
|
||||||
|
url: 'createWord.php',
|
||||||
|
type: 'POST',
|
||||||
|
data: {
|
||||||
|
title: titles,
|
||||||
|
content: contents,
|
||||||
|
filterStart: filterStart,
|
||||||
|
filterEnd: filterEnd,
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(response) {
|
||||||
|
const url = response['message'] + response['file'];
|
||||||
|
const filename = response['file'];
|
||||||
|
console.log(url, "----", filename);
|
||||||
|
fetch(url)
|
||||||
|
.then((response) => response.blob())
|
||||||
|
.then((blob) => {
|
||||||
|
const url = window.URL.createObjectURL(blob);
|
||||||
|
console.log(url);
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.style.display = "none";
|
||||||
|
a.href = url;
|
||||||
|
a.download = filename;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
window.URL.revokeObjectURL(url);
|
||||||
|
})
|
||||||
|
.catch((error) => console.error("error downloading file", error));
|
||||||
|
console.log('success', response);
|
||||||
|
},
|
||||||
|
error: function(response) {
|
||||||
|
alert('WORD download fail');
|
||||||
|
console.log('error', response);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
alert(error);
|
||||||
|
} finally {
|
||||||
|
disableModal(false);
|
||||||
|
spinner.style.display = 'none';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@ -1,6 +1,7 @@
|
|||||||
<?php include('../include/headscript.php'); ?>
|
<?php include('../include/headscript.php'); ?>
|
||||||
<?php include("../class/company.php");
|
<?php include("../class/company.php");
|
||||||
include('parsedatachart.php');
|
include('parsedatachart.php');
|
||||||
|
//include('documentModal.php');
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -219,6 +220,10 @@ include('parsedatachart.php');
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.card-body {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
@ -305,7 +310,7 @@ include('parsedatachart.php');
|
|||||||
<!-- end page title end breadcrumb -->
|
<!-- end page title end breadcrumb -->
|
||||||
|
|
||||||
<button id="toggleFilters" class="btn btn-primary">Toggle Filters</button>
|
<button id="toggleFilters" class="btn btn-primary">Toggle Filters</button>
|
||||||
|
<button id="createPDF" class="btn btn-primary">Report</button>
|
||||||
<!-- Right Sidebar -->
|
<!-- Right Sidebar -->
|
||||||
<div class="filter-sidebar" id="filterSidebar">
|
<div class="filter-sidebar" id="filterSidebar">
|
||||||
<?php
|
<?php
|
||||||
@ -380,6 +385,10 @@ include('parsedatachart.php');
|
|||||||
$('#main-content').toggleClass('collapsed');
|
$('#main-content').toggleClass('collapsed');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#createPDF').on('click', function() {
|
||||||
|
$('#documentModal').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
$('.select2').on('change', function() {
|
$('.select2').on('change', function() {
|
||||||
updateActiveFilters();
|
updateActiveFilters();
|
||||||
});
|
});
|
||||||
|
|||||||