I'm doing a check to send alerts if it exceeds the time a task has to be done.
Jquery
Code:
function session_checking1()
{
$.post( "./alertaposicionamento", function( data ) {
if(data == "-1")
{
alert('Tem posicionamentos em atraso!');
}
});
}
var validateSession1 = setInterval(session_checking1, 10000);
On the alertaposicionamento
page I have the following php:
$result1 = mysqli_query($conn, $query2);
while($row = mysqli_fetch_array($result1))
{
$teste = $row["codigo"];
$teste1 = $row["Colaborador"];
$teste2 = $row["FimTarefa"];
$teste3 = $row["TipoPeriodicidade"];
$teste4 = $row["Tempo"];
$teste5 = $row["Ala"];
$teste8 = $row["nome"];
}
$query = "SELECT iduser, hostname FROM raddb.sessoes
WHERE datafim IS NULL AND hostname = '$teste5'";
$result = mysqli_query($conn, $query);
while($row1 = mysqli_fetch_array($result))
{
$teste6 = $row1["iduser"];
$teste7 = $row1["hostname"];
}
if($teste4 > $teste3 AND $teste5 == $teste7 AND $teste6 == $_SESSION['usuarioId'])
{
//expired
echo "-1";
}
else
{
//not expired
echo "1";
}
It works properly and as I intend.
I wanted to make an improvement, I wanted to get the value of the $test8
variable, send it by the URL and add the value of that variable to the message I have inside the Jquery
alert ('Tem posicionamento em atraso do (and the value of $test8 variable)! ');