Echte grafiekfix en andere dingen
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user