functions.inc.php:

- add functions db_quota_text() and db_quota_percent() to generate
  queries for used quota ("x/y" and percentage)



git-svn-id: https://svn.code.sf.net/p/postfixadmin/code/trunk@1712 a1433add-5e2c-0410-b055-b7f2511e0802
pull/2/head
Christian Boltz 10 years ago
parent 647aa39218
commit 9093a946b4

@ -1302,6 +1302,34 @@ function db_get_boolean($bool) {
}
}
/**
* Returns a query that reports the used quota ("x / y")
* @param string column containing used quota
* @param string column containing allowed quota
* @param string column that will contain "x / y"
* @return string
*/
function db_quota_text($count, $quota, $fieldname) {
return " CASE $quota
WHEN '-1' THEN coalesce($count,0)
ELSE CONCAT(coalesce($count,0), ' / ', $quota)
END AS $fieldname";
}
/**
* Returns a query that reports the used quota ("x / y")
* @param string column containing used quota
* @param string column containing allowed quota
* @param string column that will contain "x / y"
* @return string
*/
function db_quota_percent($count, $quota, $fieldname) {
return " CASE $quota
WHEN '-1' THEN -1
ELSE round(100 * coalesce($count,0) / $quota)
END AS $fieldname";
}
/**
* returns true if PostgreSQL is used, false otherwise
*/

Loading…
Cancel
Save