2019-05-04 02:03:42 +02:00
|
|
|
<?php
|
2020-09-07 15:04:06 +02:00
|
|
|
/*
|
|
|
|
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
2021-01-20 15:08:51 +01:00
|
|
|
* Copyright (C) DevCode s.r.l.
|
2020-09-07 15:04:06 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2019-05-04 02:03:42 +02:00
|
|
|
|
|
|
|
include_once __DIR__.'/../../../core.php';
|
2024-03-05 16:01:45 +01:00
|
|
|
use Models\Module;
|
2019-05-04 02:03:42 +02:00
|
|
|
|
2024-06-11 16:58:27 +02:00
|
|
|
$id_module = Module::where('name', 'Stato dei servizi')->first()->id;
|
2019-05-04 02:03:42 +02:00
|
|
|
|
|
|
|
echo '
|
2022-07-07 15:31:53 +02:00
|
|
|
<script src="'.base_path().'/assets/dist/js/chartjs/chart.min.js"></script>';
|
2019-05-04 02:03:42 +02:00
|
|
|
|
|
|
|
// Operazioni JavaScript
|
|
|
|
echo '
|
|
|
|
<script>
|
|
|
|
|
2020-06-25 17:56:59 +02:00
|
|
|
function formatBytes(a,b=2){if(0===a)return"0 Bytes";const c=0>b?0:b,d=Math.floor(Math.log(a)/Math.log(1024));return parseFloat((a/Math.pow(1024,d)).toFixed(c))+" "+["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"][d]}
|
|
|
|
|
2019-05-04 02:03:42 +02:00
|
|
|
$(document).ready(function() {
|
|
|
|
$.ajax({
|
|
|
|
url: globals.rootdir + "/actions.php",
|
|
|
|
type: "get",
|
|
|
|
data: {
|
2024-05-21 16:26:19 +02:00
|
|
|
id_module: '.$id_module.',
|
2019-05-04 02:03:42 +02:00
|
|
|
op: "sizes",
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
data = JSON.parse(data);
|
|
|
|
crea_grafico(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
function crea_grafico(values){
|
2024-09-09 09:28:48 +02:00
|
|
|
var ctx = $("#chart");
|
|
|
|
$data = [];
|
|
|
|
$labels = [];
|
2022-10-06 13:30:07 +02:00
|
|
|
|
2024-09-09 09:28:48 +02:00
|
|
|
values.forEach(function(element) {
|
2019-05-04 02:03:42 +02:00
|
|
|
$data.push(element.size);
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2020-06-25 17:56:59 +02:00
|
|
|
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
|
2024-09-09 09:28:48 +02:00
|
|
|
if (element.dbSize > 0 && element.description == "Allegati"){
|
|
|
|
if (element.size < element.dbSize){
|
|
|
|
var diff = (element.dbSize - element.size);
|
|
|
|
if (diff > 1000){
|
|
|
|
$("#message").append("<div class=\"badge badge-warning\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+formatBytes(diff)+" di files mancanti per allegati.</div><br>");
|
2020-06-25 17:56:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//Segnalazione se sul server sembrano mancare file rispetto a quanto previsto a DB
|
2024-09-09 09:28:48 +02:00
|
|
|
if (element.dbCount > 0 && element.description == "Allegati" ){
|
|
|
|
if (element.count < element.dbCount){
|
|
|
|
var diff = (element.dbCount - element.count);
|
|
|
|
$("#message").append("<div class=\"badge badge-warning\"><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" files non trovati per allegati.</div><br>");
|
2020-06-25 17:56:59 +02:00
|
|
|
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2020-06-25 17:56:59 +02:00
|
|
|
}
|
|
|
|
}
|
2022-10-06 13:30:07 +02:00
|
|
|
|
|
|
|
//Numero di file in Allegati suddivisi per estensione
|
2020-06-26 13:02:38 +02:00
|
|
|
if (element.dbExtensions.length > 0){
|
2020-07-17 17:34:06 +02:00
|
|
|
$("#message").append("<br><p><b>Top 10 allegati:</b></p>");
|
2022-10-06 13:30:07 +02:00
|
|
|
element.dbExtensions.forEach(function(ext) {
|
2024-09-09 09:28:48 +02:00
|
|
|
$("#message").append("<div class=\"badge badge-info\"><i class=\"fa fa-file\" aria-hidden=\"true\"></i> <b>"+ext.num+"</b> files con estensione <b>"+ext.extension+"</b>.</div><br>");
|
2020-06-26 13:02:38 +02:00
|
|
|
|
|
|
|
|
2024-09-09 09:28:48 +02:00
|
|
|
});
|
2020-06-26 13:02:38 +02:00
|
|
|
}
|
2024-09-09 09:28:48 +02:00
|
|
|
$labels.push(`${element.description} (${element.formattedSize}) [${element.count}]`);
|
2019-05-04 02:03:42 +02:00
|
|
|
});
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2024-09-09 09:28:48 +02:00
|
|
|
const options = {
|
2024-05-14 16:29:55 +02:00
|
|
|
responsive: true,
|
|
|
|
maintainAspectRatio: false,
|
2024-09-09 09:28:48 +02:00
|
|
|
legend: {
|
|
|
|
display: true,
|
|
|
|
position: "right",
|
|
|
|
},
|
|
|
|
animation: {
|
|
|
|
animateScale: true,
|
|
|
|
animateRotate: true,
|
2020-06-26 13:02:38 +02:00
|
|
|
},
|
|
|
|
tooltips: {
|
|
|
|
callbacks: {
|
2024-09-09 09:28:48 +02:00
|
|
|
title: function(tooltipItem, data) {
|
|
|
|
return data.labels[tooltipItem[0].index];
|
|
|
|
},
|
|
|
|
label: function(tooltipItem, data) {
|
|
|
|
const dataset = data.datasets[0];
|
|
|
|
const percent = Math.round((dataset.data[tooltipItem.index] / dataset._meta[0].total) * 100);
|
|
|
|
return `(${percent}%)`;
|
|
|
|
},
|
2020-06-26 13:02:38 +02:00
|
|
|
},
|
|
|
|
backgroundColor: "#fbfbfb",
|
|
|
|
titleFontSize: 12,
|
|
|
|
titleFontColor: "#000",
|
|
|
|
bodyFontColor: "#444",
|
|
|
|
bodyFontSize: 10,
|
|
|
|
displayColors: true
|
|
|
|
}
|
2019-05-04 02:03:42 +02:00
|
|
|
};
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2019-05-04 02:03:42 +02:00
|
|
|
data = {
|
|
|
|
datasets: [{
|
|
|
|
data: $data,
|
|
|
|
backgroundColor: [
|
|
|
|
\'rgba(255, 99, 132, 0.2)\',
|
|
|
|
\'rgba(54, 162, 235, 0.2)\',
|
|
|
|
\'rgba(255, 206, 86, 0.2)\',
|
|
|
|
\'rgba(75, 192, 192, 0.2)\',
|
|
|
|
\'rgba(153, 102, 255, 0.2)\',
|
|
|
|
\'rgba(255, 159, 64, 0.2)\'
|
|
|
|
],
|
|
|
|
borderColor: [
|
|
|
|
\'rgba(255, 99, 132, 1)\',
|
|
|
|
\'rgba(54, 162, 235, 1)\',
|
|
|
|
\'rgba(255, 206, 86, 1)\',
|
|
|
|
\'rgba(75, 192, 192, 1)\',
|
|
|
|
\'rgba(153, 102, 255, 1)\',
|
|
|
|
\'rgba(255, 159, 64, 1)\'
|
|
|
|
],
|
|
|
|
}],
|
2020-09-07 15:04:06 +02:00
|
|
|
|
2019-05-04 02:03:42 +02:00
|
|
|
labels: $labels,
|
|
|
|
};
|
|
|
|
|
|
|
|
var chart = new Chart(ctx, {
|
|
|
|
type: "pie",
|
|
|
|
data: data,
|
|
|
|
options: options
|
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|
2024-09-09 09:28:48 +02:00
|
|
|
<div id="message float-right"></div>
|
2024-05-14 16:29:55 +02:00
|
|
|
<div class="chart-container">
|
2019-05-04 02:03:42 +02:00
|
|
|
<canvas id="chart"></canvas>
|
2020-06-26 13:02:38 +02:00
|
|
|
</div>';
|