I have a table of usuarios
in a BD, where I have the following fields:
id_ususario
login
passwd
dias_disponibles (Los usuarios fijos tienen 24 días disponibles)
fecha_ingreso (Fecha ingreso en empresa)
tipo_usuario (Fijo o Temporal)
Each user can make a request for a vacation. The user admin
is responsible for adding the new users. My problem is with users temporales
. A temporary user will have the available days according to the months worked up to one year. For each month worked, dias_disponibles
is increased by 2. For example, if usuario1
since you joined the company, takes 2 months worked because it will have 4 dias_disponibles
and so on until it takes 12 months, then starting from there, they will always be 24 dias_disponibles
.
I have this function that calculates the difference of months since I joined the company until today:
function difmeses($fechaingreso){
$fechainicial = new DateTime($fechaingreso);
$fechaactual = (new DateTime)->format('Y-m-d H:i');
$fechafinal = new DateTime($fechaactual);
$diferencia = $fechainicial->diff($fechafinal);
$meses = ( $diferencia->y * 12 ) + $diferencia->m;
return $meses;
}
My question is what to use to increase it until 12 months in the company, if it has been 12 months. Any help on how to do the increase of 2 days, a for
, a while
... ??