From bba793847fc7beb3a0c022c4d03867150ff59762 Mon Sep 17 00:00:00 2001 From: Herman van Rink Date: Tue, 9 May 2023 15:01:37 +0200 Subject: [PATCH] Sum for quota usage --- interface/web/dashboard/dashlets/databasequota.php | 5 +++++ interface/web/dashboard/dashlets/mailquota.php | 3 +++ interface/web/dashboard/dashlets/quota.php | 2 ++ .../dashboard/dashlets/templates/databasequota.htm | 11 +++++++++-- .../web/dashboard/dashlets/templates/mailquota.htm | 10 +++++++++- interface/web/dashboard/dashlets/templates/quota.htm | 11 +++++++++-- 6 files changed, 37 insertions(+), 5 deletions(-) diff --git a/interface/web/dashboard/dashlets/databasequota.php b/interface/web/dashboard/dashlets/databasequota.php index 641dfd7784..077a7ddbcb 100644 --- a/interface/web/dashboard/dashlets/databasequota.php +++ b/interface/web/dashboard/dashlets/databasequota.php @@ -33,12 +33,17 @@ class dashlet_databasequota { //print_r($databases); $has_databasequota = false; + $total_used = 0; if(is_array($databases) && !empty($databases)){ + foreach ($databases as &$db) { + $total_used += $db['used_raw'] * 1000 * 1000; + } $databases = $app->functions->htmlentities($databases); $tpl->setloop('databasequota', $databases); $has_databasequota = isset($databases[0]['used']); } $tpl->setVar('has_databasequota', $has_databasequota); + $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); return $tpl->grab(); } diff --git a/interface/web/dashboard/dashlets/mailquota.php b/interface/web/dashboard/dashlets/mailquota.php index b310cc1dcb..8b328ab6f9 100644 --- a/interface/web/dashboard/dashlets/mailquota.php +++ b/interface/web/dashboard/dashlets/mailquota.php @@ -26,9 +26,11 @@ class dashlet_mailquota { //print_r($emails); $has_mailquota = false; + $total_used = 0; if(is_array($emails) && !empty($emails)){ foreach($emails as &$email) { $email['email'] = $app->functions->idn_decode($email['email']); + $total_used += $email['used_raw']; } unset($email); // email username is quoted in quota.lib already, so no htmlentities here to prevent double encoding @@ -37,6 +39,7 @@ class dashlet_mailquota { $has_mailquota = isset($emails[0]['used']); } $tpl->setVar('has_mailquota', $has_mailquota); + $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); return $tpl->grab(); } diff --git a/interface/web/dashboard/dashlets/quota.php b/interface/web/dashboard/dashlets/quota.php index 3225bd304f..adedbcf5c9 100644 --- a/interface/web/dashboard/dashlets/quota.php +++ b/interface/web/dashboard/dashlets/quota.php @@ -38,6 +38,7 @@ class dashlet_quota { foreach($sites as &$site) { $site['domain'] = $app->functions->idn_decode($site['domain']); $site['progressbar'] = $site['hd_quota']; + $total_used += $site['used_raw'] * 1000; } unset($site); @@ -46,6 +47,7 @@ class dashlet_quota { $has_quota = isset($sites[0]['used']); } $tpl->setVar('has_quota', $has_quota); + $tpl->setVar('total_used', $app->functions->formatBytes($total_used, 0)); return $tpl->grab(); diff --git a/interface/web/dashboard/dashlets/templates/databasequota.htm b/interface/web/dashboard/dashlets/templates/databasequota.htm index a2ecc2e47d..2676b65b35 100644 --- a/interface/web/dashboard/dashlets/templates/databasequota.htm +++ b/interface/web/dashboard/dashlets/templates/databasequota.htm @@ -24,5 +24,12 @@ - - + + + {tmpl_var name='total_txt'} + {tmpl_var name='total_used'} + + + + + diff --git a/interface/web/dashboard/dashlets/templates/mailquota.htm b/interface/web/dashboard/dashlets/templates/mailquota.htm index 08834fa5ab..b30815456d 100644 --- a/interface/web/dashboard/dashlets/templates/mailquota.htm +++ b/interface/web/dashboard/dashlets/templates/mailquota.htm @@ -26,5 +26,13 @@ + + + + {tmpl_var name='total_txt'} + {tmpl_var name='total_used'} + + + - + diff --git a/interface/web/dashboard/dashlets/templates/quota.htm b/interface/web/dashboard/dashlets/templates/quota.htm index 6014467e80..7fab69413b 100644 --- a/interface/web/dashboard/dashlets/templates/quota.htm +++ b/interface/web/dashboard/dashlets/templates/quota.htm @@ -29,6 +29,13 @@ {tmpl_else}{/tmpl_if} - + + + + {tmpl_var name='total_txt'} + {tmpl_var name='total_used'} + + + - \ No newline at end of file + -- GitLab