mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2024-09-19 19:22:14 +02:00
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
This commit is contained in:
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
|
* returns true if PostgreSQL is used, false otherwise
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user