1
0

Echte grafiekfix en andere dingen

This commit is contained in:
JelmerHinssen
2017-04-03 18:49:46 +02:00
parent dfc5b993f6
commit fbde1a0406
3 changed files with 22 additions and 32 deletions

View File

@ -59,35 +59,33 @@ class Overboekingen
return $message;
}
private static function isValidFloat($bedrag)
public static function isValidFloat($bedrag)
{
$hasdecimal = false;
$decimals = 0;
$voorcijfers = 0;
$komma = 0;
$decimalen = 0;
$cijfers = 0;
for ($i = 0; $i < strlen($bedrag); $i++) {
$char = substr($bedrag, $i, 1);
$ascii = ord($char);
if ($hasdecimal) {
if ($char === "." || $char === ",") {
if ($char === "." || $char === ",") {
$komma++;
if($komma > 1){
//Twee komma's
return false;
} elseif ($ascii >= ord("0") && $ascii <= ord("9")) {
$decimals++;
if ($decimals > 2) {
}
} elseif (($ascii >= ord("0") && $ascii <= ord("9") || $char === "-")) {
if($komma >= 1){
$decimalen++;
if ($decimalen > 2) {
//Meer dan twee cijfers achter de komma
return false;
}
} else {
//Ongeldig teken
return false;
}
} elseif ($char === "." || $char === ",") {
$hasdecimal = true;
} elseif ($ascii >= ord("0") || $ascii <= ord("9")) {
$voorcijfers++;
if ($voorcijfers > 9) {
//Te veel cijfers voor de komma
return false;
}else{
$cijfers++;
if($cijfers > 9){
//Te veel cijfers voor de komma
return false;
}
}
} else {
//Ongeldig teken