1
I’m doing a list of accounts receivable.
To get interactive, I’m creating an IF to show when it’s near.
Problem
Shows no negative date, which would represent overdue invoice.
In this case the low image, today are 08/02/2020
, the tag that should be shown, is the Vencido
.
Code
if (data[5] == null) {
hoje = new Date('<?= date('Y - m - d '); ?>');
data = new Date(data[4]);
diferenfa = Math.abs(data.getTime() - hoje.getTime());
nDias = Math.ceil(diferenfa / (1000 * 3600 * 24));
if (nDias >= 8) {
return '<span class="label">Faltam ' + nDias + ' dias</span>';
} else if (nDias <= 7 && nDias >= 3) {
return '<span class="label label-warning">Está proximo</span>';
} else if (nDias <= 2 && nDias >= 1) {
return '<span class="label label-sm label-yellow">Amanhã</span>';
} else if (nDias == 0) {
return '<span class="label label-info">Hoje</span>';
}else if (nDias < 0){
return '<span class="label label-info">Vencido</span>';
}
} else {
return '<span class="label label-success">Pago</span>';
}
Question
How can I ride these if
s so that it works correctly?