From cb16c002bd3d520d38fa8294185278f159d6a556 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Thu, 7 May 2026 13:17:47 +0200 Subject: [PATCH] add new chart with docs per size range --- views/bootstrap/class.Charts.php | 54 +++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/views/bootstrap/class.Charts.php b/views/bootstrap/class.Charts.php index 06eed4d2d..679e227e9 100644 --- a/views/bootstrap/class.Charts.php +++ b/views/bootstrap/class.Charts.php @@ -173,7 +173,7 @@ if(in_array($type, array('docspermonth'))) { getKeyValue($type, $rec).'", data: [[1,'.$rec['total'].']]},'."\n"; } } ?> @@ -245,7 +245,31 @@ $(document).ready( function() { return true; } /* }}} */ - protected function getSearchUrl($type, $item) { + protected function getKeyValue($type, $item) { /* {{{ */ + switch ($type) { + case 'docspersizerange': + return htmlspecialchars('< '.SeedDMS_Core_File::format_filesize(pow(10, $item['key']+1), ['Bytes', 'KB', 'MB', 'GB'], 10, 1000).', >= '.SeedDMS_Core_File::format_filesize(pow(10, $item['key']), ['Bytes', 'KB', 'MB', 'GB'], 10, 1000)); + break; + case 'docsaccumulated': + return getReadableDate($item['key']/1000); + break; + default: + return htmlspecialchars($item['key']); + } + } /* }}} */ + + protected function getTotalValue($type, $total) { /* {{{ */ + switch ($type) { + case 'sizeperuser': + case 'sizepermonth': + return htmlspecialchars(SeedDMS_Core_File::format_filesize($total)); + break; + default: + return htmlspecialchars($total); + } + } /* }}} */ + + protected function getSearchUrl($type, $item) { /* {{{ */ $dms = $this->params['dms']; $settings = $this->params['settings']; @@ -270,6 +294,11 @@ $(document).ready( function() { $endmonth = date('Y-m-t', strtotime($startmonth)); $searchurl = $settings->_httpRoot.'out/out.Search.php?fullsearch=0&query=&mode=1&orderby=&resultmode=1&created%5Bfrom%5D='.$startmonth.'&created%5Bto%5D='.$endmonth; break; + case 'docspersizerange': + $filesizestart = pow(10, $item['key']); + $filesizeend = pow(10, $item['key']+1)-1; + $searchurl = $settings->_httpRoot.'out/out.Search.php?fullsearch=0&query=&mode=1&orderby=&resultmode=1&filesize%5Bfrom%5D='.$filesizestart.'&filesize%5Bto%5D='.$filesizeend; + break; case 'docspermimetype': $searchurl = $settings->_httpRoot.'out/out.Search.php?fullsearch=0&query=&mode=1&orderby=&resultmode=1&mimetype%5B%5D='.urlencode($item['key']); break; @@ -280,7 +309,7 @@ $(document).ready( function() { break; } return $searchurl; - } + } /* }}} */ public function show() { /* {{{ */ $dms = $this->params['dms']; @@ -306,7 +335,7 @@ $(document).ready( function() { $this->columnStart(3); $this->contentHeading(getMLText("chart_selection")); $this->contentContainerStart(); - foreach(array('docsperuser', 'foldersperuser', 'sizeperuser', 'sizepermonth','docspermimetype', 'docspercategory', 'docsperstatus', 'docspermonth', 'docsaccumulated') as $atype) { + foreach(array('docsperuser', 'foldersperuser', 'sizeperuser', 'sizepermonth','docspersizerange', 'docspermimetype', 'docspercategory', 'docsperstatus', 'docspermonth', 'docsaccumulated') as $atype) { if($this->showChart($atype)) echo "
".getMLText('chart_'.$atype.'_title')."
\n"; } @@ -349,7 +378,7 @@ $(document).ready( function() { $oldtotal = 0; foreach($data as $item) { echo ""; - echo "".htmlspecialchars($item['key']).""; + echo "".$this->getKeyValue($type, $item).""; echo "".$item['total'].""; if(in_array($type, array('docspermonth'))) echo "".sprintf('%+d', $item['total']-$oldtotal).""; @@ -371,7 +400,7 @@ $(document).ready( function() { $oldtotal = 0; foreach($data as $item) { echo ""; - echo "".getReadableDate($item['key']/1000).""; + echo "".$this->getKeyValue($type, $item).""; echo "".$item['total'].""; echo "".sprintf('%+d', $item['total']-$oldtotal).""; $searchurl = $this->getSearchUrl($type, $item); @@ -388,8 +417,8 @@ $(document).ready( function() { case 'sizeperuser': foreach($data as $item) { $currUser = $dms->getUser($item['res']); - echo "".htmlspecialchars($item['key']).""; - echo "".SeedDMS_Core_File::format_filesize((int) $item['total']).""; + echo "".$this->getKeyValue($type, $item).""; + echo "".$this->getTotalValue($type, (int) $item['total']).""; if($quota) { echo ""; $qt = $currUser->getQuota() ? $currUser->getQuota() : $quota; @@ -406,13 +435,14 @@ $(document).ready( function() { } echo ""; echo ""; - echo "".SeedDMS_Core_File::format_filesize($total).""; + echo "".$this->getTotalValue($type, $total).""; echo ""; break; + case 'docspersizerange': case 'sizepermonth': foreach($data as $item) { - echo "".htmlspecialchars($item['key']).""; - echo "".SeedDMS_Core_File::format_filesize((int) $item['total']).""; + echo "".$this->getKeyValue($type, $item).""; + echo "".$this->getTotalValue($type, (int) $item['total']).""; $searchurl = $this->getSearchUrl($type, $item); if($searchurl) echo ""; @@ -423,7 +453,7 @@ $(document).ready( function() { } echo ""; echo ""; - echo "".SeedDMS_Core_File::format_filesize($total).""; + echo "".$this->getTotalValue($type, $total).""; echo ""; break; }