2014-04-01 19:02:32 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Implementation of Charts view
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @license GPL 2
|
|
|
|
* @version @version@
|
|
|
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
|
|
|
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
|
|
|
* 2010-2012 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include parent class
|
|
|
|
*/
|
2021-04-18 05:08:00 +00:00
|
|
|
//require_once("class.Bootstrap.php");
|
2014-04-01 19:02:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class which outputs the html page for Charts view
|
|
|
|
*
|
|
|
|
* @category DMS
|
|
|
|
* @package SeedDMS
|
|
|
|
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
|
|
|
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
|
|
|
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
|
|
|
* 2010-2012 Uwe Steinmann
|
|
|
|
* @version Release: @package_version@
|
|
|
|
*/
|
2021-04-18 05:08:00 +00:00
|
|
|
class SeedDMS_View_Charts extends SeedDMS_Theme_Style {
|
2014-04-01 19:02:32 +00:00
|
|
|
|
2015-12-16 06:14:04 +00:00
|
|
|
function js() { /* {{{ */
|
2014-04-01 19:02:32 +00:00
|
|
|
$data = $this->params['data'];
|
|
|
|
$type = $this->params['type'];
|
|
|
|
|
2021-03-10 14:58:22 +00:00
|
|
|
header('Content-Type: application/javascript; charset=UTF-8');
|
2015-08-06 11:41:49 +00:00
|
|
|
?>
|
2014-04-08 13:28:38 +00:00
|
|
|
$("<div id='tooltip'></div>").css({
|
|
|
|
position: "absolute",
|
|
|
|
display: "none",
|
|
|
|
padding: "5px",
|
|
|
|
color: "white",
|
|
|
|
"background-color": "#000",
|
|
|
|
"border-radius": "5px",
|
|
|
|
opacity: 0.80
|
|
|
|
}).appendTo("body");
|
|
|
|
|
2014-04-08 08:48:44 +00:00
|
|
|
<?php
|
2014-04-09 07:25:56 +00:00
|
|
|
if(in_array($type, array('docspermonth'))) {
|
|
|
|
?>
|
|
|
|
var data = [
|
|
|
|
<?php
|
2016-08-09 04:51:43 +00:00
|
|
|
if($data) {
|
|
|
|
foreach($data as $i=>$rec) {
|
|
|
|
$key = mktime(12, 0, 0, substr($rec['key'], 5, 2), 1, substr($rec['key'], 0, 4)) * 1000;
|
|
|
|
echo '["'.$rec['key'].'",'.$rec['total'].'],'."\n";
|
|
|
|
}
|
2014-04-09 07:25:56 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
];
|
|
|
|
$.plot("#chart", [data], {
|
|
|
|
xaxis: {
|
|
|
|
mode: "categories",
|
|
|
|
tickLength: 0,
|
|
|
|
},
|
|
|
|
series: {
|
|
|
|
bars: {
|
|
|
|
show: true,
|
|
|
|
align: "center",
|
|
|
|
barWidth: 0.8,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true
|
2015-08-06 11:41:49 +00:00
|
|
|
}
|
2014-04-09 07:25:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$("#chart").bind("plothover", function (event, pos, item) {
|
|
|
|
if(item) {
|
|
|
|
var x = item.datapoint[0];//.toFixed(2),
|
|
|
|
y = item.datapoint[1];//.toFixed(2);
|
|
|
|
$("#tooltip").html(item.series.xaxis.ticks[x].label + ": " + y)
|
|
|
|
.css({top: pos.pageY-35, left: pos.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
<?php
|
2024-08-12 08:25:54 +00:00
|
|
|
} elseif(in_array($type, array('sizepermonth'))) {
|
|
|
|
?>
|
|
|
|
var data = [
|
|
|
|
<?php
|
|
|
|
if($data) {
|
|
|
|
foreach($data as $i=>$rec) {
|
|
|
|
$key = mktime(12, 0, 0, substr($rec['key'], 5, 2), 1, substr($rec['key'], 0, 4)) * 1000;
|
|
|
|
echo '["'.$rec['key'].'",'.$rec['total'].'],'."\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
];
|
|
|
|
$.plot("#chart", [data], {
|
|
|
|
xaxis: {
|
|
|
|
mode: "categories",
|
|
|
|
tickLength: 0,
|
|
|
|
},
|
|
|
|
series: {
|
|
|
|
bars: {
|
|
|
|
show: true,
|
|
|
|
align: "center",
|
|
|
|
barWidth: 0.8,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#chart").bind("plothover", function (event, pos, item) {
|
|
|
|
if(item) {
|
|
|
|
var x = item.datapoint[0];//.toFixed(2),
|
|
|
|
y = item.datapoint[1];//.toFixed(2);
|
|
|
|
$("#tooltip").html(item.series.xaxis.ticks[x].label + ": " + formatFileSize(y, false, 2))
|
|
|
|
.css({top: pos.pageY-35, left: pos.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
<?php
|
2014-04-09 07:25:56 +00:00
|
|
|
} elseif(in_array($type, array('docsaccumulated'))) {
|
2014-04-08 08:48:44 +00:00
|
|
|
?>
|
|
|
|
var data = [
|
|
|
|
<?php
|
2016-08-09 04:51:43 +00:00
|
|
|
if($data) {
|
|
|
|
foreach($data as $rec) {
|
|
|
|
echo '['.htmlspecialchars($rec['key']).','.$rec['total'].'],'."\n";
|
|
|
|
}
|
2014-04-08 08:48:44 +00:00
|
|
|
}
|
|
|
|
?>
|
|
|
|
];
|
2014-04-08 13:28:38 +00:00
|
|
|
var plot = $.plot("#chart", [data], {
|
|
|
|
xaxis: { mode: "time" },
|
|
|
|
series: {
|
|
|
|
lines: {
|
|
|
|
show: true
|
|
|
|
},
|
|
|
|
points: {
|
|
|
|
show: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true
|
2015-08-06 11:41:49 +00:00
|
|
|
}
|
2014-04-08 08:48:44 +00:00
|
|
|
});
|
|
|
|
|
2014-04-08 13:28:38 +00:00
|
|
|
$("#chart").bind("plothover", function (event, pos, item) {
|
|
|
|
if(item) {
|
|
|
|
var x = item.datapoint[0];//.toFixed(2),
|
|
|
|
y = item.datapoint[1];//.toFixed(2);
|
|
|
|
$("#tooltip").html($.plot.formatDate(new Date(x), '%e. %b %Y') + ": " + y)
|
|
|
|
.css({top: pos.pageY-35, left: pos.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
2014-04-08 08:48:44 +00:00
|
|
|
<?php
|
|
|
|
} else {
|
|
|
|
?>
|
2014-04-02 06:42:49 +00:00
|
|
|
var data = [
|
2014-04-01 19:02:32 +00:00
|
|
|
<?php
|
2016-08-09 04:51:43 +00:00
|
|
|
if($data) {
|
|
|
|
foreach($data as $rec) {
|
|
|
|
echo '{ label: "'.htmlspecialchars($rec['key']).'", data: [[1,'.$rec['total'].']]},'."\n";
|
|
|
|
}
|
2014-04-09 07:25:56 +00:00
|
|
|
}
|
2014-04-01 19:02:32 +00:00
|
|
|
?>
|
2014-04-02 06:42:49 +00:00
|
|
|
];
|
2015-08-06 11:41:49 +00:00
|
|
|
$(document).ready( function() {
|
2014-04-02 06:42:49 +00:00
|
|
|
$.plot('#chart', data, {
|
|
|
|
series: {
|
|
|
|
pie: {
|
|
|
|
show: true,
|
|
|
|
radius: 1,
|
|
|
|
label: {
|
2014-04-01 19:02:32 +00:00
|
|
|
show: true,
|
2014-04-02 06:42:49 +00:00
|
|
|
radius: 2/3,
|
|
|
|
formatter: labelFormatter,
|
|
|
|
threshold: 0.1,
|
|
|
|
background: {
|
|
|
|
opacity: 0.8
|
2014-04-01 19:02:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-02 06:42:49 +00:00
|
|
|
},
|
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true
|
2015-08-06 11:41:49 +00:00
|
|
|
},
|
|
|
|
legend: {
|
|
|
|
show: true,
|
|
|
|
container: '#legend'
|
2014-04-02 06:42:49 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#chart").bind("plothover", function (event, pos, item) {
|
|
|
|
if(item) {
|
|
|
|
var x = item.series.data[0][0];//.toFixed(2),
|
|
|
|
y = item.series.data[0][1];//.toFixed(2);
|
|
|
|
|
|
|
|
$("#tooltip").html(item.series.label + ": " + y + " (" + Math.round(item.series.percent) + "%)")
|
|
|
|
.css({top: pos.pageY-35, left: pos.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
2014-04-01 19:02:32 +00:00
|
|
|
function labelFormatter(label, series) {
|
2014-04-02 06:42:49 +00:00
|
|
|
return "<div style='font-size:8pt; line-height: 14px; text-align:center; padding:2px; color:black; background: white; border-radius: 5px;'>" + label + "<br/>" + series.data[0][1] + " (" + Math.round(series.percent) + "%)</div>";
|
2014-04-01 19:02:32 +00:00
|
|
|
}
|
2015-08-06 11:41:49 +00:00
|
|
|
});
|
2014-04-08 08:48:44 +00:00
|
|
|
<?php
|
|
|
|
}
|
2015-12-16 06:14:04 +00:00
|
|
|
} /* }}} */
|
|
|
|
|
|
|
|
function show() { /* {{{ */
|
|
|
|
$this->dms = $this->params['dms'];
|
|
|
|
$user = $this->params['user'];
|
|
|
|
$data = $this->params['data'];
|
|
|
|
$type = $this->params['type'];
|
|
|
|
|
|
|
|
$this->htmlAddHeader(
|
|
|
|
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.min.js"></script>'."\n".
|
|
|
|
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.pie.min.js"></script>'."\n".
|
|
|
|
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.categories.min.js"></script>'."\n".
|
|
|
|
'<script type="text/javascript" src="../styles/bootstrap/flot/jquery.flot.time.min.js"></script>'."\n");
|
|
|
|
|
|
|
|
$this->htmlStartPage(getMLText("folders_and_documents_statistic"));
|
|
|
|
$this->globalNavigation();
|
|
|
|
$this->contentStart();
|
|
|
|
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
|
|
|
|
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->rowStart();
|
|
|
|
$this->columnStart(3);
|
2016-03-15 07:30:53 +00:00
|
|
|
$this->contentHeading(getMLText("chart_selection"));
|
2018-04-26 06:50:44 +00:00
|
|
|
$this->contentContainerStart();
|
2024-08-12 08:25:54 +00:00
|
|
|
foreach(array('docsperuser', 'foldersperuser', 'sizeperuser', 'sizepermonth','docspermimetype', 'docspercategory', 'docsperstatus', 'docspermonth', 'docsaccumulated') as $atype) {
|
2016-03-15 07:30:53 +00:00
|
|
|
echo "<div><a href=\"?type=".$atype."\">".getMLText('chart_'.$atype.'_title')."</a></div>\n";
|
|
|
|
}
|
2018-04-26 06:50:44 +00:00
|
|
|
$this->contentContainerEnd();
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->columnEnd();
|
2015-12-16 06:14:04 +00:00
|
|
|
|
2016-03-15 07:30:53 +00:00
|
|
|
if(in_array($type, array('docspermonth', 'docsaccumulated'))) {
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->columnStart(9);
|
2016-03-15 07:30:53 +00:00
|
|
|
} else {
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->columnStart(6);
|
2016-03-15 07:30:53 +00:00
|
|
|
}
|
|
|
|
$this->contentHeading(getMLText('chart_'.$type.'_title'));
|
2018-04-26 06:50:44 +00:00
|
|
|
$this->contentContainerStart();
|
2014-04-08 08:48:44 +00:00
|
|
|
?>
|
2015-12-16 06:14:04 +00:00
|
|
|
<div id="chart" style="height: 400px;" class="chart"></div>
|
2014-04-01 19:02:32 +00:00
|
|
|
<?php
|
2018-04-26 06:50:44 +00:00
|
|
|
$this->contentContainerEnd();
|
2021-05-02 05:54:38 +00:00
|
|
|
echo "<table class=\"table table-condensed table-sm table-hover\">";
|
2021-01-31 12:48:25 +00:00
|
|
|
echo "<tr>";
|
|
|
|
echo "<th>".getMLText('chart_'.$type.'_title')."</th><th>".getMLText('total')."</th>";
|
|
|
|
if(in_array($type, array('docspermonth', 'docsaccumulated')))
|
|
|
|
echo "<th></th>";
|
|
|
|
echo "</tr>";
|
2020-04-02 10:38:16 +00:00
|
|
|
$total = 0;
|
|
|
|
switch($type) {
|
|
|
|
case 'docspermonth':
|
|
|
|
case 'docsperuser':
|
2021-07-09 12:24:03 +00:00
|
|
|
case 'foldersperuser':
|
2020-04-02 10:38:16 +00:00
|
|
|
case 'docspermimetype':
|
|
|
|
case 'docspercategory':
|
|
|
|
case 'docsperstatus':
|
2021-01-31 12:48:25 +00:00
|
|
|
$oldtotal = 0;
|
2020-04-02 10:38:16 +00:00
|
|
|
foreach($data as $item) {
|
2021-01-31 12:48:25 +00:00
|
|
|
echo "<tr>";
|
|
|
|
echo "<td>".htmlspecialchars($item['key'])."</td>";
|
|
|
|
echo "<td>".$item['total']."</td>";
|
|
|
|
if(in_array($type, array('docspermonth')))
|
|
|
|
echo "<td>".sprintf('%+d', $item['total']-$oldtotal)."</td>";
|
|
|
|
echo "</tr>";
|
|
|
|
$oldtotal = $item['total'];
|
2020-04-02 10:38:16 +00:00
|
|
|
$total += $item['total'];
|
|
|
|
}
|
2020-04-02 11:59:38 +00:00
|
|
|
echo "<tr><th></th><th>".$total."<th></tr>";
|
2020-04-02 10:38:16 +00:00
|
|
|
break;
|
|
|
|
case 'docsaccumulated':
|
2021-01-31 12:48:25 +00:00
|
|
|
$oldtotal = 0;
|
2020-04-02 10:38:16 +00:00
|
|
|
foreach($data as $item) {
|
2021-01-31 12:48:25 +00:00
|
|
|
echo "<tr>";
|
|
|
|
echo "<td>".getReadableDate($item['key']/1000)."</td>";
|
|
|
|
echo "<td>".$item['total']."</td>";
|
|
|
|
echo "<td>".sprintf('%+d', $item['total']-$oldtotal)."</td>";
|
|
|
|
echo "</tr>";
|
|
|
|
$oldtotal = $item['total'];
|
2020-04-02 10:38:16 +00:00
|
|
|
$total += $item['total'];
|
|
|
|
}
|
2020-04-02 11:59:38 +00:00
|
|
|
break;
|
|
|
|
case 'sizeperuser':
|
2024-08-12 08:25:54 +00:00
|
|
|
case 'sizepermonth':
|
2020-04-02 11:59:38 +00:00
|
|
|
foreach($data as $item) {
|
2024-01-26 11:54:15 +00:00
|
|
|
echo "<tr><td>".htmlspecialchars($item['key'])."</td><td>".SeedDMS_Core_File::format_filesize((int) $item['total'])."</td></tr>";
|
2020-04-02 11:59:38 +00:00
|
|
|
$total += $item['total'];
|
|
|
|
}
|
|
|
|
echo "<tr><th></th><th>".SeedDMS_Core_File::format_filesize($total)."<th></tr>";
|
2020-04-02 10:38:16 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
echo "</table>";
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->columnEnd();
|
2016-03-15 07:30:53 +00:00
|
|
|
|
|
|
|
if(!in_array($type, array('docspermonth', 'docsaccumulated'))) {
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->columnStart(3);
|
2016-03-15 07:30:53 +00:00
|
|
|
$this->contentHeading(getMLText('legend'));
|
2018-04-26 06:50:44 +00:00
|
|
|
$this->contentContainerStart('', 'legend');
|
|
|
|
$this->contentContainerEnd();
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->columnEnd();
|
2016-03-15 07:30:53 +00:00
|
|
|
}
|
2015-12-16 06:14:04 +00:00
|
|
|
|
2020-10-08 05:57:23 +00:00
|
|
|
$this->rowEnd();
|
2016-03-15 07:30:53 +00:00
|
|
|
$this->contentContainerEnd();
|
|
|
|
$this->contentEnd();
|
|
|
|
$this->htmlEndPage();
|
2014-04-01 19:02:32 +00:00
|
|
|
} /* }}} */
|
|
|
|
}
|